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

@@ 1802-1857 (lines=56) @@
1799
 * wet4_messages_page_handler
1800
 * Override page handler for wet4 theme - messages
1801
 */
1802
function wet4_messages_page_handler($page)
1803
{
1804
	$current_user = elgg_get_logged_in_user_entity();
1805
	if (!$current_user) {
1806
		register_error(elgg_echo('noaccess'));
1807
		elgg_get_session()->set('last_forward_from', current_page_url());
1808
		forward('');
1809
	}
1810
1811
	elgg_load_library('elgg:messages');
1812
1813
	elgg_push_breadcrumb(elgg_echo('messages'), 'messages/inbox/' . $current_user->username);
1814
1815
	if (!isset($page[0])) {
1816
		$page[0] = 'inbox';
1817
	}
1818
1819
	// Support the old inbox url /messages/<username>, but only if it matches the logged in user.
1820
	// Otherwise having a username like "read" on the system could confuse this function.
1821
	if ($current_user->username === $page[0]) {
1822
		$page[1] = $page[0];
1823
		$page[0] = 'inbox';
1824
	}
1825
1826
	if (!isset($page[1])) {
1827
		$page[1] = $current_user->username;
1828
	}
1829
1830
	$base_dir = elgg_get_plugins_path() . 'wet4/pages/messages';
1831
1832
	switch ($page[0]) {
1833
		case 'inbox':
1834
			set_input('username', $page[1]);
1835
			include("$base_dir/inbox.php");
1836
			break;
1837
		case 'notifications':
1838
			set_input('username', $page[1]);
1839
			include("$base_dir/notifications.php");
1840
			break;
1841
		case 'sent':
1842
			set_input('username', $page[1]);
1843
			include("$base_dir/sent.php");
1844
			break;
1845
		case 'read':
1846
			set_input('guid', $page[1]);
1847
			include("$base_dir/read.php");
1848
			break;
1849
		case 'compose':
1850
		case 'add':
1851
			include("$base_dir/send.php");
1852
			break;
1853
		default:
1854
			return false;
1855
	}
1856
	return true;
1857
}
1858
1859
/*
1860
 * enhanced_friendly_time_hook