-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstart.php
327 lines (253 loc) · 8.43 KB
/
start.php
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<?php
/**
* @package Deyan
* @author Angel Gabriel
* @web http://angelgabriel.tk
* @mail angel.wrt@gmail.com
**/
function deyan_init() {
//Register & Load our libraries
$lib_path = elgg_get_plugins_path() . 'deyan/lib/';
elgg_register_library('deyan', $lib_path . 'deyan.php');
elgg_register_library('iconslib', $lib_path . 'icons.php');
elgg_register_library('panel', $lib_path . 'panel.php');
elgg_register_library('themes', $lib_path . 'themes.php');
elgg_load_library('deyan');
elgg_load_library('iconslib');
elgg_load_library('panel');
elgg_load_library('themes');
//Register our hook for the index
elgg_register_plugin_hook_handler('index', 'system', 'deyan_index_handler');
//Register actions
$action_path = elgg_get_plugins_path() . 'deyan/actions/deyan';
elgg_register_action("deyan/xor_selector", "$action_path/xor_selector.php");
elgg_register_action("deyan/background", "$action_path/background.php");
elgg_register_action("deyan/panel", "$action_path/panel.php");
elgg_register_action("deyan/iconadmin", "$action_path/iconadmin.php");
//page handlers
elgg_register_page_handler('dashboard', 'deyan_dashboard_handler');
elgg_register_page_handler('personalize', 'deyan_personalize_handler');
elgg_register_page_handler('register', 'deyan_register_handler');
elgg_register_page_handler('login', 'deyan_login_handler');
elgg_register_page_handler('forgotpassword', 'deyan_forgotpassword_handler');
//render admin section
deyan_admin_init();
//we don't want search box in the header
elgg_unextend_view('page/elements/header', 'search/search_box');
//also the search css is included on theme's panel css
elgg_unextend_view('css/elgg', 'search/css');
//Page menus
$user = elgg_get_logged_in_user_entity();
// Personalize > appearance
elgg_register_menu_item('page', array(
'name' => 'personalize_appearance',
'text' => elgg_echo('deyan:appearance'),
'href' => "personalize/appearance/{$user->username}",
'context' => 'personalize',
));
// Personalize > theme
if(elgg_get_plugin_setting('theme_selector', 'deyan') == 'yes') {
elgg_register_menu_item('page', array(
'name' => 'personalize_theme',
'text' => elgg_echo('deyan:theme'),
'href' => "personalize/theme/{$user->username}",
'context' => 'personalize',
));
}
// Personalize > icons
if(elgg_get_plugin_setting('icon_selector', 'deyan') == 'yes') {
elgg_register_menu_item('page', array(
'name' => 'personalize_icons',
'text' => elgg_echo('deyan:icons'),
'href' => "personalize/icons/{$user->username}",
'context' => 'personalize',
));
}
// personalize > panel
elgg_register_menu_item('page', array(
'name' => 'personalize_panel',
'text' => elgg_echo('deyan:panel'),
'href' => "personalize/panel/{$user->username}",
'context' => 'personalize',
));
// Register our panel modules. Also we register the user & start menus to be showed on the modules
// user_menu & start_menu.
if (elgg_is_active_plugin('search')) {
deyan_register_panel_mod('search', 'right', 1000);
}
if(elgg_is_logged_in()){
// Mods for the left side of the panel
deyan_register_panel_mod('dashboard', 'left', 600);
deyan_register_panel_mod('start_menu');
//Register the start menu
elgg_register_menu_item('start', array(
'name' => 'activity',
'href' => "activity",
'text' => deyan_view_icon('world') . elgg_echo('activity'),
'priority' => 10,
));
if (elgg_is_active_plugin('blog')) {
elgg_register_menu_item('start', array(
'name' => 'blog',
'href' => "/blog/owner/$user->username",
'text' => deyan_view_icon('notepad') . elgg_echo('blog'),
'priority' => 70,
));
}
if (elgg_is_active_plugin('pages')) {
elgg_register_menu_item('start', array(
'name' => 'pages',
'href' => "/pages/owner/$user->username",
'text' => deyan_view_icon('file') . elgg_echo('pages'),
'priority' => 20,
));
}
if (elgg_is_active_plugin('groups')) {
elgg_register_menu_item('start', array(
'name' => 'groups',
'href' => "/groups/member/$user->username",
'text' => deyan_view_icon('friends') . elgg_echo('groups'),
'priority' => 30,
));
}
if (elgg_is_active_plugin('bookmarks')) {
elgg_register_menu_item('start', array(
'name' => 'bookmarks',
'href' => "/bookmarks/owner/$user->username",
'text' => deyan_view_icon('bookmarks') . elgg_echo('bookmarks'),
'priority' => 40,
));
}
if (elgg_is_active_plugin('file')) {
elgg_register_menu_item('start', array(
'name' => 'file',
'href' => "/file/owner/$user->username",
'text' => deyan_view_icon('hard-drive') . elgg_echo('files'),
'priority' => 50,
));
}
if (elgg_is_active_plugin('thewire')) {
elgg_register_menu_item('start', array(
'name' => 'thewire',
'href' => "/thewire/friends/$user->username",
'text' => deyan_view_icon('wireless') . elgg_echo('thewire'),
'priority' => 60,
));
}
// Mods for the right side of the panel
deyan_register_panel_mod('friends', 'right', 800);
if (elgg_is_active_plugin('messages')) {
deyan_register_panel_mod('messages', 'right', 600);
}
deyan_register_panel_mod('user_menu', 'right', 400);
//Register the user menu
elgg_register_menu_item('user', array(
'name' => 'usersettings',
'href' => "settings/user/" . $user->username,
'text' => deyan_view_icon('settings', 16) . elgg_echo('settings'),
'priority' => 800,
));
elgg_register_menu_item('user', array(
'name' => 'logout',
'href' => "action/logout",
'text' => deyan_view_icon('logout', 16) . elgg_echo('logout'),
'is_action' => TRUE,
'priority' => 1000,
));
elgg_register_menu_item('user', array(
'name' => 'profile',
'href' => $user->getURL(),
'text' => deyan_view_icon('user', 16) . elgg_echo('profile'),
'priority' => 200,
));
elgg_register_menu_item('user', array(
'name' => 'personalize',
'href' => "personalize/appearance/$user->username",
'text' => deyan_view_icon('paint', 16) . elgg_echo('deyan:personalize'),
'priority' => 400,
));
if (elgg_is_admin_logged_in()) {
elgg_register_menu_item('user', array(
'name' => 'administration',
'href' => 'admin',
'text' => deyan_view_icon('gear', 16) . elgg_echo('admin'),
'priority' => 600,
));
}
}
else{
// Mods for non-logged in people
deyan_register_panel_mod('login_menu', 'right');
deyan_register_panel_mod('register', 'right');
}
// Register default theme <glass>
deyan_register_theme('glass');
// Register the default icon library
deyan_register_iconlib('gray');
}
function deyan_index_handler() {
if (elgg_is_logged_in()) {
forward('/dashboard');
}
else {
deyan_load_page('index');
}
return true;
}
function deyan_dashboard_handler() {
deyan_load_page('dashboard');
return true;
}
function deyan_register_handler() {
deyan_load_page('register');
return true;
}
function deyan_login_handler() {
deyan_load_page('login');
return true;
}
function deyan_forgotpassword_handler() {
deyan_load_page('forgotten_password');
return true;
}
function deyan_personalize_handler($page) {
if ($page[1]) {
$user = get_user_by_username($page[1]);
elgg_set_page_owner_guid($user->guid);
} else {
$user = elgg_get_logged_in_user_guid();
$user = get_user($user);
elgg_set_page_owner_guid($user->guid);
if (!isset($page[0])) {
forward("personalize/appearance/$user->username");
}
forward("personalize/$page[0]/$user->username");
}
elgg_push_breadcrumb(elgg_echo('deyan:personalize'), "personalize/appearance/$user->username");
switch ($page[0]) {
case 'theme':
if(elgg_get_plugin_setting('theme_selector', 'deyan') != 'yes') {
register_error(elgg_echo('deyan:theme:error'));
forward('personalize');
}
elgg_push_breadcrumb(elgg_echo('deyan:theme'));
break;
case 'icons':
if(elgg_get_plugin_setting('icon_selector', 'deyan') != 'yes') {
register_error(elgg_echo('deyan:icons:library:error'));
forward('personalize');
}
elgg_push_breadcrumb(elgg_echo('deyan:icons'));
break;
case 'panel':
elgg_push_breadcrumb(elgg_echo('deyan:panel'));
break;
case 'appearance':
default:
break;
}
deyan_load_page('personalize', array('page' => $page[0], 'user' => $user));
return true;
}
elgg_register_event_handler('init', 'system', 'deyan_init');
?>