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