1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
//------------------------------------------------------------------------------ |
4
|
|
|
// |
5
|
|
|
// eTraxis - Records tracking web-based system |
6
|
|
|
// Copyright (C) 2005-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/accounts.php'); |
33
|
|
|
require_once('../dbo/events.php'); |
34
|
|
|
require_once('../dbo/records.php'); |
35
|
|
|
/**#@-*/ |
36
|
|
|
|
37
|
|
|
init_page(LOAD_TAB, GUEST_IS_ALLOWED); |
|
|
|
|
38
|
|
|
|
39
|
|
|
// check that requested record exists |
40
|
|
|
|
41
|
|
|
$id = ustr2int(try_request('id')); |
42
|
|
|
$record = record_find($id); |
43
|
|
|
|
44
|
|
|
if (!$record) |
45
|
|
|
{ |
46
|
|
|
debug_write_log(DEBUG_NOTICE, 'Record cannot be found.'); |
47
|
|
|
exit; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
// get current user's permissions and verify them |
51
|
|
|
|
52
|
|
|
$permissions = record_get_permissions($record['template_id'], $record['creator_id'], $record['responsible_id']); |
53
|
|
|
|
54
|
|
|
if (!can_record_be_displayed($permissions)) |
55
|
|
|
{ |
56
|
|
|
debug_write_log(DEBUG_NOTICE, 'Record cannot be displayed.'); |
57
|
|
|
exit; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
// mark the record as read |
61
|
|
|
|
62
|
|
|
record_read($id); |
63
|
|
|
|
64
|
|
|
// get the history |
65
|
|
|
|
66
|
|
|
$sort = $page = NULL; |
67
|
|
|
$list = history_list($id, $permissions, $sort, $page); |
68
|
|
|
|
69
|
|
|
if ($list->rows == 0) |
|
|
|
|
70
|
|
|
{ |
71
|
|
|
debug_write_log(DEBUG_WARNING, 'History is empty.'); |
72
|
|
|
exit; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
// generate list header |
76
|
|
|
|
77
|
|
|
$columns = array |
78
|
|
|
( |
79
|
|
|
RES_TIMESTAMP_ID, |
80
|
|
|
RES_ORIGINATOR_ID, |
81
|
|
|
RES_DESCRIPTION_ID, |
82
|
|
|
); |
83
|
|
|
|
84
|
|
|
$rec_from = $rec_to = 0; |
85
|
|
|
|
86
|
|
|
$bookmarks = gen_xml_bookmarks($page, $list->rows, $rec_from, $rec_to, 'history.php?id=' . $id . '&'); |
|
|
|
|
87
|
|
|
|
88
|
|
|
$xml = '<list>' |
89
|
|
|
. '<hrow>'; |
90
|
|
|
|
91
|
|
View Code Duplication |
for ($i = 1; $i <= count($columns); $i++) |
92
|
|
|
{ |
93
|
|
|
$smode = ($sort == $i ? ($i + count($columns)) : $i); |
94
|
|
|
|
95
|
|
|
$xml .= "<hcell url=\"history.php?id={$id}&sort={$smode}\">" |
96
|
|
|
. get_html_resource($columns[$i - 1]) |
97
|
|
|
. '</hcell>'; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
$xml .= '</hrow>'; |
101
|
|
|
|
102
|
|
|
// go through the history |
103
|
|
|
|
104
|
|
|
$list->seek($rec_from - 1); |
105
|
|
|
|
106
|
|
|
for ($i = $rec_from; $i <= $rec_to; $i++) |
107
|
|
|
{ |
108
|
|
|
$row = $list->fetch(); |
109
|
|
|
|
110
|
|
|
$event = get_event_string($row['event_id'], $row['event_type'], $row['event_param']); |
111
|
|
|
|
112
|
|
|
$xml .= '<row>' |
113
|
|
|
. '<cell>' . get_datetime($row['event_time']) . '</cell>' |
114
|
|
|
. '<cell>' . ustr2html(sprintf('%s (%s)', $row['fullname'], account_get_username($row['username']))) . '</cell>' |
115
|
|
|
. '<cell>' . $event . '</cell>' |
116
|
|
|
. '</row>'; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
$xml .= '</list>' |
120
|
|
|
. $bookmarks; |
121
|
|
|
|
122
|
|
|
echo(xml2html($xml)); |
123
|
|
|
|
124
|
|
|
?> |
125
|
|
|
|
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: