Code Duplication    Length = 56-56 lines in 2 locations

mod/messages/start.php 1 location

@@ 80-135 (lines=56) @@
77
 * @param array $page Array of URL components for routing
78
 * @return bool
79
 */
80
function messages_page_handler($page) {
81
82
	$current_user = elgg_get_logged_in_user_entity();
83
	if (!$current_user) {
84
		register_error(elgg_echo('noaccess'));
85
		elgg_get_session()->set('last_forward_from', current_page_url());
86
		forward('');
87
	}
88
89
	elgg_load_library('elgg:messages');
90
91
	elgg_push_breadcrumb(elgg_echo('messages'), 'messages/inbox/' . $current_user->username);
92
93
	if (!isset($page[0])) {
94
		$page[0] = 'inbox';
95
	}
96
97
	// Support the old inbox url /messages/<username>, but only if it matches the logged in user.
98
	// Otherwise having a username like "read" on the system could confuse this function.
99
	if ($current_user->username === $page[0]) {
100
		$page[1] = $page[0];
101
		$page[0] = 'inbox';
102
	}
103
104
	if (!isset($page[1])) {
105
		$page[1] = $current_user->username;
106
	}
107
108
	$base_dir = elgg_get_plugins_path() . 'messages/pages/messages';
109
110
	switch ($page[0]) {
111
		case 'inbox':
112
			set_input('username', $page[1]);
113
			include("$base_dir/inbox.php");
114
			break;
115
		case 'notifications':
116
			set_input('username', $page[1]);
117
			include("$base_dir/notifications.php");
118
			break;
119
		case 'sent':
120
			set_input('username', $page[1]);
121
			include("$base_dir/sent.php");
122
			break;
123
		case 'read':
124
			set_input('guid', $page[1]);
125
			include("$base_dir/read.php");
126
			break;
127
		case 'compose':
128
		case 'add':
129
			include("$base_dir/send.php");
130
			break;
131
		default:
132
			return false;
133
	}
134
	return true;
135
}
136
137
/**
138
 * Display notification of new messages in topbar

mod/wet4/start.php 1 location

@@ 1710-1765 (lines=56) @@
1707
 * wet4_messages_page_handler
1708
 * Override page handler for wet4 theme - messages
1709
 */
1710
function wet4_messages_page_handler($page)
1711
{
1712
	$current_user = elgg_get_logged_in_user_entity();
1713
	if (!$current_user) {
1714
		register_error(elgg_echo('noaccess'));
1715
		elgg_get_session()->set('last_forward_from', current_page_url());
1716
		forward('');
1717
	}
1718
1719
	elgg_load_library('elgg:messages');
1720
1721
	elgg_push_breadcrumb(elgg_echo('messages'), 'messages/inbox/' . $current_user->username);
1722
1723
	if (!isset($page[0])) {
1724
		$page[0] = 'inbox';
1725
	}
1726
1727
	// Support the old inbox url /messages/<username>, but only if it matches the logged in user.
1728
	// Otherwise having a username like "read" on the system could confuse this function.
1729
	if ($current_user->username === $page[0]) {
1730
		$page[1] = $page[0];
1731
		$page[0] = 'inbox';
1732
	}
1733
1734
	if (!isset($page[1])) {
1735
		$page[1] = $current_user->username;
1736
	}
1737
1738
	$base_dir = elgg_get_plugins_path() . 'wet4/pages/messages';
1739
1740
	switch ($page[0]) {
1741
		case 'inbox':
1742
			set_input('username', $page[1]);
1743
			include("$base_dir/inbox.php");
1744
			break;
1745
		case 'notifications':
1746
			set_input('username', $page[1]);
1747
			include("$base_dir/notifications.php");
1748
			break;
1749
		case 'sent':
1750
			set_input('username', $page[1]);
1751
			include("$base_dir/sent.php");
1752
			break;
1753
		case 'read':
1754
			set_input('guid', $page[1]);
1755
			include("$base_dir/read.php");
1756
			break;
1757
		case 'compose':
1758
		case 'add':
1759
			include("$base_dir/send.php");
1760
			break;
1761
		default:
1762
			return false;
1763
	}
1764
	return true;
1765
}
1766
1767
/*
1768
 * enhanced_friendly_time_hook