1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
//------------------------------------------------------------------------------ |
4
|
|
|
// |
5
|
|
|
// eTraxis - Records tracking web-based system |
6
|
|
|
// Copyright (C) 2010-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/accounts.php'); |
33
|
|
|
require_once('../dbo/fields.php'); |
34
|
|
|
require_once('../dbo/values.php'); |
35
|
|
|
require_once('../dbo/records.php'); |
36
|
|
|
require_once('../dbo/views.php'); |
37
|
|
|
/**#@-*/ |
38
|
|
|
|
39
|
|
|
init_page(LOAD_TAB, GUEST_IS_ALLOWED); |
|
|
|
|
40
|
|
|
|
41
|
|
|
// check that requested record exists |
42
|
|
|
|
43
|
|
|
$id = ustr2int(try_request('id')); |
44
|
|
|
$record = record_find($id); |
45
|
|
|
|
46
|
|
|
if (!$record) |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
debug_write_log(DEBUG_NOTICE, 'Record cannot be found.'); |
49
|
|
|
exit; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
// get current user's permissions and verify them |
53
|
|
|
|
54
|
|
|
$permissions = record_get_permissions($record['template_id'], $record['creator_id'], $record['responsible_id']); |
55
|
|
|
|
56
|
|
|
if (!can_record_be_displayed($permissions)) |
57
|
|
|
{ |
58
|
|
|
debug_write_log(DEBUG_NOTICE, 'Record cannot be displayed.'); |
59
|
|
|
exit; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
// mark the record as read |
63
|
|
|
|
64
|
|
|
record_read($id); |
65
|
|
|
|
66
|
|
|
// generate general information |
67
|
|
|
|
68
|
|
|
$xml = '<group title="' . get_html_resource(RES_GENERAL_INFO_ID) . '">' |
69
|
|
|
. '<text label="' . get_html_resource(RES_SUBJECT_ID) . '">' . update_references($record['subject'], BBCODE_MINIMUM) . '</text>' |
70
|
|
|
. '<text label="' . get_html_resource(RES_STATE_ID) . '">' . ustr2html($record['state_name']) . '</text>' |
71
|
|
|
. '<text label="' . get_html_resource(RES_RESPONSIBLE_ID) . '">' . (is_null($record['username']) ? get_html_resource(RES_NONE_ID) : ustr2html(sprintf('%s (%s)', $record['fullname'], account_get_username($record['username'])))) . '</text>' |
72
|
|
|
. '<text label="' . get_html_resource(RES_AUTHOR_ID) . '">' . ustr2html(sprintf('%s (%s)', $record['author_fullname'], account_get_username($record['author_username']))) . '</text>' |
73
|
|
|
. '<text label="' . get_html_resource(RES_AGE_ID) . '">' . get_record_last_event($record) . '/' . get_record_age($record) . '</text>' |
74
|
|
|
. '<text label="' . get_html_resource(RES_PROJECT_ID) . '">' . ustr2html($record['project_name']) . '</text>' |
75
|
|
|
. '<text label="' . get_html_resource(RES_TEMPLATE_ID) . '">' . ustr2html($record['template_name']) . '</text>'; |
76
|
|
|
|
77
|
|
View Code Duplication |
if (is_record_postponed($record)) |
78
|
|
|
{ |
79
|
|
|
$xml .= '<text label="' . get_html_resource(RES_POSTPONED_ID) . '">' . get_date($record['postpone_time']) . '</text>'; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
$xml .= '</group>'; |
83
|
|
|
|
84
|
|
|
// go through the list of all states and their fields |
85
|
|
|
|
86
|
|
|
$states = dal_query('records/elist.sql', $id); |
87
|
|
|
|
88
|
|
|
while (($state = $states->fetch())) |
89
|
|
|
{ |
90
|
|
|
$fields = dal_query('records/flist.sql', |
91
|
|
|
$id, |
92
|
|
|
$state['state_id'], |
93
|
|
|
$record['creator_id'], |
94
|
|
|
is_null($record['responsible_id']) ? 0 : $record['responsible_id'], |
95
|
|
|
$_SESSION[VAR_USERID], |
96
|
|
|
FIELD_ALLOW_TO_READ); |
97
|
|
|
|
98
|
|
|
if ($fields->rows != 0) |
|
|
|
|
99
|
|
|
{ |
100
|
|
|
$xml .= '<group title="' . ustr2html($state['state_name']) . '">'; |
101
|
|
|
|
102
|
|
View Code Duplication |
while (($field = $fields->fetch())) |
103
|
|
|
{ |
104
|
|
|
$value = value_find($field['field_type'], $field['value_id']); |
105
|
|
|
|
106
|
|
|
if ($field['field_type'] == FIELD_TYPE_CHECKBOX) |
107
|
|
|
{ |
108
|
|
|
$value = get_html_resource($value ? RES_YES_ID : RES_NO_ID); |
109
|
|
|
} |
110
|
|
|
elseif ($field['field_type'] == FIELD_TYPE_LIST) |
111
|
|
|
{ |
112
|
|
|
$value = (is_null($value) ? NULL : value_find_listvalue($field['field_id'], $value)); |
113
|
|
|
} |
114
|
|
|
elseif ($field['field_type'] == FIELD_TYPE_RECORD) |
115
|
|
|
{ |
116
|
|
|
$value = (is_null($value) ? NULL : 'rec#' . $value); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
$xml .= '<text label="' . ustr2html($field['field_name']) . '">' |
120
|
|
|
. (is_null($value) ? get_html_resource(RES_NONE_ID) : update_references($value, BBCODE_ALL, $field['regex_search'], $field['regex_replace'])) |
121
|
|
|
. '</text>'; |
122
|
|
|
|
123
|
|
|
if ($field['add_separator']) |
124
|
|
|
{ |
125
|
|
|
$xml .= '<hr/>'; |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
$xml .= '</group>'; |
130
|
|
|
} |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
echo(xml2html($xml)); |
134
|
|
|
|
135
|
|
|
?> |
|
|
|
|
136
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: