-
Notifications
You must be signed in to change notification settings - Fork 1
/
tiki-admin_chart_items.php
executable file
·158 lines (126 loc) · 3.7 KB
/
tiki-admin_chart_items.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
// $Id: /cvsroot/tikiwiki/tiki/tiki-admin_chart_items.php,v 1.19 2007-10-14 15:17:16 nyloth Exp $
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// 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.
require_once ('tiki-setup.php');
include_once ('lib/charts/chartlib.php');
if ($prefs['feature_charts'] != 'y') {
$smarty->assign('msg', tra("This feature is disabled").": feature_charts");
$smarty->display("error.tpl");
die;
}
if ($tiki_p_admin_charts != 'y' and $tiki_p_suggest_chart_item != 'y') {
$smarty->assign('errortype', 401);
$smarty->assign('msg', tra("Permission denied"));
$smarty->display("error.tpl");
die;
}
if (!isset($_REQUEST['chartId'])) {
$smarty->assign('msg', tra("No chart indicated"));
$smarty->display("error.tpl");
die;
}
if (!isset($_REQUEST['itemId']))
$_REQUEST['itemId'] = 0;
if ($_REQUEST["itemId"]) {
$info = $chartlib->get_chart_item($_REQUEST["itemId"]);
} else {
$info = array(
'title' => '',
'description' => '',
'created' => 0,
'URL' => '',
'votes' => 0,
'points' => 0,
'average' => 0
);
}
$smarty->assign_by_ref('item_info', $info);
$smarty->assign('chartId', $_REQUEST['chartId']);
$smarty->assign('itemId', $_REQUEST['itemId']);
$smarty->assign('info', $info);
if (isset($_REQUEST["delete"])) {
check_ticket('admin-chart-items');
foreach (array_keys($_REQUEST["item"])as $item) {
$chartlib->remove_chart_item($item);
}
}
if (isset($_REQUEST['save'])) {
check_ticket('admin-chart-items');
$vars = array();
$vars['chartId'] = $_REQUEST['chartId'];
$_REQUEST['created'] = $tikilib->now;
foreach (array_keys($info)as $key) {
if (isset($_REQUEST[$key])) {
$vars[$key] = $_REQUEST[$key];
}
}
$itemId = $chartlib->replace_chart_item($_REQUEST['itemId'], $vars);
$info = array(
'title' => '',
'description' => '',
'created' => 0,
'URL' => '',
'votes' => 0,
'points' => 0,
'average' => 0
);
$_REQUEST['itemId'] = 0;
$smarty->assign('itemId', 0);
$smarty->assign('info', $info);
}
// the $where is unused for now i think, but beware of using it in the template
// it's a security problem in list_chart_items().
$where = 'chartId = '.$_REQUEST['chartId'];
$wherekey = 'chartId';
$whereval = $_REQUEST['chartId'];
if (!isset($_REQUEST["sort_mode"])) {
$sort_mode = 'created_desc';
} else {
$sort_mode = $_REQUEST["sort_mode"];
}
if (!isset($_REQUEST["offset"])) {
$offset = 0;
} else {
$offset = $_REQUEST["offset"];
}
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
$find = $_REQUEST["find"];
} else {
$find = '';
}
$smarty->assign('find', $find);
$smarty->assign('where', $where);
$smarty->assign_by_ref('sort_mode', $sort_mode);
$items = $chartlib->list_chart_items($offset, $maxRecords, $sort_mode, $find, $wherekey,$whereval);
$smarty->assign('cant', $items['cant']);
$cant_pages = ceil($items["cant"] / $maxRecords);
$smarty->assign_by_ref('cant_pages', $cant_pages);
$smarty->assign('actual_page', 1 + ($offset / $maxRecords));
if ($items["cant"] > ($offset + $maxRecords)) {
$smarty->assign('next_offset', $offset + $maxRecords);
} else {
$smarty->assign('next_offset', -1);
}
if ($offset > 0) {
$smarty->assign('prev_offset', $offset - $maxRecords);
} else {
$smarty->assign('prev_offset', -1);
}
$smarty->assign_by_ref('items', $items["data"]);
$sameurl_elements = array(
'offset',
'sort_mode',
'where',
'find',
'chartId',
'itemId'
);
ask_ticket('admin-chart-items');
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
$smarty->assign('mid', 'tiki-admin_chart_items.tpl');
$smarty->display("tiki.tpl");
?>