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

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