1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | |
---|
13 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
---|
14 | |
---|
15 | dcPage::check('usage,contentadmin'); |
---|
16 | |
---|
17 | $page_title = __('My preferences'); |
---|
18 | |
---|
19 | $user_name = $core->auth->getInfo('user_name'); |
---|
20 | $user_firstname = $core->auth->getInfo('user_firstname'); |
---|
21 | $user_displayname = $core->auth->getInfo('user_displayname'); |
---|
22 | $user_email = $core->auth->getInfo('user_email'); |
---|
23 | $user_url = $core->auth->getInfo('user_url'); |
---|
24 | $user_lang = $core->auth->getInfo('user_lang'); |
---|
25 | $user_tz = $core->auth->getInfo('user_tz'); |
---|
26 | $user_post_status = $core->auth->getInfo('user_post_status'); |
---|
27 | |
---|
28 | $user_options = $core->auth->getOptions(); |
---|
29 | |
---|
30 | $core->auth->user_prefs->addWorkspace('dashboard'); |
---|
31 | $user_dm_doclinks = $core->auth->user_prefs->dashboard->doclinks; |
---|
32 | $user_dm_dcnews = $core->auth->user_prefs->dashboard->dcnews; |
---|
33 | $user_dm_quickentry = $core->auth->user_prefs->dashboard->quickentry; |
---|
34 | |
---|
35 | $core->auth->user_prefs->addWorkspace('accessibility'); |
---|
36 | $user_acc_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop; |
---|
37 | |
---|
38 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
39 | $user_ui_enhanceduploader = $core->auth->user_prefs->interface->enhanceduploader; |
---|
40 | if ($core->auth->isSuperAdmin()) { |
---|
41 | $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon; |
---|
42 | } |
---|
43 | |
---|
44 | $default_tab = !empty($_GET['tab']) ? html::escapeHTML($_GET['tab']) : 'user-profile'; |
---|
45 | |
---|
46 | if (!empty($_GET['append']) || !empty($_GET['removed']) || !empty($_GET['neworder']) || |
---|
47 | !empty($_GET['replaced']) || !empty($_POST['appendaction']) || !empty($_POST['removeaction'])) { |
---|
48 | $default_tab = 'user-favorites'; |
---|
49 | } elseif (!empty($_GET['updated'])) { |
---|
50 | $default_tab = 'user-options'; |
---|
51 | } |
---|
52 | if (($default_tab != 'user-profile') && ($default_tab != 'user-options') && ($default_tab != 'user-favorites')) { |
---|
53 | $default_tab = 'user-profile'; |
---|
54 | } |
---|
55 | |
---|
56 | foreach ($core->getFormaters() as $v) { |
---|
57 | $formaters_combo[$v] = $v; |
---|
58 | } |
---|
59 | |
---|
60 | foreach ($core->blog->getAllPostStatus() as $k => $v) { |
---|
61 | $status_combo[$v] = $k; |
---|
62 | } |
---|
63 | |
---|
64 | # Language codes |
---|
65 | $langs = l10n::getISOcodes(1,1); |
---|
66 | foreach ($langs as $k => $v) { |
---|
67 | $lang_avail = $v == 'en' || is_dir(DC_L10N_ROOT.'/'.$v); |
---|
68 | $lang_combo[] = new formSelectOption($k,$v,$lang_avail ? 'avail10n' : ''); |
---|
69 | } |
---|
70 | |
---|
71 | # Add or update user |
---|
72 | if (isset($_POST['user_name'])) |
---|
73 | { |
---|
74 | try |
---|
75 | { |
---|
76 | $pwd_check = !empty($_POST['cur_pwd']) && $core->auth->checkPassword(crypt::hmac(DC_MASTER_KEY,$_POST['cur_pwd'])); |
---|
77 | |
---|
78 | if ($core->auth->allowPassChange() && !$pwd_check && $user_email != $_POST['user_email']) { |
---|
79 | throw new Exception(__('If you want to change your email or password you must provide your current password.')); |
---|
80 | } |
---|
81 | |
---|
82 | $cur = $core->con->openCursor($core->prefix.'user'); |
---|
83 | |
---|
84 | $cur->user_name = $user_name = $_POST['user_name']; |
---|
85 | $cur->user_firstname = $user_firstname = $_POST['user_firstname']; |
---|
86 | $cur->user_displayname = $user_displayname = $_POST['user_displayname']; |
---|
87 | $cur->user_email = $user_email = $_POST['user_email']; |
---|
88 | $cur->user_url = $user_url = $_POST['user_url']; |
---|
89 | $cur->user_lang = $user_lang = $_POST['user_lang']; |
---|
90 | $cur->user_tz = $user_tz = $_POST['user_tz']; |
---|
91 | |
---|
92 | $cur->user_options = new ArrayObject($user_options); |
---|
93 | |
---|
94 | if ($core->auth->allowPassChange() && !empty($_POST['new_pwd'])) |
---|
95 | { |
---|
96 | if (!$pwd_check) { |
---|
97 | throw new Exception(__('If you want to change your email or password you must provide your current password.')); |
---|
98 | } |
---|
99 | |
---|
100 | if ($_POST['new_pwd'] != $_POST['new_pwd_c']) { |
---|
101 | throw new Exception(__("Passwords don't match")); |
---|
102 | } |
---|
103 | |
---|
104 | $cur->user_pwd = $_POST['new_pwd']; |
---|
105 | } |
---|
106 | |
---|
107 | # --BEHAVIOR-- adminBeforeUserUpdate |
---|
108 | $core->callBehavior('adminBeforeUserProfileUpdate',$cur,$core->auth->userID()); |
---|
109 | |
---|
110 | # Udate user |
---|
111 | $core->updUser($core->auth->userID(),$cur); |
---|
112 | |
---|
113 | # --BEHAVIOR-- adminAfterUserUpdate |
---|
114 | $core->callBehavior('adminAfterUserProfileUpdate',$cur,$core->auth->userID()); |
---|
115 | |
---|
116 | http::redirect('preferences.php?upd=1'); |
---|
117 | } |
---|
118 | catch (Exception $e) |
---|
119 | { |
---|
120 | $core->error->add($e->getMessage()); |
---|
121 | } |
---|
122 | } |
---|
123 | |
---|
124 | # Update user options |
---|
125 | if (isset($_POST['user_post_format'])) |
---|
126 | { |
---|
127 | try |
---|
128 | { |
---|
129 | $cur = $core->con->openCursor($core->prefix.'user'); |
---|
130 | |
---|
131 | $cur->user_name = $user_name; |
---|
132 | $cur->user_firstname = $user_firstname; |
---|
133 | $cur->user_displayname = $user_displayname; |
---|
134 | $cur->user_email = $user_email; |
---|
135 | $cur->user_url = $user_url; |
---|
136 | $cur->user_lang = $user_lang; |
---|
137 | $cur->user_tz = $user_tz; |
---|
138 | |
---|
139 | $cur->user_post_status = $user_post_status = $_POST['user_post_status']; |
---|
140 | |
---|
141 | $user_options['edit_size'] = (integer) $_POST['user_edit_size']; |
---|
142 | if ($user_options['edit_size'] < 1) { |
---|
143 | $user_options['edit_size'] = 10; |
---|
144 | } |
---|
145 | $user_options['post_format'] = $_POST['user_post_format']; |
---|
146 | $user_options['enable_wysiwyg'] = !empty($_POST['user_wysiwyg']); |
---|
147 | |
---|
148 | $cur->user_options = new ArrayObject($user_options); |
---|
149 | |
---|
150 | # --BEHAVIOR-- adminBeforeUserUpdate |
---|
151 | $core->callBehavior('adminBeforeUserUpdate',$cur,$core->auth->userID()); |
---|
152 | |
---|
153 | # Update user prefs |
---|
154 | $core->auth->user_prefs->dashboard->put('doclinks',!empty($_POST['user_dm_doclinks']),'boolean'); |
---|
155 | $core->auth->user_prefs->dashboard->put('dcnews',!empty($_POST['user_dm_dcnews']),'boolean'); |
---|
156 | $core->auth->user_prefs->dashboard->put('quickentry',!empty($_POST['user_dm_quickentry']),'boolean'); |
---|
157 | $core->auth->user_prefs->accessibility->put('nodragdrop',!empty($_POST['user_acc_nodragdrop']),'boolean'); |
---|
158 | $core->auth->user_prefs->interface->put('enhanceduploader',!empty($_POST['user_ui_enhanceduploader']),'boolean'); |
---|
159 | if ($core->auth->isSuperAdmin()) { |
---|
160 | # Applied to all users |
---|
161 | $core->auth->user_prefs->interface->put('hide_std_favicon',!empty($_POST['user_ui_hide_std_favicon']),'boolean',null,true,true); |
---|
162 | } |
---|
163 | |
---|
164 | # Udate user |
---|
165 | $core->updUser($core->auth->userID(),$cur); |
---|
166 | |
---|
167 | # --BEHAVIOR-- adminAfterUserUpdate |
---|
168 | $core->callBehavior('adminAfterUserUpdate',$cur,$core->auth->userID()); |
---|
169 | |
---|
170 | http::redirect('preferences.php?updated=1'); |
---|
171 | } |
---|
172 | catch (Exception $e) |
---|
173 | { |
---|
174 | $core->error->add($e->getMessage()); |
---|
175 | } |
---|
176 | } |
---|
177 | |
---|
178 | # Add selected favorites |
---|
179 | if (!empty($_POST['appendaction'])) |
---|
180 | { |
---|
181 | try { |
---|
182 | if (empty($_POST['append'])) { |
---|
183 | throw new Exception(__('No favorite selected')); |
---|
184 | } |
---|
185 | |
---|
186 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
187 | $user_favs = $ws->DumpLocalPrefs(); |
---|
188 | $count = count($user_favs); |
---|
189 | foreach ($_POST['append'] as $k => $v) |
---|
190 | { |
---|
191 | try { |
---|
192 | $found = false; |
---|
193 | foreach ($user_favs as $f) { |
---|
194 | $f = unserialize($f['value']); |
---|
195 | if ($f['name'] == $v) { |
---|
196 | $found = true; |
---|
197 | break; |
---|
198 | } |
---|
199 | } |
---|
200 | if (!$found) { |
---|
201 | $uid = sprintf("u%03s",$count); |
---|
202 | $fav = array('name' => $_fav[$v][0],'title' => $_fav[$v][1],'url' => $_fav[$v][2],'small-icon' => $_fav[$v][3], |
---|
203 | 'large-icon' => $_fav[$v][4],'permissions' => $_fav[$v][5],'id' => $_fav[$v][6],'class' => $_fav[$v][7]); |
---|
204 | $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string'); |
---|
205 | $count++; |
---|
206 | } |
---|
207 | } catch (Exception $e) { |
---|
208 | $core->error->add($e->getMessage()); |
---|
209 | break; |
---|
210 | } |
---|
211 | } |
---|
212 | |
---|
213 | if (!$core->error->flag()) { |
---|
214 | http::redirect('preferences.php?append=1'); |
---|
215 | } |
---|
216 | } catch (Exception $e) { |
---|
217 | $core->error->add($e->getMessage()); |
---|
218 | } |
---|
219 | } |
---|
220 | |
---|
221 | # Delete selected favorites |
---|
222 | if (!empty($_POST['removeaction'])) |
---|
223 | { |
---|
224 | try { |
---|
225 | if (empty($_POST['remove'])) { |
---|
226 | throw new Exception(__('No favorite selected')); |
---|
227 | } |
---|
228 | |
---|
229 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
230 | foreach ($_POST['remove'] as $k => $v) |
---|
231 | { |
---|
232 | try { |
---|
233 | $core->auth->user_prefs->favorites->drop($v); |
---|
234 | } catch (Exception $e) { |
---|
235 | $core->error->add($e->getMessage()); |
---|
236 | break; |
---|
237 | } |
---|
238 | } |
---|
239 | // Update pref_id values |
---|
240 | try { |
---|
241 | $user_favs = $ws->DumpLocalPrefs(); |
---|
242 | $core->auth->user_prefs->favorites->dropAll(); |
---|
243 | $count = 0; |
---|
244 | foreach ($user_favs as $k => $v) |
---|
245 | { |
---|
246 | $uid = sprintf("u%03s",$count); |
---|
247 | $f = unserialize($v['value']); |
---|
248 | $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'], |
---|
249 | 'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']); |
---|
250 | $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string'); |
---|
251 | $count++; |
---|
252 | } |
---|
253 | } catch (Exception $e) { |
---|
254 | $core->error->add($e->getMessage()); |
---|
255 | } |
---|
256 | |
---|
257 | if (!$core->error->flag()) { |
---|
258 | http::redirect('preferences.php?removed=1'); |
---|
259 | } |
---|
260 | } catch (Exception $e) { |
---|
261 | $core->error->add($e->getMessage()); |
---|
262 | } |
---|
263 | } |
---|
264 | |
---|
265 | # Order favs |
---|
266 | $order = array(); |
---|
267 | if (empty($_POST['favs_order']) && !empty($_POST['order'])) { |
---|
268 | $order = $_POST['order']; |
---|
269 | asort($order); |
---|
270 | $order = array_keys($order); |
---|
271 | } elseif (!empty($_POST['favs_order'])) { |
---|
272 | $order = explode(',',$_POST['favs_order']); |
---|
273 | } |
---|
274 | |
---|
275 | if (!empty($_POST['saveorder']) && !empty($order)) |
---|
276 | { |
---|
277 | try { |
---|
278 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
279 | $user_favs = $ws->DumpLocalPrefs(); |
---|
280 | $core->auth->user_prefs->favorites->dropAll(); |
---|
281 | $count = 0; |
---|
282 | foreach ($order as $i => $k) { |
---|
283 | $uid = sprintf("u%03s",$count); |
---|
284 | $f = unserialize($user_favs[$k]['value']); |
---|
285 | $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'], |
---|
286 | 'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']); |
---|
287 | $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string'); |
---|
288 | $count++; |
---|
289 | } |
---|
290 | } catch (Exception $e) { |
---|
291 | $core->error->add($e->getMessage()); |
---|
292 | } |
---|
293 | |
---|
294 | if (!$core->error->flag()) { |
---|
295 | http::redirect('preferences.php?&neworder=1'); |
---|
296 | } |
---|
297 | } |
---|
298 | |
---|
299 | # Replace default favorites by current set (super admin only) |
---|
300 | if (!empty($_POST['replace']) && $core->auth->isSuperAdmin()) { |
---|
301 | try { |
---|
302 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
303 | $user_favs = $ws->DumpLocalPrefs(); |
---|
304 | $core->auth->user_prefs->favorites->dropAll(true); |
---|
305 | $count = 0; |
---|
306 | foreach ($user_favs as $k => $v) |
---|
307 | { |
---|
308 | $uid = sprintf("g%03s",$count); |
---|
309 | $f = unserialize($v['value']); |
---|
310 | $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'], |
---|
311 | 'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']); |
---|
312 | $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string',null,null,true); |
---|
313 | $count++; |
---|
314 | } |
---|
315 | } catch (Exception $e) { |
---|
316 | $core->error->add($e->getMessage()); |
---|
317 | } |
---|
318 | |
---|
319 | if (!$core->error->flag()) { |
---|
320 | http::redirect('preferences.php?&replaced=1'); |
---|
321 | } |
---|
322 | } |
---|
323 | |
---|
324 | /* DISPLAY |
---|
325 | -------------------------------------------------------- */ |
---|
326 | dcPage::open($page_title, |
---|
327 | dcPage::jsLoad('js/_preferences.js'). |
---|
328 | ($user_acc_nodragdrop ? '' : dcPage::jsLoad('js/_preferences-dragdrop.js')). |
---|
329 | dcPage::jsLoad('js/jquery/jquery-ui-1.8.12.custom.min.js'). |
---|
330 | dcPage::jsPageTabs($default_tab). |
---|
331 | dcPage::jsConfirmClose('user-form'). |
---|
332 | |
---|
333 | # --BEHAVIOR-- adminPreferencesHeaders |
---|
334 | $core->callBehavior('adminPreferencesHeaders') |
---|
335 | ); |
---|
336 | |
---|
337 | if (!empty($_GET['upd'])) { |
---|
338 | echo '<p class="message">'.__('Personal information has been successfully updated.').'</p>'; |
---|
339 | } |
---|
340 | if (!empty($_GET['updated'])) { |
---|
341 | echo '<p class="message">'.__('Personal options has been successfully updated.').'</p>'; |
---|
342 | } |
---|
343 | if (!empty($_GET['append'])) { |
---|
344 | echo '<p class="message">'.__('Favorites have been successfully added.').'</p>'; |
---|
345 | } |
---|
346 | if (!empty($_GET['neworder'])) { |
---|
347 | echo '<p class="message">'.__('Favorites have been successfully updated.').'</p>'; |
---|
348 | } |
---|
349 | if (!empty($_GET['removed'])) { |
---|
350 | echo '<p class="message">'.__('Favorites have been successfully removed.').'</p>'; |
---|
351 | } |
---|
352 | if (!empty($_GET['replaced'])) { |
---|
353 | echo '<p class="message">'.__('Default favorites have been successfully updated.').'</p>'; |
---|
354 | } |
---|
355 | |
---|
356 | echo '<h2 class="page-title">'.$page_title.'</h2>'; |
---|
357 | |
---|
358 | # User profile |
---|
359 | echo '<div class="multi-part" id="user-profile" title="'.__('My profile').'">'; |
---|
360 | |
---|
361 | echo |
---|
362 | '<form action="preferences.php" method="post" id="user-form">'. |
---|
363 | '<fieldset><legend>'.__('My profile').'</legend>'. |
---|
364 | '<div class="two-cols">'. |
---|
365 | '<div class="col">'. |
---|
366 | '<p><label for="user_name">'.__('Last Name:'). |
---|
367 | form::field('user_name',20,255,html::escapeHTML($user_name)).'</label></p>'. |
---|
368 | |
---|
369 | '<p><label for="user_firstname">'.__('First Name:'). |
---|
370 | form::field('user_firstname',20,255,html::escapeHTML($user_firstname)).'</label></p>'. |
---|
371 | |
---|
372 | '<p><label for="user_displayname">'.__('Display name:'). |
---|
373 | form::field('user_displayname',20,255,html::escapeHTML($user_displayname)).'</label></p>'. |
---|
374 | |
---|
375 | '<p><label for="user_email">'.__('Email:'). |
---|
376 | form::field('user_email',20,255,html::escapeHTML($user_email)).'</label></p>'. |
---|
377 | |
---|
378 | '<p><label for="user_url">'.__('URL:'). |
---|
379 | form::field('user_url',30,255,html::escapeHTML($user_url)).'</label></p>'. |
---|
380 | |
---|
381 | '</div>'. |
---|
382 | |
---|
383 | '<div class="col">'. |
---|
384 | |
---|
385 | '<p><label for="user_lang">'.__('User language:'). |
---|
386 | form::combo('user_lang',$lang_combo,$user_lang,'l10n').'</label></p>'. |
---|
387 | |
---|
388 | '<p><label for="user_tz">'.__('User timezone:'). |
---|
389 | form::combo('user_tz',dt::getZones(true,true),$user_tz).'</label></p>'. |
---|
390 | |
---|
391 | '</div>'. |
---|
392 | '</div>'. |
---|
393 | '<br class="clear" />'. //Opera sucks |
---|
394 | '</fieldset>'; |
---|
395 | |
---|
396 | if ($core->auth->allowPassChange()) |
---|
397 | { |
---|
398 | echo |
---|
399 | '<fieldset>'. |
---|
400 | '<legend>'.__('Change your password').'</legend>'. |
---|
401 | |
---|
402 | '<p><label for="new_pwd">'.__('New password:'). |
---|
403 | form::password('new_pwd',20,255).'</label></p>'. |
---|
404 | |
---|
405 | '<p><label for="new_pwd_c">'.__('Confirm password:'). |
---|
406 | form::password('new_pwd_c',20,255).'</label></p>'. |
---|
407 | '</fieldset>'. |
---|
408 | |
---|
409 | '<p>'.__('If you have changed this user email or password you must provide your current password to save these modifications.').'</p>'. |
---|
410 | '<p><label for="cur_pwd">'.__('Your password:'). |
---|
411 | form::password('cur_pwd',20,255).'</label></p>'; |
---|
412 | } |
---|
413 | |
---|
414 | echo |
---|
415 | '<p class="clear">'. |
---|
416 | $core->formNonce(). |
---|
417 | '<input type="submit" accesskey="s" value="'.__('Save').'" /></p>'. |
---|
418 | '</form>'; |
---|
419 | |
---|
420 | echo '</div>'; |
---|
421 | |
---|
422 | # User options : some from actual user profile, dashboard modules, ... |
---|
423 | echo '<div class="multi-part" id="user-options" title="'.__('My options').'">'; |
---|
424 | |
---|
425 | echo |
---|
426 | '<form action="preferences.php" method="post" id="opts-forms">'. |
---|
427 | '<fieldset><legend>'.__('My options').'</legend>'. |
---|
428 | |
---|
429 | '<p><label for="user_post_format">'.__('Preferred format:'). |
---|
430 | form::combo('user_post_format',$formaters_combo,$user_options['post_format']).'</label></p>'. |
---|
431 | |
---|
432 | '<p><label for="user_post_status">'.__('Default entry status:'). |
---|
433 | form::combo('user_post_status',$status_combo,$user_post_status).'</label></p>'. |
---|
434 | |
---|
435 | '<p><label for="user_edit_size">'.__('Entry edit field height:'). |
---|
436 | form::field('user_edit_size',5,4,(integer) $user_options['edit_size']).'</label></p>'. |
---|
437 | |
---|
438 | '<p><label for="user_wysiwyg" class="classic">'. |
---|
439 | form::checkbox('user_wysiwyg',1,$user_options['enable_wysiwyg']).' '. |
---|
440 | __('Enable WYSIWYG mode').'</label></p>'. |
---|
441 | |
---|
442 | '<p><label for="user_ui_enhanceduploader" class="classic">'. |
---|
443 | form::checkbox('user_ui_enhanceduploader',1,$user_ui_enhanceduploader).' '. |
---|
444 | __('Activate enhanced uploader in media manager').'</label></p>'; |
---|
445 | |
---|
446 | if ($core->auth->isSuperAdmin()) { |
---|
447 | echo |
---|
448 | '<p><label for="user_ui_hide_std_favicon" class="classic">'. |
---|
449 | form::checkbox('user_ui_hide_std_favicon',1,$user_ui_hide_std_favicon).' '. |
---|
450 | __('Do not use standard favicon').'</label></p>'. |
---|
451 | '<p class="clear form-note info">'.__('This will be applied for all users').'</p>'; |
---|
452 | } |
---|
453 | |
---|
454 | echo |
---|
455 | '<br class="clear" />'. //Opera sucks |
---|
456 | '</fieldset>'; |
---|
457 | |
---|
458 | echo |
---|
459 | '<fieldset><legend>'.__('Accessibility options').'</legend>'. |
---|
460 | |
---|
461 | '<p><label for="user_acc_nodragdrop" class="classic">'. |
---|
462 | form::checkbox('user_acc_nodragdrop',1,$user_acc_nodragdrop).' '. |
---|
463 | __('Disable javascript powered drag and drop for ordering items').'</label></p>'. |
---|
464 | |
---|
465 | '<p class="clear form-note info">'.__('Numeric fields will allow to type the elements\' ordering number.').'</p>'. |
---|
466 | '</fieldset>'; |
---|
467 | |
---|
468 | echo |
---|
469 | '<fieldset><legend>'.__('Dashboard modules').'</legend>'. |
---|
470 | |
---|
471 | '<p><label for="user_dm_doclinks" class="classic">'. |
---|
472 | form::checkbox('user_dm_doclinks',1,$user_dm_doclinks).' '. |
---|
473 | __('Display documentation links').'</label></p>'. |
---|
474 | |
---|
475 | '<p><label for="user_dm_dcnews" class="classic">'. |
---|
476 | form::checkbox('user_dm_dcnews',1,$user_dm_dcnews).' '. |
---|
477 | __('Display Dotclear news').'</label></p>'. |
---|
478 | |
---|
479 | '<p><label for="user_dm_quickentry" class="classic">'. |
---|
480 | form::checkbox('user_dm_quickentry',1,$user_dm_quickentry).' '. |
---|
481 | __('Display quick entry form').'</label></p>'. |
---|
482 | |
---|
483 | '<br class="clear" />'. //Opera sucks |
---|
484 | '</fieldset>'; |
---|
485 | |
---|
486 | # --BEHAVIOR-- adminPreferencesForm |
---|
487 | $core->callBehavior('adminPreferencesForm',$core); |
---|
488 | |
---|
489 | echo |
---|
490 | '<p class="clear">'. |
---|
491 | $core->formNonce(). |
---|
492 | '<input type="submit" accesskey="s" value="'.__('Save').'" /></p>'. |
---|
493 | '</form>'; |
---|
494 | |
---|
495 | echo '</div>'; |
---|
496 | |
---|
497 | # User favorites |
---|
498 | echo '<div class="multi-part" id="user-favorites" title="'.__('My favorites').'">'; |
---|
499 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
500 | echo '<form action="preferences.php" method="post" id="favs-form">'; |
---|
501 | echo '<div class="two-cols">'; |
---|
502 | echo '<div class="col70">'; |
---|
503 | echo '<fieldset id="my-favs"><legend>'.__('My favorites').'</legend>'; |
---|
504 | |
---|
505 | $count = 0; |
---|
506 | foreach ($ws->dumpPrefs() as $k => $v) { |
---|
507 | // User favorites only |
---|
508 | if (!$v['global']) { |
---|
509 | $fav = unserialize($v['value']); |
---|
510 | if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) { |
---|
511 | if ($count == 0) echo '<ul>'; |
---|
512 | $count++; |
---|
513 | echo '<li id="fu-'.$k.'">'. |
---|
514 | '<img src="'.dc_admin_icon_url($fav['large-icon']).'" alt="" /> '. |
---|
515 | form::field(array('order['.$k.']'),2,3,$count,'position','',false,'title="'.sprintf(__('position of %s'),$fav['title']).'"'). |
---|
516 | form::hidden(array('dynorder[]','dynorder-'.$k.''),$k). |
---|
517 | '<label for="fuk-'.$k.'">'.form::checkbox(array('remove[]','fuk-'.$k),$k).__($fav['title']).'</label>'. |
---|
518 | '</li>'; |
---|
519 | } |
---|
520 | } |
---|
521 | } |
---|
522 | if ($count > 0) echo '</ul>'; |
---|
523 | if ($count > 0) { |
---|
524 | echo |
---|
525 | '<div class="clear">'. |
---|
526 | '<p>'.form::hidden('favs_order',''). |
---|
527 | $core->formNonce(). |
---|
528 | '<input type="submit" name="saveorder" value="'.__('Save order').'" /> '. |
---|
529 | |
---|
530 | '<input type="submit" class="delete" name="removeaction" '. |
---|
531 | 'value="'.__('Delete selected favorites').'" '. |
---|
532 | 'onclick="return window.confirm(\''.html::escapeJS( |
---|
533 | __('Are you sure you want to remove selected favorites?')).'\');" /></p>'. |
---|
534 | |
---|
535 | ($core->auth->isSuperAdmin() ? |
---|
536 | '<hr />'. |
---|
537 | '<p>'.__('If you are a super administrator, you may define this set of favorites to be used by default on all blogs of this installation:').'</p>'. |
---|
538 | '<p><input class="reset" type="submit" name="replace" value="'.__('Define as default favorites').'" />' : |
---|
539 | ''). |
---|
540 | '</p>'. |
---|
541 | '</div>'; |
---|
542 | } else { |
---|
543 | echo |
---|
544 | '<p>'.__('Currently no personal favorites.').'</p>'; |
---|
545 | } |
---|
546 | |
---|
547 | echo '</fieldset>'; |
---|
548 | |
---|
549 | echo '<div id="default-favs"><h3>'.__('Default favorites').'</h3>'; |
---|
550 | echo '<p class="form-note info clear">'.__('Those favorites are displayed when My Favorites list is empty.').'</p>'; |
---|
551 | $count = 0; |
---|
552 | foreach ($ws->dumpPrefs() as $k => $v) { |
---|
553 | // Global favorites only |
---|
554 | if ($v['global']) { |
---|
555 | $fav = unserialize($v['value']); |
---|
556 | if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) { |
---|
557 | if ($count == 0) echo '<ul class="fav-list">'; |
---|
558 | $count++; |
---|
559 | echo '<li id="fd-'.$k.'">'. |
---|
560 | '<img src="'.dc_admin_icon_url($fav['small-icon']).'" alt="" /> '.__($fav['title']).'</li>'; |
---|
561 | } |
---|
562 | } |
---|
563 | } |
---|
564 | if ($count > 0) echo '</ul>'; |
---|
565 | echo '</div>'; |
---|
566 | echo '</div>'; |
---|
567 | echo '<div class="col30" id="available-favs">'; |
---|
568 | # Available favorites |
---|
569 | echo '<fieldset><legend>'.__('Available favorites').'</legend>'; |
---|
570 | $count = 0; |
---|
571 | $array = $_fav; |
---|
572 | function cmp($a,$b) { |
---|
573 | if (__($a[1]) == __($b[1])) { |
---|
574 | return 0; |
---|
575 | } |
---|
576 | return (__($a[1]) < __($b[1])) ? -1 : 1; |
---|
577 | } |
---|
578 | $array=$array->getArrayCopy(); |
---|
579 | uasort($array,'cmp'); |
---|
580 | foreach ($array as $k => $fav) { |
---|
581 | if (($fav[5] == '*') || $core->auth->check($fav[5],$core->blog->id)) { |
---|
582 | if ($count == 0) echo '<ul class="fav-list">'; |
---|
583 | $count++; |
---|
584 | echo '<li id="fa-'.$fav[0].'">'.'<label for="fak-'.$fav[0].'">'. |
---|
585 | form::checkbox(array('append[]','fak-'.$fav[0]),$k). |
---|
586 | '<img src="'.dc_admin_icon_url($fav[3]).'" alt="" /> '.'<span class="zoom"><img src="'.dc_admin_icon_url($fav[4]).'" alt="" /></span>'. |
---|
587 | __($fav[1]).'</label>'.'</li>'; |
---|
588 | } |
---|
589 | } |
---|
590 | if ($count > 0) echo '</ul>'; |
---|
591 | echo |
---|
592 | '<p>'. |
---|
593 | $core->formNonce(). |
---|
594 | '<input type="submit" name="appendaction" value="'.__('Add to my favorites').'" /></p>'; |
---|
595 | echo '</fieldset>'; |
---|
596 | echo '</div>'; |
---|
597 | echo '</div>'; # Two-cols |
---|
598 | echo '</form>'; |
---|
599 | echo '</div>'; # user-favorites |
---|
600 | |
---|
601 | dcPage::helpBlock('core_user_pref'); |
---|
602 | dcPage::close(); |
---|
603 | ?> |
---|