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