1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
//------------------------------------------------------------------------------ |
4
|
|
|
// |
5
|
|
|
// eTraxis - Records tracking web-based system |
6
|
|
|
// Copyright (C) 2007-2011 Artem Rodygin |
7
|
|
|
// |
8
|
|
|
// This program is free software: you can redistribute it and/or modify |
9
|
|
|
// it under the terms of the GNU General Public License as published by |
10
|
|
|
// the Free Software Foundation, either version 3 of the License, or |
11
|
|
|
// (at your option) any later version. |
12
|
|
|
// |
13
|
|
|
// This program is distributed in the hope that it will be useful, |
14
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
// GNU General Public License for more details. |
17
|
|
|
// |
18
|
|
|
// You should have received a copy of the GNU General Public License |
19
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
// |
21
|
|
|
//------------------------------------------------------------------------------ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @package eTraxis |
25
|
|
|
* @ignore |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
/**#@+ |
29
|
|
|
* Dependency. |
30
|
|
|
*/ |
31
|
|
|
require_once('../engine/engine.php'); |
32
|
|
|
require_once('../dbo/filters.php'); |
33
|
|
|
require_once('../dbo/views.php'); |
34
|
|
|
/**#@-*/ |
35
|
|
|
|
36
|
|
|
init_page(LOAD_TAB); |
37
|
|
|
|
38
|
|
|
// check that requested view exists |
39
|
|
|
|
40
|
|
|
$id = ustr2int(try_request('id')); |
41
|
|
|
$view = view_find($id); |
42
|
|
|
|
43
|
|
|
if (!$view) |
|
|
|
|
44
|
|
|
{ |
45
|
|
|
debug_write_log(DEBUG_NOTICE, 'View cannot be found.'); |
46
|
|
|
exit; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
// add/remove selected filters |
50
|
|
|
|
51
|
|
View Code Duplication |
if (try_request('submitted') == 'fdisabledform') |
52
|
|
|
{ |
53
|
|
|
debug_write_log(DEBUG_NOTICE, 'Data are submitted (adding new filters).'); |
54
|
|
|
|
55
|
|
|
if (isset($_REQUEST['filters'])) |
56
|
|
|
{ |
57
|
|
|
foreach ($_REQUEST['filters'] as $filter) |
58
|
|
|
{ |
59
|
|
|
dal_query('views/fcreate.sql', $id, $filter); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
else |
63
|
|
|
{ |
64
|
|
|
debug_write_log(DEBUG_NOTICE, 'No filters are selected.'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
exit; |
68
|
|
|
} |
69
|
|
|
elseif (try_request('submitted') == 'fenabledform') |
70
|
|
|
{ |
71
|
|
|
debug_write_log(DEBUG_NOTICE, 'Data are submitted (removing selected filters).'); |
72
|
|
|
|
73
|
|
|
if (isset($_REQUEST['filters'])) |
74
|
|
|
{ |
75
|
|
|
foreach ($_REQUEST['filters'] as $filter) |
76
|
|
|
{ |
77
|
|
|
dal_query('views/fdelete.sql', $id, $filter); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
else |
81
|
|
|
{ |
82
|
|
|
debug_write_log(DEBUG_NOTICE, 'No filters are selected.'); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
exit; |
86
|
|
|
} |
87
|
|
|
else |
88
|
|
|
{ |
89
|
|
|
debug_write_log(DEBUG_NOTICE, 'Data are being requested.'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
// generate left side |
93
|
|
|
|
94
|
|
|
$xml = '<dual>' |
95
|
|
|
. '<dualleft>' |
96
|
|
|
. '<form name="fdisabledform" action="filters.php?id=' . $id . '" success="reloadTab">' |
97
|
|
|
. '<group title="' . get_html_resource(RES_DISABLED2_ID) . '">' |
98
|
|
|
. '<control name="filters[]">' |
99
|
|
|
. '<listbox size="10">'; |
100
|
|
|
|
101
|
|
|
$filters = view_filters_list($id); |
102
|
|
|
|
103
|
|
|
$rs = dal_query('filters/list.sql', $_SESSION[VAR_USERID], 'filter_name'); |
104
|
|
|
|
105
|
|
View Code Duplication |
while (($row = $rs->fetch())) |
106
|
|
|
{ |
107
|
|
|
if (!in_array($row['filter_id'], $filters)) |
108
|
|
|
{ |
109
|
|
|
$xml .= '<listitem value="' . $row['filter_id'] . '">' |
110
|
|
|
. ustr2html(is_null($row['fullname']) ? sprintf('%s', $row['filter_name']) |
111
|
|
|
: sprintf('%s (%s)', $row['filter_name'], $row['fullname'])) |
112
|
|
|
. '</listitem>'; |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
$xml .= '</listbox>' |
117
|
|
|
. '</control>' |
118
|
|
|
. '</group>' |
119
|
|
|
. '</form>' |
120
|
|
|
. '</dualleft>'; |
121
|
|
|
|
122
|
|
|
// generate right side |
123
|
|
|
|
124
|
|
|
$xml .= '<dualright>' |
125
|
|
|
. '<form name="fenabledform" action="filters.php?id=' . $id . '" success="reloadTab">' |
126
|
|
|
. '<group title="' . get_html_resource(RES_ENABLED2_ID) . '">' |
127
|
|
|
. '<control name="filters[]">' |
128
|
|
|
. '<listbox size="10">'; |
129
|
|
|
|
130
|
|
|
$rs->seek(); |
131
|
|
|
|
132
|
|
View Code Duplication |
while (($row = $rs->fetch())) |
133
|
|
|
{ |
134
|
|
|
if (in_array($row['filter_id'], $filters)) |
135
|
|
|
{ |
136
|
|
|
$xml .= '<listitem value="' . $row['filter_id'] . '">' |
137
|
|
|
. ustr2html(is_null($row['fullname']) ? sprintf('%s', $row['filter_name']) |
138
|
|
|
: sprintf('%s (%s)', $row['filter_name'], $row['fullname'])) |
139
|
|
|
. '</listitem>'; |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
$xml .= '</listbox>' |
144
|
|
|
. '</control>' |
145
|
|
|
. '</group>' |
146
|
|
|
. '</form>' |
147
|
|
|
. '</dualright>'; |
148
|
|
|
|
149
|
|
|
// generate buttons |
150
|
|
|
|
151
|
|
|
$xml .= '<button action="$(\'#fdisabledform\').submit()">%gt;%gt;</button>' |
152
|
|
|
. '<button action="$(\'#fenabledform\').submit()">%lt;%lt;</button>' |
153
|
|
|
. '</dual>'; |
154
|
|
|
|
155
|
|
|
echo(xml2html($xml)); |
156
|
|
|
|
157
|
|
|
?> |
158
|
|
|
|
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.