[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
| 6 | # Copyright (c) 2003-2010 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 | |
---|
[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 | |
---|
[3] | 35 | $default_tab = 'user-profile'; |
---|
| 36 | |
---|
[30] | 37 | if (!empty($_GET['append']) || !empty($_GET['removed']) || !empty($_GET['neworder']) || !empty($_GET['replaced'])) { |
---|
[3] | 38 | $default_tab = 'user-favorites'; |
---|
[13] | 39 | } elseif (!empty($_GET['updated'])) { |
---|
| 40 | $default_tab = 'user-options'; |
---|
[3] | 41 | } |
---|
| 42 | |
---|
[0] | 43 | foreach ($core->getFormaters() as $v) { |
---|
| 44 | $formaters_combo[$v] = $v; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | foreach ($core->blog->getAllPostStatus() as $k => $v) { |
---|
| 48 | $status_combo[$v] = $k; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | # Language codes |
---|
| 52 | $langs = l10n::getISOcodes(1,1); |
---|
| 53 | foreach ($langs as $k => $v) { |
---|
| 54 | $lang_avail = $v == 'en' || is_dir(DC_L10N_ROOT.'/'.$v); |
---|
| 55 | $lang_combo[] = new formSelectOption($k,$v,$lang_avail ? 'avail10n' : ''); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | # Add or update user |
---|
| 59 | if (isset($_POST['user_name'])) |
---|
| 60 | { |
---|
| 61 | try |
---|
| 62 | { |
---|
| 63 | $pwd_check = !empty($_POST['cur_pwd']) && $core->auth->checkPassword(crypt::hmac(DC_MASTER_KEY,$_POST['cur_pwd'])); |
---|
| 64 | |
---|
| 65 | if ($core->auth->allowPassChange() && !$pwd_check && $user_email != $_POST['user_email']) { |
---|
| 66 | throw new Exception(__('If you want to change your email or password you must provide your current password.')); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | $cur = $core->con->openCursor($core->prefix.'user'); |
---|
| 70 | |
---|
| 71 | $cur->user_name = $user_name = $_POST['user_name']; |
---|
| 72 | $cur->user_firstname = $user_firstname = $_POST['user_firstname']; |
---|
| 73 | $cur->user_displayname = $user_displayname = $_POST['user_displayname']; |
---|
| 74 | $cur->user_email = $user_email = $_POST['user_email']; |
---|
| 75 | $cur->user_url = $user_url = $_POST['user_url']; |
---|
| 76 | $cur->user_lang = $user_lang = $_POST['user_lang']; |
---|
| 77 | $cur->user_tz = $user_tz = $_POST['user_tz']; |
---|
[13] | 78 | |
---|
[0] | 79 | $cur->user_options = new ArrayObject($user_options); |
---|
| 80 | |
---|
| 81 | if ($core->auth->allowPassChange() && !empty($_POST['new_pwd'])) |
---|
| 82 | { |
---|
| 83 | if (!$pwd_check) { |
---|
| 84 | throw new Exception(__('If you want to change your email or password you must provide your current password.')); |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | if ($_POST['new_pwd'] != $_POST['new_pwd_c']) { |
---|
| 88 | throw new Exception(__("Passwords don't match")); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | $cur->user_pwd = $_POST['new_pwd']; |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | # --BEHAVIOR-- adminBeforeUserUpdate |
---|
[13] | 95 | $core->callBehavior('adminBeforeUserProfileUpdate',$cur,$core->auth->userID()); |
---|
| 96 | |
---|
| 97 | # Udate user |
---|
| 98 | $core->updUser($core->auth->userID(),$cur); |
---|
| 99 | |
---|
| 100 | # --BEHAVIOR-- adminAfterUserUpdate |
---|
| 101 | $core->callBehavior('adminAfterUserProfileUpdate',$cur,$core->auth->userID()); |
---|
| 102 | |
---|
| 103 | http::redirect('preferences.php?upd=1'); |
---|
| 104 | } |
---|
| 105 | catch (Exception $e) |
---|
| 106 | { |
---|
| 107 | $core->error->add($e->getMessage()); |
---|
| 108 | } |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | # Update user options |
---|
| 112 | if (isset($_POST['user_post_format'])) { |
---|
| 113 | try |
---|
| 114 | { |
---|
| 115 | $cur = $core->con->openCursor($core->prefix.'user'); |
---|
| 116 | |
---|
| 117 | $cur->user_name = $user_name; |
---|
| 118 | $cur->user_firstname = $user_firstname; |
---|
| 119 | $cur->user_displayname = $user_displayname; |
---|
| 120 | $cur->user_email = $user_email; |
---|
| 121 | $cur->user_url = $user_url; |
---|
| 122 | $cur->user_lang = $user_lang; |
---|
| 123 | $cur->user_tz = $user_tz; |
---|
| 124 | |
---|
| 125 | $cur->user_post_status = $user_post_status = $_POST['user_post_status']; |
---|
| 126 | |
---|
| 127 | $user_options['edit_size'] = (integer) $_POST['user_edit_size']; |
---|
| 128 | if ($user_options['edit_size'] < 1) { |
---|
| 129 | $user_options['edit_size'] = 10; |
---|
| 130 | } |
---|
| 131 | $user_options['post_format'] = $_POST['user_post_format']; |
---|
| 132 | $user_options['enable_wysiwyg'] = !empty($_POST['user_wysiwyg']); |
---|
| 133 | |
---|
| 134 | $cur->user_options = new ArrayObject($user_options); |
---|
| 135 | |
---|
| 136 | # --BEHAVIOR-- adminBeforeUserUpdate |
---|
[0] | 137 | $core->callBehavior('adminBeforeUserUpdate',$cur,$core->auth->userID()); |
---|
| 138 | |
---|
[13] | 139 | # Update user prefs |
---|
| 140 | $core->auth->user_prefs->dashboard->put('doclinks',!empty($_POST['user_dm_doclinks']),'boolean'); |
---|
| 141 | $core->auth->user_prefs->dashboard->put('dcnews',!empty($_POST['user_dm_dcnews']),'boolean'); |
---|
| 142 | $core->auth->user_prefs->dashboard->put('quickentry',!empty($_POST['user_dm_quickentry']),'boolean'); |
---|
| 143 | |
---|
[0] | 144 | # Udate user |
---|
| 145 | $core->updUser($core->auth->userID(),$cur); |
---|
| 146 | |
---|
| 147 | # --BEHAVIOR-- adminAfterUserUpdate |
---|
| 148 | $core->callBehavior('adminAfterUserUpdate',$cur,$core->auth->userID()); |
---|
| 149 | |
---|
[13] | 150 | http::redirect('preferences.php?updated=1'); |
---|
[0] | 151 | } |
---|
| 152 | catch (Exception $e) |
---|
| 153 | { |
---|
| 154 | $core->error->add($e->getMessage()); |
---|
| 155 | } |
---|
| 156 | } |
---|
| 157 | |
---|
[3] | 158 | # Add selected favorites |
---|
| 159 | if (!empty($_POST['appendaction']) && !empty($_POST['append'])) { |
---|
| 160 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
| 161 | $user_favs = $ws->DumpLocalPrefs(); |
---|
| 162 | $count = count($user_favs); |
---|
| 163 | foreach ($_POST['append'] as $k => $v) |
---|
| 164 | { |
---|
| 165 | try { |
---|
| 166 | $found = false; |
---|
| 167 | foreach ($user_favs as $f) { |
---|
| 168 | $f = unserialize($f['value']); |
---|
| 169 | if ($f['name'] == $v) { |
---|
| 170 | $found = true; |
---|
| 171 | break; |
---|
| 172 | } |
---|
| 173 | } |
---|
| 174 | if (!$found) { |
---|
| 175 | $uid = sprintf("u%03s",$count); |
---|
| 176 | $fav = array('name' => $_fav[$v][0],'title' => $_fav[$v][1],'url' => $_fav[$v][2],'small-icon' => $_fav[$v][3], |
---|
| 177 | 'large-icon' => $_fav[$v][4],'permissions' => $_fav[$v][5],'id' => $_fav[$v][6],'class' => $_fav[$v][7]); |
---|
| 178 | $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string'); |
---|
| 179 | $count++; |
---|
| 180 | } |
---|
| 181 | } catch (Exception $e) { |
---|
| 182 | $core->error->add($e->getMessage()); |
---|
| 183 | break; |
---|
| 184 | } |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | if (!$core->error->flag()) { |
---|
| 188 | http::redirect('preferences.php?append=1'); |
---|
| 189 | } |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | # Delete selected favorites |
---|
| 193 | if (!empty($_POST['removeaction']) && !empty($_POST['remove'])) { |
---|
| 194 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
| 195 | foreach ($_POST['remove'] as $k => $v) |
---|
| 196 | { |
---|
| 197 | try { |
---|
| 198 | $core->auth->user_prefs->favorites->drop($v); |
---|
| 199 | } catch (Exception $e) { |
---|
| 200 | $core->error->add($e->getMessage()); |
---|
| 201 | break; |
---|
| 202 | } |
---|
| 203 | } |
---|
| 204 | // Update pref_id values |
---|
| 205 | try { |
---|
| 206 | $user_favs = $ws->DumpLocalPrefs(); |
---|
| 207 | foreach ($user_favs as $k => $v) |
---|
| 208 | { |
---|
| 209 | $core->auth->user_prefs->favorites->drop($k); |
---|
| 210 | } |
---|
| 211 | $count = 0; |
---|
| 212 | foreach ($user_favs as $k => $v) |
---|
| 213 | { |
---|
| 214 | $uid = sprintf("u%03s",$count); |
---|
| 215 | $f = unserialize($v['value']); |
---|
| 216 | $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'], |
---|
| 217 | 'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']); |
---|
| 218 | $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string'); |
---|
| 219 | $count++; |
---|
| 220 | } |
---|
| 221 | } catch (Exception $e) { |
---|
| 222 | $core->error->add($e->getMessage()); |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | if (!$core->error->flag()) { |
---|
| 226 | http::redirect('preferences.php?removed=1'); |
---|
| 227 | } |
---|
| 228 | } |
---|
| 229 | |
---|
| 230 | # Order favs |
---|
| 231 | $order = array(); |
---|
| 232 | if (empty($_POST['favs_order']) && !empty($_POST['order'])) { |
---|
| 233 | $order = $_POST['order']; |
---|
| 234 | asort($order); |
---|
| 235 | $order = array_keys($order); |
---|
| 236 | } elseif (!empty($_POST['favs_order'])) { |
---|
| 237 | $order = explode(',',$_POST['favs_order']); |
---|
| 238 | } |
---|
| 239 | |
---|
| 240 | if (!empty($_POST['saveorder']) && !empty($order)) |
---|
| 241 | { |
---|
| 242 | try { |
---|
[26] | 243 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
[3] | 244 | $user_favs = $ws->DumpLocalPrefs(); |
---|
| 245 | foreach ($user_favs as $k => $v) |
---|
| 246 | { |
---|
| 247 | $core->auth->user_prefs->favorites->drop($k); |
---|
| 248 | } |
---|
| 249 | $count = 0; |
---|
| 250 | foreach ($order as $i => $k) { |
---|
| 251 | $uid = sprintf("u%03s",$count); |
---|
| 252 | $f = unserialize($user_favs[$k]['value']); |
---|
| 253 | $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'], |
---|
| 254 | 'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']); |
---|
| 255 | $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string'); |
---|
| 256 | $count++; |
---|
| 257 | } |
---|
| 258 | } catch (Exception $e) { |
---|
| 259 | $core->error->add($e->getMessage()); |
---|
| 260 | } |
---|
| 261 | |
---|
| 262 | if (!$core->error->flag()) { |
---|
| 263 | http::redirect('preferences.php?&neworder=1'); |
---|
| 264 | } |
---|
| 265 | } |
---|
| 266 | |
---|
[30] | 267 | # Replace default favorites by current set (super admin only) |
---|
| 268 | if (!empty($_POST['replace']) && $core->auth->isSuperAdmin()) { |
---|
| 269 | try { |
---|
| 270 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
| 271 | $user_favs = $ws->DumpLocalPrefs(); |
---|
| 272 | $def_favs = $ws->DumpGlobalPrefs(); |
---|
| 273 | foreach ($def_favs as $k => $v) |
---|
| 274 | { |
---|
| 275 | $core->auth->user_prefs->favorites->drop($k,true); |
---|
| 276 | } |
---|
| 277 | $count = 0; |
---|
| 278 | foreach ($user_favs as $k => $v) |
---|
| 279 | { |
---|
| 280 | $uid = sprintf("g%03s",$count); |
---|
| 281 | $f = unserialize($v['value']); |
---|
| 282 | $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'], |
---|
| 283 | 'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']); |
---|
| 284 | $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string',null,null,true); |
---|
| 285 | $count++; |
---|
| 286 | } |
---|
| 287 | } catch (Exception $e) { |
---|
| 288 | $core->error->add($e->getMessage()); |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | if (!$core->error->flag()) { |
---|
| 292 | http::redirect('preferences.php?&replaced=1'); |
---|
| 293 | } |
---|
| 294 | } |
---|
[0] | 295 | |
---|
| 296 | /* DISPLAY |
---|
| 297 | -------------------------------------------------------- */ |
---|
| 298 | dcPage::open($page_title, |
---|
| 299 | dcPage::jsLoad('js/_preferences.js'). |
---|
[15] | 300 | dcPage::jsLoad('js/jquery/jquery-ui-1.8.12.custom.min.js'). |
---|
[3] | 301 | dcPage::jsPageTabs($default_tab). |
---|
[0] | 302 | dcPage::jsConfirmClose('user-form'). |
---|
| 303 | |
---|
| 304 | # --BEHAVIOR-- adminPreferencesHeaders |
---|
| 305 | $core->callBehavior('adminPreferencesHeaders') |
---|
| 306 | ); |
---|
| 307 | |
---|
| 308 | if (!empty($_GET['upd'])) { |
---|
| 309 | echo '<p class="message">'.__('Personal information has been successfully updated.').'</p>'; |
---|
| 310 | } |
---|
[13] | 311 | if (!empty($_GET['updated'])) { |
---|
| 312 | echo '<p class="message">'.__('Personal options has been successfully updated.').'</p>'; |
---|
| 313 | } |
---|
[3] | 314 | if (!empty($_GET['append'])) { |
---|
| 315 | echo '<p class="message">'.__('Favorites have been successfully added.').'</p>'; |
---|
| 316 | } |
---|
| 317 | if (!empty($_GET['neworder'])) { |
---|
| 318 | echo '<p class="message">'.__('Favorites has been successfully updated.').'</p>'; |
---|
| 319 | } |
---|
| 320 | if (!empty($_GET['removed'])) { |
---|
| 321 | echo '<p class="message">'.__('Favorites have been successfully removed.').'</p>'; |
---|
| 322 | } |
---|
[30] | 323 | if (!empty($_GET['replaced'])) { |
---|
| 324 | echo '<p class="message">'.__('Default favorites have been successfully updated.').'</p>'; |
---|
| 325 | } |
---|
[3] | 326 | |
---|
[13] | 327 | echo '<h2>'.$page_title.'</h2>'; |
---|
| 328 | |
---|
[3] | 329 | # User profile |
---|
| 330 | echo '<div class="multi-part" id="user-profile" title="'.__('My profile').'">'; |
---|
[0] | 331 | |
---|
| 332 | echo |
---|
| 333 | '<form action="preferences.php" method="post" id="user-form">'. |
---|
[3] | 334 | '<fieldset><legend>'.__('My profile').'</legend>'. |
---|
[0] | 335 | '<div class="two-cols">'. |
---|
| 336 | '<div class="col">'. |
---|
[11] | 337 | '<p><label for="user_name">'.__('Last Name:'). |
---|
[0] | 338 | form::field('user_name',20,255,html::escapeHTML($user_name),'',2).'</label></p>'. |
---|
| 339 | |
---|
[3] | 340 | '<p><label for="user_firstname">'.__('First Name:'). |
---|
[0] | 341 | form::field('user_firstname',20,255,html::escapeHTML($user_firstname),'',3).'</label></p>'. |
---|
| 342 | |
---|
[3] | 343 | '<p><label for="user_displayname">'.__('Display name:'). |
---|
[0] | 344 | form::field('user_displayname',20,255,html::escapeHTML($user_displayname),'',4).'</label></p>'. |
---|
| 345 | |
---|
[3] | 346 | '<p><label for="user_email">'.__('Email:'). |
---|
[0] | 347 | form::field('user_email',20,255,html::escapeHTML($user_email),'',5).'</label></p>'. |
---|
| 348 | |
---|
[3] | 349 | '<p><label for="user_url">'.__('URL:'). |
---|
[0] | 350 | form::field('user_url',30,255,html::escapeHTML($user_url),'',6).'</label></p>'. |
---|
| 351 | |
---|
| 352 | '</div>'. |
---|
| 353 | |
---|
| 354 | '<div class="col">'. |
---|
| 355 | |
---|
[3] | 356 | '<p><label for="user_lang">'.__('User language:'). |
---|
[0] | 357 | form::combo('user_lang',$lang_combo,$user_lang,'l10n',10).'</label></p>'. |
---|
| 358 | |
---|
[3] | 359 | '<p><label for="user_tz">'.__('User timezone:'). |
---|
[0] | 360 | form::combo('user_tz',dt::getZones(true,true),$user_tz,'',11).'</label></p>'. |
---|
| 361 | |
---|
| 362 | '</div>'. |
---|
| 363 | '</div>'. |
---|
| 364 | '<br class="clear" />'. //Opera sucks |
---|
| 365 | '</fieldset>'; |
---|
| 366 | |
---|
| 367 | if ($core->auth->allowPassChange()) |
---|
| 368 | { |
---|
| 369 | echo |
---|
| 370 | '<fieldset>'. |
---|
| 371 | '<legend>'.__('Change your password').'</legend>'. |
---|
| 372 | |
---|
[3] | 373 | '<p><label for="new_pwd">'.__('New password:'). |
---|
[0] | 374 | form::password('new_pwd',20,255,'','',30).'</label></p>'. |
---|
| 375 | |
---|
[3] | 376 | '<p><label for="new_pwd_c">'.__('Confirm password:'). |
---|
[0] | 377 | form::password('new_pwd_c',20,255,'','',31).'</label></p>'. |
---|
| 378 | '</fieldset>'. |
---|
| 379 | |
---|
| 380 | '<fieldset>'. |
---|
| 381 | '<p>'.__('If you want to change your email or password you must provide your current password.').'</p>'. |
---|
[3] | 382 | '<p><label for="cur_pwd">'.__('Your password:'). |
---|
[0] | 383 | form::password('cur_pwd',20,255,'','',32).'</label></p>'. |
---|
| 384 | '</fieldset>'; |
---|
| 385 | } |
---|
| 386 | |
---|
| 387 | echo |
---|
| 388 | '<p class="clear">'. |
---|
| 389 | $core->formNonce(). |
---|
| 390 | '<input type="submit" accesskey="s" value="'.__('Save').'" tabindex="33" /></p>'. |
---|
| 391 | '</form>'; |
---|
| 392 | |
---|
[3] | 393 | echo '</div>'; |
---|
| 394 | |
---|
| 395 | # User options : some from actual user profile, dashboard modules, ... |
---|
| 396 | echo '<div class="multi-part" id="user-options" title="'.__('My options').'">'; |
---|
| 397 | |
---|
| 398 | echo |
---|
[13] | 399 | '<form action="preferences.php" method="post" id="user-options">'. |
---|
[3] | 400 | '<fieldset><legend>'.__('My options').'</legend>'. |
---|
| 401 | |
---|
| 402 | '<p><label for="user_post_format">'.__('Preferred format:'). |
---|
| 403 | form::combo('user_post_format',$formaters_combo,$user_options['post_format'],'',7).'</label></p>'. |
---|
| 404 | |
---|
| 405 | '<p><label for="user_post_status">'.__('Default entry status:'). |
---|
| 406 | form::combo('user_post_status',$status_combo,$user_post_status,'',8).'</label></p>'. |
---|
| 407 | |
---|
| 408 | '<p><label for="user_edit_size">'.__('Entry edit field height:'). |
---|
| 409 | form::field('user_edit_size',5,4,(integer) $user_options['edit_size'],'',9).'</label></p>'. |
---|
| 410 | |
---|
| 411 | '<p><label for="user_wysiwyg" class="classic">'. |
---|
| 412 | form::checkbox('user_wysiwyg',1,$user_options['enable_wysiwyg'],'',12).' '. |
---|
| 413 | __('Enable WYSIWYG mode').'</label></p>'. |
---|
| 414 | '<br class="clear" />'. //Opera sucks |
---|
| 415 | '</fieldset>'; |
---|
| 416 | |
---|
[13] | 417 | echo |
---|
| 418 | '<fieldset><legend>'.__('Dashboard modules').'</legend>'. |
---|
| 419 | |
---|
| 420 | '<p><label for="user_dm_doclinks" class="classic">'. |
---|
| 421 | form::checkbox('user_dm_doclinks',1,$user_dm_doclinks,'',13).' '. |
---|
| 422 | __('Display documentation links').'</label></p>'. |
---|
| 423 | |
---|
| 424 | '<p><label for="user_dm_dcnews" class="classic">'. |
---|
| 425 | form::checkbox('user_dm_dcnews',1,$user_dm_dcnews,'',14).' '. |
---|
| 426 | __('Display Dotclear news').'</label></p>'. |
---|
| 427 | |
---|
| 428 | '<p><label for="user_dm_quickentry" class="classic">'. |
---|
| 429 | form::checkbox('user_dm_quickentry',1,$user_dm_quickentry,'',15).' '. |
---|
| 430 | __('Display quick entry form').'</label></p>'. |
---|
| 431 | |
---|
| 432 | '<br class="clear" />'. //Opera sucks |
---|
| 433 | '</fieldset>'; |
---|
| 434 | |
---|
[3] | 435 | # --BEHAVIOR-- adminPreferencesForm |
---|
| 436 | $core->callBehavior('adminPreferencesForm',$core); |
---|
| 437 | |
---|
| 438 | echo |
---|
| 439 | '<p class="clear">'. |
---|
| 440 | $core->formNonce(). |
---|
| 441 | '<input type="submit" accesskey="s" value="'.__('Save').'" tabindex="33" /></p>'. |
---|
| 442 | '</form>'; |
---|
| 443 | |
---|
| 444 | echo '</div>'; |
---|
| 445 | |
---|
| 446 | # User favorites |
---|
| 447 | echo '<div class="multi-part" id="user-favorites" title="'.__('My favorites').'">'; |
---|
| 448 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
| 449 | echo '<form action="preferences.php" method="post" id="favs-form">'; |
---|
| 450 | echo '<div class="two-cols">'; |
---|
| 451 | echo '<div class="col70">'; |
---|
| 452 | echo '<fieldset id="my-favs"><legend>'.__('My favorites').'</legend>'; |
---|
[32] | 453 | |
---|
[3] | 454 | $count = 0; |
---|
| 455 | foreach ($ws->dumpPrefs() as $k => $v) { |
---|
| 456 | // User favorites only |
---|
| 457 | if (!$v['global']) { |
---|
| 458 | $fav = unserialize($v['value']); |
---|
| 459 | if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) { |
---|
| 460 | if ($count == 0) echo '<ul>'; |
---|
| 461 | $count++; |
---|
| 462 | echo '<li id="fu-'.$k.'">'. |
---|
| 463 | '<img src="'.$fav['large-icon'].'" alt="" /> '. |
---|
[11] | 464 | form::field(array('order['.$k.']'),2,3,$count,'position','',false,'title="position de '.$fav['title'].'"'). |
---|
[15] | 465 | form::hidden('dynorder[]',$k). |
---|
[3] | 466 | '<label for="fuk-'.$k.'">'.form::checkbox(array('remove[]','fuk-'.$k),$k).$fav['title'].'</label>'. |
---|
| 467 | '</li>'; |
---|
| 468 | } |
---|
| 469 | } |
---|
| 470 | } |
---|
| 471 | if ($count > 0) echo '</ul>'; |
---|
| 472 | if ($count > 0) { |
---|
| 473 | echo |
---|
| 474 | '<div class="clear">'. |
---|
| 475 | '<p class="col">'.form::hidden('favs_order',''). |
---|
| 476 | $core->formNonce(). |
---|
[30] | 477 | '<input type="submit" name="saveorder" value="'.__('Save order').'">'. |
---|
[32] | 478 | ($core->auth->isSuperAdmin() ? ' <input class="reset" type="submit" name="replace" value="'.__('Define as default favorites').'">' : ''). |
---|
[30] | 479 | '</p>'. |
---|
[3] | 480 | |
---|
| 481 | '<p class="right"><input type="submit" class="delete" name="removeaction"'. |
---|
| 482 | 'value="'.__('Delete selected favorites').'" '. |
---|
| 483 | 'onclick="return window.confirm(\''.html::escapeJS( |
---|
| 484 | __('Are you sure you want to remove selected favorites?')).'\');" /></p>'. |
---|
| 485 | '</div>'; |
---|
| 486 | } else { |
---|
| 487 | echo |
---|
| 488 | '<p>'.__('Currently no personal favorites.').'</p>'; |
---|
| 489 | } |
---|
| 490 | |
---|
| 491 | echo '</fieldset>'; |
---|
| 492 | |
---|
| 493 | echo '<div id="default-favs"><h3>'.__('Default favorites').'</h3>'; |
---|
| 494 | echo '<p class="form-note clear">'.__('Those favorites are displayed when My Favorites list is empty.').'</p>'; |
---|
| 495 | $count = 0; |
---|
| 496 | foreach ($ws->dumpPrefs() as $k => $v) { |
---|
| 497 | // Global favorites only |
---|
| 498 | if ($v['global']) { |
---|
| 499 | $fav = unserialize($v['value']); |
---|
| 500 | if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) { |
---|
| 501 | if ($count == 0) echo '<ul class="fav-list">'; |
---|
| 502 | $count++; |
---|
| 503 | echo '<li id="fd-'.$k.'">'. |
---|
| 504 | '<img src="'.$fav['small-icon'].'" alt="" /> '.$fav['title'].'</li>'; |
---|
| 505 | } |
---|
| 506 | } |
---|
| 507 | } |
---|
| 508 | if ($count > 0) echo '</ul>'; |
---|
| 509 | echo '</div>'; |
---|
| 510 | echo '</div>'; |
---|
| 511 | echo '<div class="col30" id="available-favs">'; |
---|
| 512 | # Available favorites |
---|
| 513 | echo '<fieldset><legend>'.__('Available favorites').'</legend>'; |
---|
| 514 | $count = 0; |
---|
| 515 | $array = $_fav; |
---|
| 516 | function cmp($a,$b) { |
---|
| 517 | if ($a[1] == $b[1]) { |
---|
| 518 | return 0; |
---|
| 519 | } |
---|
| 520 | return ($a[1] < $b[1]) ? -1 : 1; |
---|
| 521 | } |
---|
[10] | 522 | $array->uasort('cmp'); |
---|
[3] | 523 | foreach ($array as $k => $fav) { |
---|
| 524 | if (($fav[5] == '*') || $core->auth->check($fav[5],$core->blog->id)) { |
---|
| 525 | if ($count == 0) echo '<ul class="fav-list">'; |
---|
| 526 | $count++; |
---|
| 527 | echo '<li id="fa-'.$fav[0].'">'.'<label for="fak-'.$fav[0].'">'. |
---|
[11] | 528 | form::checkbox(array('append[]','fak-'.$fav[0]),$k). |
---|
[3] | 529 | '<img src="'.$fav[3].'" alt="" /> '.'<span class="zoom"><img src="'.$fav[4].'" alt="" /></span>'.$fav[1]. |
---|
| 530 | '</label>'.'</li>'; |
---|
| 531 | } |
---|
| 532 | } |
---|
| 533 | if ($count > 0) echo '</ul>'; |
---|
| 534 | echo |
---|
| 535 | '<p>'. |
---|
| 536 | $core->formNonce(). |
---|
| 537 | '<input type="submit" name="appendaction" value="'.__('Add to my favorites').'"></p>'; |
---|
| 538 | echo '</div>'; |
---|
| 539 | echo '</div>'; # Two-cols |
---|
| 540 | echo '</form>'; |
---|
| 541 | echo '</div>'; # user-favorites |
---|
| 542 | |
---|
[0] | 543 | dcPage::helpBlock('core_user_pref'); |
---|
| 544 | dcPage::close(); |
---|
| 545 | ?> |
---|