|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
//------------------------------------------------------------------------------ |
|
4
|
|
|
// |
|
5
|
|
|
// eTraxis - Records tracking web-based system |
|
6
|
|
|
// Copyright (C) 2010 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/views.php'); |
|
33
|
|
|
/**#@-*/ |
|
34
|
|
|
|
|
35
|
|
|
global $column_type_res; |
|
36
|
|
|
|
|
37
|
|
|
init_page(LOAD_TAB); |
|
38
|
|
|
|
|
39
|
|
|
$error = NO_ERROR; |
|
40
|
|
|
|
|
41
|
|
|
// check that requested column exists |
|
42
|
|
|
|
|
43
|
|
|
$id = ustr2int(try_request('id')); |
|
44
|
|
|
$column = column_find($id); |
|
45
|
|
|
|
|
46
|
|
|
if (!$column) |
|
|
|
|
|
|
47
|
|
|
{ |
|
48
|
|
|
debug_write_log(DEBUG_NOTICE, 'Column cannot be found.'); |
|
49
|
|
|
exit; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
// move the column |
|
53
|
|
|
|
|
54
|
|
|
$offset = ustr2int(try_request('offset'), -1, +1); |
|
55
|
|
|
$count = columns_count($column['view_id']); |
|
56
|
|
|
|
|
57
|
|
|
if ($column['column_order'] + $offset >= 1 && |
|
58
|
|
|
$column['column_order'] + $offset <= $count) |
|
59
|
|
|
{ |
|
60
|
|
|
dal_query('columns/setorder.sql', $column['view_id'], $column['column_order'], 0); |
|
61
|
|
|
dal_query('columns/setorder.sql', $column['view_id'], $column['column_order'] + $offset, $column['column_order']); |
|
62
|
|
|
dal_query('columns/setorder.sql', $column['view_id'], 0, $column['column_order'] + $offset); |
|
63
|
|
|
|
|
64
|
|
|
$xml = '<container>'; |
|
65
|
|
|
|
|
66
|
|
|
$list = columns_list($column['view_id']); |
|
67
|
|
|
|
|
68
|
|
|
foreach ($list as $item) |
|
69
|
|
|
{ |
|
70
|
|
View Code Duplication |
if ($item['column_type'] >= COLUMN_TYPE_MINIMUM && |
|
|
|
|
|
|
71
|
|
|
$item['column_type'] <= COLUMN_TYPE_MAXIMUM) |
|
72
|
|
|
{ |
|
73
|
|
|
$text = get_html_resource($column_type_res[$item['column_type']]); |
|
74
|
|
|
} |
|
75
|
|
|
else |
|
76
|
|
|
{ |
|
77
|
|
|
$text = ustr2html(sprintf('%s: %s (%s)', |
|
78
|
|
|
$item['state_name'], |
|
79
|
|
|
$item['field_name'], |
|
80
|
|
|
get_html_resource($column_type_res[$item['column_type']]))); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
$xml .= ($item['column_id'] == $id |
|
84
|
|
|
? '<listitem value="' . $item['column_id'] . '" selected="true">' |
|
85
|
|
|
: '<listitem value="' . $item['column_id'] . '">') |
|
86
|
|
|
. $text |
|
87
|
|
|
. '</listitem>'; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
$xml .= '</container>'; |
|
91
|
|
|
|
|
92
|
|
|
echo(xml2html($xml)); |
|
93
|
|
|
} |
|
94
|
|
|
else |
|
95
|
|
|
{ |
|
96
|
|
|
debug_write_log(DEBUG_NOTICE, 'Column cannot be moved - will be out of range.'); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
?> |
|
|
|
|
|
|
100
|
|
|
|
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.