Dotclear

source: admin/preferences.php @ 1941:84f59a80ffe8

Revision 1941:84f59a80ffe8, 22.9 KB checked in by Dsls, 12 years ago (diff)

po_update.sh no more complains, removed duplicate l10n entries, replaced french words in code.

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

Sites map