tiki-admin.php 19.7 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
6
//
7 8
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
9
// $Id$
changi67's avatar
changi67 committed
10

11
$section = 'admin';
pkdille's avatar
pkdille committed
12

13
require_once ('tiki-setup.php');
lphuberdeau's avatar
lphuberdeau committed
14
$adminlib = TikiLib::lib('admin');
pkdille's avatar
pkdille committed
15

16 17 18 19 20 21 22
if (! empty($_SESSION['tikifeedback'])) {
	$tikifeedback = $_SESSION['tikifeedback'];
	$_SESSION['tikifeedback'] = array();
} else {
	$tikifeedback = array();
	$_SESSION['tikifeedback'] = array();
}
pkdille's avatar
pkdille committed
23 24
$auto_query_args = array('page');

25
$access->check_permission('tiki_p_admin');
lphuberdeau's avatar
lphuberdeau committed
26
$logslib = TikiLib::lib('logs');
pkdille's avatar
pkdille committed
27

jonnybradley's avatar
jonnybradley committed
28 29
/**
 * Display feedback on prefs changed
30
 *
31 32 33 34
 * @param string $name		Name of feature
 * @param string $message	Other message
 * @param int $st		    Type of change (0=disabled, 1=enabled, 2=changed, 3=info, 4=reset)
 * @param int $num		    unknown
jonnybradley's avatar
jonnybradley committed
35 36
 * @return void
 */
pkdille's avatar
pkdille committed
37 38
function add_feedback( $name, $message, $st, $num = null )
{
39 40
	TikiLib::lib('prefs')->addRecent($name);

41
	$_SESSION['tikifeedback'][] = array(
42 43 44 45 46 47
		'num' => $num,
		'mes' => $message,
		'st' => $st,
		'name' => $name,
	);
}
pkdille's avatar
pkdille committed
48 49

/**
50 51 52
 * simple_set_toggle
 *
 * @param mixed $feature
pkdille's avatar
pkdille committed
53 54 55 56 57
 * @access public
 * @return void
 */
function simple_set_toggle($feature)
{
lphuberdeau's avatar
lphuberdeau committed
58 59 60 61
	global $prefs;
	$logslib = TikiLib::lib('logs');
	$tikilib = TikiLib::lib('tiki');
	$smarty = TikiLib::lib('smarty');
pkdille's avatar
pkdille committed
62
	if (isset($_REQUEST[$feature]) && $_REQUEST[$feature] == 'on') {
63 64
		if ((!isset($prefs[$feature]) || $prefs[$feature] != 'y')) {
			// not yet set at all or not set to y
65
			if ($tikilib->set_preference($feature, 'y')) {
changi67's avatar
changi67 committed
66
				add_feedback($feature, tr('%0 enabled', $feature), 1, 1);
67 68
				$logslib->add_action('feature', $feature, 'system', 'enabled');
			}
69
		}
70 71 72
	} else {
		if ((!isset($prefs[$feature]) || $prefs[$feature] != 'n')) {
			// not yet set at all or not set to n
73 74 75 76
			if ($tikilib->set_preference($feature, 'n')) {
				add_feedback($feature, tr('%0 disabled', $feature), 0, 1);
				$logslib->add_action('feature', $feature, 'system', 'disabled');
			}
77 78
		}
	}
lphuberdeau's avatar
lphuberdeau committed
79
	$cachelib = TikiLib::lib('cache');
80
	$cachelib->invalidate('allperms');
81
}
pkdille's avatar
pkdille committed
82 83

/**
84 85 86 87 88
 * simple_set_value
 *
 * @param mixed $feature
 * @param string $pref
 * @param mixed $isMultiple
pkdille's avatar
pkdille committed
89 90 91 92 93
 * @access public
 * @return void
 */
function simple_set_value($feature, $pref = '', $isMultiple = false)
{
lphuberdeau's avatar
lphuberdeau committed
94 95 96 97
	global $prefs;
	$logslib = TikiLib::lib('logs');
	$tikilib = TikiLib::lib('tiki');
	$smarty = TikiLib::lib('smarty');
98 99 100
	$old = $prefs[$feature];
	if (isset($_REQUEST[$feature])) {
		if ($pref != '') {
101 102 103
			if ($tikilib->set_preference($pref, $_REQUEST[$feature])) {
				$prefs[$feature] = $_REQUEST[$feature];
			}
104 105 106 107 108 109 110
		} else {
			$tikilib->set_preference($feature, $_REQUEST[$feature]);
		}
	} elseif ($isMultiple) {
		// Multiple selection controls do not exist if no item is selected.
		// We still want the value to be updated.
		if ($pref != '') {
111 112 113
			if ($tikilib->set_preference($pref, array())) {
				$prefs[$feature] = $_REQUEST[$feature];
			}
114 115 116 117 118
		} else {
			$tikilib->set_preference($feature, array());
		}
	}
	if (isset($_REQUEST[$feature]) && $old != $_REQUEST[$feature]) {
changi67's avatar
changi67 committed
119
		add_feedback($feature, ($_REQUEST[$feature]) ? tr('%0 set', $feature) : tr('%0 unset', $feature), 2);
120
		$logslib->add_action('feature', $feature, 'system', $old .'=>'.isset($_REQUEST['feature'])?$_REQUEST['feature']:'');
121
	}
lphuberdeau's avatar
lphuberdeau committed
122
	$cachelib = TikiLib::lib('cache');
123
	$cachelib->invalidate('allperms');
124
}
pkdille's avatar
pkdille committed
125 126

/**
127 128 129
 * simple_set_int
 *
 * @param mixed $feature
pkdille's avatar
pkdille committed
130 131 132
 * @access public
 * @return void
 */
133
function simple_set_int($feature)
pkdille's avatar
pkdille committed
134
{
lphuberdeau's avatar
lphuberdeau committed
135 136 137 138
	global $prefs;
	$logslib = TikiLib::lib('logs');
	$tikilib = TikiLib::lib('tiki');
	$smarty = TikiLib::lib('smarty');
139 140
	if (isset($_REQUEST[$feature]) && is_numeric($_REQUEST[$feature])) {
		$old = $prefs[$feature];
141 142
		if ($old != $_REQUEST[$feature]) {
			$tikilib->set_preference($feature, $_REQUEST[$feature]);
changi67's avatar
changi67 committed
143
			add_feedback($feature, tr('%0 set', $feature), 2);
pkdille's avatar
pkdille committed
144
			$logslib->add_action('feature', $feature, 'system', $old . '=>' . $_REQUEST['feature']);
145
		}
146
	}
147
}
pkdille's avatar
pkdille committed
148 149

/**
150 151 152 153
 * byref_set_value
 *
 * @param mixed $feature
 * @param string $pref
pkdille's avatar
pkdille committed
154 155 156 157 158
 * @access public
 * @return void
 */
function byref_set_value($feature, $pref = '')
{
159
	simple_set_value($feature, $pref);
160
}
pkdille's avatar
pkdille committed
161

162
$crumbs[] = new Breadcrumb(tra('Control Panels'), tra('Sections'), 'tiki-admin.php', 'Admin+Home', tra('Help on Configuration Sections', '', true));
sept_7's avatar
sept_7 committed
163
// Default values for AdminHome
164
$admintitle = tra('Control Panels');
sept_7's avatar
sept_7 committed
165
$helpUrl = 'Admin+Home';
sylvieg's avatar
sylvieg committed
166 167
$helpDescription = $description = '';
$url = 'tiki-admin.php';
mose's avatar
mose committed
168
$adminPage = '';
169

lphuberdeau's avatar
lphuberdeau committed
170
$prefslib = TikiLib::lib('prefs');
171

172
if ( isset ($_REQUEST['pref_filters']) ) {
changi67's avatar
changi67 committed
173
	$prefslib->setFilters($_REQUEST['pref_filters']);
174 175
}

176 177
$temp_filters = isset($_REQUEST['filters']) ? explode(' ', $_REQUEST['filters']) : null;
$smarty->assign('pref_filters', $prefslib->getFilters($temp_filters));
178

179
if ( isset( $_REQUEST['lm_preference'] ) ) {
180 181 182 183 184 185 186
	$check = key_check(null, false);
	if ($check === true) {
		$changes = $prefslib->applyChanges((array) $_REQUEST['lm_preference'], $_REQUEST);
		foreach ( $changes as $pref => $val ) {
			if ($val['type'] == 'reset') {
				add_feedback($pref, tr('%0 reset', $pref), 4);
				$logslib->add_action('feature', $pref, 'system', 'reset');
187
			} else {
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
				$value = $val['new'];
				if ( $value == 'y' ) {
					add_feedback($pref, tr('%0 enabled', $pref), 1, 1);
					$logslib->add_action('feature', $pref, 'system', 'enabled');
				} elseif ( $value == 'n' ) {
					add_feedback($pref, tr('%0 disabled', $pref), 0, 1);
					$logslib->add_action('feature', $pref, 'system', 'disabled');
				} else {
					add_feedback($pref, tr('%0 set', $pref), 1, 1);
					$logslib->add_action('feature', $pref, 'system', (is_array($val['old'])?implode($val['old'], ','):$val['old']).'=>'.(is_array($value)?implode($value, ','):$value));
				}
				/*
					Enable/disable addreference/showreference plugins alognwith references feature.
				*/
				if ($pref == 'feature_references') {
					$tikilib->set_preference('wikiplugin_addreference', $value);
					$tikilib->set_preference('wikiplugin_showreference', $value);
205

206 207 208 209 210
					/* Add/Remove the plugin toolbars from the editor */
					$toolbars = array('wikiplugin_addreference', 'wikiplugin_showreference');
					$t_action = ($value=='y') ? 'add' : 'remove';
					$tikilib->saveEditorToolbars($toolbars, 'global', $t_action);
				}
211
			}
212
		}
213
	} else {
214 215
		$smarty->assign('csrferror',
			tr('Bad request - potential cross-site request forgery (CSRF) detected. Operation blocked. The security ticket may have expired - try reloading the page in this case.'));
216
	}
217 218
}

219
if ( isset( $_REQUEST['lm_criteria'] ) ) {
220 221
	$check = key_get(null, null, null, false);
	$smarty->assign('ticket', $check['ticket']);
222
	set_time_limit(0);
223
	try {
224
		$smarty->assign('lm_criteria', $_REQUEST['lm_criteria']);
drsassafras's avatar
drsassafras committed
225
		$results = $prefslib->getMatchingPreferences($_REQUEST['lm_criteria']);
226 227 228
		$results = array_slice($results, 0, 50);
		$smarty->assign('lm_searchresults', $results);
		$smarty->assign('lm_error', '');
229
	} catch(ZendSearch\Lucene\Exception\ExceptionInterface $e) {
230 231 232
		$smarty->assign('lm_criteria', $_REQUEST['lm_criteria']);
		$smarty->assign('lm_error', $e->getMessage());
		$smarty->assign('lm_searchresults', '');
233
	}
234
} else {
235 236 237
	$smarty->assign('lm_criteria', '');
	$smarty->assign('lm_searchresults', '');
	$smarty->assign('lm_error', '');
238 239
}

240 241
$smarty->assign('indexNeedsRebuilding', $prefslib->indexNeedsRebuilding());

242
if (isset($_REQUEST['prefrebuild'])) {
243
	$prefslib->rebuildIndex();
244
	header('Location: ' . $base_url . 'tiki-admin.php');
245 246
}

247
$admin_icons = array(
248 249
	"general" => array(
		'title' => tr('General'),
drsassafras's avatar
drsassafras committed
250
		'description' => tr('Global site configuration, date formats, etc.'),
gezzzan's avatar
gezzzan committed
251
		'help' => 'General Admin',
252 253 254
	),
	"features" => array(
		'title' => tr('Features'),
255
		'description' => tr('Switches for major features'),
gezzzan's avatar
gezzzan committed
256
		'help' => 'Features Admin',
257 258 259
	),
	"login" => array(
		'title' => tr('Log in'),
260
		'description' => tr('User registration, remember me cookie settings and authentication methods'),
gezzzan's avatar
gezzzan committed
261
		'help' => 'Login Config',
262 263 264
	),
	"community" => array(
		'title' => tr('Community'),
265
		'description' => tr('User specific features and settings'),
266
		'help' => 'Community',
267 268 269
	),
	"profiles" => array(
		'title' => tr('Profiles'),
270
		'description' => tr('Repository configuration, browse and apply profiles'),
271
		'help' => 'Profiles',
272 273 274
	),
	"look" => array(
		'title' => tr('Look & Feel'),
275
		'description' => tr('Theme selection, layout settings and UI effect controls'),
gezzzan's avatar
gezzzan committed
276
		'help' => 'Look and Feel',
277 278 279
	),
	"textarea" => array(
		'title' => tr('Editing and Plugins'),
280
		'description' => tr('Text editing settings applicable to many areas. Plugin activation and plugin alias management'),
gezzzan's avatar
gezzzan committed
281
		'help' => 'Text area',
282 283
	),
	"module" => array(
284
		'title' => tr('Modules'),
285
		'description' => tr('Module appearance settings'),
286
		'help' => 'Module',
287 288 289
	),
	"metatags" => array(
		'title' => tr('Meta Tags'),
290
		'description' => tr('Information to include in the header of each page'),
gezzzan's avatar
gezzzan committed
291
		'help' => 'Meta Tags',
292
	),
293 294
	"i18n" => array(
		'title' => tr('i18n'),
changi67's avatar
changi67 committed
295
		'description' => tr('Internationalization and localization - multilingual features'),
296 297 298 299 300 301
		'help' => 'i18n',
	),
	"maps" => array(
		'title' => tr('Maps'),
		'description' => tr('Settings and features for maps'),
		'help' => 'Maps',
302
		'disabled' => false,
303
	),
304 305
	"performance" => array(
		'title' => tr('Performance'),
306
		'description' => tr('Server performance settings'),
307
		'help' => 'Performance',
308 309 310
	),
	"security" => array(
		'title' => tr('Security'),
311
		'description' => tr('Site security settings'),
312
		'help' => 'Security',
313 314 315
	),
	"comments" => array(
		'title' => tr('Comments'),
316
		'description' => tr('Comments settings'),
317
		'help' => 'Comments',
318 319 320
	),
	"rss" => array(
		'title' => tr('Feeds'),
321
		'help' => 'Feeds User',
322
		'description' => tr('Outgoing RSS feed setup'),
323 324 325
	),
	"connect" => array(
		'title' => tr('Connect'),
326
		'help' => 'Connect',
327
		'description' => tr('Tiki Connect - join in!'),
328 329 330
	),
	"rating" => array(
		'title' => tr('Rating'),
331
		'help' => 'Rating',
332
		'description' => tr('Rating settings'),
333
		'disabled' => $prefs['wiki_simple_ratings'] !== 'y' &&
334
						$prefs['wiki_comments_simple_ratings'] !== 'y' &&
335
						$prefs['comments_vote'] !== 'y' &&
336
						$prefs['rating_advanced'] !== 'y' &&
337
						$prefs['trackerfield_rating'] !== 'y' &&
338 339 340
						$prefs['article_user_rating'] !== 'y' &&
						$prefs['rating_results_detailed'] !== 'y' &&
						$prefs['rating_smileys'] !== 'y',
341
	),
342 343 344 345
	"search" => array(
		'title' => tr('Search'),
		'description' => tr('Search configuration'),
		'help' => 'Search',
346
		'disabled' => $prefs['feature_search'] !== 'y' &&
347
						$prefs['feature_search_fulltext'] !== 'y',
348
	),
349 350 351
	"wiki" => array(
		'title' => tr('Wiki'),
		'disabled' => $prefs['feature_wiki'] != 'y',
352
		'description' => tr('Wiki page settings and features'),
gezzzan's avatar
gezzzan committed
353
		'help' => 'Wiki Config',
354 355 356 357
	),
	"fgal" => array(
		'title' => tr('File Galleries'),
		'disabled' => $prefs['feature_file_galleries'] != 'y',
358
		'description' => tr('Defaults and configuration for file galleries'),
gezzzan's avatar
gezzzan committed
359
		'help' => 'File Gallery',
360 361 362 363
	),
	"blogs" => array(
		'title' => tr('Blogs'),
		'disabled' => $prefs['feature_blogs'] != 'y',
364
		'description' => tr('Settings for blogs'),
365
		'help' => 'Blog',
366 367 368 369
	),
	"gal" => array(
		'title' => tr('Image Galleries'),
		'disabled' => $prefs['feature_galleries'] != 'y',
370
		'description' => tr('Defaults and configuration for image galleries (will be phased out in favour of file galleries)'),
gezzzan's avatar
gezzzan committed
371
		'help' => 'Image Gallery',
372 373 374 375
	),
	"articles" => array(
		'title' => tr('Articles'),
		'disabled' => $prefs['feature_articles'] != 'y',
376
		'description' => tr('Settings and features for articles'),
377
		'help' => 'Articles',
378 379 380 381
	),
	"forums" => array(
		'title' => tr('Forums'),
		'disabled' => $prefs['feature_forums'] != 'y',
382
		'description' => tr('Settings and features for forums'),
383
		'help' => 'Forum',
384 385 386 387
	),
	"trackers" => array(
		'title' => tr('Trackers'),
		'disabled' => $prefs['feature_trackers'] != 'y',
388
		'description' => tr('Settings and features for trackers'),
389
		'help' => 'Trackers',
390 391 392 393
	),
	"polls" => array(
		'title' => tr('Polls'),
		'disabled' => $prefs['feature_polls'] != 'y',
394
		'description' => tr('Settings and features for polls'),
395
		'help' => 'Polls',
396 397 398 399
	),
	"calendar" => array(
		'title' => tr('Calendar'),
		'disabled' => $prefs['feature_calendar'] != 'y',
400
		'description' => tr('Settings and features for calendars'),
401
		'help' => 'Calendar',
402 403 404 405
	),
	"category" => array(
		'title' => tr('Categories'),
		'disabled' => $prefs['feature_categories'] != 'y',
406
		'description' => tr('Settings and features for categories'),
407
		'help' => 'Category',
408
	),
409
	"workspace" => array(
410
		'title' => tr('Workspaces'),
411
		'disabled' => $prefs['workspace_ui'] != 'y' && $prefs['feature_areas'] != 'y',
412
		'description' => tr('Configure workspace feature'),
gezzzan's avatar
gezzzan committed
413
		'help' => 'Workspace',
414
	),
415 416 417
	"score" => array(
		'title' => tr('Score'),
		'disabled' => $prefs['feature_score'] != 'y',
418
		'description' => tr('Values of actions for users rank score'),
419
		'help' => 'Score',
420 421
	),
	"freetags" => array(
422
		'title' => tr('Tags'),
423
		'disabled' => $prefs['feature_freetags'] != 'y',
424
		'description' => tr('Settings and features for tags'),
425
		'help' => 'Tags',
426 427 428 429
	),
	"faqs" => array(
		'title' => tr('FAQs'),
		'disabled' => $prefs['feature_faqs'] != 'y',
430
		'description' => tr('Settings and features for FAQs'),
431
		'help' => 'FAQ',
432 433 434 435
	),
	"directory" => array(
		'title' => tr('Directory'),
		'disabled' => $prefs['feature_directory'] != 'y',
436
		'description' => tr('Settings and features for directory of links'),
437
		'help' => 'Directory',
438 439 440 441
	),
	"copyright" => array(
		'title' => tr('Copyright'),
		'disabled' => $prefs['feature_copyright'] != 'y',
442
		'description' => tr('Site-wide copyright information'),
443
		'help' => 'Copyright',
444 445 446 447
	),
	"messages" => array(
		'title' => tr('Messages'),
		'disabled' => $prefs['feature_messages'] != 'y',
448
		'description' => tr('Message settings'),
gezzzan's avatar
gezzzan committed
449
		'help' => 'Inter-User Messages',
450 451
	),
	"userfiles" => array(
452
		'title' => tr('User Files'),
453
		'disabled' => $prefs['feature_userfiles'] != 'y',
454
		'description' => tr('User files settings'),
gezzzan's avatar
gezzzan committed
455
		'help' => 'User Files',
456 457 458 459
	),
	"webmail" => array(
		'title' => tr('Webmail'),
		'disabled' => $prefs['feature_webmail'] != 'y',
460
		'description' => tr('Webmail settings'),
461
		'help' => 'Webmail',
462 463 464 465
	),
	"wysiwyg" => array(
		'title' => tr('Wysiwyg'),
		'disabled' => $prefs['feature_wysiwyg'] != 'y',
466
		'description' => tr('Options for WYSIWYG editor'),
467
		'help' => 'Wysiwyg',
468 469
	),
	"ads" => array(
470
		'title' => tr('Banners'),
471
		'disabled' => $prefs['feature_banners'] != 'y',
472
		'description' => tr('Site advertisements and notices'),
gezzzan's avatar
gezzzan committed
473
		'help' => 'Banners',
474 475 476 477
	),
	"intertiki" => array(
		'title' => tr('InterTiki'),
		'disabled' => $prefs['feature_intertiki'] != 'y',
478
		'description' => tr('Set up links between Tiki servers'),
479
		'help' => 'InterTiki',
480 481
	),
	"semantic" => array(
482
		'title' => tr('Semantic Links'),
483
		'disabled' => $prefs['feature_semantic'] != 'y',
484
		'description' => tr('Manage semantic wiki links'),
gezzzan's avatar
gezzzan committed
485
		'help' => 'Semantic Admin',
486 487 488 489
	),
	"webservices" => array(
		'title' => tr('Webservices'),
		'disabled' => $prefs['feature_webservices'] != 'y',
490
		'description' => tr('Register and manage web services'),
491
		'help' => 'WebServices',
492 493
	),
	"sefurl" => array(
494
		'title' => tr('SEF URL'),
495
		'disabled' => $prefs['feature_sefurl'] != 'y' && $prefs['feature_canonical_url'] != 'y',
496
		'description' => tr('Search Engine Friendly URLs'),
gezzzan's avatar
gezzzan committed
497
		'help' => 'Rewrite Rules',
498 499
	),
	"video" => array(
500
		'title' => tr('Video'),
501
		'disabled' => $prefs['feature_kaltura'] != 'y',
502
		'description' => tr('Video integration configuration'),
gezzzan's avatar
gezzzan committed
503
		'help' => 'Kaltura Config',
504 505 506 507
	),
	"payment" => array(
		'title' => tr('Payment'),
		'disabled' => $prefs['payment_feature'] != 'y',
508
		'description' => tr('Payment settings'),
509
		'help' => 'Payment',
510 511 512 513
	),
	"socialnetworks" => array(
		'title' => tr('Social networks'),
		'disabled' => $prefs['feature_socialnetworks'] != 'y',
514
		'description' => tr('Configure social networks integration'),
gezzzan's avatar
gezzzan committed
515
		'help' => 'Social Networks',
516 517 518 519
	),
	"share" => array(
		'title' => tr('Share'),
		'disabled' => $prefs['feature_share'] != 'y',
520
		'description' => tr('Configure share feature'),
gezzzan's avatar
gezzzan committed
521
		'help' => 'Share',
522
	),
523 524 525 526 527 528
	"stats" => array(
		'title' => tr('Statistics'),
//		'disabled' => $prefs['feature_stats'] != 'y',
		'description' => tr('Configure statistics reporting for your site usage'),
		'help' => 'Statistics',
	),
529 530
);

531 532
if (isset($_REQUEST['page'])) {
	$adminPage = $_REQUEST['page'];
533 534
	$check = key_get(null, null, null, false);
	$smarty->assign('ticket', $check['ticket']);
535 536 537
	// Check if the associated incude_*.php file exists. If not, check to see if it might exist in the Addons.
	// If it exists, include the associated file and generate the ticket.
	$utilities = new TikiAddons_Utilities();
538 539
	if (file_exists("admin/include_$adminPage.php")) {
		include_once ("admin/include_$adminPage.php");
540 541
	} elseif ($filepath = $utilities->getAddonFilePath("admin/include_$adminPage.php")) {
		include_once ($filepath);
542
	}
543
	$url = 'tiki-admin.php' . '?page=' . $adminPage;
544

545 546
	if (isset($admin_icons[$adminPage])) {
		$admin_icon = $admin_icons[$adminPage];
547

548 549 550
		$admintitle = $admin_icon['title'];
		$description = isset($admin_icon['description']) ? $admin_icon['description'] : '';
		$helpUrl = isset($admin_icon['help']) ? $admin_icon['help'] : '';
551 552
	}
	$helpDescription = tr("Help on %0 Config", $admintitle);
553

554 555
	$smarty->assign('include', $adminPage);

556 557 558 559
	if (!empty($changes) && key_check(null, false)) {
		$access->redirect($_SERVER['REQUEST_URI'], '', 200);
	}

560
} else {
561
	$smarty->assign('include', 'list_sections');
562
	$smarty->assign('admintitle', 'Control Panels');
563 564 565 566
	$smarty->assign('description', 'Home Page for Administrators');
	$smarty->assign('headtitle', breadcrumb_buildHeadTitle($crumbs));
	$smarty->assign('description', $crumbs[0]->description);
}
567
$headerlib->add_cssfile('themes/base_files/feature_css/admin.css');
568 569 570 571 572 573 574 575 576 577
if (isset($admintitle) && isset($description)) {
	$crumbs[] = new Breadcrumb($admintitle, $description, $url, $helpUrl, $helpDescription);
	$smarty->assign_by_ref('admintitle', $admintitle);
	$headtitle = breadcrumb_buildHeadTitle($crumbs);
	$smarty->assign_by_ref('headtitle', $headtitle);
	$smarty->assign_by_ref('helpUrl', $helpUrl);
	$smarty->assign_by_ref('description', $description);
}

// VERSION TRACKING
578
$forcecheck = ! empty($_GET['forcecheck']);
579 580 581

// Versioning feature has been enabled, so if the time is right, do a live
// check, otherwise display the stored data.
582 583 584 585 586 587
if ($prefs['feature_version_checks'] == 'y' || $forcecheck) {
	$checker = new Tiki_Version_Checker;
	$checker->setVersion($TWV->version);
	$checker->setCycle($prefs['tiki_release_cycle']);

	$expiry = $tikilib->now - $prefs['tiki_version_check_frequency'];
588 589 590 591 592
	$upgrades = $checker->check(
		function ($url) use ($expiry)
		{
			$cachelib = TikiLib::lib('cache');
			$tikilib = TikiLib::lib('tiki');
593

594
			$content = $cachelib->getCached($url, 'http', $expiry);
595

596 597 598 599
			if ($content === false) {
				$content = $tikilib->httprequest($url);
				$cachelib->cacheItem($url, $content, 'http');
			}
600

601 602 603
			return $content;
		}
	);
604

605 606 607 608 609 610 611 612 613 614
	$smarty->assign(
		'upgrade_messages',
		array_map(
			function ($upgrade)
			{
				return $upgrade->getMessage();
			},
			$upgrades
		)
	);
615 616
}

617 618
foreach ($admin_icons as &$admin_icon) {
	$admin_icon = array_merge(array( 'disabled' => false, 'description' => ''), $admin_icon);
619 620
}

621 622 623
// SSL setup
$haveMySQLSSL = $tikilib->haveMySQLSSL();
$smarty->assign('haveMySQLSSL', $haveMySQLSSL);
624 625 626 627 628 629
if ($haveMySQLSSL) {
	$isSSL = $tikilib->isMySQLConnSSL();
} else {
	$isSSL = false;
}
$smarty->assign('mysqlSSL', $isSSL);
630

631
$smarty->assign('admin_icons', $admin_icons);
632

633
$smarty->assign_by_ref('tikifeedback', $tikifeedback);
634 635
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
636
// Display the template
mose's avatar
mose committed
637
$smarty->assign('adminpage', $adminPage);
638
$smarty->assign('mid', 'tiki-admin.tpl');
639
$smarty->assign('trail', $crumbs);
changi67's avatar
changi67 committed
640
$smarty->assign('crumb', count($crumbs) - 1);
641 642 643
include_once ('installer/installlib.php');
$installer = new Installer;
$smarty->assign('db_requires_update', $installer->requiresUpdate());
pkdille's avatar
pkdille committed
644
$smarty->display('tiki.tpl');