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