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