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