Dotclear

source: admin/preferences.php @ 3731:3770620079d4

Revision 3731:3770620079d4, 31.6 KB checked in by franck <carnet.franck.paul@…>, 8 years ago (diff)

Simplify licence block at the beginning of each file

Line 
1<?php
2/**
3 * @package Dotclear
4 * @subpackage Backend
5 *
6 * @copyright Olivier Meunier & Association Dotclear
7 * @copyright GPL-2.0-only
8 */
9
10require dirname(__FILE__) . '/../inc/admin/prepend.php';
11
12dcPage::check('usage,contentadmin');
13
14$page_title = __('My preferences');
15
16$user_name        = $core->auth->getInfo('user_name');
17$user_firstname   = $core->auth->getInfo('user_firstname');
18$user_displayname = $core->auth->getInfo('user_displayname');
19$user_email       = $core->auth->getInfo('user_email');
20$user_url         = $core->auth->getInfo('user_url');
21$user_lang        = $core->auth->getInfo('user_lang');
22$user_tz          = $core->auth->getInfo('user_tz');
23$user_post_status = $core->auth->getInfo('user_post_status');
24
25$user_options = $core->auth->getOptions();
26if (empty($user_options['editor']) || !is_array($user_options['editor'])) {
27    $user_options['editor'] = array();
28}
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$user_dm_nofavicons = $core->auth->user_prefs->dashboard->nofavicons;
35if ($core->auth->isSuperAdmin()) {
36    $user_dm_nodcupdate = $core->auth->user_prefs->dashboard->nodcupdate;
37}
38
39$core->auth->user_prefs->addWorkspace('accessibility');
40$user_acc_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop;
41
42$core->auth->user_prefs->addWorkspace('interface');
43$user_ui_enhanceduploader = $core->auth->user_prefs->interface->enhanceduploader;
44$user_ui_hidemoreinfo     = $core->auth->user_prefs->interface->hidemoreinfo;
45$user_ui_hidehelpbutton   = $core->auth->user_prefs->interface->hidehelpbutton;
46$user_ui_showajaxloader   = $core->auth->user_prefs->interface->showajaxloader;
47$user_ui_htmlfontsize     = $core->auth->user_prefs->interface->htmlfontsize;
48$user_ui_dynfontsize      = $core->auth->user_prefs->interface->dynfontsize;
49if ($core->auth->isSuperAdmin()) {
50    $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon;
51}
52$user_ui_iconset            = @$core->auth->user_prefs->interface->iconset;
53$user_ui_nofavmenu          = $core->auth->user_prefs->interface->nofavmenu;
54$user_ui_media_by_page      = ($core->auth->user_prefs->interface->media_by_page ?: 30);
55$user_ui_media_nb_last_dirs = $core->auth->user_prefs->interface->media_nb_last_dirs;
56
57$default_tab = !empty($_GET['tab']) ? html::escapeHTML($_GET['tab']) : 'user-profile';
58
59if (!empty($_GET['append']) || !empty($_GET['removed']) || !empty($_GET['neworder']) ||
60    !empty($_GET['replaced']) || !empty($_POST['appendaction']) || !empty($_POST['removeaction']) ||
61    !empty($_GET['db-updated'])) {
62    $default_tab = 'user-favorites';
63} elseif (!empty($_GET['updated'])) {
64    $default_tab = 'user-options';
65}
66if (($default_tab != 'user-profile') && ($default_tab != 'user-options') && ($default_tab != 'user-favorites')) {
67    $default_tab = 'user-profile';
68}
69
70# Editors combo
71$editors_combo = dcAdminCombos::getEditorsCombo();
72$editors       = array_keys($editors_combo);
73
74# Format by editors
75$formaters         = $core->getFormaters();
76$format_by_editors = array();
77foreach ($formaters as $editor => $formats) {
78    foreach ($formats as $format) {
79        $format_by_editors[$format][$editor] = $editor;
80    }
81}
82$available_formats = array('' => '');
83foreach (array_keys($format_by_editors) as $format) {
84    $available_formats[$format] = $format;
85    if (!isset($user_options['editor'][$format])) {
86        $user_options['editor'][$format] = '';
87    }
88}
89$status_combo = dcAdminCombos::getPostStatusescombo();
90
91$iconsets_combo = array(__('Default') => '');
92$iconsets_root  = dirname(__FILE__) . '/images/iconset/';
93if (is_dir($iconsets_root) && is_readable($iconsets_root)) {
94    if (($d = @dir($iconsets_root)) !== false) {
95        while (($entry = $d->read()) !== false) {
96            if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.' && is_dir($iconsets_root . '/' . $entry)) {
97                $iconsets_combo[$entry] = $entry;
98            }
99        }
100    }
101}
102
103# Body base font size (37.5% = 6px, 50% = 8px, 62.5% = 10px, 75% = 12px, 87.5% = 14px)
104$htmlfontsize_combo = array(
105    __('Smallest') => '37.5%',
106    __('Smaller')  => '50%',
107    __('Default')  => '62.5%',
108    __('Larger')   => '75%',
109    __('Largest')  => '87,5%'
110);
111
112# Language codes
113$lang_combo = dcAdminCombos::getAdminLangsCombo();
114
115# Get 3rd parts xhtml editor flags
116$rte = array(
117    'blog_descr' => array(true, __('Blog description (in blog parameters)')),
118    'cat_descr'  => array(true, __('Category description'))
119);
120$rte = new ArrayObject($rte);
121$core->callBehavior('adminRteFlags', $core, $rte);
122# Load user settings
123$rte_flags = @$core->auth->user_prefs->interface->rte_flags;
124if (is_array($rte_flags)) {
125    foreach ($rte_flags as $fk => $fv) {
126        if (isset($rte[$fk])) {
127            $rte[$fk][0] = $fv;
128        }
129    }
130}
131
132# Get default colums (admin lists)
133$cols = array(
134    'posts' => array(__('Posts'), array(
135        'date'       => array(true, __('Date')),
136        'category'   => array(true, __('Category')),
137        'author'     => array(true, __('Author')),
138        'comments'   => array(true, __('Comments')),
139        'trackbacks' => array(true, __('Trackbacks'))
140    ))
141);
142$cols = new arrayObject($cols);
143$core->callBehavior('adminColumnsLists', $core, $cols);
144# Load user settings
145$cols_user = @$core->auth->user_prefs->interface->cols;
146if (is_array($cols_user)) {
147    foreach ($cols_user as $ct => $cv) {
148        foreach ($cv as $cn => $cd) {
149            if (isset($cols[$ct][1][$cn])) {
150                $cols[$ct][1][$cn][0] = $cd;
151            }
152        }
153    }
154}
155
156# Add or update user
157if (isset($_POST['user_name'])) {
158    try
159    {
160        $pwd_check = !empty($_POST['cur_pwd']) && $core->auth->checkPassword($_POST['cur_pwd']);
161
162        if ($core->auth->allowPassChange() && !$pwd_check && $user_email != $_POST['user_email']) {
163            throw new Exception(__('If you want to change your email or password you must provide your current password.'));
164        }
165
166        $cur = $core->con->openCursor($core->prefix . 'user');
167
168        $cur->user_name        = $user_name        = $_POST['user_name'];
169        $cur->user_firstname   = $user_firstname   = $_POST['user_firstname'];
170        $cur->user_displayname = $user_displayname = $_POST['user_displayname'];
171        $cur->user_email       = $user_email       = $_POST['user_email'];
172        $cur->user_url         = $user_url         = $_POST['user_url'];
173        $cur->user_lang        = $user_lang        = $_POST['user_lang'];
174        $cur->user_tz          = $user_tz          = $_POST['user_tz'];
175
176        $cur->user_options = new ArrayObject($user_options);
177
178        if ($core->auth->allowPassChange() && !empty($_POST['new_pwd'])) {
179            if (!$pwd_check) {
180                throw new Exception(__('If you want to change your email or password you must provide your current password.'));
181            }
182
183            if ($_POST['new_pwd'] != $_POST['new_pwd_c']) {
184                throw new Exception(__("Passwords don't match"));
185            }
186
187            $cur->user_pwd = $_POST['new_pwd'];
188        }
189
190        # --BEHAVIOR-- adminBeforeUserUpdate
191        $core->callBehavior('adminBeforeUserProfileUpdate', $cur, $core->auth->userID());
192
193        # Udate user
194        $core->updUser($core->auth->userID(), $cur);
195
196        # --BEHAVIOR-- adminAfterUserUpdate
197        $core->callBehavior('adminAfterUserProfileUpdate', $cur, $core->auth->userID());
198
199        dcPage::addSuccessNotice(__('Personal information has been successfully updated.'));
200
201        $core->adminurl->redirect("admin.user.preferences");
202    } catch (Exception $e) {
203        $core->error->add($e->getMessage());
204    }
205}
206
207# Update user options
208if (isset($_POST['user_editor'])) {
209    try
210    {
211        $cur = $core->con->openCursor($core->prefix . 'user');
212
213        $cur->user_name        = $user_name;
214        $cur->user_firstname   = $user_firstname;
215        $cur->user_displayname = $user_displayname;
216        $cur->user_email       = $user_email;
217        $cur->user_url         = $user_url;
218        $cur->user_lang        = $user_lang;
219        $cur->user_tz          = $user_tz;
220
221        $cur->user_post_status = $user_post_status = $_POST['user_post_status'];
222
223        $user_options['edit_size'] = (integer) $_POST['user_edit_size'];
224        if ($user_options['edit_size'] < 1) {
225            $user_options['edit_size'] = 10;
226        }
227        $user_options['post_format']    = $_POST['user_post_format'];
228        $user_options['editor']         = $_POST['user_editor'];
229        $user_options['enable_wysiwyg'] = !empty($_POST['user_wysiwyg']);
230        $user_options['toolbar_bottom'] = !empty($_POST['user_toolbar_bottom']);
231
232        $cur->user_options = new ArrayObject($user_options);
233
234        # --BEHAVIOR-- adminBeforeUserOptionsUpdate
235        $core->callBehavior('adminBeforeUserOptionsUpdate', $cur, $core->auth->userID());
236
237        # Update user prefs
238        $core->auth->user_prefs->accessibility->put('nodragdrop', !empty($_POST['user_acc_nodragdrop']), 'boolean');
239        $core->auth->user_prefs->interface->put('enhanceduploader', !empty($_POST['user_ui_enhanceduploader']), 'boolean');
240        $core->auth->user_prefs->interface->put('hidemoreinfo', !empty($_POST['user_ui_hidemoreinfo']), 'boolean');
241        $core->auth->user_prefs->interface->put('hidehelpbutton', !empty($_POST['user_ui_hidehelpbutton']), 'boolean');
242        $core->auth->user_prefs->interface->put('showajaxloader', !empty($_POST['user_ui_showajaxloader']), 'boolean');
243        $core->auth->user_prefs->interface->put('htmlfontsize', $_POST['user_ui_htmlfontsize'], 'string');
244        $core->auth->user_prefs->interface->put('dynfontsize', !empty($_POST['user_ui_dynfontsize']), 'boolean');
245        if ($core->auth->isSuperAdmin()) {
246            # Applied to all users
247            $core->auth->user_prefs->interface->put('hide_std_favicon', !empty($_POST['user_ui_hide_std_favicon']), 'boolean', null, true, true);
248        }
249        $core->auth->user_prefs->interface->put('media_by_page', (integer) $_POST['user_ui_media_by_page'], 'integer');
250        $core->auth->user_prefs->interface->put('media_nb_last_dirs', (integer) $_POST['user_ui_media_nb_last_dirs'], 'integer');
251        $core->auth->user_prefs->interface->put('media_last_dirs', array(), 'array', null, false);
252        $core->auth->user_prefs->interface->put('media_fav_dirs', array(), 'array', null, false);
253
254        # Update user columns (lists)
255        $cu = array();
256        foreach ($cols as $col_type => $cols_list) {
257            $ct = array();
258            foreach ($cols_list[1] as $col_name => $col_data) {
259                $ct[$col_name] = isset($_POST['cols_' . $col_type]) && in_array($col_name, $_POST['cols_' . $col_type], true) ? true : false;
260            }
261            if (count($ct)) {
262                $cu[$col_type] = $ct;
263            }
264        }
265        $core->auth->user_prefs->interface->put('cols', $cu, 'array');
266
267        # Update user xhtml editor flags
268        $rf = array();
269        foreach ($rte as $rk => $rv) {
270            $rf[$rk] = isset($_POST['rte_flags']) && in_array($rk, $_POST['rte_flags'], true) ? true : false;
271        }
272        $core->auth->user_prefs->interface->put('rte_flags', $rf, 'array');
273
274        # Update user
275        $core->updUser($core->auth->userID(), $cur);
276
277        # --BEHAVIOR-- adminAfterUserOptionsUpdate
278        $core->callBehavior('adminAfterUserOptionsUpdate', $cur, $core->auth->userID());
279
280        dcPage::addSuccessNotice(__('Personal options has been successfully updated.'));
281        $core->adminurl->redirect("admin.user.preferences", array(), '#user-options');
282    } catch (Exception $e) {
283        $core->error->add($e->getMessage());
284    }
285}
286
287# Dashboard options
288if (isset($_POST['db-options'])) {
289    try
290    {
291        # --BEHAVIOR-- adminBeforeUserOptionsUpdate
292        $core->callBehavior('adminBeforeDashboardOptionsUpdate', $core->auth->userID());
293
294        # Update user prefs
295        $core->auth->user_prefs->dashboard->put('doclinks', !empty($_POST['user_dm_doclinks']), 'boolean');
296        $core->auth->user_prefs->dashboard->put('dcnews', !empty($_POST['user_dm_dcnews']), 'boolean');
297        $core->auth->user_prefs->dashboard->put('quickentry', !empty($_POST['user_dm_quickentry']), 'boolean');
298        $core->auth->user_prefs->dashboard->put('nofavicons', empty($_POST['user_dm_nofavicons']), 'boolean');
299        if ($core->auth->isSuperAdmin()) {
300            $core->auth->user_prefs->dashboard->put('nodcupdate', !empty($_POST['user_dm_nodcupdate']), 'boolean');
301        }
302        $core->auth->user_prefs->interface->put('iconset', (!empty($_POST['user_ui_iconset']) ? $_POST['user_ui_iconset'] : ''));
303        $core->auth->user_prefs->interface->put('nofavmenu', empty($_POST['user_ui_nofavmenu']), 'boolean');
304
305        # --BEHAVIOR-- adminAfterUserOptionsUpdate
306        $core->callBehavior('adminAfterDashboardOptionsUpdate', $core->auth->userID());
307
308        dcPage::addSuccessNotice(__('Dashboard options has been successfully updated.'));
309        $core->adminurl->redirect("admin.user.preferences", array(), '#user-favorites');
310    } catch (Exception $e) {
311        $core->error->add($e->getMessage());
312    }
313}
314
315# Add selected favorites
316if (!empty($_POST['appendaction'])) {
317    try {
318        if (empty($_POST['append'])) {
319            throw new Exception(__('No favorite selected'));
320        }
321        $user_favs = $core->favs->getFavoriteIDs(false);
322        foreach ($_POST['append'] as $k => $v) {
323            if ($core->favs->exists($v)) {
324                $user_favs[] = $v;
325            }
326        }
327        $core->favs->setFavoriteIDs($user_favs, false);
328
329        if (!$core->error->flag()) {
330            dcPage::addSuccessNotice(__('Favorites have been successfully added.'));
331            $core->adminurl->redirect("admin.user.preferences", array(), '#user-favorites');
332        }
333    } catch (Exception $e) {
334        $core->error->add($e->getMessage());
335    }
336}
337
338# Delete selected favorites
339if (!empty($_POST['removeaction'])) {
340    try {
341        if (empty($_POST['remove'])) {
342            throw new Exception(__('No favorite selected'));
343        }
344        $user_fav_ids = array();
345        foreach ($core->favs->getFavoriteIDs(false) as $v) {
346            $user_fav_ids[$v] = true;
347        }
348        foreach ($_POST['remove'] as $v) {
349            if (isset($user_fav_ids[$v])) {
350                unset($user_fav_ids[$v]);
351            }
352        }
353        $core->favs->setFavoriteIDs(array_keys($user_fav_ids), false);
354        if (!$core->error->flag()) {
355            dcPage::addSuccessNotice(__('Favorites have been successfully removed.'));
356            $core->adminurl->redirect("admin.user.preferences", array(), '#user-favorites');
357        }
358    } catch (Exception $e) {
359        $core->error->add($e->getMessage());
360    }
361}
362
363# Order favs
364$order = array();
365if (empty($_POST['favs_order']) && !empty($_POST['order'])) {
366    $order = $_POST['order'];
367    asort($order);
368    $order = array_keys($order);
369} elseif (!empty($_POST['favs_order'])) {
370    $order = explode(',', $_POST['favs_order']);
371}
372
373if (!empty($_POST['saveorder']) && !empty($order)) {
374    foreach ($order as $k => $v) {
375        if (!$core->favs->exists($v)) {
376            unset($order[$k]);
377        }
378    }
379    $core->favs->setFavoriteIDs($order, false);
380    if (!$core->error->flag()) {
381        dcPage::addSuccessNotice(__('Favorites have been successfully updated.'));
382        $core->adminurl->redirect("admin.user.preferences", array(), '#user-favorites');
383    }
384}
385
386# Replace default favorites by current set (super admin only)
387if (!empty($_POST['replace']) && $core->auth->isSuperAdmin()) {
388    $user_favs = $core->favs->getFavoriteIDs(false);
389    $core->favs->setFavoriteIDs($user_favs, true);
390
391    if (!$core->error->flag()) {
392        dcPage::addSuccessNotice(__('Default favorites have been successfully updated.'));
393        $core->adminurl->redirect("admin.user.preferences", array(), '#user-favorites');
394    }
395}
396
397/* DISPLAY
398-------------------------------------------------------- */
399dcPage::open($page_title,
400    dcPage::jsLoad('js/_preferences.js') .
401    ($user_acc_nodragdrop ? '' : dcPage::jsLoad('js/_preferences-dragdrop.js')) .
402    dcPage::jsLoad('js/jquery/jquery-ui.custom.js') .
403    dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js') .
404    dcPage::jsLoad('js/jquery/jquery.pwstrength.js') .
405    '<script type="text/javascript">' . "\n" .
406    "\$(function() {\n" .
407    "   \$('#new_pwd').pwstrength({texts: ['" .
408    sprintf(__('Password strength: %s'), __('very weak')) . "', '" .
409    sprintf(__('Password strength: %s'), __('weak')) . "', '" .
410    sprintf(__('Password strength: %s'), __('mediocre')) . "', '" .
411    sprintf(__('Password strength: %s'), __('strong')) . "', '" .
412    sprintf(__('Password strength: %s'), __('very strong')) . "']});\n" .
413    "});\n" .
414    "</script>\n" .
415    dcPage::jsPageTabs($default_tab) .
416    dcPage::jsConfirmClose('user-form', 'opts-forms', 'favs-form') .
417
418    # --BEHAVIOR-- adminPreferencesHeaders
419    $core->callBehavior('adminPreferencesHeaders'),
420
421    dcPage::breadcrumb(
422        array(
423            html::escapeHTML($core->auth->userID()) => '',
424            $page_title                             => ''
425        ))
426);
427
428# User profile
429echo '<div class="multi-part" id="user-profile" title="' . __('My profile') . '">';
430
431echo
432'<h3>' . __('My profile') . '</h3>' .
433'<form action="' . $core->adminurl->get("admin.user.preferences") . '" method="post" id="user-form">' .
434
435'<p><label for="user_name">' . __('Last Name:') . '</label>' .
436form::field('user_name', 20, 255, array(
437    'default'      => html::escapeHTML($user_name),
438    'autocomplete' => 'family-name'
439)) .
440'</p>' .
441
442'<p><label for="user_firstname">' . __('First Name:') . '</label>' .
443form::field('user_firstname', 20, 255, array(
444    'default'      => html::escapeHTML($user_firstname),
445    'autocomplete' => 'given-name'
446)) .
447'</p>' .
448
449'<p><label for="user_displayname">' . __('Display name:') . '</label>' .
450form::field('user_displayname', 20, 255, array(
451    'default'      => html::escapeHTML($user_displayname),
452    'autocomplete' => 'nickname'
453)) .
454'</p>' .
455
456'<p><label for="user_email">' . __('Email:') . '</label>' .
457form::email('user_email', array(
458    'default'      => html::escapeHTML($user_email),
459    'autocomplete' => 'email'
460)) .
461'</p>' .
462
463'<p><label for="user_url">' . __('URL:') . '</label>' .
464form::url('user_url', array(
465    'size'         => 30,
466    'default'      => html::escapeHTML($user_url),
467    'autocomplete' => 'url'
468)) .
469'</p>' .
470
471'<p><label for="user_lang">' . __('Language for my interface:') . '</label>' .
472form::combo('user_lang', $lang_combo, $user_lang, 'l10n') . '</p>' .
473
474'<p><label for="user_tz">' . __('My timezone:') . '</label>' .
475form::combo('user_tz', dt::getZones(true, true), $user_tz) . '</p>';
476
477if ($core->auth->allowPassChange()) {
478    echo
479    '<h4 class="vertical-separator pretty-title">' . __('Change my password') . '</h4>' .
480
481    '<div class="pw-table">' .
482    '<p class="pw-cell"><label for="new_pwd">' . __('New password:') . '</label>' .
483    form::password('new_pwd', 20, 255,
484        array(
485            'extra_html'   => 'data-indicator="pwindicator"',
486            'autocomplete' => 'new-password')
487    ) . '</p>' .
488    '<div id="pwindicator">' .
489    '    <div class="bar"></div>' .
490    '    <p class="label no-margin"></p>' .
491    '</div>' .
492    '</div>' .
493
494    '<p><label for="new_pwd_c">' . __('Confirm new password:') . '</label>' .
495    form::password('new_pwd_c', 20, 255,
496        array(
497            'autocomplete' => 'new-password')
498    ) . '</p>' .
499
500    '<p><label for="cur_pwd">' . __('Your current password:') . '</label>' .
501    form::password('cur_pwd', 20, 255,
502        array(
503            'autocomplete' => 'current-password')
504    ) . '</p>' .
505    '<p class="form-note warn">' .
506    __('If you have changed your email or password you must provide your current password to save these modifications.') .
507        '</p>';
508}
509
510echo
511'<p class="clear vertical-separator">' .
512$core->formNonce() .
513'<input type="submit" accesskey="s" value="' . __('Update my profile') . '" /></p>' .
514    '</form>' .
515
516    '</div>';
517
518# User options : some from actual user profile, dashboard modules, ...
519echo '<div class="multi-part" id="user-options" title="' . __('My options') . '">';
520
521echo
522'<form action="' . $core->adminurl->get("admin.user.preferences") . '#user-options" method="post" id="opts-forms">' .
523'<h3>' . __('My options') . '</h3>';
524
525echo
526'<div class="fieldset">' .
527'<h4 id="user_options_interface">' . __('Interface') . '</h4>' .
528
529'<p><label for="user_ui_enhanceduploader" class="classic">' .
530form::checkbox('user_ui_enhanceduploader', 1, $user_ui_enhanceduploader) . ' ' .
531__('Activate enhanced uploader in media manager') . '</label></p>' .
532
533'<p><label for="user_acc_nodragdrop" class="classic">' .
534form::checkbox('user_acc_nodragdrop', 1, $user_acc_nodragdrop) . ' ' .
535__('Disable javascript powered drag and drop for ordering items') . '</label></p>' .
536'<p class="clear form-note">' . __('If checked, numeric fields will allow to type the elements\' ordering number.') . '</p>' .
537
538'<p><label for="user_ui_hidemoreinfo" class="classic">' .
539form::checkbox('user_ui_hidemoreinfo', 1, $user_ui_hidemoreinfo) . ' ' .
540__('Hide all secondary information and notes') . '</label></p>' .
541
542'<p><label for="user_ui_hidehelpbutton" class="classic">' .
543form::checkbox('user_ui_hidehelpbutton', 1, $user_ui_hidehelpbutton) . ' ' .
544__('Hide help button') . '</label></p>' .
545
546'<p><label for="user_ui_showajaxloader" class="classic">' .
547form::checkbox('user_ui_showajaxloader', 1, $user_ui_showajaxloader) . ' ' .
548__('Show asynchronous requests indicator') . '</label></p>' .
549
550'<p><label for="user_ui_htmlfontsize" class="classic">' . __('Font size:') . '</label>' . ' ' .
551form::combo('user_ui_htmlfontsize', $htmlfontsize_combo, $user_ui_htmlfontsize) . '</p>' .
552
553'<p><label for="user_ui_dynfontsize" class="classic">' .
554form::checkbox('user_ui_dynfontsize', 1, $user_ui_dynfontsize) . ' ' .
555__('Activate adpative font size') . '</label></p>' .
556'<p class="clear form-note">' . __('If checked, font size will vary depending on viewport size (from 12px to 16px with default font size selected).') . '</p>';
557
558echo
559'<p><label for="user_ui_media_by_page" class="classic">' . __('Number of elements displayed per page in media manager:') . '</label> ' .
560form::number('user_ui_media_by_page', 0, 999, (integer) $user_ui_media_by_page) . '</p>';
561
562echo
563'<p><label for="user_ui_media_nb_last_dirs" class="classic">' . __('Number of recent folders proposed in media manager:') . '</label> ' .
564form::number('user_ui_media_nb_last_dirs', 0, 999, (integer) $user_ui_media_nb_last_dirs) . '</p>' .
565'<p class="clear form-note">' . __('Leave empty to ignore, displayed only if Javascript is enabled in your browser.') . '</p>';
566
567if ($core->auth->isSuperAdmin()) {
568    echo
569    '<p><label for="user_ui_hide_std_favicon" class="classic">' .
570    form::checkbox('user_ui_hide_std_favicon', 1, $user_ui_hide_std_favicon) . ' ' .
571    __('Do not use standard favicon') . '</label> ' .
572    '<span class="clear form-note warn">' . __('This will be applied for all users') . '.</span>' .
573        '</p>'; //Opera sucks;
574}
575
576echo
577    '</div>';
578
579echo
580'<div class="fieldset">' .
581'<h4 id="user_options_columns">' . __('Optional columns displayed in lists') . '</h4>';
582$odd = true;
583foreach ($cols as $col_type => $col_list) {
584    echo '<div class="two-boxes ' . ($odd ? 'odd' : 'even') . '">';
585    echo '<h5>' . $col_list[0] . '</h5>';
586    foreach ($col_list[1] as $col_name => $col_data) {
587        echo
588        '<p><label for="cols_' . $col_type . '-' . $col_name . '" class="classic">' .
589        form::checkbox(array('cols_' . $col_type . '[]', 'cols_' . $col_type . '-' . $col_name), $col_name, $col_data[0]) . $col_data[1] . '</label>';
590    }
591    echo '</div>';
592    $odd = !$odd;
593}
594echo '</div>';
595
596echo
597'<div class="fieldset">' .
598'<h4 id="user_options_edition">' . __('Edition') . '</h4>';
599
600echo '<div class="two-boxes odd">';
601foreach ($format_by_editors as $format => $editors) {
602    echo
603    '<p class="field"><label for="user_editor_' . $format . '">' . sprintf(__('Preferred editor for %s:'), $format) . '</label>' .
604    form::combo(
605        array('user_editor[' . $format . ']', 'user_editor_' . $format),
606        array_merge(array(__('Choose an editor') => ''), $editors),
607        $user_options['editor'][$format]
608    ) . '</p>';
609}
610echo
611'<p class="field"><label for="user_post_format">' . __('Preferred format:') . '</label>' .
612form::combo('user_post_format', $available_formats, $user_options['post_format']) . '</p>';
613
614echo
615'<p class="field"><label for="user_post_status">' . __('Default entry status:') . '</label>' .
616form::combo('user_post_status', $status_combo, $user_post_status) . '</p>' .
617
618'<p class="field"><label for="user_edit_size">' . __('Entry edit field height:') . '</label>' .
619form::number('user_edit_size', 10, 999, (integer) $user_options['edit_size']) . '</p>' .
620
621'<p><label for="user_wysiwyg" class="classic">' .
622form::checkbox('user_wysiwyg', 1, $user_options['enable_wysiwyg']) . ' ' .
623__('Enable WYSIWYG mode') . '</label></p>' .
624
625'<p><label for="user_toolbar_bottom" class="classic">' .
626form::checkbox('user_toolbar_bottom', 1, $user_options['toolbar_bottom']) . ' ' .
627__('Display editor\'s toolbar at bottom of textarea (if possible)') . '</label></p>' .
628
629    '</div>';
630
631echo '<div class="two-boxes even">';
632echo '<h5>' . __('Use xhtml editor for:') . '</h5>';
633foreach ($rte as $rk => $rv) {
634    echo
635    '<p><label for="rte_' . $rk . '" class="classic">' .
636    form::checkbox(array('rte_flags[]', 'rte_' . $rk), $rk, $rv[0]) . $rv[1] . '</label>';
637}
638echo '</div>';
639
640echo '</div>'; // fieldset
641
642echo
643'<h4 class="pretty-title">' . __('Other options') . '</h4>';
644
645# --BEHAVIOR-- adminPreferencesForm
646$core->callBehavior('adminPreferencesForm', $core);
647
648echo
649'<p class="clear vertical-separator">' .
650$core->formNonce() .
651'<input type="submit" accesskey="s" value="' . __('Save my options') . '" /></p>' .
652    '</form>';
653
654echo '</div>';
655
656# My dashboard
657echo '<div class="multi-part" id="user-favorites" title="' . __('My dashboard') . '">';
658$ws = $core->auth->user_prefs->addWorkspace('favorites');
659echo '<h3>' . __('My dashboard') . '</h3>';
660
661echo '<form action="' . $core->adminurl->get("admin.user.preferences") . '" method="post" id="favs-form" class="two-boxes odd">';
662
663echo '<div id="my-favs" class="fieldset"><h4>' . __('My favorites') . '</h4>';
664
665$count    = 0;
666$user_fav = $core->favs->getFavoriteIDs(false);
667foreach ($user_fav as $id) {
668    $fav = $core->favs->getFavorite($id);
669    if ($fav != false) {
670        // User favorites only
671        if ($count == 0) {
672            echo '<ul class="fav-list">';
673        }
674
675        $count++;
676        echo '<li id="fu-' . $id . '">' . '<label for="fuk-' . $id . '">' .
677        '<img src="' . dc_admin_icon_url($fav['small-icon']) . '" alt="" /> ' . '<span class="zoom"><img src="' . dc_admin_icon_url($fav['large-icon']) . '" alt="" /></span>' .
678        form::field(array('order[' . $id . ']'), 2, 3, array(
679            'default'    => $count,
680            'class'      => 'position',
681            'extra_html' => 'title="' . sprintf(__('position of %s'), $fav['title']) . '"'
682        )) .
683        form::hidden(array('dynorder[]', 'dynorder-' . $id . ''), $id) .
684        form::checkbox(array('remove[]', 'fuk-' . $id), $id) . __($fav['title']) . '</label>' .
685            '</li>';
686    }
687}
688if ($count > 0) {
689    echo '</ul>';
690}
691
692if ($count > 0) {
693    echo
694    '<div class="clear">' .
695    '<p>' . form::hidden('favs_order', '') .
696    $core->formNonce() .
697    '<input type="submit" name="saveorder" value="' . __('Save order') . '" /> ' .
698
699    '<input type="submit" class="delete" name="removeaction" ' .
700    'value="' . __('Delete selected favorites') . '" ' .
701    'onclick="return window.confirm(\'' . html::escapeJS(
702        __('Are you sure you want to remove selected favorites?')) . '\');" /></p>' .
703
704        ($core->auth->isSuperAdmin() ?
705        '<div class="info">' .
706        '<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>' .
707        '<p><input class="reset" type="submit" name="replace" value="' . __('Define as default favorites') . '" />' . '</p>' .
708        '</div>'
709        :
710        '') .
711
712        '</div>';
713} else {
714    echo
715    '<p>' . __('Currently no personal favorites.') . '</p>';
716}
717
718$avail_fav       = $core->favs->getFavorites($core->favs->getAvailableFavoritesIDs());
719$default_fav_ids = array();
720foreach ($core->favs->getFavoriteIDs(true) as $v) {
721    $default_fav_ids[$v] = true;
722}
723echo '</div>'; # /box my-fav
724
725echo '<div class="fieldset" id="available-favs">';
726# Available favorites
727echo '<h5 class="pretty-title">' . __('Other available favorites') . '</h5>';
728$count = 0;
729uasort($avail_fav, function ($a, $b) {
730    return strcoll(
731        strtolower(dcUtils::removeDiacritics($a['title'])),
732        strtolower(dcUtils::removeDiacritics($b['title'])));
733});
734
735foreach ($avail_fav as $k => $v) {
736    if (in_array($k, $user_fav)) {
737        unset($avail_fav[$k]);
738    }
739}
740foreach ($avail_fav as $k => $fav) {
741    if ($count == 0) {
742        echo '<ul class="fav-list">';
743    }
744
745    $count++;
746    echo '<li id="fa-' . $k . '">' . '<label for="fak-' . $k . '">' .
747    '<img src="' . dc_admin_icon_url($fav['small-icon']) . '" alt="" /> ' .
748    '<span class="zoom"><img src="' . dc_admin_icon_url($fav['large-icon']) . '" alt="" /></span>' .
749    form::checkbox(array('append[]', 'fak-' . $k), $k) .
750        $fav['title'] . '</label>' .
751        (isset($default_fav_ids[$k]) ? ' <span class="default-fav"><img src="images/selected.png" alt="' . __('(default favorite)') . '" /></span>' : '') .
752        '</li>';
753}
754if ($count > 0) {
755    echo '</ul>';
756}
757
758echo
759'<p>' .
760$core->formNonce() .
761'<input type="submit" name="appendaction" value="' . __('Add to my favorites') . '" /></p>';
762echo '</div>'; # /available favorites
763
764echo '</form>';
765
766echo
767'<form action="' . $core->adminurl->get("admin.user.preferences") . '" method="post" id="db-forms" class="two-boxes even">' .
768
769'<div class="fieldset">' .
770'<h4>' . __('Menu') . '</h4>' .
771'<p><label for="user_ui_nofavmenu" class="classic">' .
772form::checkbox('user_ui_nofavmenu', 1, !$user_ui_nofavmenu) . ' ' .
773__('Display favorites at the top of the menu') . '</label></p></div>';
774
775echo
776'<div class="fieldset">' .
777'<h4>' . __('Dashboard icons') . '</h4>' .
778'<p><label for="user_dm_nofavicons" class="classic">' .
779form::checkbox('user_dm_nofavicons', 1, !$user_dm_nofavicons) . ' ' .
780__('Display dashboard icons') . '</label></p>';
781
782if (count($iconsets_combo) > 1) {
783    echo
784    '<p><label for="user_ui_iconset" class="classic">' . __('Iconset:') . '</label> ' .
785    form::combo('user_ui_iconset', $iconsets_combo, $user_ui_iconset) . '</p>';
786} else {
787    echo '<p class="hidden">' . form::hidden('user_ui_iconset', '') . '</p>';
788}
789echo
790    '</div>';
791
792echo
793'<div class="fieldset">' .
794'<h4>' . __('Dashboard modules') . '</h4>' .
795
796'<p><label for="user_dm_doclinks" class="classic">' .
797form::checkbox('user_dm_doclinks', 1, $user_dm_doclinks) . ' ' .
798__('Display documentation links') . '</label></p>' .
799
800'<p><label for="user_dm_dcnews" class="classic">' .
801form::checkbox('user_dm_dcnews', 1, $user_dm_dcnews) . ' ' .
802__('Display Dotclear news') . '</label></p>' .
803
804'<p><label for="user_dm_quickentry" class="classic">' .
805form::checkbox('user_dm_quickentry', 1, $user_dm_quickentry) . ' ' .
806__('Display quick entry form') . '</label></p>';
807
808if ($core->auth->isSuperAdmin()) {
809    echo
810    '<p><label for="user_dm_nodcupdate" class="classic">' .
811    form::checkbox('user_dm_nodcupdate', 1, $user_dm_nodcupdate) . ' ' .
812    __('Do not display Dotclear updates') . '</label></p>';
813}
814
815echo '</div>';
816
817# --BEHAVIOR-- adminDashboardOptionsForm
818$core->callBehavior('adminDashboardOptionsForm', $core);
819
820echo
821'<p>' .
822form::hidden('db-options', '-') .
823$core->formNonce() .
824'<input type="submit" accesskey="s" value="' . __('Save my dashboard options') . '" /></p>' .
825    '</form>';
826
827echo '</div>'; # /multipart-user-favorites
828
829dcPage::helpBlock('core_user_pref');
830dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map