Dotclear

source: admin/preferences.php @ 1607:d8d8ff4c2474

Revision 1607:d8d8ff4c2474, 21.6 KB checked in by Anne Kozlika <kozlika@…>, 11 years ago (diff)

My preferences. Wording and design.

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

Sites map