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

@@ 1670-1725 (lines=56) @@
1667
 * wet4_messages_page_handler
1668
 * Override page handler for wet4 theme - messages
1669
 */
1670
function wet4_messages_page_handler($page)
1671
{
1672
	$current_user = elgg_get_logged_in_user_entity();
1673
	if (!$current_user) {
1674
		register_error(elgg_echo('noaccess'));
1675
		elgg_get_session()->set('last_forward_from', current_page_url());
1676
		forward('');
1677
	}
1678
1679
	elgg_load_library('elgg:messages');
1680
1681
	elgg_push_breadcrumb(elgg_echo('messages'), 'messages/inbox/' . $current_user->username);
1682
1683
	if (!isset($page[0])) {
1684
		$page[0] = 'inbox';
1685
	}
1686
1687
	// Support the old inbox url /messages/<username>, but only if it matches the logged in user.
1688
	// Otherwise having a username like "read" on the system could confuse this function.
1689
	if ($current_user->username === $page[0]) {
1690
		$page[1] = $page[0];
1691
		$page[0] = 'inbox';
1692
	}
1693
1694
	if (!isset($page[1])) {
1695
		$page[1] = $current_user->username;
1696
	}
1697
1698
	$base_dir = elgg_get_plugins_path() . 'wet4/pages/messages';
1699
1700
	switch ($page[0]) {
1701
		case 'inbox':
1702
			set_input('username', $page[1]);
1703
			include("$base_dir/inbox.php");
1704
			break;
1705
		case 'notifications':
1706
			set_input('username', $page[1]);
1707
			include("$base_dir/notifications.php");
1708
			break;
1709
		case 'sent':
1710
			set_input('username', $page[1]);
1711
			include("$base_dir/sent.php");
1712
			break;
1713
		case 'read':
1714
			set_input('guid', $page[1]);
1715
			include("$base_dir/read.php");
1716
			break;
1717
		case 'compose':
1718
		case 'add':
1719
			include("$base_dir/send.php");
1720
			break;
1721
		default:
1722
			return false;
1723
	}
1724
	return true;
1725
}
1726
1727
/*
1728
 * enhanced_friendly_time_hook