tiki-usermenu.php 2.48 KB
Newer Older
lrargerich's avatar
lrargerich committed
1
<?php
2
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
changi67's avatar
changi67 committed
3
// 
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.
changi67's avatar
changi67 committed
6 7
// $Id$

mose's avatar
mose committed
8
$section = 'mytiki';
9 10
require_once ('tiki-setup.php');
include_once ('lib/usermenu/usermenulib.php');
11 12 13 14 15

$access->check_feature('feature_usermenu');
$access->check_user($user);
$access->check_permission('tiki_p_usermenu');

changi67's avatar
changi67 committed
16
if (!isset($_REQUEST["menuId"])) $_REQUEST["menuId"] = 0;
17
if (isset($_REQUEST["delete"]) && isset($_REQUEST["menu"])) {
18
	check_ticket('user-menu');
19
	foreach (array_keys($_REQUEST["menu"]) as $men) {
20 21
		$usermenulib->remove_usermenu($user, $men);
	}
changi67's avatar
changi67 committed
22
	if (isset($_SESSION['usermenu'])) unset($_SESSION['usermenu']);
lrargerich's avatar
lrargerich committed
23
}
24
if (isset($_REQUEST['addbk'])) {
25
	check_ticket('user-menu');
26
	$usermenulib->add_bk($user);
changi67's avatar
changi67 committed
27
	if (isset($_SESSION['usermenu'])) unset($_SESSION['usermenu']);
lrargerich's avatar
lrargerich committed
28
}
29 30
if ($_REQUEST["menuId"]) {
	$info = $usermenulib->get_usermenu($user, $_REQUEST["menuId"]);
lrargerich's avatar
lrargerich committed
31
} else {
32 33 34
	$info = array();
	$info['name'] = '';
	$info['url'] = isset($_REQUEST['url']) ? $_REQUEST['url'] : '';
35
	$info['mode'] = 'w';
36
	$info['position'] = $usermenulib->get_max_position($user) + 1;
lrargerich's avatar
lrargerich committed
37
}
38
if (isset($_REQUEST['save'])) {
39
	check_ticket('user-menu');
changi67's avatar
changi67 committed
40
	$usermenulib->replace_usermenu($user, $_REQUEST["menuId"], $_REQUEST["name"], $_REQUEST["url"], $_REQUEST['position'], $_REQUEST['mode']);
41 42 43 44 45
	$info = array();
	$info['name'] = '';
	$info['url'] = '';
	$info['position'] = 1;
	$_REQUEST["menuId"] = 0;
changi67's avatar
changi67 committed
46
	unset($_SESSION['usermenu']);
lrargerich's avatar
lrargerich committed
47
}
48 49 50 51
$smarty->assign('menuId', $_REQUEST["menuId"]);
$smarty->assign('info', $info);
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'position_asc';
lrargerich's avatar
lrargerich committed
52
} else {
53 54 55 56
	$sort_mode = $_REQUEST["sort_mode"];
}
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
lrargerich's avatar
lrargerich committed
57
} else {
58
	$offset = $_REQUEST["offset"];
lrargerich's avatar
lrargerich committed
59
}
60 61 62
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
lrargerich's avatar
lrargerich committed
63
} else {
64
	$find = '';
lrargerich's avatar
lrargerich committed
65
}
66 67 68 69
$smarty->assign('find', $find);
$smarty->assign_by_ref('sort_mode', $sort_mode);
if (isset($_SESSION['thedate'])) {
	$pdate = $_SESSION['thedate'];
lrargerich's avatar
lrargerich committed
70
} else {
mose's avatar
mose committed
71
	$pdate = $tikilib->now;
lrargerich's avatar
lrargerich committed
72
}
73
$channels = $usermenulib->list_usermenus($user, $offset, $maxRecords, $sort_mode, $find);
74
$smarty->assign_by_ref('cant_pages', $channels["cant"]);
75 76
$smarty->assign_by_ref('channels', $channels["data"]);
include_once ('tiki-mytiki_shared.php');
77
ask_ticket('user-menu');
78
$smarty->assign('mid', 'tiki-usermenu.tpl');
79
$smarty->display("tiki.tpl");