Dotclear

source: admin/preferences.php @ 1967:9c5136273bb2

Revision 1967:9c5136273bb2, 22.6 KB checked in by franck <carnet.franck.paul@…>, 12 years ago (diff)

Some settings have been moved, so the code should follow!

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

Sites map