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