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/records.php'); |
33
|
|
|
/**#@-*/ |
34
|
|
|
|
35
|
|
|
init_page(LOAD_TAB, GUEST_IS_ALLOWED); |
36
|
|
|
|
37
|
|
|
// check that requested record exists |
38
|
|
|
|
39
|
|
|
$id = ustr2int(try_request('id')); |
40
|
|
|
$record = record_find($id); |
41
|
|
|
|
42
|
|
|
if (!$record) |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
debug_write_log(DEBUG_NOTICE, 'Record cannot be found.'); |
45
|
|
|
exit; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
// get current user's permissions and verify them |
49
|
|
|
|
50
|
|
|
$permissions = record_get_permissions($record['template_id'], $record['creator_id'], $record['responsible_id']); |
51
|
|
|
|
52
|
|
|
if (!can_record_be_displayed($permissions)) |
53
|
|
|
{ |
54
|
|
|
debug_write_log(DEBUG_NOTICE, 'Record cannot be displayed.'); |
55
|
|
|
exit; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
// generate list of records |
59
|
|
|
|
60
|
|
|
$xml = NULL; |
61
|
|
|
|
62
|
|
|
$list = parents_list($id); |
63
|
|
|
|
64
|
|
|
if ($list->rows != 0) |
65
|
|
|
{ |
66
|
|
|
$columns = array |
67
|
|
|
( |
68
|
|
|
RES_ID_ID, |
69
|
|
|
RES_STATE_ID, |
70
|
|
|
RES_SUBJECT_ID, |
71
|
|
|
RES_RESPONSIBLE_ID, |
72
|
|
|
); |
73
|
|
|
|
74
|
|
|
$xml .= '<list>' |
75
|
|
|
. '<hrow>'; |
76
|
|
|
|
77
|
|
|
foreach ($columns as $column) |
78
|
|
|
{ |
79
|
|
|
$xml .= "<hcell>" . get_html_resource($column) . '</hcell>'; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
$xml .= '</hrow>'; |
83
|
|
|
|
84
|
|
View Code Duplication |
while (($row = $list->fetch())) |
85
|
|
|
{ |
86
|
|
|
if (is_record_closed($row)) |
87
|
|
|
{ |
88
|
|
|
$color = 'grey'; |
89
|
|
|
} |
90
|
|
|
elseif ($row['is_dependency']) |
91
|
|
|
{ |
92
|
|
|
$color = 'red'; |
93
|
|
|
} |
94
|
|
|
else |
95
|
|
|
{ |
96
|
|
|
$color = NULL; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
$xml .= "<row url=\"view.php?id={$row['record_id']}\" color=\"{$color}\">" |
100
|
|
|
. '<cell align="left" nowrap="true">' . record_id($row['record_id'], $row['template_prefix']) . '</cell>' |
101
|
|
|
. '<cell align="left">' . ustr2html($row['state_abbr']) . '</cell>' |
102
|
|
|
. '<cell align="left">' . update_references($row['subject'], BBCODE_SEARCH_ONLY) . '</cell>' |
103
|
|
|
. '<cell align="left">' . (is_null($row['fullname']) ? get_html_resource(RES_NONE_ID) : ustr2html($row['fullname'])) . '</cell>' |
104
|
|
|
. '</row>'; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
$xml .= '</list>'; |
108
|
|
|
} |
109
|
|
|
else |
110
|
|
|
{ |
111
|
|
|
$xml .= '<text>' . get_html_resource(RES_NONE2_ID) . '</text>'; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
echo(xml2html($xml)); |
115
|
|
|
|
116
|
|
|
?> |
|
|
|
|
117
|
|
|
|
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.