1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
<?php
/**
* Elgg user settings functions.
* Functions for adding and manipulating options on the user settings panel.
*
* @package Elgg.Core
* @subpackage Settings.User
*/
/**
* Set up the page for user settings
*
* @return void
*/
function usersettings_pagesetup() {
if (elgg_get_context() == "settings" && get_loggedin_userid()) {
$user = get_loggedin_user();
$params = array(
'name' => '1_account',
'title' => elgg_echo('usersettings:user:opt:linktext'),
'url' => "pg/settings/user/{$user->username}",
);
elgg_register_menu_item('page', $params);
$params = array(
'name' => '1_plugins',
'title' => elgg_echo('usersettings:plugins:opt:linktext'),
'url' => "pg/settings/plugins/{$user->username}",
);
elgg_register_menu_item('page', $params);
$params = array(
'name' => '1_statistics',
'title' => elgg_echo('usersettings:statistics:opt:linktext'),
'url' => "pg/settings/statistics/{$user->username}",
);
elgg_register_menu_item('page', $params);
}
}
/**
* Page handler for user settings
*
* @param array $page Pages array
*
* @return void
*/
function usersettings_page_handler($page) {
global $CONFIG;
if (!isset($page[0])) {
$page[0] = 'user';
}
switch ($page[0]) {
case 'statistics':
$path = $CONFIG->path . "pages/settings/statistics.php";
break;
case 'plugins':
$path = $CONFIG->path . "pages/settings/tools.php";
break;
case 'user':
default:
$path = $CONFIG->path . "pages/settings/account.php";
break;
}
if ($page[1]) {
$user = get_user_by_username($page[1]);
elgg_set_page_owner_guid($user->guid);
} else {
elgg_set_page_owner_guid(get_loggedin_userid());
}
require($path);
}
/**
* Initialise the admin page.
*
* @return void
*/
function usersettings_init() {
// Page handler
register_page_handler('settings', 'usersettings_page_handler');
}
/// Register init function
elgg_register_event_handler('init', 'system', 'usersettings_init');
elgg_register_event_handler('pagesetup', 'system', 'usersettings_pagesetup');
|