Dotclear

source: admin/preferences.php @ 1763:9484581a2909

Revision 1763:9484581a2909, 23.4 KB checked in by Anne Kozlika <kozlika@…>, 12 years ago (diff)

User preference re-factoring in progress, step 2.

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 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
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::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;
40if ($core->auth->isSuperAdmin()) {
41     $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon;
42}
43$user_ui_iconset = @$core->auth->user_prefs->interface->iconset;
44$user_ui_nofavmenu = $core->auth->user_prefs->interface->nofavmenu;
45
46$default_tab = !empty($_GET['tab']) ? html::escapeHTML($_GET['tab']) : 'user-profile';
47
48if (!empty($_GET['append']) || !empty($_GET['removed']) || !empty($_GET['neworder']) || 
49     !empty($_GET['replaced']) || !empty($_POST['appendaction']) || !empty($_POST['removeaction']) || 
50     !empty($_GET['db-updated'])) {
51     $default_tab = 'user-favorites';
52} elseif (!empty($_GET['updated'])) {
53     $default_tab = 'user-options';
54}
55if (($default_tab != 'user-profile') && ($default_tab != 'user-options') && ($default_tab != 'user-favorites')) {
56     $default_tab = 'user-profile';
57}
58
59# Formaters combo
60$formaters_combo = dcAdminCombos::getFormatersCombo();
61
62$status_combo = dcAdminCombos::getPostStatusescombo();
63
64$iconsets_combo = array(__('Default') => '');
65$iconsets_root = dirname(__FILE__).'/images/iconset/';
66if (is_dir($iconsets_root) && is_readable($iconsets_root)) {
67     if (($d = @dir($iconsets_root)) !== false) {
68          while (($entry = $d->read()) !== false) {
69               if ($entry != '.' && $entry != '..' && is_dir($iconsets_root.'/'.$entry)) {
70                    $iconsets_combo[$entry] = $entry;
71               }
72          }
73     }
74}
75
76# Language codes
77$lang_combo = dcAdminCombos::getAdminLangsCombo();
78
79# Add or update user
80if (isset($_POST['user_name']))
81{
82     try
83     {
84          $pwd_check = !empty($_POST['cur_pwd']) && $core->auth->checkPassword(crypt::hmac(DC_MASTER_KEY,$_POST['cur_pwd']));
85         
86          if ($core->auth->allowPassChange() && !$pwd_check && $user_email != $_POST['user_email']) {
87               throw new Exception(__('If you want to change your email or password you must provide your current password.'));
88          }
89         
90          $cur = $core->con->openCursor($core->prefix.'user');
91         
92          $cur->user_name = $user_name = $_POST['user_name'];
93          $cur->user_firstname = $user_firstname = $_POST['user_firstname'];
94          $cur->user_displayname = $user_displayname = $_POST['user_displayname'];
95          $cur->user_email = $user_email = $_POST['user_email'];
96          $cur->user_url = $user_url = $_POST['user_url'];
97          $cur->user_lang = $user_lang = $_POST['user_lang'];
98          $cur->user_tz = $user_tz = $_POST['user_tz'];
99
100          $cur->user_options = new ArrayObject($user_options);
101         
102          if ($core->auth->allowPassChange() && !empty($_POST['new_pwd']))
103          {
104               if (!$pwd_check) {
105                    throw new Exception(__('If you want to change your email or password you must provide your current password.'));
106               }
107               
108               if ($_POST['new_pwd'] != $_POST['new_pwd_c']) {
109                    throw new Exception(__("Passwords don't match"));
110               }
111               
112               $cur->user_pwd = $_POST['new_pwd'];
113          }
114         
115          # --BEHAVIOR-- adminBeforeUserUpdate
116          $core->callBehavior('adminBeforeUserProfileUpdate',$cur,$core->auth->userID());
117         
118          # Udate user
119          $core->updUser($core->auth->userID(),$cur);
120         
121          # --BEHAVIOR-- adminAfterUserUpdate
122          $core->callBehavior('adminAfterUserProfileUpdate',$cur,$core->auth->userID());
123         
124          http::redirect('preferences.php?upd=1');
125     }
126     catch (Exception $e)
127     {
128          $core->error->add($e->getMessage());
129     }
130}
131
132# Update user options
133if (isset($_POST['user_post_format'])) 
134{
135     try
136     {
137          $cur = $core->con->openCursor($core->prefix.'user');
138         
139          $cur->user_name = $user_name;
140          $cur->user_firstname = $user_firstname;
141          $cur->user_displayname = $user_displayname;
142          $cur->user_email = $user_email;
143          $cur->user_url = $user_url;
144          $cur->user_lang = $user_lang;
145          $cur->user_tz = $user_tz;
146
147          $cur->user_post_status = $user_post_status = $_POST['user_post_status'];
148         
149          $user_options['edit_size'] = (integer) $_POST['user_edit_size'];
150          if ($user_options['edit_size'] < 1) {
151               $user_options['edit_size'] = 10;
152          }
153          $user_options['post_format'] = $_POST['user_post_format'];
154          $user_options['enable_wysiwyg'] = !empty($_POST['user_wysiwyg']);
155         
156          $cur->user_options = new ArrayObject($user_options);
157         
158          # --BEHAVIOR-- adminBeforeUserOptionsUpdate
159          $core->callBehavior('adminBeforeUserOptionsUpdate',$cur,$core->auth->userID());
160         
161          # Update user prefs
162          $core->auth->user_prefs->dashboard->put('doclinks',!empty($_POST['user_dm_doclinks']),'boolean');
163          $core->auth->user_prefs->dashboard->put('dcnews',!empty($_POST['user_dm_dcnews']),'boolean');
164          $core->auth->user_prefs->dashboard->put('quickentry',!empty($_POST['user_dm_quickentry']),'boolean');
165          $core->auth->user_prefs->accessibility->put('nodragdrop',!empty($_POST['user_acc_nodragdrop']),'boolean');
166          $core->auth->user_prefs->interface->put('enhanceduploader',!empty($_POST['user_ui_enhanceduploader']),'boolean');
167          if ($core->auth->isSuperAdmin()) {
168               # Applied to all users
169               $core->auth->user_prefs->interface->put('hide_std_favicon',!empty($_POST['user_ui_hide_std_favicon']),'boolean',null,true,true);
170          }
171          $core->auth->user_prefs->interface->put('iconset',(!empty($_POST['user_ui_iconset']) ? $_POST['user_ui_iconset'] : ''));
172          $core->auth->user_prefs->interface->put('nofavmenu',!empty($_POST['user_ui_nofavmenu']),'boolean');
173         
174          # Udate user
175          $core->updUser($core->auth->userID(),$cur);
176         
177          # --BEHAVIOR-- adminAfterUserOptionsUpdate
178          $core->callBehavior('adminAfterUserOptionsUpdate',$cur,$core->auth->userID());
179         
180          http::redirect('preferences.php?updated=1');
181     }
182     catch (Exception $e)
183     {
184          $core->error->add($e->getMessage());
185     }
186}
187
188# Dashboard options
189if (isset($_POST['db-options'])) {
190     try
191     {
192          # --BEHAVIOR-- adminBeforeUserOptionsUpdate
193          $core->callBehavior('adminBeforeDashboardOptionsUpdate',$core->auth->userID());
194         
195          # Update user prefs
196          $core->auth->user_prefs->dashboard->put('doclinks',!empty($_POST['user_dm_doclinks']),'boolean');
197          $core->auth->user_prefs->dashboard->put('dcnews',!empty($_POST['user_dm_dcnews']),'boolean');
198          $core->auth->user_prefs->dashboard->put('quickentry',!empty($_POST['user_dm_quickentry']),'boolean');
199          $core->auth->user_prefs->interface->put('iconset',(!empty($_POST['user_ui_iconset']) ? $_POST['user_ui_iconset'] : ''));
200          $core->auth->user_prefs->interface->put('nofavmenu',empty($_POST['user_ui_nofavmenu']),'boolean');
201         
202          # --BEHAVIOR-- adminAfterUserOptionsUpdate
203          $core->callBehavior('adminAfterDashboardOptionsUpdate',$core->auth->userID());
204         
205          http::redirect('preferences.php?db-updated=1');
206     }
207     catch (Exception $e)
208     {
209          $core->error->add($e->getMessage());
210     }
211}
212
213# Add selected favorites
214if (!empty($_POST['appendaction'])) 
215{
216     try {
217          if (empty($_POST['append'])) {
218               throw new Exception(__('No favorite selected'));
219          }
220
221          $ws = $core->auth->user_prefs->addWorkspace('favorites');
222          $user_favs = $ws->DumpLocalPrefs();
223          $count = count($user_favs);
224          foreach ($_POST['append'] as $k => $v)
225          {
226               try {
227                    $found = false;
228                    foreach ($user_favs as $f) {
229                         $f = unserialize($f['value']);
230                         if ($f['name'] == $v) {
231                              $found = true;
232                              break;
233                         }
234                    }
235                    if (!$found) {
236                         $uid = sprintf("u%03s",$count);
237                         $fav = array('name' => $_fav[$v][0],'title' => $_fav[$v][1],'url' => $_fav[$v][2],'small-icon' => $_fav[$v][3],
238                              'large-icon' => $_fav[$v][4],'permissions' => $_fav[$v][5],'id' => $_fav[$v][6],'class' => $_fav[$v][7]);
239                         $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string');
240                         $count++;
241                    }
242               } catch (Exception $e) {
243                    $core->error->add($e->getMessage());
244                    break;
245               }
246          }
247     
248          if (!$core->error->flag()) {
249               http::redirect('preferences.php?append=1');
250          }
251     } catch (Exception $e) {
252          $core->error->add($e->getMessage());
253     }
254}
255
256# Delete selected favorites
257if (!empty($_POST['removeaction']))
258{
259     try {
260          if (empty($_POST['remove'])) {
261               throw new Exception(__('No favorite selected'));
262          }
263         
264          $ws = $core->auth->user_prefs->addWorkspace('favorites');
265          foreach ($_POST['remove'] as $k => $v)
266          {
267               try {
268                    $core->auth->user_prefs->favorites->drop($v);
269               } catch (Exception $e) {
270                    $core->error->add($e->getMessage());
271                    break;
272               }
273          }
274          // Update pref_id values
275          try {
276               $user_favs = $ws->DumpLocalPrefs();
277               $core->auth->user_prefs->favorites->dropAll();
278               $count = 0;
279               foreach ($user_favs as $k => $v)
280               {
281                    $uid = sprintf("u%03s",$count);
282                    $f = unserialize($v['value']);
283                    $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'],
284                         'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']);
285                    $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string');
286                    $count++;
287               }
288          } catch (Exception $e) {
289               $core->error->add($e->getMessage());
290          }
291     
292          if (!$core->error->flag()) {
293               http::redirect('preferences.php?removed=1');
294          }
295     } catch (Exception $e) {
296          $core->error->add($e->getMessage());
297     }
298}
299
300# Order favs
301$order = array();
302if (empty($_POST['favs_order']) && !empty($_POST['order'])) {
303     $order = $_POST['order'];
304     asort($order);
305     $order = array_keys($order);
306} elseif (!empty($_POST['favs_order'])) {
307     $order = explode(',',$_POST['favs_order']);
308}
309
310if (!empty($_POST['saveorder']) && !empty($order))
311{
312     try {
313          $ws = $core->auth->user_prefs->addWorkspace('favorites');
314          $user_favs = $ws->DumpLocalPrefs();
315          $core->auth->user_prefs->favorites->dropAll();
316          $count = 0;
317          foreach ($order as $i => $k) {
318               $uid = sprintf("u%03s",$count);
319               $f = unserialize($user_favs[$k]['value']);
320               $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'],
321                    'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']);
322               $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string');
323               $count++;
324          }
325     } catch (Exception $e) {
326          $core->error->add($e->getMessage());
327     }
328
329     if (!$core->error->flag()) {
330          http::redirect('preferences.php?&neworder=1');
331     }
332}
333
334# Replace default favorites by current set (super admin only)
335if (!empty($_POST['replace']) && $core->auth->isSuperAdmin()) {
336     try {
337          $ws = $core->auth->user_prefs->addWorkspace('favorites');
338          $user_favs = $ws->DumpLocalPrefs();
339          $core->auth->user_prefs->favorites->dropAll(true);
340          $count = 0;
341          foreach ($user_favs as $k => $v)
342          {
343               $uid = sprintf("g%03s",$count);
344               $f = unserialize($v['value']);
345               $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'],
346                    'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']);
347               $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string',null,null,true);
348               $count++;
349          }
350     } catch (Exception $e) {
351          $core->error->add($e->getMessage());
352     }
353
354     if (!$core->error->flag()) {
355          http::redirect('preferences.php?&replaced=1');
356     }
357}
358
359/* DISPLAY
360-------------------------------------------------------- */
361dcPage::open($page_title,
362     dcPage::jsLoad('js/_preferences.js').
363     ($user_acc_nodragdrop ? '' : dcPage::jsLoad('js/_preferences-dragdrop.js')).
364     dcPage::jsLoad('js/jquery/jquery-ui.custom.js').
365     dcPage::jsLoad('js/jquery/jquery.pwstrength.js').
366          '<script type="text/javascript">'."\n".
367          "//<![CDATA[\n".
368          "\$(function() {\n".
369          "    \$('#new_pwd').pwstrength({texts: ['".
370                    sprintf(__('Password strength: %s'),__('very weak'))."', '".
371                    sprintf(__('Password strength: %s'),__('weak'))."', '".
372                    sprintf(__('Password strength: %s'),__('mediocre'))."', '".
373                    sprintf(__('Password strength: %s'),__('strong'))."', '".
374                    sprintf(__('Password strength: %s'),__('very strong'))."']});\n".
375          "});\n".
376          "\n//]]>\n".
377          "</script>\n".
378     dcPage::jsPageTabs($default_tab).
379     dcPage::jsConfirmClose('user-form').
380     
381     # --BEHAVIOR-- adminPreferencesHeaders
382     $core->callBehavior('adminPreferencesHeaders'),
383
384     dcPage::breadcrumb(
385     array(
386          html::escapeHTML($core->auth->userID()) => '',
387          '<span class="page-title">'.$page_title.'</span>' => ''
388     ))
389);
390
391if (!empty($_GET['upd'])) {
392     dcPage::success(__('Personal information has been successfully updated.'));
393}
394if (!empty($_GET['updated'])) {
395     dcPage::success(__('Personal options has been successfully updated.'));
396}
397if (!empty($_GET['db-updated'])) {
398     dcPage::success(__('Dashboard options has been successfully updated.'));
399}
400if (!empty($_GET['append'])) {
401     dcPage::success(__('Favorites have been successfully added.'));
402}
403if (!empty($_GET['neworder'])) {
404     dcPage::success(__('Favorites have been successfully updated.'));
405}
406if (!empty($_GET['removed'])) {
407     dcPage::success(__('Favorites have been successfully removed.'));
408}
409if (!empty($_GET['replaced'])) {
410     dcPage::success(__('Default favorites have been successfully updated.'));
411}
412
413# User profile
414echo '<div class="multi-part" id="user-profile" title="'.__('My profile').'">';
415
416echo
417'<h3 class="hidden-if-js">'.__('My profile').'</h3>'.
418'<form action="preferences.php" method="post" id="user-form">'.
419
420'<p><label for="user_name">'.__('Last Name:').'</label>'.
421form::field('user_name',20,255,html::escapeHTML($user_name)).'</p>'.
422
423'<p><label for="user_firstname">'.__('First Name:').'</label>'.
424form::field('user_firstname',20,255,html::escapeHTML($user_firstname)).'</p>'.
425
426'<p><label for="user_displayname">'.__('Display name:').'</label>'.
427form::field('user_displayname',20,255,html::escapeHTML($user_displayname)).'</p>'.
428
429'<p><label for="user_email">'.__('Email:').'</label>'.
430form::field('user_email',20,255,html::escapeHTML($user_email)).'</p>'.
431
432'<p><label for="user_url">'.__('URL:').'</label>'.
433form::field('user_url',30,255,html::escapeHTML($user_url)).'</p>'.
434
435'<p><label for="user_lang">'.__('Language for my interface:').'</label>'.
436form::combo('user_lang',$lang_combo,$user_lang,'l10n').'</p>'.
437
438'<p><label for="user_tz">'.__('My timezone:').'</label>'.
439form::combo('user_tz',dt::getZones(true,true),$user_tz).'</p>';
440
441
442if ($core->auth->allowPassChange())
443{
444     echo
445     '<h4 class="vertical-separator">'.__('Change my password').'</h4>'.
446     
447     '<div class="pw-table">'.
448     '<p class="pw-cell"><label for="new_pwd">'.__('New password:').'</label>'.
449     form::password('new_pwd',20,255,'','','',false,' data-indicator="pwindicator" ').'</p>'.
450     '<div id="pwindicator">'.
451     '    <div class="bar"></div>'.
452     '    <p class="label no-margin"></p>'.
453     '</div>'.
454     '</div>'.
455     
456     '<p><label for="new_pwd_c">'.__('Confirm new password:').'</label>'.
457     form::password('new_pwd_c',20,255).'</p>'.
458     
459     '<p><label for="cur_pwd">'.__('Your current password:').'</label>'.
460     form::password('cur_pwd',20,255).'</p>'.
461     '<p class="form-note warn">'.
462     __('If you have changed your email or password you must provide your current password to save these modifications.').
463     '</p>';
464}
465
466echo
467'<p class="clear vertical-separator">'.
468$core->formNonce().
469'<input type="submit" accesskey="s" value="'.__('Update my profile').'" /></p>'.
470'</form>'.
471
472'</div>';
473
474# User options : some from actual user profile, dashboard modules, ...
475echo '<div class="multi-part" id="user-options" title="'.__('My options').'">';
476
477echo
478'<form action="preferences.php" method="post" id="opts-forms">'.
479'<h3 class="hidden-if-js">'.__('My options').'</h3>';
480
481echo
482'<div class="two-cols">'.
483
484'<div class="col">'.
485'<h4>'.__('Interface').'</h4>'.
486
487'<p><label for="user_ui_enhanceduploader" class="classic">'.
488form::checkbox('user_ui_enhanceduploader',1,$user_ui_enhanceduploader).' '.
489__('Activate enhanced uploader in media manager').'</label></p>';
490
491if ($core->auth->isSuperAdmin()) {
492     echo
493     '<p><label for="user_ui_hide_std_favicon" class="classic">'.
494     form::checkbox('user_ui_hide_std_favicon',1,$user_ui_hide_std_favicon).' '.
495     __('Do not use standard favicon').'</label></p>'.
496     '<p class="clear form-note warn">'.__('This will be applied for all users').'.'.
497     '</p>';//Opera sucks;
498}
499
500echo
501'<h5>'.__('Accessibility').'</h5>'.
502
503'<p><label for="user_acc_nodragdrop" class="classic">'.
504form::checkbox('user_acc_nodragdrop',1,$user_acc_nodragdrop).' '.
505__('Disable javascript powered drag and drop for ordering items').'</label></p>'.
506
507'<p class="clear form-note">'.__('If checked, numeric fields will allow to type the elements\' ordering number.').'</p>';
508
509echo
510'<h4 class="border-top">'.__('Edition').'</h4>'.
511
512'<p><label for="user_post_format">'.__('Preferred format:').'</label>'.
513form::combo('user_post_format',$formaters_combo,$user_options['post_format']).'</p>'.
514
515'<p><label for="user_post_status">'.__('Default entry status:').'</label>'.
516form::combo('user_post_status',$status_combo,$user_post_status).'</p>'.
517
518'<p><label for="user_edit_size">'.__('Entry edit field height:').'</label>'.
519form::field('user_edit_size',5,4,(integer) $user_options['edit_size']).'</p>'.
520
521'<p><label for="user_wysiwyg" class="classic">'.
522form::checkbox('user_wysiwyg',1,$user_options['enable_wysiwyg']).' '.
523__('Enable WYSIWYG mode').'</label></p>';
524
525echo
526'<h4 class="border-top">'.__('Other options').'</h4>';
527
528# --BEHAVIOR-- adminPreferencesForm
529$core->callBehavior('adminPreferencesForm',$core);
530
531echo
532'</div>';
533
534echo
535'</div>';
536
537echo
538'<p class="clear">'.
539$core->formNonce().
540'<input type="submit" accesskey="s" value="'.__('Save my options').'" /></p>'.
541'</form>';
542
543echo '</div>';
544
545# My dashboard
546echo '<div class="multi-part" id="user-favorites" title="'.__('My dashboard').'">';
547$ws = $core->auth->user_prefs->addWorkspace('favorites');
548echo '<h3 class="hidden-if-js">'.__('Mon tableau de bord').'</h3>';
549
550echo '<form action="preferences.php" method="post" id="favs-form" class="two-boxes">';
551
552echo '<div id="my-favs" class="fieldset"><h4>'.__('My favorites').'</h4>';
553
554$count = 0;
555foreach ($ws->dumpPrefs() as $k => $v) {
556     // User favorites only
557     if (!$v['global']) {
558          $fav = unserialize($v['value']);
559          if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) {
560               if ($count == 0) echo '<ul class="fav-list">';
561               $count++;
562               echo '<li id="fu-'.$k.'">'.'<label for="fuk-'.$k.'">'.
563                    '<img src="'.dc_admin_icon_url($fav['small-icon']).'" alt="" /> '.'<span class="zoom"><img src="'.dc_admin_icon_url($fav['large-icon']).'" alt="" /></span>'.
564                    form::field(array('order['.$k.']'),2,3,$count,'position','',false,'title="'.sprintf(__('position of %s'),$fav['title']).'"').
565                    form::hidden(array('dynorder[]','dynorder-'.$k.''),$k).
566                    form::checkbox(array('remove[]','fuk-'.$k),$k).__($fav['title']).'</label>'.
567                    '</li>';
568          }
569     }
570}
571if ($count > 0) echo '</ul>';
572if ($count > 0) {
573     echo
574     '<div class="clear">'.
575     '<p>'.form::hidden('favs_order','').
576     $core->formNonce().
577     '<input type="submit" name="saveorder" value="'.__('Save order').'" /> '.
578
579     '<input type="submit" class="delete" name="removeaction" '.
580     'value="'.__('Delete selected favorites').'" '.
581     'onclick="return window.confirm(\''.html::escapeJS(
582          __('Are you sure you want to remove selected favorites?')).'\');" /></p>'.
583
584     ($core->auth->isSuperAdmin() ? 
585          '<hr />'.
586          '<div class="info">'.
587          '<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>'.
588          '<p><input class="reset" type="submit" name="replace" value="'.__('Define as default favorites').'" />' : 
589          '').
590          '</p>'.
591          '</div>'.
592     '</div>';
593} else {
594     echo
595     '<p>'.__('Currently no personal favorites.').'</p>';
596}
597
598/*
599echo '<div id="default-favs"><h3>'.__('Default favorites').'</h3>';
600echo '<p>'.__('Those favorites are displayed when My Favorites list is empty.').'</p>';
601$count = 0;
602foreach ($ws->dumpPrefs() as $k => $v) {
603     // Global favorites only
604     if ($v['global']) {
605          $fav = unserialize($v['value']);
606          if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) {
607               if ($count == 0) echo '<ul class="fav-list">';
608               $count++;
609               echo '<li id="fd-'.$k.'">'.
610               '<img src="'.dc_admin_icon_url($fav['small-icon']).'" alt="" /> '.__($fav['title']).'</li>';
611          }
612     }
613}   
614if ($count > 0) echo '</ul>';
615echo '</div>';
616*/
617
618echo '</div>'; # /box my-fav
619
620echo '<div class="fieldset" id="available-favs">';
621# Available favorites ------------------------------------- Ici, si possible afficher plutôt les Autres favoris disponibles
622echo '<h5>'.__('Available favorites').'</h5>';
623$count = 0;
624$array = $_fav;
625function cmp($a,$b) {
626    if (__($a[1]) == __($b[1])) {
627        return 0;
628    }
629    return (__($a[1]) < __($b[1])) ? -1 : 1;
630}
631$array=$array->getArrayCopy();
632uasort($array,'cmp');
633foreach ($array as $k => $fav) {
634     if (($fav[5] == '*') || $core->auth->check($fav[5],$core->blog->id)) {
635          if ($count == 0) echo '<ul class="fav-list">';
636          $count++;
637          echo '<li id="fa-'.$fav[0].'">'.'<label for="fak-'.$fav[0].'">'.
638               '<img src="'.dc_admin_icon_url($fav[3]).'" alt="" /> '.
639               '<span class="zoom"><img src="'.dc_admin_icon_url($fav[4]).'" alt="" /></span>'.
640               form::checkbox(array('append[]','fak-'.$fav[0]),$k).
641               __($fav[1]).'</label>'.'</li>';
642     }
643}   
644if ($count > 0) echo '</ul>';
645echo
646'<p>'.
647$core->formNonce().
648'<input type="submit" name="appendaction" value="'.__('Add to my favorites').'" /></p>';
649echo '</div>'; # /available favorites
650
651echo '</form>';
652
653echo
654'<form action="preferences.php" method="post" id="db-forms" class="two-boxes even">'.
655
656'<div class="fieldset">'.
657'<h4 class="smart-title">'.__('Menu').'</h4>'.
658'<p><label for="user_ui_nofavmenu" class="classic">'.
659form::checkbox('user_ui_nofavmenu',1,!$user_ui_nofavmenu).' '.
660__('Display favorites at the top of the menu').'</label></p></div>';
661
662if (count($iconsets_combo) > 1) {
663     echo 
664          '<div class="fieldset">'.
665          '<h4 class="smart-title">'.__('Dashboard icons').'</h4>'.
666          '<p><label for="user_ui_iconset" class="classic">'.__('Iconset:').'</label> '.
667          form::combo('user_ui_iconset',$iconsets_combo,$user_ui_iconset).'</p>'.
668          '</div>';
669} else {
670     form::hidden('user_ui_iconset','');
671}
672
673echo
674'<div class="fieldset">'.
675'<h4 class="smart-title">'.__('Dashboard modules').'</h4>'.
676
677'<p><label for="user_dm_doclinks" class="classic">'.
678form::checkbox('user_dm_doclinks',1,$user_dm_doclinks).' '.
679__('Display documentation links').'</label></p>'.
680
681'<p><label for="user_dm_dcnews" class="classic">'.
682form::checkbox('user_dm_dcnews',1,$user_dm_dcnews).' '.
683__('Display Dotclear news').'</label></p>'.
684
685'<p><label for="user_dm_quickentry" class="classic">'.
686form::checkbox('user_dm_quickentry',1,$user_dm_quickentry).' '.
687__('Display quick entry form').'</label><br class="clear" />'. //Opera sucks
688'</p>';
689
690# --BEHAVIOR-- adminDashboardOptionsForm
691$core->callBehavior('adminDashboardOptionsForm',$core);
692echo '</div>';
693
694echo
695'<p>'.
696form::hidden('db-options','-').
697$core->formNonce().
698'<input type="submit" accesskey="s" value="'.__('Save my dashboard options').'" /></p>'.
699'</form>';
700
701echo '</div>'; # /multipart-user-favorites
702
703dcPage::helpBlock('core_user_pref');
704dcPage::close();
705?>
Note: See TracBrowser for help on using the repository browser.

Sites map