1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2014 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 | if (empty($user_options['editor']) || !is_array($user_options['editor'])) { |
---|
30 | $user_options['editor'] = array(); |
---|
31 | } |
---|
32 | |
---|
33 | $core->auth->user_prefs->addWorkspace('dashboard'); |
---|
34 | $user_dm_doclinks = $core->auth->user_prefs->dashboard->doclinks; |
---|
35 | $user_dm_dcnews = $core->auth->user_prefs->dashboard->dcnews; |
---|
36 | $user_dm_quickentry = $core->auth->user_prefs->dashboard->quickentry; |
---|
37 | |
---|
38 | $core->auth->user_prefs->addWorkspace('accessibility'); |
---|
39 | $user_acc_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop; |
---|
40 | |
---|
41 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
42 | $user_ui_enhanceduploader = $core->auth->user_prefs->interface->enhanceduploader; |
---|
43 | if ($core->auth->isSuperAdmin()) { |
---|
44 | $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon; |
---|
45 | } |
---|
46 | $user_ui_iconset = @$core->auth->user_prefs->interface->iconset; |
---|
47 | $user_ui_nofavmenu = $core->auth->user_prefs->interface->nofavmenu; |
---|
48 | $user_ui_media_by_page = ($core->auth->user_prefs->interface->media_by_page ? $core->auth->user_prefs->interface->media_by_page : 30); |
---|
49 | |
---|
50 | $default_tab = !empty($_GET['tab']) ? html::escapeHTML($_GET['tab']) : 'user-profile'; |
---|
51 | |
---|
52 | if (!empty($_GET['append']) || !empty($_GET['removed']) || !empty($_GET['neworder']) || |
---|
53 | !empty($_GET['replaced']) || !empty($_POST['appendaction']) || !empty($_POST['removeaction']) || |
---|
54 | !empty($_GET['db-updated'])) { |
---|
55 | $default_tab = 'user-favorites'; |
---|
56 | } elseif (!empty($_GET['updated'])) { |
---|
57 | $default_tab = 'user-options'; |
---|
58 | } |
---|
59 | if (($default_tab != 'user-profile') && ($default_tab != 'user-options') && ($default_tab != 'user-favorites')) { |
---|
60 | $default_tab = 'user-profile'; |
---|
61 | } |
---|
62 | |
---|
63 | # Editors combo |
---|
64 | $editors_combo = dcAdminCombos::getEditorsCombo(); |
---|
65 | $editors = array_keys($editors_combo); |
---|
66 | |
---|
67 | # Format by editors |
---|
68 | $formaters = $core->getFormaters(); |
---|
69 | $format_by_editors = array(); |
---|
70 | foreach ($formaters as $editor => $formats) { |
---|
71 | foreach ($formats as $format) { |
---|
72 | $format_by_editors[$format][$editor] = $editor; |
---|
73 | } |
---|
74 | } |
---|
75 | $available_formats = array('' => ''); |
---|
76 | foreach (array_keys($format_by_editors) as $format) { |
---|
77 | $available_formats[$format] = $format; |
---|
78 | if (!isset($user_options['editor'][$format])) { |
---|
79 | $user_options['editor'][$format] = ''; |
---|
80 | } |
---|
81 | } |
---|
82 | $status_combo = dcAdminCombos::getPostStatusescombo(); |
---|
83 | |
---|
84 | $iconsets_combo = array(__('Default') => ''); |
---|
85 | $iconsets_root = dirname(__FILE__).'/images/iconset/'; |
---|
86 | if (is_dir($iconsets_root) && is_readable($iconsets_root)) { |
---|
87 | if (($d = @dir($iconsets_root)) !== false) { |
---|
88 | while (($entry = $d->read()) !== false) { |
---|
89 | if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.' && is_dir($iconsets_root.'/'.$entry)) { |
---|
90 | $iconsets_combo[$entry] = $entry; |
---|
91 | } |
---|
92 | } |
---|
93 | } |
---|
94 | } |
---|
95 | |
---|
96 | # Language codes |
---|
97 | $lang_combo = dcAdminCombos::getAdminLangsCombo(); |
---|
98 | |
---|
99 | # Add or update user |
---|
100 | if (isset($_POST['user_name'])) |
---|
101 | { |
---|
102 | try |
---|
103 | { |
---|
104 | $pwd_check = !empty($_POST['cur_pwd']) && $core->auth->checkPassword($core->auth->crypt($_POST['cur_pwd'])); |
---|
105 | |
---|
106 | if ($core->auth->allowPassChange() && !$pwd_check && $user_email != $_POST['user_email']) { |
---|
107 | throw new Exception(__('If you want to change your email or password you must provide your current password.')); |
---|
108 | } |
---|
109 | |
---|
110 | $cur = $core->con->openCursor($core->prefix.'user'); |
---|
111 | |
---|
112 | $cur->user_name = $user_name = $_POST['user_name']; |
---|
113 | $cur->user_firstname = $user_firstname = $_POST['user_firstname']; |
---|
114 | $cur->user_displayname = $user_displayname = $_POST['user_displayname']; |
---|
115 | $cur->user_email = $user_email = $_POST['user_email']; |
---|
116 | $cur->user_url = $user_url = $_POST['user_url']; |
---|
117 | $cur->user_lang = $user_lang = $_POST['user_lang']; |
---|
118 | $cur->user_tz = $user_tz = $_POST['user_tz']; |
---|
119 | |
---|
120 | $cur->user_options = new ArrayObject($user_options); |
---|
121 | |
---|
122 | if ($core->auth->allowPassChange() && !empty($_POST['new_pwd'])) |
---|
123 | { |
---|
124 | if (!$pwd_check) { |
---|
125 | throw new Exception(__('If you want to change your email or password you must provide your current password.')); |
---|
126 | } |
---|
127 | |
---|
128 | if ($_POST['new_pwd'] != $_POST['new_pwd_c']) { |
---|
129 | throw new Exception(__("Passwords don't match")); |
---|
130 | } |
---|
131 | |
---|
132 | $cur->user_pwd = $_POST['new_pwd']; |
---|
133 | } |
---|
134 | |
---|
135 | # --BEHAVIOR-- adminBeforeUserUpdate |
---|
136 | $core->callBehavior('adminBeforeUserProfileUpdate',$cur,$core->auth->userID()); |
---|
137 | |
---|
138 | # Udate user |
---|
139 | $core->updUser($core->auth->userID(),$cur); |
---|
140 | |
---|
141 | # --BEHAVIOR-- adminAfterUserUpdate |
---|
142 | $core->callBehavior('adminAfterUserProfileUpdate',$cur,$core->auth->userID()); |
---|
143 | |
---|
144 | dcPage::addSuccessNotice(__('Personal information has been successfully updated.')); |
---|
145 | |
---|
146 | $core->adminurl->redirect("admin.user.preferences"); |
---|
147 | } |
---|
148 | catch (Exception $e) |
---|
149 | { |
---|
150 | $core->error->add($e->getMessage()); |
---|
151 | } |
---|
152 | } |
---|
153 | |
---|
154 | # Update user options |
---|
155 | if (isset($_POST['user_editor'])) |
---|
156 | { |
---|
157 | try |
---|
158 | { |
---|
159 | $cur = $core->con->openCursor($core->prefix.'user'); |
---|
160 | |
---|
161 | $cur->user_name = $user_name; |
---|
162 | $cur->user_firstname = $user_firstname; |
---|
163 | $cur->user_displayname = $user_displayname; |
---|
164 | $cur->user_email = $user_email; |
---|
165 | $cur->user_url = $user_url; |
---|
166 | $cur->user_lang = $user_lang; |
---|
167 | $cur->user_tz = $user_tz; |
---|
168 | |
---|
169 | $cur->user_post_status = $user_post_status = $_POST['user_post_status']; |
---|
170 | |
---|
171 | $user_options['edit_size'] = (integer) $_POST['user_edit_size']; |
---|
172 | if ($user_options['edit_size'] < 1) { |
---|
173 | $user_options['edit_size'] = 10; |
---|
174 | } |
---|
175 | $user_options['post_format'] = $_POST['user_post_format']; |
---|
176 | $user_options['editor'] = $_POST['user_editor']; |
---|
177 | $user_options['enable_wysiwyg'] = !empty($_POST['user_wysiwyg']); |
---|
178 | $user_options['toolbar_bottom'] = !empty($_POST['user_toolbar_bottom']); |
---|
179 | |
---|
180 | $cur->user_options = new ArrayObject($user_options); |
---|
181 | |
---|
182 | # --BEHAVIOR-- adminBeforeUserOptionsUpdate |
---|
183 | $core->callBehavior('adminBeforeUserOptionsUpdate',$cur,$core->auth->userID()); |
---|
184 | |
---|
185 | # Update user prefs |
---|
186 | $core->auth->user_prefs->accessibility->put('nodragdrop',!empty($_POST['user_acc_nodragdrop']),'boolean'); |
---|
187 | $core->auth->user_prefs->interface->put('enhanceduploader',!empty($_POST['user_ui_enhanceduploader']),'boolean'); |
---|
188 | if ($core->auth->isSuperAdmin()) { |
---|
189 | # Applied to all users |
---|
190 | $core->auth->user_prefs->interface->put('hide_std_favicon',!empty($_POST['user_ui_hide_std_favicon']),'boolean',null,true,true); |
---|
191 | } |
---|
192 | $core->auth->user_prefs->interface->put('media_by_page',(integer)$_POST['user_ui_media_by_page'],'integer'); |
---|
193 | |
---|
194 | # Udate user |
---|
195 | $core->updUser($core->auth->userID(),$cur); |
---|
196 | |
---|
197 | # --BEHAVIOR-- adminAfterUserOptionsUpdate |
---|
198 | $core->callBehavior('adminAfterUserOptionsUpdate',$cur,$core->auth->userID()); |
---|
199 | |
---|
200 | dcPage::addSuccessNotice(__('Personal options has been successfully updated.')); |
---|
201 | $core->adminurl->redirect("admin.user.preferences",array(),'#user-options'); |
---|
202 | } |
---|
203 | catch (Exception $e) |
---|
204 | { |
---|
205 | $core->error->add($e->getMessage()); |
---|
206 | } |
---|
207 | } |
---|
208 | |
---|
209 | # Dashboard options |
---|
210 | if (isset($_POST['db-options'])) { |
---|
211 | try |
---|
212 | { |
---|
213 | # --BEHAVIOR-- adminBeforeUserOptionsUpdate |
---|
214 | $core->callBehavior('adminBeforeDashboardOptionsUpdate',$core->auth->userID()); |
---|
215 | |
---|
216 | # Update user prefs |
---|
217 | $core->auth->user_prefs->dashboard->put('doclinks',!empty($_POST['user_dm_doclinks']),'boolean'); |
---|
218 | $core->auth->user_prefs->dashboard->put('dcnews',!empty($_POST['user_dm_dcnews']),'boolean'); |
---|
219 | $core->auth->user_prefs->dashboard->put('quickentry',!empty($_POST['user_dm_quickentry']),'boolean'); |
---|
220 | $core->auth->user_prefs->interface->put('iconset',(!empty($_POST['user_ui_iconset']) ? $_POST['user_ui_iconset'] : '')); |
---|
221 | $core->auth->user_prefs->interface->put('nofavmenu',empty($_POST['user_ui_nofavmenu']),'boolean'); |
---|
222 | |
---|
223 | # --BEHAVIOR-- adminAfterUserOptionsUpdate |
---|
224 | $core->callBehavior('adminAfterDashboardOptionsUpdate',$core->auth->userID()); |
---|
225 | |
---|
226 | dcPage::addSuccessNotice(__('Dashboard options has been successfully updated.')); |
---|
227 | $core->adminurl->redirect("admin.user.preferences",array(),'#user-favorites'); |
---|
228 | } |
---|
229 | catch (Exception $e) |
---|
230 | { |
---|
231 | $core->error->add($e->getMessage()); |
---|
232 | } |
---|
233 | } |
---|
234 | |
---|
235 | # Add selected favorites |
---|
236 | if (!empty($_POST['appendaction'])) |
---|
237 | { |
---|
238 | try { |
---|
239 | if (empty($_POST['append'])) { |
---|
240 | throw new Exception(__('No favorite selected')); |
---|
241 | } |
---|
242 | $user_favs = $core->favs->getFavoriteIDs(false); |
---|
243 | foreach ($_POST['append'] as $k => $v) |
---|
244 | { |
---|
245 | if ($core->favs->exists($v)) { |
---|
246 | $user_favs[] = $v; |
---|
247 | } |
---|
248 | } |
---|
249 | $core->favs->setFavoriteIDs($user_favs,false); |
---|
250 | |
---|
251 | if (!$core->error->flag()) { |
---|
252 | dcPage::addSuccessNotice(__('Favorites have been successfully added.')); |
---|
253 | $core->adminurl->redirect("admin.user.preferences",array(),'#user-favorites'); |
---|
254 | } |
---|
255 | } catch (Exception $e) { |
---|
256 | $core->error->add($e->getMessage()); |
---|
257 | } |
---|
258 | } |
---|
259 | |
---|
260 | # Delete selected favorites |
---|
261 | if (!empty($_POST['removeaction'])) |
---|
262 | { |
---|
263 | try { |
---|
264 | if (empty($_POST['remove'])) { |
---|
265 | throw new Exception(__('No favorite selected')); |
---|
266 | } |
---|
267 | $user_fav_ids = array(); |
---|
268 | foreach ($core->favs->getFavoriteIDs(false) as $v) { |
---|
269 | $user_fav_ids[$v]=true; |
---|
270 | } |
---|
271 | foreach ($_POST['remove'] as $v) |
---|
272 | { |
---|
273 | if (isset($user_fav_ids[$v])) { |
---|
274 | unset($user_fav_ids[$v]); |
---|
275 | } |
---|
276 | } |
---|
277 | $core->favs->setFavoriteIDs(array_keys($user_fav_ids),false); |
---|
278 | if (!$core->error->flag()) { |
---|
279 | dcPage::addSuccessNotice(__('Favorites have been successfully removed.')); |
---|
280 | $core->adminurl->redirect("admin.user.preferences",array(),'#user-favorites'); |
---|
281 | } |
---|
282 | } catch (Exception $e) { |
---|
283 | $core->error->add($e->getMessage()); |
---|
284 | } |
---|
285 | } |
---|
286 | |
---|
287 | # Order favs |
---|
288 | $order = array(); |
---|
289 | if (empty($_POST['favs_order']) && !empty($_POST['order'])) { |
---|
290 | $order = $_POST['order']; |
---|
291 | asort($order); |
---|
292 | $order = array_keys($order); |
---|
293 | } elseif (!empty($_POST['favs_order'])) { |
---|
294 | $order = explode(',',$_POST['favs_order']); |
---|
295 | } |
---|
296 | |
---|
297 | if (!empty($_POST['saveorder']) && !empty($order)) |
---|
298 | { |
---|
299 | foreach ($order as $k => $v) { |
---|
300 | if (!$core->favs->exists($v)) { |
---|
301 | unset($order[$k]); |
---|
302 | } |
---|
303 | } |
---|
304 | $core->favs->setFavoriteIDs($order,false); |
---|
305 | if (!$core->error->flag()) { |
---|
306 | dcPage::addSuccessNotice(__('Favorites have been successfully updated.')); |
---|
307 | $core->adminurl->redirect("admin.user.preferences",array(),'#user-favorites'); |
---|
308 | } |
---|
309 | } |
---|
310 | |
---|
311 | # Replace default favorites by current set (super admin only) |
---|
312 | if (!empty($_POST['replace']) && $core->auth->isSuperAdmin()) { |
---|
313 | $user_favs = $core->favs->getFavoriteIDs(false); |
---|
314 | $core->favs->setFavoriteIDs($user_favs,true); |
---|
315 | |
---|
316 | if (!$core->error->flag()) { |
---|
317 | dcPage::addSuccessNotice(__('Default favorites have been successfully updated.')); |
---|
318 | $core->adminurl->redirect("admin.user.preferences",array(),'#user-favorites'); |
---|
319 | } |
---|
320 | } |
---|
321 | |
---|
322 | /* DISPLAY |
---|
323 | -------------------------------------------------------- */ |
---|
324 | dcPage::open($page_title, |
---|
325 | dcPage::jsLoad('js/_preferences.js'). |
---|
326 | ($user_acc_nodragdrop ? '' : dcPage::jsLoad('js/_preferences-dragdrop.js')). |
---|
327 | dcPage::jsLoad('js/jquery/jquery-ui.custom.js'). |
---|
328 | dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js'). |
---|
329 | dcPage::jsLoad('js/jquery/jquery.pwstrength.js'). |
---|
330 | '<script type="text/javascript">'."\n". |
---|
331 | "//<![CDATA[\n". |
---|
332 | "\$(function() {\n". |
---|
333 | " \$('#new_pwd').pwstrength({texts: ['". |
---|
334 | sprintf(__('Password strength: %s'),__('very weak'))."', '". |
---|
335 | sprintf(__('Password strength: %s'),__('weak'))."', '". |
---|
336 | sprintf(__('Password strength: %s'),__('mediocre'))."', '". |
---|
337 | sprintf(__('Password strength: %s'),__('strong'))."', '". |
---|
338 | sprintf(__('Password strength: %s'),__('very strong'))."']});\n". |
---|
339 | "});". |
---|
340 | "\n//]]>\n". |
---|
341 | "</script>\n". |
---|
342 | dcPage::jsPageTabs($default_tab). |
---|
343 | dcPage::jsConfirmClose('user-form'). |
---|
344 | |
---|
345 | # --BEHAVIOR-- adminPreferencesHeaders |
---|
346 | $core->callBehavior('adminPreferencesHeaders'), |
---|
347 | |
---|
348 | dcPage::breadcrumb( |
---|
349 | array( |
---|
350 | html::escapeHTML($core->auth->userID()) => '', |
---|
351 | $page_title => '' |
---|
352 | )) |
---|
353 | ); |
---|
354 | |
---|
355 | # User profile |
---|
356 | echo '<div class="multi-part" id="user-profile" title="'.__('My profile').'">'; |
---|
357 | |
---|
358 | echo |
---|
359 | '<h3>'.__('My profile').'</h3>'. |
---|
360 | '<form action="'.$core->adminurl->get("admin.user.preferences").'" method="post" id="user-form">'. |
---|
361 | |
---|
362 | '<p><label for="user_name">'.__('Last Name:').'</label>'. |
---|
363 | form::field('user_name',20,255,html::escapeHTML($user_name)).'</p>'. |
---|
364 | |
---|
365 | '<p><label for="user_firstname">'.__('First Name:').'</label>'. |
---|
366 | form::field('user_firstname',20,255,html::escapeHTML($user_firstname)).'</p>'. |
---|
367 | |
---|
368 | '<p><label for="user_displayname">'.__('Display name:').'</label>'. |
---|
369 | form::field('user_displayname',20,255,html::escapeHTML($user_displayname)).'</p>'. |
---|
370 | |
---|
371 | '<p><label for="user_email">'.__('Email:').'</label>'. |
---|
372 | form::field('user_email',20,255,html::escapeHTML($user_email)).'</p>'. |
---|
373 | |
---|
374 | '<p><label for="user_url">'.__('URL:').'</label>'. |
---|
375 | form::field('user_url',30,255,html::escapeHTML($user_url)).'</p>'. |
---|
376 | |
---|
377 | '<p><label for="user_lang">'.__('Language for my interface:').'</label>'. |
---|
378 | form::combo('user_lang',$lang_combo,$user_lang,'l10n').'</p>'. |
---|
379 | |
---|
380 | '<p><label for="user_tz">'.__('My timezone:').'</label>'. |
---|
381 | form::combo('user_tz',dt::getZones(true,true),$user_tz).'</p>'; |
---|
382 | |
---|
383 | |
---|
384 | if ($core->auth->allowPassChange()) |
---|
385 | { |
---|
386 | echo |
---|
387 | '<h4 class="vertical-separator pretty-title">'.__('Change my password').'</h4>'. |
---|
388 | |
---|
389 | '<div class="pw-table">'. |
---|
390 | '<p class="pw-cell"><label for="new_pwd">'.__('New password:').'</label>'. |
---|
391 | form::password('new_pwd',20,255,'','','',false,' data-indicator="pwindicator" ').'</p>'. |
---|
392 | '<div id="pwindicator">'. |
---|
393 | ' <div class="bar"></div>'. |
---|
394 | ' <p class="label no-margin"></p>'. |
---|
395 | '</div>'. |
---|
396 | '</div>'. |
---|
397 | |
---|
398 | '<p><label for="new_pwd_c">'.__('Confirm new password:').'</label>'. |
---|
399 | form::password('new_pwd_c',20,255).'</p>'. |
---|
400 | |
---|
401 | '<p><label for="cur_pwd">'.__('Your current password:').'</label>'. |
---|
402 | form::password('cur_pwd',20,255).'</p>'. |
---|
403 | '<p class="form-note warn">'. |
---|
404 | __('If you have changed your email or password you must provide your current password to save these modifications.'). |
---|
405 | '</p>'; |
---|
406 | } |
---|
407 | |
---|
408 | echo |
---|
409 | '<p class="clear vertical-separator">'. |
---|
410 | $core->formNonce(). |
---|
411 | '<input type="submit" accesskey="s" value="'.__('Update my profile').'" /></p>'. |
---|
412 | '</form>'. |
---|
413 | |
---|
414 | '</div>'; |
---|
415 | |
---|
416 | # User options : some from actual user profile, dashboard modules, ... |
---|
417 | echo '<div class="multi-part" id="user-options" title="'.__('My options').'">'; |
---|
418 | |
---|
419 | echo |
---|
420 | '<form action="'.$core->adminurl->get("admin.user.preferences").'#user-options" method="post" id="opts-forms">'. |
---|
421 | '<h3>'.__('My options').'</h3>'; |
---|
422 | |
---|
423 | echo |
---|
424 | '<div class="fieldset">'. |
---|
425 | '<h4>'.__('Interface').'</h4>'. |
---|
426 | |
---|
427 | '<p><label for="user_ui_enhanceduploader" class="classic">'. |
---|
428 | form::checkbox('user_ui_enhanceduploader',1,$user_ui_enhanceduploader).' '. |
---|
429 | __('Activate enhanced uploader in media manager').'</label></p>'. |
---|
430 | |
---|
431 | '<p><label for="user_acc_nodragdrop" class="classic">'. |
---|
432 | form::checkbox('user_acc_nodragdrop',1,$user_acc_nodragdrop).' '. |
---|
433 | __('Disable javascript powered drag and drop for ordering items').'</label></p>'. |
---|
434 | '<p class="clear form-note">'.__('If checked, numeric fields will allow to type the elements\' ordering number.').'</p>'; |
---|
435 | |
---|
436 | echo |
---|
437 | '<p><label for="user_ui_media_by_page" class="classic">'.__('Number of elements displayed per page in media manager:').'</label> '. |
---|
438 | form::field('user_ui_media_by_page',5,3,(integer) $user_ui_media_by_page).'</p>'; |
---|
439 | |
---|
440 | if ($core->auth->isSuperAdmin()) { |
---|
441 | echo |
---|
442 | '<p><label for="user_ui_hide_std_favicon" class="classic">'. |
---|
443 | form::checkbox('user_ui_hide_std_favicon',1,$user_ui_hide_std_favicon).' '. |
---|
444 | __('Do not use standard favicon').'</label> '. |
---|
445 | '<span class="clear form-note warn">'.__('This will be applied for all users').'.</span>'. |
---|
446 | '</p>';//Opera sucks; |
---|
447 | } |
---|
448 | |
---|
449 | echo |
---|
450 | '</div>'; |
---|
451 | |
---|
452 | echo |
---|
453 | '<div class="fieldset">'. |
---|
454 | '<h4>'.__('Edition').'</h4>'; |
---|
455 | |
---|
456 | foreach ($format_by_editors as $format => $editors) { |
---|
457 | echo |
---|
458 | '<p class="field"><label for="user_editor_'.$format.'">'.sprintf(__('Preferred editor for %s:'),$format).'</label>'. |
---|
459 | form::combo( |
---|
460 | array('user_editor['.$format.']', 'user_editor_'.$format), |
---|
461 | array_merge(array(__('Choose an editor') => ''),$editors), |
---|
462 | $user_options['editor'][$format] |
---|
463 | ).'</p>'; |
---|
464 | } |
---|
465 | echo |
---|
466 | '<p class="field"><label for="user_post_format">'.__('Preferred format:').'</label>'. |
---|
467 | form::combo('user_post_format',$available_formats,$user_options['post_format']).'</p>'; |
---|
468 | |
---|
469 | echo |
---|
470 | '<p class="field"><label for="user_post_status">'.__('Default entry status:').'</label>'. |
---|
471 | form::combo('user_post_status',$status_combo,$user_post_status).'</p>'. |
---|
472 | |
---|
473 | '<p class="field"><label for="user_edit_size">'.__('Entry edit field height:').'</label>'. |
---|
474 | form::field('user_edit_size',5,4,(integer) $user_options['edit_size']).'</p>'. |
---|
475 | |
---|
476 | '<p><label for="user_wysiwyg" class="classic">'. |
---|
477 | form::checkbox('user_wysiwyg',1,$user_options['enable_wysiwyg']).' '. |
---|
478 | __('Enable WYSIWYG mode').'</label></p>'. |
---|
479 | |
---|
480 | '<p><label for="user_toolbar_bottom" class="classic">'. |
---|
481 | form::checkbox('user_toolbar_bottom',1,$user_options['toolbar_bottom']).' '. |
---|
482 | __('Display editor\'s toolbar at bottom of textarea (if possible)').'</label></p>'. |
---|
483 | |
---|
484 | '</div>'; |
---|
485 | |
---|
486 | echo |
---|
487 | '<h4 class="pretty-title">'.__('Other options').'</h4>'; |
---|
488 | |
---|
489 | # --BEHAVIOR-- adminPreferencesForm |
---|
490 | $core->callBehavior('adminPreferencesForm',$core); |
---|
491 | |
---|
492 | echo |
---|
493 | '<p class="clear vertical-separator">'. |
---|
494 | $core->formNonce(). |
---|
495 | '<input type="submit" accesskey="s" value="'.__('Save my options').'" /></p>'. |
---|
496 | '</form>'; |
---|
497 | |
---|
498 | echo '</div>'; |
---|
499 | |
---|
500 | # My dashboard |
---|
501 | echo '<div class="multi-part" id="user-favorites" title="'.__('My dashboard').'">'; |
---|
502 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
503 | echo '<h3>'.__('My dashboard').'</h3>'; |
---|
504 | |
---|
505 | echo '<form action="'.$core->adminurl->get("admin.user.preferences").'" method="post" id="favs-form" class="two-boxes odd">'; |
---|
506 | |
---|
507 | echo '<div id="my-favs" class="fieldset"><h4>'.__('My favorites').'</h4>'; |
---|
508 | |
---|
509 | $count = 0; |
---|
510 | $user_fav = $core->favs->getFavoriteIDs(false); |
---|
511 | foreach ($user_fav as $id) { |
---|
512 | $fav = $core->favs->getFavorite($id); |
---|
513 | if ($fav != false) { |
---|
514 | // User favorites only |
---|
515 | if ($count == 0) echo '<ul class="fav-list">'; |
---|
516 | $count++; |
---|
517 | echo '<li id="fu-'.$id.'">'.'<label for="fuk-'.$id.'">'. |
---|
518 | '<img src="'.dc_admin_icon_url($fav['small-icon']).'" alt="" /> '.'<span class="zoom"><img src="'.dc_admin_icon_url($fav['large-icon']).'" alt="" /></span>'. |
---|
519 | form::field(array('order['.$id.']'),2,3,$count,'position','',false,'title="'.sprintf(__('position of %s'),$fav['title']).'"'). |
---|
520 | form::hidden(array('dynorder[]','dynorder-'.$id.''),$id). |
---|
521 | form::checkbox(array('remove[]','fuk-'.$id),$id).__($fav['title']).'</label>'. |
---|
522 | '</li>'; |
---|
523 | } |
---|
524 | } |
---|
525 | if ($count > 0) echo '</ul>'; |
---|
526 | if ($count > 0) { |
---|
527 | echo |
---|
528 | '<div class="clear">'. |
---|
529 | '<p>'.form::hidden('favs_order',''). |
---|
530 | $core->formNonce(). |
---|
531 | '<input type="submit" name="saveorder" value="'.__('Save order').'" /> '. |
---|
532 | |
---|
533 | '<input type="submit" class="delete" name="removeaction" '. |
---|
534 | 'value="'.__('Delete selected favorites').'" '. |
---|
535 | 'onclick="return window.confirm(\''.html::escapeJS( |
---|
536 | __('Are you sure you want to remove selected favorites?')).'\');" /></p>'. |
---|
537 | |
---|
538 | ($core->auth->isSuperAdmin() ? |
---|
539 | '<div class="info">'. |
---|
540 | '<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>'. |
---|
541 | '<p><input class="reset" type="submit" name="replace" value="'.__('Define as default favorites').'" />'.'</p>'. |
---|
542 | '</div>' |
---|
543 | : |
---|
544 | ''). |
---|
545 | |
---|
546 | '</div>'; |
---|
547 | } else { |
---|
548 | echo |
---|
549 | '<p>'.__('Currently no personal favorites.').'</p>'; |
---|
550 | } |
---|
551 | |
---|
552 | $avail_fav = $core->favs->getFavorites($core->favs->getAvailableFavoritesIDs()); |
---|
553 | $default_fav_ids = array(); |
---|
554 | foreach($core->favs->getFavoriteIDs(true) as $v) { |
---|
555 | $default_fav_ids[$v]=true; |
---|
556 | } |
---|
557 | echo '</div>'; # /box my-fav |
---|
558 | |
---|
559 | echo '<div class="fieldset" id="available-favs">'; |
---|
560 | # Available favorites |
---|
561 | echo '<h5 class="pretty-title">'.__('Other available favorites').'</h5>'; |
---|
562 | $count = 0; |
---|
563 | function cmp($a,$b) { |
---|
564 | if ($a['title'] == $b['title']) { |
---|
565 | return 0; |
---|
566 | } |
---|
567 | return ($a['title'] < $b['title']) ? -1 : 1; |
---|
568 | } |
---|
569 | uasort($avail_fav,'cmp'); |
---|
570 | |
---|
571 | foreach ($avail_fav as $k => $v) { |
---|
572 | if (in_array($k,$user_fav)) { |
---|
573 | unset($avail_fav[$k]); |
---|
574 | } |
---|
575 | } |
---|
576 | foreach ($avail_fav as $k=>$fav) { |
---|
577 | if ($count == 0) echo '<ul class="fav-list">'; |
---|
578 | $count++; |
---|
579 | echo '<li id="fa-'.$k.'">'.'<label for="fak-'.$k.'">'. |
---|
580 | '<img src="'.dc_admin_icon_url($fav['small-icon']).'" alt="" /> '. |
---|
581 | '<span class="zoom"><img src="'.dc_admin_icon_url($fav['large-icon']).'" alt="" /></span>'. |
---|
582 | form::checkbox(array('append[]','fak-'.$k),$k). |
---|
583 | $fav['title'].'</label>'. |
---|
584 | (isset($default_fav_ids[$k]) ? ' <span class="default-fav"><img src="images/selected.png" alt="'.__('(default favorite)').'" /></span>' : ''). |
---|
585 | '</li>'; |
---|
586 | } |
---|
587 | if ($count > 0) echo '</ul>'; |
---|
588 | echo |
---|
589 | '<p>'. |
---|
590 | $core->formNonce(). |
---|
591 | '<input type="submit" name="appendaction" value="'.__('Add to my favorites').'" /></p>'; |
---|
592 | echo '</div>'; # /available favorites |
---|
593 | |
---|
594 | echo '</form>'; |
---|
595 | |
---|
596 | echo |
---|
597 | '<form action="'.$core->adminurl->get("admin.user.preferences").'" method="post" id="db-forms" class="two-boxes even">'. |
---|
598 | |
---|
599 | '<div class="fieldset">'. |
---|
600 | '<h4>'.__('Menu').'</h4>'. |
---|
601 | '<p><label for="user_ui_nofavmenu" class="classic">'. |
---|
602 | form::checkbox('user_ui_nofavmenu',1,!$user_ui_nofavmenu).' '. |
---|
603 | __('Display favorites at the top of the menu').'</label></p></div>'; |
---|
604 | |
---|
605 | if (count($iconsets_combo) > 1) { |
---|
606 | echo |
---|
607 | '<div class="fieldset">'. |
---|
608 | '<h4>'.__('Dashboard icons').'</h4>'. |
---|
609 | '<p><label for="user_ui_iconset" class="classic">'.__('Iconset:').'</label> '. |
---|
610 | form::combo('user_ui_iconset',$iconsets_combo,$user_ui_iconset).'</p>'. |
---|
611 | '</div>'; |
---|
612 | } else { |
---|
613 | echo '<p class="hidden">'.form::hidden('user_ui_iconset','').'</p>'; |
---|
614 | } |
---|
615 | |
---|
616 | echo |
---|
617 | '<div class="fieldset">'. |
---|
618 | '<h4>'.__('Dashboard modules').'</h4>'. |
---|
619 | |
---|
620 | '<p><label for="user_dm_doclinks" class="classic">'. |
---|
621 | form::checkbox('user_dm_doclinks',1,$user_dm_doclinks).' '. |
---|
622 | __('Display documentation links').'</label></p>'. |
---|
623 | |
---|
624 | '<p><label for="user_dm_dcnews" class="classic">'. |
---|
625 | form::checkbox('user_dm_dcnews',1,$user_dm_dcnews).' '. |
---|
626 | __('Display Dotclear news').'</label></p>'. |
---|
627 | |
---|
628 | '<p><label for="user_dm_quickentry" class="classic">'. |
---|
629 | form::checkbox('user_dm_quickentry',1,$user_dm_quickentry).' '. |
---|
630 | __('Display quick entry form').'</label><br class="clear" />'. //Opera sucks |
---|
631 | '</p>'; |
---|
632 | echo '</div>'; |
---|
633 | |
---|
634 | # --BEHAVIOR-- adminDashboardOptionsForm |
---|
635 | $core->callBehavior('adminDashboardOptionsForm',$core); |
---|
636 | |
---|
637 | echo |
---|
638 | '<p>'. |
---|
639 | form::hidden('db-options','-'). |
---|
640 | $core->formNonce(). |
---|
641 | '<input type="submit" accesskey="s" value="'.__('Save my dashboard options').'" /></p>'. |
---|
642 | '</form>'; |
---|
643 | |
---|
644 | echo '</div>'; # /multipart-user-favorites |
---|
645 | |
---|
646 | dcPage::helpBlock('core_user_pref'); |
---|
647 | dcPage::close(); |
---|