Dotclear

source: admin/preferences.php @ 1786:577ff24d19ae

Revision 1786:577ff24d19ae, 23.2 KB checked in by Anne Kozlika <kozlika@…>, 12 years ago (diff)

User Preferences, on approche de la fin.
Une typo au passage.
Et un petit cadeau pour mirovinben et jcDenis.

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 != '..' && substr($entry, 0, 1) != '.' && 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>'.__('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 pretty-title">'.__('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>'.__('My options').'</h3>';
480
481echo
482'<div class="fieldset">'.
483'<h4>'.__('Interface').'</h4>'.
484
485'<p><label for="user_ui_enhanceduploader" class="classic">'.
486form::checkbox('user_ui_enhanceduploader',1,$user_ui_enhanceduploader).' '.
487__('Activate enhanced uploader in media manager').'</label></p>'.
488
489'<p><label for="user_acc_nodragdrop" class="classic">'.
490form::checkbox('user_acc_nodragdrop',1,$user_acc_nodragdrop).' '.
491__('Disable javascript powered drag and drop for ordering items').'</label></p>'.
492'<p class="clear form-note">'.__('If checked, numeric fields will allow to type the elements\' ordering number.').'</p>';
493
494if ($core->auth->isSuperAdmin()) {
495     echo
496     '<p><label for="user_ui_hide_std_favicon" class="classic">'.
497     form::checkbox('user_ui_hide_std_favicon',1,$user_ui_hide_std_favicon).' '.
498     __('Do not use standard favicon').'</label> '.
499     '<span class="clear form-note warn">'.__('This will be applied for all users').'.</span>'.
500     '</p>';//Opera sucks;
501}
502
503echo
504'</div>';
505
506echo
507'<div class="fieldset">'.
508'<h4>'.__('Edition').'</h4>'.
509
510'<p class="field"><label for="user_post_format">'.__('Preferred format:').'</label>'.
511form::combo('user_post_format',$formaters_combo,$user_options['post_format']).'</p>'.
512
513'<p class="field"><label for="user_post_status">'.__('Default entry status:').'</label>'.
514form::combo('user_post_status',$status_combo,$user_post_status).'</p>'.
515
516'<p class="field"><label for="user_edit_size">'.__('Entry edit field height:').'</label>'.
517form::field('user_edit_size',5,4,(integer) $user_options['edit_size']).'</p>'.
518
519'<p><label for="user_wysiwyg" class="classic">'.
520form::checkbox('user_wysiwyg',1,$user_options['enable_wysiwyg']).' '.
521__('Enable WYSIWYG mode').'</label></p>'.
522
523'</div>';
524
525echo
526'<h4 class="pretty-title">'.__('Other options').'</h4>';
527
528# --BEHAVIOR-- adminPreferencesForm
529$core->callBehavior('adminPreferencesForm',$core);
530
531echo
532'<p class="clear vertical-separator">'.
533$core->formNonce().
534'<input type="submit" accesskey="s" value="'.__('Save my options').'" /></p>'.
535'</form>';
536
537echo '</div>';
538
539# My dashboard
540echo '<div class="multi-part" id="user-favorites" title="'.__('My dashboard').'">';
541$ws = $core->auth->user_prefs->addWorkspace('favorites');
542echo '<h3>'.__('Mon tableau de bord').'</h3>';
543
544echo '<form action="preferences.php" method="post" id="favs-form" class="two-boxes">';
545
546echo '<div id="my-favs" class="fieldset"><h4>'.__('My favorites').'</h4>';
547
548$count = 0;
549$user_fav = array();
550foreach ($ws->dumpPrefs() as $k => $v) {
551     // User favorites only
552     if (!$v['global']) {
553          $fav = unserialize($v['value']);
554          if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) {
555               if ($count == 0) echo '<ul class="fav-list">';
556               $count++;
557               echo '<li id="fu-'.$k.'">'.'<label for="fuk-'.$k.'">'.
558                    '<img src="'.dc_admin_icon_url($fav['small-icon']).'" alt="" /> '.'<span class="zoom"><img src="'.dc_admin_icon_url($fav['large-icon']).'" alt="" /></span>'.
559                    form::field(array('order['.$k.']'),2,3,$count,'position','',false,'title="'.sprintf(__('position of %s'),$fav['title']).'"').
560                    form::hidden(array('dynorder[]','dynorder-'.$k.''),$k).
561                    form::checkbox(array('remove[]','fuk-'.$k),$k).__($fav['title']).'</label>'.
562                    '</li>';
563               $user_fav[] = $fav['name'];
564          }
565     }
566}
567if ($count > 0) echo '</ul>';
568if ($count > 0) {
569     echo
570     '<div class="clear">'.
571     '<p>'.form::hidden('favs_order','').
572     $core->formNonce().
573     '<input type="submit" name="saveorder" value="'.__('Save order').'" /> '.
574
575     '<input type="submit" class="delete" name="removeaction" '.
576     'value="'.__('Delete selected favorites').'" '.
577     'onclick="return window.confirm(\''.html::escapeJS(
578          __('Are you sure you want to remove selected favorites?')).'\');" /></p>'.
579
580     ($core->auth->isSuperAdmin() ? 
581          '<div class="info">'.
582          '<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>'.
583          '<p><input class="reset" type="submit" name="replace" value="'.__('Define as default favorites').'" />' : 
584          '').
585          '</p>'.
586          '</div>'.
587     '</div>';
588} else {
589     echo
590     '<p>'.__('Currently no personal favorites.').'</p>';
591}
592
593$default_fav = array();
594foreach ($ws->dumpPrefs() as $k => $v) {
595     // Global favorites only
596     if ($v['global']) {
597          $fav = unserialize($v['value']);
598          if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) {
599               $default_fav[] = $fav['name'];
600          }
601     }
602}
603
604echo '</div>'; # /box my-fav
605
606echo '<div class="fieldset" id="available-favs">';
607# Available favorites
608echo '<h5 class="pretty-title">'.__('Other available favorites').'</h5>';
609$count = 0;
610$array = $_fav;
611function cmp($a,$b) {
612    if (__($a[1]) == __($b[1])) {
613        return 0;
614    }
615    return (__($a[1]) < __($b[1])) ? -1 : 1;
616}
617$array=$array->getArrayCopy();
618uasort($array,'cmp');
619foreach ($array as $k => $fav) {
620     if (($fav[5] == '*') || $core->auth->check($fav[5],$core->blog->id)) {
621          if (!in_array($fav[0], $user_fav)) {
622               if ($count == 0) echo '<ul class="fav-list">';
623               $count++;
624               echo '<li id="fa-'.$fav[0].'">'.'<label for="fak-'.$fav[0].'">'.
625                    '<img src="'.dc_admin_icon_url($fav[3]).'" alt="" /> '.
626                    '<span class="zoom"><img src="'.dc_admin_icon_url($fav[4]).'" alt="" /></span>'.
627                    form::checkbox(array('append[]','fak-'.$fav[0]),$k).
628                    __($fav[1]).'</label>'.
629                    (in_array($fav[0], $default_fav) ? ' <span class="default-fav"><img src="images/selected.png" alt="'.__('(default favorite)').'" /></span>' : '').
630                    '</li>';
631          }
632     }
633}
634if ($count > 0) echo '</ul>';
635echo
636'<p>'.
637$core->formNonce().
638'<input type="submit" name="appendaction" value="'.__('Add to my favorites').'" /></p>';
639echo '</div>'; # /available favorites
640
641echo '</form>';
642
643echo
644'<form action="preferences.php" method="post" id="db-forms" class="two-boxes even">'.
645
646'<div class="fieldset">'.
647'<h4>'.__('Menu').'</h4>'.
648'<p><label for="user_ui_nofavmenu" class="classic">'.
649form::checkbox('user_ui_nofavmenu',1,!$user_ui_nofavmenu).' '.
650__('Display favorites at the top of the menu').'</label></p></div>';
651
652if (count($iconsets_combo) > 1) {
653     echo 
654          '<div class="fieldset">'.
655          '<h4>'.__('Dashboard icons').'</h4>'.
656          '<p><label for="user_ui_iconset" class="classic">'.__('Iconset:').'</label> '.
657          form::combo('user_ui_iconset',$iconsets_combo,$user_ui_iconset).'</p>'.
658          '</div>';
659} else {
660     form::hidden('user_ui_iconset','');
661}
662
663echo
664'<div class="fieldset">'.
665'<h4>'.__('Dashboard modules').'</h4>'.
666
667'<p><label for="user_dm_doclinks" class="classic">'.
668form::checkbox('user_dm_doclinks',1,$user_dm_doclinks).' '.
669__('Display documentation links').'</label></p>'.
670
671'<p><label for="user_dm_dcnews" class="classic">'.
672form::checkbox('user_dm_dcnews',1,$user_dm_dcnews).' '.
673__('Display Dotclear news').'</label></p>'.
674
675'<p><label for="user_dm_quickentry" class="classic">'.
676form::checkbox('user_dm_quickentry',1,$user_dm_quickentry).' '.
677__('Display quick entry form').'</label><br class="clear" />'. //Opera sucks
678'</p>';
679echo '</div>';
680
681# --BEHAVIOR-- adminDashboardOptionsForm
682$core->callBehavior('adminDashboardOptionsForm',$core);
683
684echo
685'<p>'.
686form::hidden('db-options','-').
687$core->formNonce().
688'<input type="submit" accesskey="s" value="'.__('Save my dashboard options').'" /></p>'.
689'</form>';
690
691echo '</div>'; # /multipart-user-favorites
692
693dcPage::helpBlock('core_user_pref');
694dcPage::close();
695?>
Note: See TracBrowser for help on using the repository browser.

Sites map