tiki-admin_menu_options.php 5.8 KB
Newer Older
lrargerich's avatar
lrargerich committed
1
<?php
2 3
// (c) Copyright 2002-2009 by authors of the Tiki Wiki/CMS/Groupware Project
// 
4 5
// 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.
6
// $Id: /cvsroot/tikiwiki/tiki/tiki-admin_menu_options.php,v 1.31.2.3 2007-11-27 14:53:11 sylvieg Exp $
7 8
require_once ('tiki-setup.php');
include_once ('lib/menubuilder/menulib.php');
9
if ($tiki_p_admin != 'y' && $tiki_p_edit_menu_option != 'y') {
10 11 12 13
	$smarty->assign('errortype', 401);
	$smarty->assign('msg', tra("You do not have permission to use this feature"));
	$smarty->display("error.tpl");
	die;
lrargerich's avatar
lrargerich committed
14
}
15
if (!isset($_REQUEST["menuId"])) {
16 17 18
	$smarty->assign('msg', tra("No menu indicated"));
	$smarty->display("error.tpl");
	die;
lrargerich's avatar
lrargerich committed
19
}
changi67's avatar
changi67 committed
20
$auto_query_args = array(
21 22 23 24 25
	'offset',
	'find',
	'sort_mode',
	'menuId',
	'maxRecords'
changi67's avatar
changi67 committed
26
);
27
if (!empty($_REQUEST['import']) && !empty($_FILES['csvfile']['tmp_name'])) {
28
	$menulib->import_menu_options();
29 30
}
if (!empty($_REQUEST['export'])) {
31
	$menulib->export_menu_options();
32
}
33
$maxPos = $menulib->get_max_option($_REQUEST["menuId"]);
34
$smarty->assign('menuId', $_REQUEST["menuId"]);
35 36
$editable_menu_info = $tikilib->get_menu($_REQUEST["menuId"]);
$smarty->assign('editable_menu_info', $editable_menu_info);
37
if (!isset($_REQUEST["optionId"])) {
38
	$_REQUEST["optionId"] = 0;
lrargerich's avatar
lrargerich committed
39
}
40 41
$smarty->assign('optionId', $_REQUEST["optionId"]);
if ($_REQUEST["optionId"]) {
42
	$info = $menulib->get_menu_option($_REQUEST["optionId"]);
lrargerich's avatar
lrargerich committed
43
} else {
44 45 46 47 48 49 50 51 52 53
	$info = array();
	$info["name"] = '';
	$info["url"] = '';
	$info["section"] = '';
	$info["perm"] = '';
	$info["groupname"] = '';
	$info["userlevel"] = '';
	$info["type"] = 'o';
	$info["icon"] = '';
	$info["position"] = $maxPos + 2;
lrargerich's avatar
lrargerich committed
54
}
55 56
$smarty->assign('name', $info["name"]);
$smarty->assign('url', $info["url"]);
57 58
$smarty->assign('section', $info["section"]);
$smarty->assign('perm', $info["perm"]);
59
$smarty->assign('type', $info["type"]);
60
$smarty->assign('icon', $info["icon"]);
61
$smarty->assign('position', $info["position"]);
62 63
$smarty->assign('groupname', $info["groupname"]);
$smarty->assign('userlevel', $info["userlevel"]);
64
if (isset($_REQUEST["remove"])) {
65 66 67 68 69 70 71 72 73 74 75
	check_ticket('admin-menu-options');
	$area = 'delmenuoption';
	if ($prefs['feature_ticketlib2'] != 'y' or (isset($_POST['daconfirm']) and isset($_SESSION["ticket_$area"]))) {
		key_check($area);
		$menulib->remove_menu_option($_REQUEST["remove"]);
		$maxPos = $menulib->get_max_option($_REQUEST["menuId"]);
		$smarty->assign('position', $maxPos + 1);
		$smarty->clear_cache(null, "menu" . $_REQUEST["menuId"]);
	} else {
		key_get($area);
	}
lrargerich's avatar
lrargerich committed
76
}
77
if (isset($_REQUEST["up"])) {
78 79
	check_ticket('admin-menu-options');
	$res = $menulib->prev_pos($_REQUEST["up"]);
80 81
}
if (isset($_REQUEST["down"])) {
82 83 84
	check_ticket('admin-menu-options');
	$area = 'downmenuoption';
	$res = $menulib->next_pos($_REQUEST["down"]);
85
}
86
if (isset($_REQUEST['delsel_x']) && isset($_REQUEST['checked'])) {
87 88 89 90 91 92 93
	check_ticket('admin-menu-options');
	foreach($_REQUEST['checked'] as $id) {
		$menulib->remove_menu_option($id);
	}
	$maxPos = $menulib->get_max_option($_REQUEST['menuId']);
	$smarty->assign('position', $maxPos + 1);
	$smarty->clear_cache(null, 'menu' . $_REQUEST['menuId']);
94
}
95
if (isset($_REQUEST["save"])) {
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
	if (!isset($_REQUEST['groupname'])) $_REQUEST['groupname'] = '';
	elseif (is_array($_REQUEST['groupname'])) $_REQUEST['groupname'] = implode(',', $_REQUEST['groupname']);
	if (!isset($_REQUEST['level'])) $_REQUEST['level'] = 0;
	include_once ('lib/modules/modlib.php');
	check_ticket('admin-menu-options');
	$menulib->replace_menu_option($_REQUEST["menuId"], $_REQUEST["optionId"], $_REQUEST["name"], $_REQUEST["url"], $_REQUEST["type"], $_REQUEST["position"], $_REQUEST["section"], $_REQUEST["perm"], $_REQUEST["groupname"], $_REQUEST['level'], $_REQUEST['icon']);
	$modlib->clear_cache();
	$smarty->clear_cache(null, "menu" . $_REQUEST["menuId"]);
	$smarty->assign('position', $_REQUEST["position"] + 1);
	$smarty->assign('name', '');
	$smarty->assign('optionId', 0);
	$smarty->assign('url', '');
	$smarty->assign('section', '');
	$smarty->assign('perm', '');
	$smarty->assign('groupname', '');
	$smarty->assign('userlevel', 0);
	$smarty->assign('type', 'o');
	$smarty->assign('icon', '');
lrargerich's avatar
lrargerich committed
114
}
115
if (!isset($_REQUEST["sort_mode"])) {
116
	$sort_mode = 'position_asc';
lrargerich's avatar
lrargerich committed
117
} else {
118
	$sort_mode = $_REQUEST["sort_mode"];
119 120
}
if (!isset($_REQUEST["offset"])) {
121
	$offset = 0;
lrargerich's avatar
lrargerich committed
122
} else {
123
	$offset = $_REQUEST["offset"];
lrargerich's avatar
lrargerich committed
124
}
125 126
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
127
	$find = $_REQUEST["find"];
lrargerich's avatar
lrargerich committed
128
} else {
129
	$find = '';
lrargerich's avatar
lrargerich committed
130
}
131
$smarty->assign('find', $find);
sylvieg's avatar
sylvieg committed
132
if (isset($_REQUEST['maxRecords'])) {
133
	$maxRecords = $_REQUEST['maxRecords'];
134
} else {
135
	$maxRecords = $prefs['maxRecords'];
136
}
137
$smarty->assign_by_ref('maxRecords', $maxRecords);
138
$smarty->assign_by_ref('sort_mode', $sort_mode);
139
$allchannels = $menulib->list_menu_options($_REQUEST["menuId"], 0, -1, $sort_mode, $find);
140
$allchannels = $menulib->sort_menu_options($allchannels);
141
$channels = $menulib->list_menu_options($_REQUEST["menuId"], $offset, $maxRecords, $sort_mode, $find, true);
142
$channels = $menulib->describe_menu_types($channels);
143
$smarty->assign_by_ref('cant_pages', $channels["cant"]);
144
$smarty->assign_by_ref('channels', $channels["data"]);
145
$smarty->assign_by_ref('allchannels', $allchannels["data"]);
changi67's avatar
changi67 committed
146
if (isset($info['groupname']) && !is_array($info['groupname'])) $info['groupname'] = explode(',', $info['groupname']);
147
$all_groups = $userlib->list_all_groups();
changi67's avatar
changi67 committed
148
if (is_array($all_groups)) foreach($all_groups as $g) $option_groups[$g] = (is_array($info['groupname']) && in_array($g, $info['groupname'])) ? 'selected="selected"' : '';
149
$smarty->assign_by_ref('option_groups', $option_groups);
150
ask_ticket('admin-menu-options');
151 152
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
lrargerich's avatar
lrargerich committed
153
// Display the template
154
$smarty->assign('mid', 'tiki-admin_menu_options.tpl');
155
$smarty->display("tiki.tpl");