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