<?php
// (c) Copyright 2002-2009 by authors of the Tiki Wiki/CMS/Groupware Project
// 
// 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.
// $Id: tiki-theme_control_sections.php 22926 2009-11-05 22:24:47Z jonnybradley $
require_once ('tiki-setup.php');
include_once ('lib/themecontrol/tcontrol.php');
include_once ('lib/categories/categlib.php');
if ($prefs['feature_theme_control'] != 'y') {
	$smarty->assign('msg', tra("This feature is disabled") . ": feature_theme_control");
	$smarty->display("error.tpl");
	die;
}
if ($tiki_p_admin != 'y') {
	$smarty->assign('errortype', 401);
	$smarty->assign('msg', tra("You do not have permission to use this feature"));
	$smarty->display("error.tpl");
	die;
}

$auto_query_args = array('find', 'sort_mode', 'offset', 'theme', 'theme-option', 'section');
$smarty->assign('a_section', isset($_REQUEST['section']) ? $_REQUEST['section'] : '');

$tcontrollib->setup_theme_menus();

if (isset($_REQUEST['assign'])) {
	check_ticket('tc-sections');
	$tcontrollib->tc_assign_section($_REQUEST['section'], $_REQUEST['theme'], isset($_REQUEST['theme-option']) ? $_REQUEST['theme-option'] : '');
}
if (isset($_REQUEST["delete"])) {
	check_ticket('tc-sections');
	foreach(array_keys($_REQUEST["sec"]) as $sec) {
		$tcontrollib->tc_remove_section($sec);
	}
}
$channels = $tcontrollib->tc_list_sections(0, -1, 'section_asc', '');
$smarty->assign_by_ref('channels', $channels["data"]);
$smarty->assign('sections', $sections_enabled);
ask_ticket('tc-sections');
// Display the template
$smarty->assign('mid', 'tiki-theme_control_sections.tpl');
$smarty->display("tiki.tpl");
