This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | //------------------------------------------------------------------------------ |
||
4 | // |
||
5 | // eTraxis - Records tracking web-based system |
||
6 | // Copyright (C) 2005-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 | * Values |
||
25 | * |
||
26 | * This module provides API to work with values of custom fields. |
||
27 | * See also {@link https://github.com/etraxis/etraxis-obsolete/wiki/tbl_field_values tbl_field_values} database table. |
||
28 | * |
||
29 | * @package DBO |
||
30 | * @subpackage Values |
||
31 | */ |
||
32 | |||
33 | /**#@+ |
||
34 | * Dependency. |
||
35 | */ |
||
36 | require_once('../engine/engine.php'); |
||
37 | require_once('../dbo/fields.php'); |
||
38 | /**#@-*/ |
||
39 | |||
40 | //------------------------------------------------------------------------------ |
||
41 | // Functions. |
||
42 | //------------------------------------------------------------------------------ |
||
43 | |||
44 | /** |
||
45 | * Finds in database and returns a custom field value by its ID. |
||
46 | * |
||
47 | * @param int $field_type Field type. |
||
48 | * @param int $value_id Value ID. |
||
49 | * @return mixed Custom field value if it's found in database, NULL otherwise. |
||
50 | */ |
||
51 | function value_find ($field_type, $value_id) |
||
52 | { |
||
53 | debug_write_log(DEBUG_TRACE, '[value_find]'); |
||
54 | debug_write_log(DEBUG_DUMP, '[value_find] $field_type = ' . $field_type); |
||
55 | debug_write_log(DEBUG_DUMP, '[value_find] $value_id = ' . $value_id); |
||
56 | |||
57 | $value = NULL; |
||
58 | |||
59 | if (!is_null($value_id)) |
||
60 | { |
||
61 | switch ($field_type) |
||
62 | { |
||
63 | case FIELD_TYPE_NUMBER: |
||
64 | case FIELD_TYPE_LIST: |
||
65 | case FIELD_TYPE_RECORD: |
||
66 | |||
67 | $value = $value_id; |
||
68 | break; |
||
69 | |||
70 | View Code Duplication | case FIELD_TYPE_FLOAT: |
|
0 ignored issues
–
show
|
|||
71 | |||
72 | $rs = dal_query('values/ffndid.sql', $value_id); |
||
73 | |||
74 | if ($rs->rows == 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
|
|||
75 | { |
||
76 | debug_write_log(DEBUG_ERROR, '[value_find] Float value cannot be found.'); |
||
77 | } |
||
78 | else |
||
79 | { |
||
80 | $value = $rs->fetch('float_value'); |
||
81 | } |
||
82 | |||
83 | break; |
||
84 | |||
85 | case NULL: // NULL is used for subject |
||
86 | View Code Duplication | case FIELD_TYPE_STRING: |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
87 | |||
88 | $rs = dal_query('values/sfndid.sql', $value_id); |
||
89 | |||
90 | if ($rs->rows == 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
|
|||
91 | { |
||
92 | debug_write_log(DEBUG_ERROR, '[value_find] String value cannot be found.'); |
||
93 | } |
||
94 | else |
||
95 | { |
||
96 | $value = $rs->fetch('string_value'); |
||
97 | } |
||
98 | |||
99 | break; |
||
100 | |||
101 | View Code Duplication | case FIELD_TYPE_MULTILINED: |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
102 | |||
103 | $rs = dal_query('values/tfndid.sql', $value_id); |
||
104 | |||
105 | if ($rs->rows == 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
|
|||
106 | { |
||
107 | debug_write_log(DEBUG_ERROR, '[value_find] Value cannot be found.'); |
||
108 | } |
||
109 | else |
||
110 | { |
||
111 | $value = $rs->fetch('text_value'); |
||
112 | } |
||
113 | |||
114 | break; |
||
115 | |||
116 | case FIELD_TYPE_CHECKBOX: |
||
117 | |||
118 | $value = (bool) $value_id; |
||
119 | break; |
||
120 | |||
121 | case FIELD_TYPE_DATE: |
||
122 | |||
123 | $value = get_date($value_id); |
||
124 | break; |
||
125 | |||
126 | case FIELD_TYPE_DURATION: |
||
127 | |||
128 | $value = time2ustr($value_id); |
||
129 | break; |
||
130 | |||
131 | default: |
||
132 | |||
133 | debug_write_log(DEBUG_WARNING, '[value_find] Unknown field type = ' . $field_type); |
||
134 | } |
||
135 | } |
||
136 | |||
137 | return $value; |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * Finds in database and returns a text value of list item, which is specified by its integer value. |
||
142 | * |
||
143 | * @param int $field_id Field ID. |
||
144 | * @param int $int_value Value ID. |
||
145 | * @return string Text value of list item, if it's found in database, NULL otherwise. |
||
146 | */ |
||
147 | function value_find_listvalue ($field_id, $int_value) |
||
148 | { |
||
149 | debug_write_log(DEBUG_TRACE, '[value_find_listvalue]'); |
||
150 | debug_write_log(DEBUG_DUMP, '[value_find_listvalue] $field_id = ' . $field_id); |
||
151 | debug_write_log(DEBUG_DUMP, '[value_find_listvalue] $int_value = ' . $int_value); |
||
152 | |||
153 | $res = NULL; |
||
154 | |||
155 | if (!is_null($int_value)) |
||
156 | { |
||
157 | $rs = dal_query('values/lvfndk1.sql', $field_id, $int_value); |
||
158 | |||
159 | if ($rs->rows == 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
|
|||
160 | { |
||
161 | debug_write_log(DEBUG_ERROR, '[value_find_listvalue] Value cannot be found.'); |
||
162 | } |
||
163 | else |
||
164 | { |
||
165 | $res = $rs->fetch('str_value'); |
||
166 | } |
||
167 | } |
||
168 | |||
169 | return $res; |
||
170 | } |
||
171 | |||
172 | /** |
||
173 | * Creates in database an integer value for specified field per specified event. |
||
174 | * |
||
175 | * @param int $event_id Event ID. |
||
176 | * @param int $field_id Field ID. |
||
177 | * @param int $field_type Field type. |
||
178 | * @param int $value Integer value to be stored in database (could be NULL). |
||
179 | * @return int Always {@link NO_ERROR}. |
||
180 | */ |
||
181 | View Code Duplication | function value_create_number ($event_id, $field_id, $field_type = FIELD_TYPE_NUMBER, $value = NULL) |
|
0 ignored issues
–
show
This function seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
182 | { |
||
183 | debug_write_log(DEBUG_TRACE, '[value_create_number]'); |
||
184 | debug_write_log(DEBUG_DUMP, '[value_create_number] $event_id = ' . $event_id); |
||
185 | debug_write_log(DEBUG_DUMP, '[value_create_number] $field_id = ' . $field_id); |
||
186 | debug_write_log(DEBUG_DUMP, '[value_create_number] $field_type = ' . $field_type); |
||
187 | debug_write_log(DEBUG_DUMP, '[value_create_number] $value = ' . $value); |
||
188 | |||
189 | dal_query('values/create.sql', |
||
190 | $event_id, |
||
191 | $field_id, |
||
192 | $field_type, |
||
193 | is_null($value) ? NULL : $value); |
||
194 | |||
195 | return NO_ERROR; |
||
196 | } |
||
197 | |||
198 | /** |
||
199 | * Modifies in database current integer value of specified field for specified record per specified event. |
||
200 | * |
||
201 | * @param int $record_id Record ID. |
||
202 | * @param int $event_id Event ID. |
||
203 | * @param int $field_id Field ID. |
||
204 | * @param int $value New integer value (could be NULL). |
||
205 | * @return int Always {@link NO_ERROR}. |
||
206 | */ |
||
207 | View Code Duplication | function value_modify_number ($record_id, $event_id, $field_id, $value = NULL) |
|
0 ignored issues
–
show
This function seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
208 | { |
||
209 | debug_write_log(DEBUG_TRACE, '[value_modify_number]'); |
||
210 | debug_write_log(DEBUG_DUMP, '[value_modify_number] $record_id = ' . $record_id); |
||
211 | debug_write_log(DEBUG_DUMP, '[value_modify_number] $event_id = ' . $event_id); |
||
212 | debug_write_log(DEBUG_DUMP, '[value_modify_number] $field_id = ' . $field_id); |
||
213 | debug_write_log(DEBUG_DUMP, '[value_modify_number] $value = ' . $value); |
||
214 | |||
215 | $rs = dal_query('values/fndk.sql', $record_id, $field_id); |
||
216 | |||
217 | if ($rs->rows != 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
|
|||
218 | { |
||
219 | $value_id = $rs->fetch('value_id'); |
||
220 | |||
221 | // If current value and new one are different - register changes. |
||
222 | if ($value_id != $value) |
||
223 | { |
||
224 | debug_write_log(DEBUG_NOTICE, '[value_modify_number] Register changes.'); |
||
225 | |||
226 | dal_query('changes/create.sql', |
||
227 | $event_id, |
||
228 | $field_id, |
||
229 | is_null($value_id) ? NULL : $value_id, |
||
230 | is_null($value) ? NULL : $value); |
||
231 | } |
||
232 | } |
||
233 | |||
234 | $rs = dal_query('values/efndid.sql', |
||
235 | $record_id, |
||
236 | $field_id); |
||
237 | |||
238 | dal_query('values/modify.sql', |
||
239 | $rs->fetch('event_id'), |
||
240 | $field_id, |
||
241 | is_null($value) ? NULL : $value); |
||
242 | |||
243 | return NO_ERROR; |
||
244 | } |
||
245 | |||
246 | /** |
||
247 | * Finds in database specified float value and returns its ID. |
||
248 | * If specified value doesn't exist in database, creates it there and returns its ID. |
||
249 | * |
||
250 | * @param string $value Float value. |
||
251 | * @return int ID of float value, NULL on error. |
||
252 | */ |
||
253 | function value_find_float ($value) |
||
254 | { |
||
255 | debug_write_log(DEBUG_TRACE, '[value_find_float]'); |
||
256 | debug_write_log(DEBUG_DUMP, '[value_find_float] $value = ' . $value); |
||
257 | |||
258 | $id = NULL; |
||
259 | |||
260 | if (!is_null($value)) |
||
261 | { |
||
262 | $rs = dal_query('values/ffndk.sql', $value); |
||
263 | |||
264 | // Value doesn't exist - must be created. |
||
265 | View Code Duplication | if ($rs->rows == 0) |
|
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
266 | { |
||
267 | debug_write_log(DEBUG_NOTICE, '[value_find_float] Register float value.'); |
||
268 | |||
269 | dal_query('values/fcreate.sql', $value); |
||
270 | $rs = dal_query('values/ffndk.sql', $value); |
||
271 | } |
||
272 | |||
273 | // Value should exist by this moment. |
||
274 | if ($rs->rows == 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
|
|||
275 | { |
||
276 | debug_write_log(DEBUG_ERROR, '[value_find_float] Value cannot be found.'); |
||
277 | } |
||
278 | else |
||
279 | { |
||
280 | $id = $rs->fetch('value_id'); |
||
281 | } |
||
282 | } |
||
283 | |||
284 | return $id; |
||
285 | } |
||
286 | |||
287 | /** |
||
288 | * Creates in database a float value for specified field per specified event. |
||
289 | * |
||
290 | * @param int $event_id Event ID. |
||
291 | * @param int $field_id Field ID. |
||
292 | * @param int $field_type Field type. |
||
293 | * @param string $value Float value to be stored in database (could be NULL). |
||
294 | * @return int Always {@link NO_ERROR}. |
||
295 | */ |
||
296 | View Code Duplication | function value_create_float ($event_id, $field_id, $field_type = FIELD_TYPE_FLOAT, $value = NULL) |
|
0 ignored issues
–
show
This function seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
297 | { |
||
298 | debug_write_log(DEBUG_TRACE, '[value_create_float]'); |
||
299 | debug_write_log(DEBUG_DUMP, '[value_create_float] $event_id = ' . $event_id); |
||
300 | debug_write_log(DEBUG_DUMP, '[value_create_float] $field_id = ' . $field_id); |
||
301 | debug_write_log(DEBUG_DUMP, '[value_create_float] $field_type = ' . $field_type); |
||
302 | debug_write_log(DEBUG_DUMP, '[value_create_float] $value = ' . $value); |
||
303 | |||
304 | $id = value_find_float($value); |
||
305 | |||
306 | dal_query('values/create.sql', |
||
307 | $event_id, |
||
308 | $field_id, |
||
309 | $field_type, |
||
310 | is_null($id) ? NULL : $id); |
||
311 | |||
312 | return NO_ERROR; |
||
313 | } |
||
314 | |||
315 | /** |
||
316 | * Modifies in database current float value of specified field for specified record per specified event. |
||
317 | * |
||
318 | * @param int $record_id Record ID. |
||
319 | * @param int $event_id Event ID. |
||
320 | * @param int $field_id Field ID. |
||
321 | * @param string $value New float value (could be NULL). |
||
322 | * @return int Always {@link NO_ERROR}. |
||
323 | */ |
||
324 | View Code Duplication | function value_modify_float ($record_id, $event_id, $field_id, $value = NULL) |
|
0 ignored issues
–
show
This function seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
325 | { |
||
326 | debug_write_log(DEBUG_TRACE, '[value_modify_float]'); |
||
327 | debug_write_log(DEBUG_DUMP, '[value_modify_float] $record_id = ' . $record_id); |
||
328 | debug_write_log(DEBUG_DUMP, '[value_modify_float] $event_id = ' . $event_id); |
||
329 | debug_write_log(DEBUG_DUMP, '[value_modify_float] $field_id = ' . $field_id); |
||
330 | debug_write_log(DEBUG_DUMP, '[value_modify_float] $value = ' . $value); |
||
331 | |||
332 | $id = value_find_float($value); |
||
333 | |||
334 | $rs = dal_query('values/fndk.sql', $record_id, $field_id); |
||
335 | |||
336 | if ($rs->rows != 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
|
|||
337 | { |
||
338 | $value_id = $rs->fetch('value_id'); |
||
339 | |||
340 | // If current value and new one are different - register changes. |
||
341 | if ($value_id != $id) |
||
342 | { |
||
343 | debug_write_log(DEBUG_NOTICE, '[value_modify_float] Register changes.'); |
||
344 | |||
345 | dal_query('changes/create.sql', |
||
346 | $event_id, |
||
347 | $field_id, |
||
348 | is_null($value_id) ? NULL : $value_id, |
||
349 | is_null($id) ? NULL : $id); |
||
350 | } |
||
351 | } |
||
352 | |||
353 | $rs = dal_query('values/efndid.sql', |
||
354 | $record_id, |
||
355 | $field_id); |
||
356 | |||
357 | dal_query('values/modify.sql', |
||
358 | $rs->fetch('event_id'), |
||
359 | $field_id, |
||
360 | is_null($id) ? NULL : $id); |
||
361 | |||
362 | return NO_ERROR; |
||
363 | } |
||
364 | |||
365 | /** |
||
366 | * Finds in database specified single string value and returns its ID. |
||
367 | * If specified value doesn't exist in database, creates it there and returns its ID. |
||
368 | * |
||
369 | * @param string $value String value. |
||
370 | * @return int ID of string value, NULL on error. |
||
371 | */ |
||
372 | function value_find_string ($value) |
||
373 | { |
||
374 | debug_write_log(DEBUG_TRACE, '[value_find_string]'); |
||
375 | debug_write_log(DEBUG_DUMP, '[value_find_string] $value = ' . $value); |
||
376 | |||
377 | $id = NULL; |
||
378 | |||
379 | if (!is_null($value)) |
||
380 | { |
||
381 | $rs = dal_query('values/sfndk.sql', md5($value)); |
||
382 | |||
383 | // Value doesn't exist - must be created. |
||
384 | View Code Duplication | if ($rs->rows == 0) |
|
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
385 | { |
||
386 | debug_write_log(DEBUG_NOTICE, '[value_find_string] Register string value.'); |
||
387 | |||
388 | dal_query('values/screate.sql', md5($value), $value); |
||
389 | $rs = dal_query('values/sfndk.sql', md5($value)); |
||
390 | } |
||
391 | |||
392 | // Value should exist by this moment. |
||
393 | if ($rs->rows == 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
|
|||
394 | { |
||
395 | debug_write_log(DEBUG_ERROR, '[value_find_string] Value cannot be found.'); |
||
396 | } |
||
397 | else |
||
398 | { |
||
399 | $id = $rs->fetch('value_id'); |
||
400 | } |
||
401 | } |
||
402 | |||
403 | return $id; |
||
404 | } |
||
405 | |||
406 | /** |
||
407 | * Creates in database a single string value for specified field per specified event. |
||
408 | * |
||
409 | * @param int $event_id Event ID. |
||
410 | * @param int $field_id Field ID. |
||
411 | * @param int $field_type Field type. |
||
412 | * @param string $value String value to be stored in database (could be NULL). |
||
413 | * @return int Always {@link NO_ERROR}. |
||
414 | */ |
||
415 | View Code Duplication | function value_create_string ($event_id, $field_id, $field_type = FIELD_TYPE_STRING, $value = NULL) |
|
0 ignored issues
–
show
This function seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
416 | { |
||
417 | debug_write_log(DEBUG_TRACE, '[value_create_string]'); |
||
418 | debug_write_log(DEBUG_DUMP, '[value_create_string] $event_id = ' . $event_id); |
||
419 | debug_write_log(DEBUG_DUMP, '[value_create_string] $field_id = ' . $field_id); |
||
420 | debug_write_log(DEBUG_DUMP, '[value_create_string] $field_type = ' . $field_type); |
||
421 | debug_write_log(DEBUG_DUMP, '[value_create_string] $value = ' . $value); |
||
422 | |||
423 | $id = value_find_string($value); |
||
424 | |||
425 | dal_query('values/create.sql', |
||
426 | $event_id, |
||
427 | $field_id, |
||
428 | $field_type, |
||
429 | is_null($id) ? NULL : $id); |
||
430 | |||
431 | return NO_ERROR; |
||
432 | } |
||
433 | |||
434 | /** |
||
435 | * Modifies in database current single string value of specified field for specified record per specified event. |
||
436 | * |
||
437 | * @param int $record_id Record ID. |
||
438 | * @param int $event_id Event ID. |
||
439 | * @param int $field_id Field ID. |
||
440 | * @param string $value New string value (could be NULL). |
||
441 | * @return int Always {@link NO_ERROR}. |
||
442 | */ |
||
443 | View Code Duplication | function value_modify_string ($record_id, $event_id, $field_id, $value = NULL) |
|
0 ignored issues
–
show
This function seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
444 | { |
||
445 | debug_write_log(DEBUG_TRACE, '[value_modify_string]'); |
||
446 | debug_write_log(DEBUG_DUMP, '[value_modify_string] $record_id = ' . $record_id); |
||
447 | debug_write_log(DEBUG_DUMP, '[value_modify_string] $event_id = ' . $event_id); |
||
448 | debug_write_log(DEBUG_DUMP, '[value_modify_string] $field_id = ' . $field_id); |
||
449 | debug_write_log(DEBUG_DUMP, '[value_modify_string] $value = ' . $value); |
||
450 | |||
451 | $id = value_find_string($value); |
||
452 | |||
453 | $rs = dal_query('values/fndk.sql', $record_id, $field_id); |
||
454 | |||
455 | if ($rs->rows != 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
|
|||
456 | { |
||
457 | $value_id = $rs->fetch('value_id'); |
||
458 | |||
459 | // If current value and new one are different - register changes. |
||
460 | if ($value_id != $id) |
||
461 | { |
||
462 | debug_write_log(DEBUG_NOTICE, '[value_modify_string] Register changes.'); |
||
463 | |||
464 | dal_query('changes/create.sql', |
||
465 | $event_id, |
||
466 | $field_id, |
||
467 | is_null($value_id) ? NULL : $value_id, |
||
468 | is_null($id) ? NULL : $id); |
||
469 | } |
||
470 | } |
||
471 | |||
472 | $rs = dal_query('values/efndid.sql', |
||
473 | $record_id, |
||
474 | $field_id); |
||
475 | |||
476 | dal_query('values/modify.sql', |
||
477 | $rs->fetch('event_id'), |
||
478 | $field_id, |
||
479 | is_null($id) ? NULL : $id); |
||
480 | |||
481 | return NO_ERROR; |
||
482 | } |
||
483 | |||
484 | /** |
||
485 | * Finds in database specified multilined text value and returns its ID. |
||
486 | * If specified value doesn't exist in database, creates it there and returns its ID. |
||
487 | * |
||
488 | * @param string $value Text value. |
||
489 | * @return int ID of text value, NULL on error. |
||
490 | */ |
||
491 | function value_find_multilined ($value) |
||
492 | { |
||
493 | debug_write_log(DEBUG_TRACE, '[value_find_multilined]'); |
||
494 | debug_write_log(DEBUG_DUMP, '[value_find_multilined] $value = ' . $value); |
||
495 | |||
496 | $id = NULL; |
||
497 | |||
498 | if (!is_null($value)) |
||
499 | { |
||
500 | $token = md5($value); |
||
501 | |||
502 | $rs = dal_query('values/tfndk.sql', "'{$token}'"); |
||
503 | |||
504 | // Value doesn't exist - must be created. |
||
505 | if ($rs->rows == 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
|
|||
506 | { |
||
507 | debug_write_log(DEBUG_NOTICE, '[value_find_multilined] Register text value.'); |
||
508 | |||
509 | // Oracle BLOB needs specific processing. |
||
510 | if (DATABASE_DRIVER == DRIVER_ORACLE9) |
||
511 | { |
||
512 | $handle = CDatabase::connect()->link->handle; |
||
513 | $sql = file_get_contents(LOCALROOT . '/sql/values/oracle/tcreate.sql'); |
||
514 | |||
515 | $stid = ociparse($handle, $sql); |
||
516 | $clob = ocinewdescriptor($handle, OCI_D_LOB); |
||
517 | |||
518 | ocibindbyname($stid, ":value_token", $token); |
||
519 | ocibindbyname($stid, ":text_value", $clob, -1, OCI_B_CLOB); |
||
520 | |||
521 | ociexecute($stid, OCI_DEFAULT); |
||
522 | $clob->save($value); |
||
523 | ocicommit($handle); |
||
524 | } |
||
525 | else |
||
526 | { |
||
527 | dal_query('values/tcreate.sql', "'{$token}'", $value); |
||
528 | } |
||
529 | |||
530 | $rs = dal_query('values/tfndk.sql', "'{$token}'"); |
||
531 | } |
||
532 | |||
533 | // Value should exist by this moment. |
||
534 | if ($rs->rows == 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
|
|||
535 | { |
||
536 | debug_write_log(DEBUG_ERROR, '[value_find_multilined] Value cannot be found.'); |
||
537 | } |
||
538 | else |
||
539 | { |
||
540 | $id = $rs->fetch('value_id'); |
||
541 | } |
||
542 | } |
||
543 | |||
544 | return $id; |
||
545 | } |
||
546 | |||
547 | /** |
||
548 | * Creates in database a multilined text value for specified field per specified event. |
||
549 | * |
||
550 | * @param int $event_id Event ID. |
||
551 | * @param int $field_id Field ID. |
||
552 | * @param int $field_type Field type. |
||
553 | * @param string $value Text value to be stored in database (could be NULL). |
||
554 | * @return int Always {@link NO_ERROR}. |
||
555 | */ |
||
556 | View Code Duplication | function value_create_multilined ($event_id, $field_id, $field_type = FIELD_TYPE_MULTILINED, $value = NULL) |
|
0 ignored issues
–
show
This function seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
557 | { |
||
558 | debug_write_log(DEBUG_TRACE, '[value_create_multilined]'); |
||
559 | debug_write_log(DEBUG_DUMP, '[value_create_multilined] $event_id = ' . $event_id); |
||
560 | debug_write_log(DEBUG_DUMP, '[value_create_multilined] $field_id = ' . $field_id); |
||
561 | debug_write_log(DEBUG_DUMP, '[value_create_multilined] $field_type = ' . $field_type); |
||
562 | debug_write_log(DEBUG_DUMP, '[value_create_multilined] $value = ' . $value); |
||
563 | |||
564 | $id = value_find_multilined($value); |
||
565 | |||
566 | dal_query('values/create.sql', |
||
567 | $event_id, |
||
568 | $field_id, |
||
569 | $field_type, |
||
570 | is_null($id) ? NULL : $id); |
||
571 | |||
572 | return NO_ERROR; |
||
573 | } |
||
574 | |||
575 | /** |
||
576 | * Modifies in database current multilined text value of specified field for specified record per specified event. |
||
577 | * |
||
578 | * @param int $record_id Record ID. |
||
579 | * @param int $event_id Event ID. |
||
580 | * @param int $field_id Field ID. |
||
581 | * @param string $value New text value (could be NULL). |
||
582 | * @return int Always {@link NO_ERROR}. |
||
583 | */ |
||
584 | View Code Duplication | function value_modify_multilined ($record_id, $event_id, $field_id, $value = NULL) |
|
0 ignored issues
–
show
This function seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
585 | { |
||
586 | debug_write_log(DEBUG_TRACE, '[value_modify_multilined]'); |
||
587 | debug_write_log(DEBUG_DUMP, '[value_modify_multilined] $record_id = ' . $record_id); |
||
588 | debug_write_log(DEBUG_DUMP, '[value_modify_multilined] $event_id = ' . $event_id); |
||
589 | debug_write_log(DEBUG_DUMP, '[value_modify_multilined] $field_id = ' . $field_id); |
||
590 | debug_write_log(DEBUG_DUMP, '[value_modify_multilined] $value = ' . $value); |
||
591 | |||
592 | $id = value_find_multilined($value); |
||
593 | |||
594 | $rs = dal_query('values/fndk.sql', $record_id, $field_id); |
||
595 | |||
596 | if ($rs->rows != 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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.
Loading history...
|
|||
597 | { |
||
598 | $value_id = $rs->fetch('value_id'); |
||
599 | |||
600 | // If current value and new one are different - register changes. |
||
601 | if ($value_id != $id) |
||
602 | { |
||
603 | debug_write_log(DEBUG_NOTICE, '[value_modify_multilined] Register changes.'); |
||
604 | |||
605 | dal_query('changes/create.sql', |
||
606 | $event_id, |
||
607 | $field_id, |
||
608 | is_null($value_id) ? NULL : $value_id, |
||
609 | is_null($id) ? NULL : $id); |
||
610 | } |
||
611 | } |
||
612 | |||
613 | $rs = dal_query('values/efndid.sql', |
||
614 | $record_id, |
||
615 | $field_id); |
||
616 | |||
617 | dal_query('values/modify.sql', |
||
618 | $rs->fetch('event_id'), |
||
619 | $field_id, |
||
620 | is_null($id) ? NULL : $id); |
||
621 | |||
622 | return NO_ERROR; |
||
623 | } |
||
624 | |||
625 | ?> |
||
626 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.