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