File: preferences.php

package info (click to toggle)
dotclear 2.6.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 8,420 kB
  • sloc: php: 54,270; sql: 1,290; sh: 213; xml: 173; makefile: 158
file content (632 lines) | stat: -rw-r--r-- 21,560 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
<?php
# -- BEGIN LICENSE BLOCK ---------------------------------------
#
# This file is part of Dotclear 2.
#
# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
# Licensed under the GPL version 2.0 license.
# See LICENSE file or
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK -----------------------------------------

require dirname(__FILE__).'/../inc/admin/prepend.php';

dcPage::check('usage,contentadmin');

$page_title = __('My preferences');

$user_name = $core->auth->getInfo('user_name');
$user_firstname = $core->auth->getInfo('user_firstname');
$user_displayname = $core->auth->getInfo('user_displayname');
$user_email = $core->auth->getInfo('user_email');
$user_url = $core->auth->getInfo('user_url');
$user_lang = $core->auth->getInfo('user_lang');
$user_tz = $core->auth->getInfo('user_tz');
$user_post_status = $core->auth->getInfo('user_post_status');

$user_options = $core->auth->getOptions();

$core->auth->user_prefs->addWorkspace('dashboard');
$user_dm_doclinks = $core->auth->user_prefs->dashboard->doclinks;
$user_dm_dcnews = $core->auth->user_prefs->dashboard->dcnews;
$user_dm_quickentry = $core->auth->user_prefs->dashboard->quickentry;

$core->auth->user_prefs->addWorkspace('accessibility');
$user_acc_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop;

$core->auth->user_prefs->addWorkspace('interface');
$user_ui_enhanceduploader = $core->auth->user_prefs->interface->enhanceduploader;
if ($core->auth->isSuperAdmin()) {
	$user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon;
}
$user_ui_iconset = @$core->auth->user_prefs->interface->iconset;
$user_ui_nofavmenu = $core->auth->user_prefs->interface->nofavmenu;
$user_ui_media_by_page = ($core->auth->user_prefs->interface->media_by_page ? $core->auth->user_prefs->interface->media_by_page : 30);

$default_tab = !empty($_GET['tab']) ? html::escapeHTML($_GET['tab']) : 'user-profile';

if (!empty($_GET['append']) || !empty($_GET['removed']) || !empty($_GET['neworder']) ||
	!empty($_GET['replaced']) || !empty($_POST['appendaction']) || !empty($_POST['removeaction']) ||
	!empty($_GET['db-updated'])) {
	$default_tab = 'user-favorites';
} elseif (!empty($_GET['updated'])) {
	$default_tab = 'user-options';
}
if (($default_tab != 'user-profile') && ($default_tab != 'user-options') && ($default_tab != 'user-favorites')) {
	$default_tab = 'user-profile';
}

# Formaters combo
$formaters_combo = dcAdminCombos::getFormatersCombo();

$status_combo = dcAdminCombos::getPostStatusescombo();

$iconsets_combo = array(__('Default') => '');
$iconsets_root = dirname(__FILE__).'/images/iconset/';
if (is_dir($iconsets_root) && is_readable($iconsets_root)) {
	if (($d = @dir($iconsets_root)) !== false) {
		while (($entry = $d->read()) !== false) {
			if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.' && is_dir($iconsets_root.'/'.$entry)) {
				$iconsets_combo[$entry] = $entry;
			}
		}
	}
}

# Language codes
$lang_combo = dcAdminCombos::getAdminLangsCombo();

# Add or update user
if (isset($_POST['user_name']))
{
	try
	{
		$pwd_check = !empty($_POST['cur_pwd']) && $core->auth->checkPassword(crypt::hmac(DC_MASTER_KEY,$_POST['cur_pwd']));

		if ($core->auth->allowPassChange() && !$pwd_check && $user_email != $_POST['user_email']) {
			throw new Exception(__('If you want to change your email or password you must provide your current password.'));
		}

		$cur = $core->con->openCursor($core->prefix.'user');

		$cur->user_name = $user_name = $_POST['user_name'];
		$cur->user_firstname = $user_firstname = $_POST['user_firstname'];
		$cur->user_displayname = $user_displayname = $_POST['user_displayname'];
		$cur->user_email = $user_email = $_POST['user_email'];
		$cur->user_url = $user_url = $_POST['user_url'];
		$cur->user_lang = $user_lang = $_POST['user_lang'];
		$cur->user_tz = $user_tz = $_POST['user_tz'];

		$cur->user_options = new ArrayObject($user_options);

		if ($core->auth->allowPassChange() && !empty($_POST['new_pwd']))
		{
			if (!$pwd_check) {
				throw new Exception(__('If you want to change your email or password you must provide your current password.'));
			}

			if ($_POST['new_pwd'] != $_POST['new_pwd_c']) {
				throw new Exception(__("Passwords don't match"));
			}

			$cur->user_pwd = $_POST['new_pwd'];
		}

		# --BEHAVIOR-- adminBeforeUserUpdate
		$core->callBehavior('adminBeforeUserProfileUpdate',$cur,$core->auth->userID());

		# Udate user
		$core->updUser($core->auth->userID(),$cur);

		# --BEHAVIOR-- adminAfterUserUpdate
		$core->callBehavior('adminAfterUserProfileUpdate',$cur,$core->auth->userID());

		dcPage::addSuccessNotice(__('Personal information has been successfully updated.'));

		http::redirect('preferences.php');
	}
	catch (Exception $e)
	{
		$core->error->add($e->getMessage());
	}
}

# Update user options
if (isset($_POST['user_post_format']))
{
	try
	{
		$cur = $core->con->openCursor($core->prefix.'user');

		$cur->user_name = $user_name;
		$cur->user_firstname = $user_firstname;
		$cur->user_displayname = $user_displayname;
		$cur->user_email = $user_email;
		$cur->user_url = $user_url;
		$cur->user_lang = $user_lang;
		$cur->user_tz = $user_tz;

		$cur->user_post_status = $user_post_status = $_POST['user_post_status'];

		$user_options['edit_size'] = (integer) $_POST['user_edit_size'];
		if ($user_options['edit_size'] < 1) {
			$user_options['edit_size'] = 10;
		}
		$user_options['post_format'] = $_POST['user_post_format'];
		$user_options['enable_wysiwyg'] = !empty($_POST['user_wysiwyg']);

		$cur->user_options = new ArrayObject($user_options);

		# --BEHAVIOR-- adminBeforeUserOptionsUpdate
		$core->callBehavior('adminBeforeUserOptionsUpdate',$cur,$core->auth->userID());

		# Update user prefs
		$core->auth->user_prefs->accessibility->put('nodragdrop',!empty($_POST['user_acc_nodragdrop']),'boolean');
		$core->auth->user_prefs->interface->put('enhanceduploader',!empty($_POST['user_ui_enhanceduploader']),'boolean');
		if ($core->auth->isSuperAdmin()) {
			# Applied to all users
			$core->auth->user_prefs->interface->put('hide_std_favicon',!empty($_POST['user_ui_hide_std_favicon']),'boolean',null,true,true);
		}
		$core->auth->user_prefs->interface->put('media_by_page',(integer)$_POST['user_ui_media_by_page'],'integer');

		# Udate user
		$core->updUser($core->auth->userID(),$cur);

		# --BEHAVIOR-- adminAfterUserOptionsUpdate
		$core->callBehavior('adminAfterUserOptionsUpdate',$cur,$core->auth->userID());

		dcPage::addSuccessNotice(__('Personal options has been successfully updated.'));
		http::redirect('preferences.php#user-options');
	}
	catch (Exception $e)
	{
		$core->error->add($e->getMessage());
	}
}

# Dashboard options
if (isset($_POST['db-options'])) {
	try
	{
		# --BEHAVIOR-- adminBeforeUserOptionsUpdate
		$core->callBehavior('adminBeforeDashboardOptionsUpdate',$core->auth->userID());

		# Update user prefs
		$core->auth->user_prefs->dashboard->put('doclinks',!empty($_POST['user_dm_doclinks']),'boolean');
		$core->auth->user_prefs->dashboard->put('dcnews',!empty($_POST['user_dm_dcnews']),'boolean');
		$core->auth->user_prefs->dashboard->put('quickentry',!empty($_POST['user_dm_quickentry']),'boolean');
		$core->auth->user_prefs->interface->put('iconset',(!empty($_POST['user_ui_iconset']) ? $_POST['user_ui_iconset'] : ''));
		$core->auth->user_prefs->interface->put('nofavmenu',empty($_POST['user_ui_nofavmenu']),'boolean');

		# --BEHAVIOR-- adminAfterUserOptionsUpdate
		$core->callBehavior('adminAfterDashboardOptionsUpdate',$core->auth->userID());

		dcPage::addSuccessNotice(__('Dashboard options has been successfully updated.'));
		http::redirect('preferences.php#user-favorites');
	}
	catch (Exception $e)
	{
		$core->error->add($e->getMessage());
	}
}

# Add selected favorites
if (!empty($_POST['appendaction']))
{
	try {
		if (empty($_POST['append'])) {
			throw new Exception(__('No favorite selected'));
		}
		$user_favs = $core->favs->getFavoriteIDs(false);
		foreach ($_POST['append'] as $k => $v)
		{
			if ($core->favs->exists($v)) {
				$user_favs[] = $v;
			}
		}
		$core->favs->setFavoriteIDs($user_favs,false);

		if (!$core->error->flag()) {
			dcPage::addSuccessNotice(__('Favorites have been successfully added.'));
			http::redirect('preferences.php#user-favorites');
		}
	} catch (Exception $e) {
		$core->error->add($e->getMessage());
	}
}

# Delete selected favorites
if (!empty($_POST['removeaction']))
{
	try {
		if (empty($_POST['remove'])) {
			throw new Exception(__('No favorite selected'));
		}
		$user_fav_ids = array();
		foreach ($core->favs->getFavoriteIDs(false) as $v) {
			$user_fav_ids[$v]=true;
		}
		foreach ($_POST['remove'] as $v)
		{
			if (isset($user_fav_ids[$v])) {
				unset($user_fav_ids[$v]);
			}
		}
		$core->favs->setFavoriteIDs(array_keys($user_fav_ids),false);
		if (!$core->error->flag()) {
			dcPage::addSuccessNotice(__('Favorites have been successfully removed.'));
			http::redirect('preferences.php#user-favorites');
		}
	} catch (Exception $e) {
		$core->error->add($e->getMessage());
	}
}

# Order favs
$order = array();
if (empty($_POST['favs_order']) && !empty($_POST['order'])) {
	$order = $_POST['order'];
	asort($order);
	$order = array_keys($order);
} elseif (!empty($_POST['favs_order'])) {
	$order = explode(',',$_POST['favs_order']);
}

if (!empty($_POST['saveorder']) && !empty($order))
{
	foreach ($order as $k => $v) {
		if (!$core->favs->exists($v)) {
			unset($order[$k]);
		}
	}
	$core->favs->setFavoriteIDs($order,false);
	if (!$core->error->flag()) {
		dcPage::addSuccessNotice(__('Favorites have been successfully updated.'));
		http::redirect('preferences.php#user-favorites');
	}
}

# Replace default favorites by current set (super admin only)
if (!empty($_POST['replace']) && $core->auth->isSuperAdmin()) {
	$user_favs = $core->favs->getFavoriteIDs(false);
	$core->favs->setFavoriteIDs($user_favs,true);

	if (!$core->error->flag()) {
		dcPage::addSuccessNotice(__('Default favorites have been successfully updated.'));
		http::redirect('preferences.php#user-favorites');
	}
}

/* DISPLAY
-------------------------------------------------------- */
dcPage::open($page_title,
	dcPage::jsLoad('js/_preferences.js').
	($user_acc_nodragdrop ? '' : dcPage::jsLoad('js/_preferences-dragdrop.js')).
	dcPage::jsLoad('js/jquery/jquery-ui.custom.js').
	dcPage::jsLoad('js/jquery/jquery.pwstrength.js').
		'<script type="text/javascript">'."\n".
		"//<![CDATA[\n".
		"\$(function() {\n".
		"	\$('#new_pwd').pwstrength({texts: ['".
				sprintf(__('Password strength: %s'),__('very weak'))."', '".
				sprintf(__('Password strength: %s'),__('weak'))."', '".
				sprintf(__('Password strength: %s'),__('mediocre'))."', '".
				sprintf(__('Password strength: %s'),__('strong'))."', '".
				sprintf(__('Password strength: %s'),__('very strong'))."']});\n".
		"});\n".
		"\n//]]>\n".
		"</script>\n".
	dcPage::jsPageTabs($default_tab).
	dcPage::jsConfirmClose('user-form').

	# --BEHAVIOR-- adminPreferencesHeaders
	$core->callBehavior('adminPreferencesHeaders'),

	dcPage::breadcrumb(
	array(
		html::escapeHTML($core->auth->userID()) => '',
		$page_title => ''
	))
);

if (!empty($_GET['upd'])) {
	dcPage::success(__('Personal information has been successfully updated.'));
}
if (!empty($_GET['updated'])) {
	dcPage::success(__('Personal options has been successfully updated.'));
}
if (!empty($_GET['db-updated'])) {
	dcPage::success(__('Dashboard options has been successfully updated.'));
}
if (!empty($_GET['append'])) {
	dcPage::success(__('Favorites have been successfully added.'));
}
if (!empty($_GET['neworder'])) {
	dcPage::success(__('Favorites have been successfully updated.'));
}
if (!empty($_GET['removed'])) {
	dcPage::success(__('Favorites have been successfully removed.'));
}
if (!empty($_GET['replaced'])) {
	dcPage::success(__('Default favorites have been successfully updated.'));
}

# User profile
echo '<div class="multi-part" id="user-profile" title="'.__('My profile').'">';

echo
'<h3>'.__('My profile').'</h3>'.
'<form action="preferences.php" method="post" id="user-form">'.

'<p><label for="user_name">'.__('Last Name:').'</label>'.
form::field('user_name',20,255,html::escapeHTML($user_name)).'</p>'.

'<p><label for="user_firstname">'.__('First Name:').'</label>'.
form::field('user_firstname',20,255,html::escapeHTML($user_firstname)).'</p>'.

'<p><label for="user_displayname">'.__('Display name:').'</label>'.
form::field('user_displayname',20,255,html::escapeHTML($user_displayname)).'</p>'.

'<p><label for="user_email">'.__('Email:').'</label>'.
form::field('user_email',20,255,html::escapeHTML($user_email)).'</p>'.

'<p><label for="user_url">'.__('URL:').'</label>'.
form::field('user_url',30,255,html::escapeHTML($user_url)).'</p>'.

'<p><label for="user_lang">'.__('Language for my interface:').'</label>'.
form::combo('user_lang',$lang_combo,$user_lang,'l10n').'</p>'.

'<p><label for="user_tz">'.__('My timezone:').'</label>'.
form::combo('user_tz',dt::getZones(true,true),$user_tz).'</p>';


if ($core->auth->allowPassChange())
{
	echo
	'<h4 class="vertical-separator pretty-title">'.__('Change my password').'</h4>'.

	'<div class="pw-table">'.
	'<p class="pw-cell"><label for="new_pwd">'.__('New password:').'</label>'.
	form::password('new_pwd',20,255,'','','',false,' data-indicator="pwindicator" ').'</p>'.
	'<div id="pwindicator">'.
	'    <div class="bar"></div>'.
	'    <p class="label no-margin"></p>'.
	'</div>'.
	'</div>'.

	'<p><label for="new_pwd_c">'.__('Confirm new password:').'</label>'.
	form::password('new_pwd_c',20,255).'</p>'.

	'<p><label for="cur_pwd">'.__('Your current password:').'</label>'.
	form::password('cur_pwd',20,255).'</p>'.
	'<p class="form-note warn">'.
	__('If you have changed your email or password you must provide your current password to save these modifications.').
	'</p>';
}

echo
'<p class="clear vertical-separator">'.
$core->formNonce().
'<input type="submit" accesskey="s" value="'.__('Update my profile').'" /></p>'.
'</form>'.

'</div>';

# User options : some from actual user profile, dashboard modules, ...
echo '<div class="multi-part" id="user-options" title="'.__('My options').'">';

echo
'<form action="preferences.php" method="post" id="opts-forms">'.
'<h3>'.__('My options').'</h3>';

echo
'<div class="fieldset">'.
'<h4>'.__('Interface').'</h4>'.

'<p><label for="user_ui_enhanceduploader" class="classic">'.
form::checkbox('user_ui_enhanceduploader',1,$user_ui_enhanceduploader).' '.
__('Activate enhanced uploader in media manager').'</label></p>'.

'<p><label for="user_acc_nodragdrop" class="classic">'.
form::checkbox('user_acc_nodragdrop',1,$user_acc_nodragdrop).' '.
__('Disable javascript powered drag and drop for ordering items').'</label></p>'.
'<p class="clear form-note">'.__('If checked, numeric fields will allow to type the elements\' ordering number.').'</p>';

echo
'<p><label for="user_ui_media_by_page" class="classic">'.__('Number of elements displayed per page in media manager:').'</label> '.
form::field('user_ui_media_by_page',5,3,(integer) $user_ui_media_by_page).'</p>';

if ($core->auth->isSuperAdmin()) {
	echo
	'<p><label for="user_ui_hide_std_favicon" class="classic">'.
	form::checkbox('user_ui_hide_std_favicon',1,$user_ui_hide_std_favicon).' '.
	__('Do not use standard favicon').'</label> '.
	'<span class="clear form-note warn">'.__('This will be applied for all users').'.</span>'.
	'</p>';//Opera sucks;
}

echo
'</div>';

echo
'<div class="fieldset">'.
'<h4>'.__('Edition').'</h4>'.

'<p class="field"><label for="user_post_format">'.__('Preferred format:').'</label>'.
form::combo('user_post_format',$formaters_combo,$user_options['post_format']).'</p>'.

'<p class="field"><label for="user_post_status">'.__('Default entry status:').'</label>'.
form::combo('user_post_status',$status_combo,$user_post_status).'</p>'.

'<p class="field"><label for="user_edit_size">'.__('Entry edit field height:').'</label>'.
form::field('user_edit_size',5,4,(integer) $user_options['edit_size']).'</p>'.

'<p><label for="user_wysiwyg" class="classic">'.
form::checkbox('user_wysiwyg',1,$user_options['enable_wysiwyg']).' '.
__('Enable WYSIWYG mode').'</label></p>'.

'</div>';

echo
'<h4 class="pretty-title">'.__('Other options').'</h4>';

# --BEHAVIOR-- adminPreferencesForm
$core->callBehavior('adminPreferencesForm',$core);

echo
'<p class="clear vertical-separator">'.
$core->formNonce().
'<input type="submit" accesskey="s" value="'.__('Save my options').'" /></p>'.
'</form>';

echo '</div>';

# My dashboard
echo '<div class="multi-part" id="user-favorites" title="'.__('My dashboard').'">';
$ws = $core->auth->user_prefs->addWorkspace('favorites');
echo '<h3>'.__('My dashboard').'</h3>';

echo '<form action="preferences.php" method="post" id="favs-form" class="two-boxes odd">';

echo '<div id="my-favs" class="fieldset"><h4>'.__('My favorites').'</h4>';

$count = 0;
$user_fav = $core->favs->getFavoriteIDs(false);
foreach ($user_fav as $id) {
	$fav = $core->favs->getFavorite($id);
	if ($fav != false) {
		// User favorites only
		if ($count == 0) echo '<ul class="fav-list">';
		$count++;
		echo '<li id="fu-'.$id.'">'.'<label for="fuk-'.$id.'">'.
			'<img src="'.dc_admin_icon_url($fav['small-icon']).'" alt="" /> '.'<span class="zoom"><img src="'.dc_admin_icon_url($fav['large-icon']).'" alt="" /></span>'.
			form::field(array('order['.$id.']'),2,3,$count,'position','',false,'title="'.sprintf(__('position of %s'),$fav['title']).'"').
			form::hidden(array('dynorder[]','dynorder-'.$id.''),$id).
			form::checkbox(array('remove[]','fuk-'.$id),$id).__($fav['title']).'</label>'.
			'</li>';
	}
}
if ($count > 0) echo '</ul>';
if ($count > 0) {
	echo
	'<div class="clear">'.
	'<p>'.form::hidden('favs_order','').
	$core->formNonce().
	'<input type="submit" name="saveorder" value="'.__('Save order').'" /> '.

	'<input type="submit" class="delete" name="removeaction" '.
	'value="'.__('Delete selected favorites').'" '.
	'onclick="return window.confirm(\''.html::escapeJS(
		__('Are you sure you want to remove selected favorites?')).'\');" /></p>'.

	($core->auth->isSuperAdmin() ?
		'<div class="info">'.
		'<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>'.
		'<p><input class="reset" type="submit" name="replace" value="'.__('Define as default favorites').'" />'.'</p>'.
		'</div>'
		:
		'').

	'</div>';
} else {
	echo
	'<p>'.__('Currently no personal favorites.').'</p>';
}

$avail_fav = $core->favs->getFavorites($core->favs->getAvailableFavoritesIDs());
$default_fav_ids = array();
foreach($core->favs->getFavoriteIDs(true) as $v) {
	$default_fav_ids[$v]=true;
}
echo '</div>'; # /box my-fav

echo '<div class="fieldset" id="available-favs">';
# Available favorites
echo '<h5 class="pretty-title">'.__('Other available favorites').'</h5>';
$count = 0;
function cmp($a,$b) {
    if ($a['title'] == $b['title']) {
        return 0;
    }
    return ($a['title'] < $b['title']) ? -1 : 1;
}
uasort($avail_fav,'cmp');

foreach ($avail_fav as $k => $v) {
	if (in_array($k,$user_fav)) {
		unset($avail_fav[$k]);
	}
}
foreach ($avail_fav as $k=>$fav) {
	if ($count == 0) echo '<ul class="fav-list">';
	$count++;
	echo '<li id="fa-'.$k.'">'.'<label for="fak-'.$k.'">'.
		'<img src="'.dc_admin_icon_url($fav['small-icon']).'" alt="" /> '.
		'<span class="zoom"><img src="'.dc_admin_icon_url($fav['large-icon']).'" alt="" /></span>'.
		form::checkbox(array('append[]','fak-'.$k),$k).
		$fav['title'].'</label>'.
		(isset($default_fav_ids[$k]) ? ' <span class="default-fav"><img src="images/selected.png" alt="'.__('(default favorite)').'" /></span>' : '').
		'</li>';
}
if ($count > 0) echo '</ul>';
echo
'<p>'.
$core->formNonce().
'<input type="submit" name="appendaction" value="'.__('Add to my favorites').'" /></p>';
echo '</div>'; # /available favorites

echo '</form>';

echo
'<form action="preferences.php" method="post" id="db-forms" class="two-boxes even">'.

'<div class="fieldset">'.
'<h4>'.__('Menu').'</h4>'.
'<p><label for="user_ui_nofavmenu" class="classic">'.
form::checkbox('user_ui_nofavmenu',1,!$user_ui_nofavmenu).' '.
__('Display favorites at the top of the menu').'</label></p></div>';

if (count($iconsets_combo) > 1) {
	echo
		'<div class="fieldset">'.
		'<h4>'.__('Dashboard icons').'</h4>'.
		'<p><label for="user_ui_iconset" class="classic">'.__('Iconset:').'</label> '.
		form::combo('user_ui_iconset',$iconsets_combo,$user_ui_iconset).'</p>'.
		'</div>';
} else {
	echo '<p class="hidden">'.form::hidden('user_ui_iconset','').'</p>';
}

echo
'<div class="fieldset">'.
'<h4>'.__('Dashboard modules').'</h4>'.

'<p><label for="user_dm_doclinks" class="classic">'.
form::checkbox('user_dm_doclinks',1,$user_dm_doclinks).' '.
__('Display documentation links').'</label></p>'.

'<p><label for="user_dm_dcnews" class="classic">'.
form::checkbox('user_dm_dcnews',1,$user_dm_dcnews).' '.
__('Display Dotclear news').'</label></p>'.

'<p><label for="user_dm_quickentry" class="classic">'.
form::checkbox('user_dm_quickentry',1,$user_dm_quickentry).' '.
__('Display quick entry form').'</label><br class="clear" />'. //Opera sucks
'</p>';
echo '</div>';

# --BEHAVIOR-- adminDashboardOptionsForm
$core->callBehavior('adminDashboardOptionsForm',$core);

echo
'<p>'.
form::hidden('db-options','-').
$core->formNonce().
'<input type="submit" accesskey="s" value="'.__('Save my dashboard options').'" /></p>'.
'</form>';

echo '</div>'; # /multipart-user-favorites

dcPage::helpBlock('core_user_pref');
dcPage::close();