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