[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(); |
---|
[34] | 207 | $core->auth->user_prefs->favorites->dropAll(); |
---|
[3] | 208 | $count = 0; |
---|
| 209 | foreach ($user_favs as $k => $v) |
---|
| 210 | { |
---|
| 211 | $uid = sprintf("u%03s",$count); |
---|
| 212 | $f = unserialize($v['value']); |
---|
| 213 | $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'], |
---|
| 214 | 'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']); |
---|
| 215 | $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string'); |
---|
| 216 | $count++; |
---|
| 217 | } |
---|
| 218 | } catch (Exception $e) { |
---|
| 219 | $core->error->add($e->getMessage()); |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | if (!$core->error->flag()) { |
---|
| 223 | http::redirect('preferences.php?removed=1'); |
---|
| 224 | } |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | # Order favs |
---|
| 228 | $order = array(); |
---|
| 229 | if (empty($_POST['favs_order']) && !empty($_POST['order'])) { |
---|
| 230 | $order = $_POST['order']; |
---|
| 231 | asort($order); |
---|
| 232 | $order = array_keys($order); |
---|
| 233 | } elseif (!empty($_POST['favs_order'])) { |
---|
| 234 | $order = explode(',',$_POST['favs_order']); |
---|
| 235 | } |
---|
| 236 | |
---|
| 237 | if (!empty($_POST['saveorder']) && !empty($order)) |
---|
| 238 | { |
---|
| 239 | try { |
---|
[26] | 240 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
[3] | 241 | $user_favs = $ws->DumpLocalPrefs(); |
---|
[34] | 242 | $core->auth->user_prefs->favorites->dropAll(); |
---|
[3] | 243 | $count = 0; |
---|
| 244 | foreach ($order as $i => $k) { |
---|
| 245 | $uid = sprintf("u%03s",$count); |
---|
| 246 | $f = unserialize($user_favs[$k]['value']); |
---|
| 247 | $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'], |
---|
| 248 | 'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']); |
---|
| 249 | $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string'); |
---|
| 250 | $count++; |
---|
| 251 | } |
---|
| 252 | } catch (Exception $e) { |
---|
| 253 | $core->error->add($e->getMessage()); |
---|
| 254 | } |
---|
| 255 | |
---|
| 256 | if (!$core->error->flag()) { |
---|
| 257 | http::redirect('preferences.php?&neworder=1'); |
---|
| 258 | } |
---|
| 259 | } |
---|
| 260 | |
---|
[30] | 261 | # Replace default favorites by current set (super admin only) |
---|
| 262 | if (!empty($_POST['replace']) && $core->auth->isSuperAdmin()) { |
---|
| 263 | try { |
---|
| 264 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
| 265 | $user_favs = $ws->DumpLocalPrefs(); |
---|
[34] | 266 | $core->auth->user_prefs->favorites->dropAll(true); |
---|
[30] | 267 | $count = 0; |
---|
| 268 | foreach ($user_favs as $k => $v) |
---|
| 269 | { |
---|
| 270 | $uid = sprintf("g%03s",$count); |
---|
| 271 | $f = unserialize($v['value']); |
---|
| 272 | $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'], |
---|
| 273 | 'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']); |
---|
| 274 | $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string',null,null,true); |
---|
| 275 | $count++; |
---|
| 276 | } |
---|
| 277 | } catch (Exception $e) { |
---|
| 278 | $core->error->add($e->getMessage()); |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | if (!$core->error->flag()) { |
---|
| 282 | http::redirect('preferences.php?&replaced=1'); |
---|
| 283 | } |
---|
| 284 | } |
---|
[0] | 285 | |
---|
| 286 | /* DISPLAY |
---|
| 287 | -------------------------------------------------------- */ |
---|
| 288 | dcPage::open($page_title, |
---|
| 289 | dcPage::jsLoad('js/_preferences.js'). |
---|
[15] | 290 | dcPage::jsLoad('js/jquery/jquery-ui-1.8.12.custom.min.js'). |
---|
[3] | 291 | dcPage::jsPageTabs($default_tab). |
---|
[0] | 292 | dcPage::jsConfirmClose('user-form'). |
---|
| 293 | |
---|
| 294 | # --BEHAVIOR-- adminPreferencesHeaders |
---|
| 295 | $core->callBehavior('adminPreferencesHeaders') |
---|
| 296 | ); |
---|
| 297 | |
---|
| 298 | if (!empty($_GET['upd'])) { |
---|
| 299 | echo '<p class="message">'.__('Personal information has been successfully updated.').'</p>'; |
---|
| 300 | } |
---|
[13] | 301 | if (!empty($_GET['updated'])) { |
---|
| 302 | echo '<p class="message">'.__('Personal options has been successfully updated.').'</p>'; |
---|
| 303 | } |
---|
[3] | 304 | if (!empty($_GET['append'])) { |
---|
| 305 | echo '<p class="message">'.__('Favorites have been successfully added.').'</p>'; |
---|
| 306 | } |
---|
| 307 | if (!empty($_GET['neworder'])) { |
---|
| 308 | echo '<p class="message">'.__('Favorites has been successfully updated.').'</p>'; |
---|
| 309 | } |
---|
| 310 | if (!empty($_GET['removed'])) { |
---|
| 311 | echo '<p class="message">'.__('Favorites have been successfully removed.').'</p>'; |
---|
| 312 | } |
---|
[30] | 313 | if (!empty($_GET['replaced'])) { |
---|
| 314 | echo '<p class="message">'.__('Default favorites have been successfully updated.').'</p>'; |
---|
| 315 | } |
---|
[3] | 316 | |
---|
[13] | 317 | echo '<h2>'.$page_title.'</h2>'; |
---|
| 318 | |
---|
[3] | 319 | # User profile |
---|
| 320 | echo '<div class="multi-part" id="user-profile" title="'.__('My profile').'">'; |
---|
[0] | 321 | |
---|
| 322 | echo |
---|
| 323 | '<form action="preferences.php" method="post" id="user-form">'. |
---|
[3] | 324 | '<fieldset><legend>'.__('My profile').'</legend>'. |
---|
[0] | 325 | '<div class="two-cols">'. |
---|
| 326 | '<div class="col">'. |
---|
[11] | 327 | '<p><label for="user_name">'.__('Last Name:'). |
---|
[0] | 328 | form::field('user_name',20,255,html::escapeHTML($user_name),'',2).'</label></p>'. |
---|
| 329 | |
---|
[3] | 330 | '<p><label for="user_firstname">'.__('First Name:'). |
---|
[0] | 331 | form::field('user_firstname',20,255,html::escapeHTML($user_firstname),'',3).'</label></p>'. |
---|
| 332 | |
---|
[3] | 333 | '<p><label for="user_displayname">'.__('Display name:'). |
---|
[0] | 334 | form::field('user_displayname',20,255,html::escapeHTML($user_displayname),'',4).'</label></p>'. |
---|
| 335 | |
---|
[3] | 336 | '<p><label for="user_email">'.__('Email:'). |
---|
[0] | 337 | form::field('user_email',20,255,html::escapeHTML($user_email),'',5).'</label></p>'. |
---|
| 338 | |
---|
[3] | 339 | '<p><label for="user_url">'.__('URL:'). |
---|
[0] | 340 | form::field('user_url',30,255,html::escapeHTML($user_url),'',6).'</label></p>'. |
---|
| 341 | |
---|
| 342 | '</div>'. |
---|
| 343 | |
---|
| 344 | '<div class="col">'. |
---|
| 345 | |
---|
[3] | 346 | '<p><label for="user_lang">'.__('User language:'). |
---|
[0] | 347 | form::combo('user_lang',$lang_combo,$user_lang,'l10n',10).'</label></p>'. |
---|
| 348 | |
---|
[3] | 349 | '<p><label for="user_tz">'.__('User timezone:'). |
---|
[0] | 350 | form::combo('user_tz',dt::getZones(true,true),$user_tz,'',11).'</label></p>'. |
---|
| 351 | |
---|
| 352 | '</div>'. |
---|
| 353 | '</div>'. |
---|
| 354 | '<br class="clear" />'. //Opera sucks |
---|
| 355 | '</fieldset>'; |
---|
| 356 | |
---|
| 357 | if ($core->auth->allowPassChange()) |
---|
| 358 | { |
---|
| 359 | echo |
---|
| 360 | '<fieldset>'. |
---|
| 361 | '<legend>'.__('Change your password').'</legend>'. |
---|
| 362 | |
---|
[3] | 363 | '<p><label for="new_pwd">'.__('New password:'). |
---|
[0] | 364 | form::password('new_pwd',20,255,'','',30).'</label></p>'. |
---|
| 365 | |
---|
[3] | 366 | '<p><label for="new_pwd_c">'.__('Confirm password:'). |
---|
[0] | 367 | form::password('new_pwd_c',20,255,'','',31).'</label></p>'. |
---|
| 368 | '</fieldset>'. |
---|
| 369 | |
---|
| 370 | '<fieldset>'. |
---|
| 371 | '<p>'.__('If you want to change your email or password you must provide your current password.').'</p>'. |
---|
[3] | 372 | '<p><label for="cur_pwd">'.__('Your password:'). |
---|
[0] | 373 | form::password('cur_pwd',20,255,'','',32).'</label></p>'. |
---|
| 374 | '</fieldset>'; |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | echo |
---|
| 378 | '<p class="clear">'. |
---|
| 379 | $core->formNonce(). |
---|
| 380 | '<input type="submit" accesskey="s" value="'.__('Save').'" tabindex="33" /></p>'. |
---|
| 381 | '</form>'; |
---|
| 382 | |
---|
[3] | 383 | echo '</div>'; |
---|
| 384 | |
---|
| 385 | # User options : some from actual user profile, dashboard modules, ... |
---|
| 386 | echo '<div class="multi-part" id="user-options" title="'.__('My options').'">'; |
---|
| 387 | |
---|
| 388 | echo |
---|
[13] | 389 | '<form action="preferences.php" method="post" id="user-options">'. |
---|
[3] | 390 | '<fieldset><legend>'.__('My options').'</legend>'. |
---|
| 391 | |
---|
| 392 | '<p><label for="user_post_format">'.__('Preferred format:'). |
---|
| 393 | form::combo('user_post_format',$formaters_combo,$user_options['post_format'],'',7).'</label></p>'. |
---|
| 394 | |
---|
| 395 | '<p><label for="user_post_status">'.__('Default entry status:'). |
---|
| 396 | form::combo('user_post_status',$status_combo,$user_post_status,'',8).'</label></p>'. |
---|
| 397 | |
---|
| 398 | '<p><label for="user_edit_size">'.__('Entry edit field height:'). |
---|
| 399 | form::field('user_edit_size',5,4,(integer) $user_options['edit_size'],'',9).'</label></p>'. |
---|
| 400 | |
---|
| 401 | '<p><label for="user_wysiwyg" class="classic">'. |
---|
| 402 | form::checkbox('user_wysiwyg',1,$user_options['enable_wysiwyg'],'',12).' '. |
---|
| 403 | __('Enable WYSIWYG mode').'</label></p>'. |
---|
| 404 | '<br class="clear" />'. //Opera sucks |
---|
| 405 | '</fieldset>'; |
---|
| 406 | |
---|
[13] | 407 | echo |
---|
| 408 | '<fieldset><legend>'.__('Dashboard modules').'</legend>'. |
---|
| 409 | |
---|
| 410 | '<p><label for="user_dm_doclinks" class="classic">'. |
---|
| 411 | form::checkbox('user_dm_doclinks',1,$user_dm_doclinks,'',13).' '. |
---|
| 412 | __('Display documentation links').'</label></p>'. |
---|
| 413 | |
---|
| 414 | '<p><label for="user_dm_dcnews" class="classic">'. |
---|
| 415 | form::checkbox('user_dm_dcnews',1,$user_dm_dcnews,'',14).' '. |
---|
| 416 | __('Display Dotclear news').'</label></p>'. |
---|
| 417 | |
---|
| 418 | '<p><label for="user_dm_quickentry" class="classic">'. |
---|
| 419 | form::checkbox('user_dm_quickentry',1,$user_dm_quickentry,'',15).' '. |
---|
| 420 | __('Display quick entry form').'</label></p>'. |
---|
| 421 | |
---|
| 422 | '<br class="clear" />'. //Opera sucks |
---|
| 423 | '</fieldset>'; |
---|
| 424 | |
---|
[3] | 425 | # --BEHAVIOR-- adminPreferencesForm |
---|
| 426 | $core->callBehavior('adminPreferencesForm',$core); |
---|
| 427 | |
---|
| 428 | echo |
---|
| 429 | '<p class="clear">'. |
---|
| 430 | $core->formNonce(). |
---|
| 431 | '<input type="submit" accesskey="s" value="'.__('Save').'" tabindex="33" /></p>'. |
---|
| 432 | '</form>'; |
---|
| 433 | |
---|
| 434 | echo '</div>'; |
---|
| 435 | |
---|
| 436 | # User favorites |
---|
| 437 | echo '<div class="multi-part" id="user-favorites" title="'.__('My favorites').'">'; |
---|
| 438 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
| 439 | echo '<form action="preferences.php" method="post" id="favs-form">'; |
---|
| 440 | echo '<div class="two-cols">'; |
---|
| 441 | echo '<div class="col70">'; |
---|
| 442 | echo '<fieldset id="my-favs"><legend>'.__('My favorites').'</legend>'; |
---|
[32] | 443 | |
---|
[3] | 444 | $count = 0; |
---|
| 445 | foreach ($ws->dumpPrefs() as $k => $v) { |
---|
| 446 | // User favorites only |
---|
| 447 | if (!$v['global']) { |
---|
| 448 | $fav = unserialize($v['value']); |
---|
| 449 | if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) { |
---|
| 450 | if ($count == 0) echo '<ul>'; |
---|
| 451 | $count++; |
---|
| 452 | echo '<li id="fu-'.$k.'">'. |
---|
| 453 | '<img src="'.$fav['large-icon'].'" alt="" /> '. |
---|
[35] | 454 | form::field(array('order['.$k.']'),2,3,$count,'position','',false,'title="'.sprintf(__('position of %s'),$fav['title']).'"'). |
---|
[15] | 455 | form::hidden('dynorder[]',$k). |
---|
[3] | 456 | '<label for="fuk-'.$k.'">'.form::checkbox(array('remove[]','fuk-'.$k),$k).$fav['title'].'</label>'. |
---|
| 457 | '</li>'; |
---|
| 458 | } |
---|
| 459 | } |
---|
| 460 | } |
---|
| 461 | if ($count > 0) echo '</ul>'; |
---|
| 462 | if ($count > 0) { |
---|
| 463 | echo |
---|
| 464 | '<div class="clear">'. |
---|
| 465 | '<p class="col">'.form::hidden('favs_order',''). |
---|
| 466 | $core->formNonce(). |
---|
[30] | 467 | '<input type="submit" name="saveorder" value="'.__('Save order').'">'. |
---|
[32] | 468 | ($core->auth->isSuperAdmin() ? ' <input class="reset" type="submit" name="replace" value="'.__('Define as default favorites').'">' : ''). |
---|
[30] | 469 | '</p>'. |
---|
[3] | 470 | |
---|
| 471 | '<p class="right"><input type="submit" class="delete" name="removeaction"'. |
---|
| 472 | 'value="'.__('Delete selected favorites').'" '. |
---|
| 473 | 'onclick="return window.confirm(\''.html::escapeJS( |
---|
| 474 | __('Are you sure you want to remove selected favorites?')).'\');" /></p>'. |
---|
| 475 | '</div>'; |
---|
| 476 | } else { |
---|
| 477 | echo |
---|
| 478 | '<p>'.__('Currently no personal favorites.').'</p>'; |
---|
| 479 | } |
---|
| 480 | |
---|
| 481 | echo '</fieldset>'; |
---|
| 482 | |
---|
| 483 | echo '<div id="default-favs"><h3>'.__('Default favorites').'</h3>'; |
---|
| 484 | echo '<p class="form-note clear">'.__('Those favorites are displayed when My Favorites list is empty.').'</p>'; |
---|
| 485 | $count = 0; |
---|
| 486 | foreach ($ws->dumpPrefs() as $k => $v) { |
---|
| 487 | // Global favorites only |
---|
| 488 | if ($v['global']) { |
---|
| 489 | $fav = unserialize($v['value']); |
---|
| 490 | if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) { |
---|
| 491 | if ($count == 0) echo '<ul class="fav-list">'; |
---|
| 492 | $count++; |
---|
| 493 | echo '<li id="fd-'.$k.'">'. |
---|
| 494 | '<img src="'.$fav['small-icon'].'" alt="" /> '.$fav['title'].'</li>'; |
---|
| 495 | } |
---|
| 496 | } |
---|
| 497 | } |
---|
| 498 | if ($count > 0) echo '</ul>'; |
---|
| 499 | echo '</div>'; |
---|
| 500 | echo '</div>'; |
---|
| 501 | echo '<div class="col30" id="available-favs">'; |
---|
| 502 | # Available favorites |
---|
| 503 | echo '<fieldset><legend>'.__('Available favorites').'</legend>'; |
---|
| 504 | $count = 0; |
---|
| 505 | $array = $_fav; |
---|
| 506 | function cmp($a,$b) { |
---|
| 507 | if ($a[1] == $b[1]) { |
---|
| 508 | return 0; |
---|
| 509 | } |
---|
| 510 | return ($a[1] < $b[1]) ? -1 : 1; |
---|
| 511 | } |
---|
[10] | 512 | $array->uasort('cmp'); |
---|
[3] | 513 | foreach ($array as $k => $fav) { |
---|
| 514 | if (($fav[5] == '*') || $core->auth->check($fav[5],$core->blog->id)) { |
---|
| 515 | if ($count == 0) echo '<ul class="fav-list">'; |
---|
| 516 | $count++; |
---|
| 517 | echo '<li id="fa-'.$fav[0].'">'.'<label for="fak-'.$fav[0].'">'. |
---|
[11] | 518 | form::checkbox(array('append[]','fak-'.$fav[0]),$k). |
---|
[3] | 519 | '<img src="'.$fav[3].'" alt="" /> '.'<span class="zoom"><img src="'.$fav[4].'" alt="" /></span>'.$fav[1]. |
---|
| 520 | '</label>'.'</li>'; |
---|
| 521 | } |
---|
| 522 | } |
---|
| 523 | if ($count > 0) echo '</ul>'; |
---|
| 524 | echo |
---|
| 525 | '<p>'. |
---|
| 526 | $core->formNonce(). |
---|
| 527 | '<input type="submit" name="appendaction" value="'.__('Add to my favorites').'"></p>'; |
---|
| 528 | echo '</div>'; |
---|
| 529 | echo '</div>'; # Two-cols |
---|
| 530 | echo '</form>'; |
---|
| 531 | echo '</div>'; # user-favorites |
---|
| 532 | |
---|
[0] | 533 | dcPage::helpBlock('core_user_pref'); |
---|
| 534 | dcPage::close(); |
---|
| 535 | ?> |
---|