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/records.php'); |
33
|
|
|
/**#@-*/ |
34
|
|
|
|
35
|
|
|
init_page(LOAD_INLINE); |
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
|
|
|
header('HTTP/1.1 307 index.php'); |
46
|
|
|
exit; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
// get current user's permissions and verify them |
50
|
|
|
|
51
|
|
|
$permissions = record_get_permissions($record['template_id'], $record['creator_id'], $record['responsible_id']); |
52
|
|
|
|
53
|
|
View Code Duplication |
if (!can_subrecord_be_added($record, $permissions)) |
54
|
|
|
{ |
55
|
|
|
debug_write_log(DEBUG_NOTICE, 'Subrecord cannot be added.'); |
56
|
|
|
header('HTTP/1.1 307 subrecords.php?id=' . $id); |
57
|
|
|
exit; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
// get current date |
61
|
|
|
|
62
|
|
|
$today = date_floor(time()); |
63
|
|
|
|
64
|
|
|
// subrecords form is submitted |
65
|
|
|
|
66
|
|
|
if (try_request('submitted') == 'addsubrecform') |
67
|
|
|
{ |
68
|
|
|
debug_write_log(DEBUG_NOTICE, 'Data are submitted.'); |
69
|
|
|
|
70
|
|
|
$subrecords = ustrcut(try_request('subrecords'), 100); |
71
|
|
|
$subrecords = ustr_replace(',', ' ', $subrecords); |
72
|
|
|
|
73
|
|
|
$is_dependency = isset($_REQUEST['is_dependency']); |
74
|
|
|
|
75
|
|
|
mb_regex_encoding('UTF-8'); |
76
|
|
|
$subrecords = mb_split(' ', $subrecords); |
77
|
|
|
|
78
|
|
|
foreach ($subrecords as $subrecord) |
79
|
|
|
{ |
80
|
|
|
$pos = strrpos($subrecord, '-'); |
81
|
|
|
|
82
|
|
|
if ($pos !== FALSE) |
83
|
|
|
{ |
84
|
|
|
$prefix = substr($subrecord, 0, $pos); |
85
|
|
|
$subrecord = substr($subrecord, $pos + 1); |
86
|
|
|
debug_write_log(DEBUG_DUMP, "prefix = {$subrecord}"); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
if (is_intvalue($subrecord)) |
90
|
|
|
{ |
91
|
|
|
$subrecord = ustr2int($subrecord); |
92
|
|
|
$srec = record_find($subrecord); |
93
|
|
|
|
94
|
|
|
if ($srec) |
95
|
|
|
{ |
96
|
|
|
if (!isset($prefix) || $srec['template_prefix'] == $prefix) |
97
|
|
|
{ |
98
|
|
|
subrecord_add($id, $subrecord, $is_dependency); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
record_read($id); |
105
|
|
|
|
106
|
|
|
$rs = dal_query('depends/list.sql', $record['record_id']); |
107
|
|
|
echo(sprintf('%s (%u)', get_html_resource(RES_SUBRECORDS_ID), $rs->rows)); |
|
|
|
|
108
|
|
|
exit; |
109
|
|
|
} |
110
|
|
|
else |
111
|
|
|
{ |
112
|
|
|
debug_write_log(DEBUG_NOTICE, 'Data are being requested.'); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
// local JS functions |
116
|
|
|
|
117
|
|
|
$xml = <<<JQUERY |
118
|
|
|
<script> |
119
|
|
|
|
120
|
|
|
function addSubrecordSuccess (data) |
121
|
|
|
{ |
122
|
|
|
var index = $("#tabs").tabs("option", "selected") + 1; |
123
|
|
|
$("[href=#ui-tabs-" + index + "]").html(data); |
124
|
|
|
closeModal(); |
125
|
|
|
reloadTab(); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
</script> |
129
|
|
|
JQUERY; |
130
|
|
|
|
131
|
|
|
// generate subrecords form |
132
|
|
|
|
133
|
|
|
$xml .= '<form name="addsubrecform" action="addsubrec.php?id=' . $id . '" success="addSubrecordSuccess">' |
134
|
|
|
. '<group>' |
135
|
|
|
. '<control name="subrecords">' |
136
|
|
|
. '<label>' . get_html_resource(RES_ID_ID) . '</label>' |
137
|
|
|
. '<editbox maxlen="100"/>' |
138
|
|
|
. '</control>' |
139
|
|
|
. '<control name="is_dependency">' |
140
|
|
|
. '<label/>' |
141
|
|
|
. '<checkbox checked="true">' |
142
|
|
|
. get_html_resource(RES_DEPENDENCY_ID) |
143
|
|
|
. '</checkbox>' |
144
|
|
|
. '</control>' |
145
|
|
|
. '</group>' |
146
|
|
|
. '</form>'; |
147
|
|
|
|
148
|
|
|
echo(xml2html($xml)); |
149
|
|
|
|
150
|
|
|
?> |
151
|
|
|
|
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.