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 | $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 | |
---|
35 | $default_tab = 'user-profile'; |
---|
36 | |
---|
37 | if (!empty($_GET['append']) || !empty($_GET['removed']) || !empty($_GET['neworder']) || !empty($_GET['replaced'])) { |
---|
38 | $default_tab = 'user-favorites'; |
---|
39 | } elseif (!empty($_GET['updated'])) { |
---|
40 | $default_tab = 'user-options'; |
---|
41 | } |
---|
42 | |
---|
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']; |
---|
78 | |
---|
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 |
---|
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 |
---|
137 | $core->callBehavior('adminBeforeUserUpdate',$cur,$core->auth->userID()); |
---|
138 | |
---|
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 | |
---|
144 | # Udate user |
---|
145 | $core->updUser($core->auth->userID(),$cur); |
---|
146 | |
---|
147 | # --BEHAVIOR-- adminAfterUserUpdate |
---|
148 | $core->callBehavior('adminAfterUserUpdate',$cur,$core->auth->userID()); |
---|
149 | |
---|
150 | http::redirect('preferences.php?updated=1'); |
---|
151 | } |
---|
152 | catch (Exception $e) |
---|
153 | { |
---|
154 | $core->error->add($e->getMessage()); |
---|
155 | } |
---|
156 | } |
---|
157 | |
---|
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 | $core->auth->user_prefs->favorites->dropAll(); |
---|
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 { |
---|
240 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
241 | $user_favs = $ws->DumpLocalPrefs(); |
---|
242 | $core->auth->user_prefs->favorites->dropAll(); |
---|
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 | |
---|
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(); |
---|
266 | $core->auth->user_prefs->favorites->dropAll(true); |
---|
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 | } |
---|
285 | |
---|
286 | /* DISPLAY |
---|
287 | -------------------------------------------------------- */ |
---|
288 | dcPage::open($page_title, |
---|
289 | dcPage::jsLoad('js/_preferences.js'). |
---|
290 | dcPage::jsLoad('js/jquery/jquery-ui-1.8.12.custom.min.js'). |
---|
291 | dcPage::jsPageTabs($default_tab). |
---|
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 | } |
---|
301 | if (!empty($_GET['updated'])) { |
---|
302 | echo '<p class="message">'.__('Personal options has been successfully updated.').'</p>'; |
---|
303 | } |
---|
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 have been successfully updated.').'</p>'; |
---|
309 | } |
---|
310 | if (!empty($_GET['removed'])) { |
---|
311 | echo '<p class="message">'.__('Favorites have been successfully removed.').'</p>'; |
---|
312 | } |
---|
313 | if (!empty($_GET['replaced'])) { |
---|
314 | echo '<p class="message">'.__('Default favorites have been successfully updated.').'</p>'; |
---|
315 | } |
---|
316 | |
---|
317 | echo '<h2>'.$page_title.'</h2>'; |
---|
318 | |
---|
319 | # User profile |
---|
320 | echo '<div class="multi-part" id="user-profile" title="'.__('My profile').'">'; |
---|
321 | |
---|
322 | echo |
---|
323 | '<form action="preferences.php" method="post" id="user-form">'. |
---|
324 | '<fieldset><legend>'.__('My profile').'</legend>'. |
---|
325 | '<div class="two-cols">'. |
---|
326 | '<div class="col">'. |
---|
327 | '<p><label for="user_name">'.__('Last Name:'). |
---|
328 | form::field('user_name',20,255,html::escapeHTML($user_name),'',2).'</label></p>'. |
---|
329 | |
---|
330 | '<p><label for="user_firstname">'.__('First Name:'). |
---|
331 | form::field('user_firstname',20,255,html::escapeHTML($user_firstname),'',3).'</label></p>'. |
---|
332 | |
---|
333 | '<p><label for="user_displayname">'.__('Display name:'). |
---|
334 | form::field('user_displayname',20,255,html::escapeHTML($user_displayname),'',4).'</label></p>'. |
---|
335 | |
---|
336 | '<p><label for="user_email">'.__('Email:'). |
---|
337 | form::field('user_email',20,255,html::escapeHTML($user_email),'',5).'</label></p>'. |
---|
338 | |
---|
339 | '<p><label for="user_url">'.__('URL:'). |
---|
340 | form::field('user_url',30,255,html::escapeHTML($user_url),'',6).'</label></p>'. |
---|
341 | |
---|
342 | '</div>'. |
---|
343 | |
---|
344 | '<div class="col">'. |
---|
345 | |
---|
346 | '<p><label for="user_lang">'.__('User language:'). |
---|
347 | form::combo('user_lang',$lang_combo,$user_lang,'l10n',10).'</label></p>'. |
---|
348 | |
---|
349 | '<p><label for="user_tz">'.__('User timezone:'). |
---|
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 | |
---|
363 | '<p><label for="new_pwd">'.__('New password:'). |
---|
364 | form::password('new_pwd',20,255,'','',30).'</label></p>'. |
---|
365 | |
---|
366 | '<p><label for="new_pwd_c">'.__('Confirm password:'). |
---|
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>'. |
---|
372 | '<p><label for="cur_pwd">'.__('Your password:'). |
---|
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 | |
---|
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 |
---|
389 | '<form action="preferences.php" method="post" id="opts-forms">'. |
---|
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 | |
---|
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 | |
---|
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>'; |
---|
443 | |
---|
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="" /> '. |
---|
454 | form::field(array('order['.$k.']'),2,3,$count,'position','',false,'title="'.sprintf(__('position of %s'),$fav['title']).'"'). |
---|
455 | form::hidden(array('dynorder[]','dynorder-'.$k.''),$k). |
---|
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 | |
---|
463 | if ($count > 0) { |
---|
464 | echo |
---|
465 | '<div class="clear">'. |
---|
466 | '<p>'.form::hidden('favs_order',''). |
---|
467 | $core->formNonce(). |
---|
468 | '<input type="submit" name="saveorder" value="'.__('Save order').'" /> '. |
---|
469 | |
---|
470 | '<input type="submit" class="delete" name="removeaction" '. |
---|
471 | 'value="'.__('Delete selected favorites').'" '. |
---|
472 | 'onclick="return window.confirm(\''.html::escapeJS( |
---|
473 | __('Are you sure you want to remove selected favorites?')).'\');" /></p>'. |
---|
474 | |
---|
475 | ($core->auth->isSuperAdmin() ? |
---|
476 | '<hr />'. |
---|
477 | '<p>'.__('If you are a super administrator, you may define this set of favorites to be used by default on all blogs of this installation:').'</p>'. |
---|
478 | '<p><input class="reset" type="submit" name="replace" value="'.__('Define as default favorites').'" />' : |
---|
479 | ''). |
---|
480 | '</p>'. |
---|
481 | '</div>'; |
---|
482 | } else { |
---|
483 | echo |
---|
484 | '<p>'.__('Currently no personal favorites.').'</p>'; |
---|
485 | } |
---|
486 | |
---|
487 | echo '</fieldset>'; |
---|
488 | |
---|
489 | echo '<div id="default-favs"><h3>'.__('Default favorites').'</h3>'; |
---|
490 | echo '<p class="form-note clear">'.__('Those favorites are displayed when My Favorites list is empty.').'</p>'; |
---|
491 | $count = 0; |
---|
492 | foreach ($ws->dumpPrefs() as $k => $v) { |
---|
493 | // Global favorites only |
---|
494 | if ($v['global']) { |
---|
495 | $fav = unserialize($v['value']); |
---|
496 | if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) { |
---|
497 | if ($count == 0) echo '<ul class="fav-list">'; |
---|
498 | $count++; |
---|
499 | echo '<li id="fd-'.$k.'">'. |
---|
500 | '<img src="'.$fav['small-icon'].'" alt="" /> '.$fav['title'].'</li>'; |
---|
501 | } |
---|
502 | } |
---|
503 | } |
---|
504 | if ($count > 0) echo '</ul>'; |
---|
505 | echo '</div>'; |
---|
506 | echo '</div>'; |
---|
507 | echo '<div class="col30" id="available-favs">'; |
---|
508 | # Available favorites |
---|
509 | echo '<fieldset><legend>'.__('Available favorites').'</legend>'; |
---|
510 | $count = 0; |
---|
511 | $array = $_fav; |
---|
512 | function cmp($a,$b) { |
---|
513 | if ($a[1] == $b[1]) { |
---|
514 | return 0; |
---|
515 | } |
---|
516 | return ($a[1] < $b[1]) ? -1 : 1; |
---|
517 | } |
---|
518 | $array->uasort('cmp'); |
---|
519 | foreach ($array as $k => $fav) { |
---|
520 | if (($fav[5] == '*') || $core->auth->check($fav[5],$core->blog->id)) { |
---|
521 | if ($count == 0) echo '<ul class="fav-list">'; |
---|
522 | $count++; |
---|
523 | echo '<li id="fa-'.$fav[0].'">'.'<label for="fak-'.$fav[0].'">'. |
---|
524 | form::checkbox(array('append[]','fak-'.$fav[0]),$k). |
---|
525 | '<img src="'.$fav[3].'" alt="" /> '.'<span class="zoom"><img src="'.$fav[4].'" alt="" /></span>'.$fav[1]. |
---|
526 | '</label>'.'</li>'; |
---|
527 | } |
---|
528 | } |
---|
529 | if ($count > 0) echo '</ul>'; |
---|
530 | echo |
---|
531 | '<p>'. |
---|
532 | $core->formNonce(). |
---|
533 | '<input type="submit" name="appendaction" value="'.__('Add to my favorites').'" /></p>'; |
---|
534 | echo '</fieldset>'; |
---|
535 | echo '</div>'; |
---|
536 | echo '</div>'; # Two-cols |
---|
537 | echo '</form>'; |
---|
538 | echo '</div>'; # user-favorites |
---|
539 | |
---|
540 | dcPage::helpBlock('core_user_pref'); |
---|
541 | dcPage::close(); |
---|
542 | ?> |
---|