Dotclear

source: admin/preferences.php @ 1719:b8c48f380463

Revision 1719:b8c48f380463, 21.5 KB checked in by Dsls, 12 years ago (diff)

Added dcAdminCombos utility class, lots of combos available from everywhere now. Closes #1599

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

Sites map