Issues (1098)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/filters/modify.php (8 issues)

Upgrade to new PHP Analysis Engine

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
 * @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/projects.php');
34
require_once('../dbo/templates.php');
35
require_once('../dbo/fields.php');
36
require_once('../dbo/filters.php');
37
/**#@-*/
38
39
init_page(LOAD_INLINE);
40
41
// check that requested filter exists
42
43
$id     = ustr2int(try_request('id'));
44
$filter = filter_find($id);
45
46
if (!$filter)
0 ignored issues
show
Bug Best Practice introduced by
The expression $filter of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

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.

Loading history...
47
{
48
    debug_write_log(DEBUG_NOTICE, 'Filter cannot be found.');
49
    header('HTTP/1.1 307 index.php');
50
    exit;
51
}
52
53
// changed filter has been submitted
54
55
if (try_request('submitted') == 'modifyform')
56
{
57
    debug_write_log(DEBUG_NOTICE, 'Data are submitted.');
58
59
    $filter_name = ustrcut($_REQUEST['filter_name'], MAX_FILTER_NAME);
60
    $unclosed    = isset($_REQUEST['unclosed']);
61
    $postponed   = ustr2int(try_request('postponed', 0));
62
63 View Code Duplication
    if (!in_array($postponed, array(0, FILTER_FLAG_POSTPONED, FILTER_FLAG_ACTIVE)))
64
    {
65
        $postponed = 0;
66
    }
67
68
    $error = filter_validate($filter_name);
69
70
    if ($error == NO_ERROR)
71
    {
72
        $filter_type = $filter['filter_type'];
73
74
        if ($filter_type == FILTER_TYPE_ALL_STATES ||
75
            $filter_type == FILTER_TYPE_SEL_STATES)
76
        {
77
            $states = (isset($_REQUEST['states']) ? $_REQUEST['states'] : array());
78
            $filter_type = (count($states) == 0 ? FILTER_TYPE_ALL_STATES : FILTER_TYPE_SEL_STATES);
79
        }
80
81
        $filter_flags  = ($unclosed ? FILTER_FLAG_UNCLOSED : 0);
82
        $filter_flags |= ($postponed);
83
84 View Code Duplication
        if (isset($_REQUEST['created_by']) &&
85
            count($_REQUEST['created_by']) != 0)
86
        {
87
            $filter_flags |= FILTER_FLAG_CREATED_BY;
88
        }
89
90 View Code Duplication
        if (isset($_REQUEST['assigned_to']) &&
91
            count($_REQUEST['assigned_to']) != 0)
92
        {
93
            if (in_array(0, $_REQUEST['assigned_to']))
94
            {
95
                $filter_flags |= FILTER_FLAG_UNASSIGNED;
96
97
                if (count($_REQUEST['assigned_to']) > 1)
98
                {
99
                    $filter_flags |= FILTER_FLAG_ASSIGNED_TO;
100
                }
101
            }
102
            else
103
            {
104
                $filter_flags |= FILTER_FLAG_ASSIGNED_TO;
105
            }
106
        }
107
108
        $error = filter_modify($id,
109
                               $filter_name,
110
                               $filter_type,
111
                               $filter_flags);
112
113
        if ($error == NO_ERROR)
114
        {
115
            if ($filter_type == FILTER_TYPE_ALL_STATES ||
116
                $filter_type == FILTER_TYPE_SEL_STATES)
117
            {
118
                dal_query('filters/fsdelall.sql', $id, $_SESSION[VAR_USERID]);
119
120
                foreach ($states as $item)
121
                {
122
                    dal_query('filters/fscreate.sql', $id, $item);
123
                }
124
            }
125
126
            dal_query('filters/fadelall.sql',  $id, $_SESSION[VAR_USERID]);
127
128 View Code Duplication
            if (($filter_flags & FILTER_FLAG_CREATED_BY) != 0)
129
            {
130
                foreach ($_REQUEST['created_by'] as $item)
131
                {
132
                    dal_query('filters/facreate.sql', $id, FILTER_FLAG_CREATED_BY, $item);
133
                }
134
            }
135
136 View Code Duplication
            if (($filter_flags & FILTER_FLAG_ASSIGNED_TO) != 0)
137
            {
138
                foreach ($_REQUEST['assigned_to'] as $item)
139
                {
140
                    dal_query('filters/facreate.sql', $id, FILTER_FLAG_ASSIGNED_TO, $item);
141
                }
142
            }
143
144
            switch ($filter['filter_type'])
145
            {
146
                case FILTER_TYPE_ALL_PROJECTS:
147
                case FILTER_TYPE_ALL_TEMPLATES:
148
149
                    $template_id = 0;
150
151
                    break;
152
153
                case FILTER_TYPE_ALL_STATES:
154
                case FILTER_TYPE_SEL_STATES:
155
156
                    $template = template_find($filter['filter_param']);
157
158
                    if (!$template)
0 ignored issues
show
Bug Best Practice introduced by
The expression $template of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

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.

Loading history...
159
                    {
160
                        debug_write_log(DEBUG_WARNING, 'Template cannot be found.');
161
                        header('HTTP/1.1 307 view.php?id=' . $id);
162
                        exit;
163
                    }
164
165
                    $template_id = $template['template_id'];
166
167
                    break;
168
169
                default:
170
171
                    debug_write_log(DEBUG_WARNING, 'Unknown filter type = ' . $filter['filter_type']);
172
            }
173
174
            if ($template_id != 0)
175
            {
176
                filter_trans_set($id, $template_id);
177
                filter_fields_set($id, $template_id);
178
            }
179
        }
180
    }
181
182
    switch ($error)
183
    {
184
        case NO_ERROR:
185
            header('HTTP/1.0 200 OK');
186
            break;
187
188
        case ERROR_INCOMPLETE_FORM:
189
            send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID));
190
            break;
191
192
        case ERROR_ALREADY_EXISTS:
193
            send_http_error(get_html_resource(RES_ALERT_FILTER_ALREADY_EXISTS_ID));
194
            break;
195
196
        default:
197
            send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID));
198
    }
199
200
    exit;
201
}
202
else
203
{
204
    debug_write_log(DEBUG_NOTICE, 'Data are being requested.');
205
206
    $error = NO_ERROR;
207
208
    $filter_name = $filter['filter_name'];
209
    $unclosed    = ($filter['filter_flags'] & FILTER_FLAG_UNCLOSED);
210
    $postponed   = ($filter['filter_flags'] & (FILTER_FLAG_POSTPONED | FILTER_FLAG_ACTIVE));
211
}
212
213
// local JS functions
214
215
$resTitle = get_js_resource(RES_ERROR_ID);
216
$resOK    = get_js_resource(RES_OK_ID);
217
218
$xml = <<<JQUERY
219
<script>
220
221
function modifySuccess ()
222
{
223
    closeModal();
224
    reloadTab();
225
}
226
227
function modifyError (XMLHttpRequest)
228
{
229
    jqAlert("{$resTitle}", XMLHttpRequest.responseText, "{$resOK}");
230
}
231
232
</script>
233
JQUERY;
234
235
// generate header
236
237
$xml .= '<form name="modifyform" action="modify.php?id=' . $id . '" success="modifySuccess" error="modifyError">'
238
      . '<group>';
239
240
// generate project and template selectors
241
242
switch ($filter['filter_type'])
243
{
244
    case FILTER_TYPE_ALL_PROJECTS:
245
246
        $project_id  = 0;
247
        $template_id = 0;
248
249
        $xml .= '<control name="project">'
250
              . '<label>' . get_html_resource(RES_PROJECT_ID) . '</label>'
251
              . '<combobox>'
252
              . '<listitem value="0">' . get_html_resource(RES_ALL_PROJECTS_ID) . '</listitem>'
253
              . '</combobox>'
254
              . '</control>';
255
256
        break;
257
258
    case FILTER_TYPE_ALL_TEMPLATES:
259
260
        $project = project_find($filter['filter_param']);
261
262
        if (!$project)
0 ignored issues
show
Bug Best Practice introduced by
The expression $project of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

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.

Loading history...
263
        {
264
            debug_write_log(DEBUG_WARNING, 'Project cannot be found.');
265
            header('HTTP/1.1 307 view.php?id=' . $id);
266
            exit;
267
        }
268
269
        $project_id  = $project['project_id'];
270
        $template_id = 0;
271
272
        $xml .= '<control name="project">'
273
              . '<label>' . get_html_resource(RES_PROJECT_ID) . '</label>'
274
              . '<combobox>'
275
              . '<listitem value="0">' . ustr2html($project['project_name']) . '</listitem>'
276
              . '</combobox>'
277
              . '</control>';
278
279
        $xml .= '<control name="template">'
280
              . '<label>' . get_html_resource(RES_TEMPLATE_ID) . '</label>'
281
              . '<combobox>'
282
              . '<listitem value="0">' . get_html_resource(RES_ALL_TEMPLATES_ID) . '</listitem>'
283
              . '</combobox>'
284
              . '</control>';
285
286
        break;
287
288
    case FILTER_TYPE_ALL_STATES:
289
    case FILTER_TYPE_SEL_STATES:
290
291
        $template = template_find($filter['filter_param']);
292
293
        if (!$template)
0 ignored issues
show
Bug Best Practice introduced by
The expression $template of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

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.

Loading history...
294
        {
295
            debug_write_log(DEBUG_WARNING, 'Template cannot be found.');
296
            header('HTTP/1.1 307 view.php?id=' . $id);
297
            exit;
298
        }
299
300
        $project_id  = $template['project_id'];
301
        $template_id = $template['template_id'];
302
303
        $xml .= '<control name="project">'
304
              . '<label>' . get_html_resource(RES_PROJECT_ID) . '</label>'
305
              . '<combobox>'
306
              . '<listitem value="0">' . ustr2html($template['project_name']) . '</listitem>'
307
              . '</combobox>'
308
              . '</control>';
309
310
        $xml .= '<control name="template">'
311
              . '<label>' . get_html_resource(RES_TEMPLATE_ID) . '</label>'
312
              . '<combobox>'
313
              . '<listitem value="0">' . ustr2html($template['template_name']) . '</listitem>'
314
              . '</combobox>'
315
              . '</control>';
316
317
        break;
318
319
    default:
320
321
        debug_write_log(DEBUG_WARNING, 'Unknown filter type = ' . $filter['filter_type']);
322
}
323
324
// generate filter name and other common options
325
326
$xml .= '<control name="filter_name" required="' . get_html_resource(RES_REQUIRED3_ID) . '">'
327
      . '<label>' . get_html_resource(RES_FILTER_NAME_ID) . '</label>'
328
      . '<editbox maxlen="' . MAX_FILTER_NAME . '">' . ustr2html($filter_name) . '</editbox>'
329
      . '</control>';
330
331
$xml .= '<control name="unclosed">'
332
      . '<label/>'
333
      . ($unclosed
334
            ? '<checkbox checked="true">'
335
            : '<checkbox>')
336
      . ustrtolower(get_html_resource(RES_SHOW_UNCLOSED_ONLY_ID))
337
      . '</checkbox>'
338
      . '</control>';
339
340
$xml .= '<control name="postponed">'
341
      . '<label>' . get_html_resource(RES_POSTPONE_STATUS_ID) . '</label>'
342
      . '<radio value="' . 0                     . ($postponed == 0                     ? '" checked="true">' : '">') . get_html_resource(RES_SHOW_ALL_ID)            . '</radio>'
343
      . '<radio value="' . FILTER_FLAG_ACTIVE    . ($postponed == FILTER_FLAG_ACTIVE    ? '" checked="true">' : '">') . get_html_resource(RES_SHOW_ACTIVE_ONLY_ID)    . '</radio>'
344
      . '<radio value="' . FILTER_FLAG_POSTPONED . ($postponed == FILTER_FLAG_POSTPONED ? '" checked="true">' : '">') . get_html_resource(RES_SHOW_POSTPONED_ONLY_ID) . '</radio>'
345
      . '</control>';
346
347
$xml .= '</group>';
348
349
// generate list of states
350
351 View Code Duplication
if ($template_id != 0)
352
{
353
    $states = filter_states_get($id, $template_id);
354
355
    $xml .= '<group title="' . get_html_resource(RES_STATES_ID) . '">'
356
          . '<control name="states[]">'
357
          . '<listbox size="10">';
358
359
    $rs = dal_query('states/list.sql', $template_id, 'state_name');
360
361
    while (($row = $rs->fetch()))
362
    {
363
        $xml .= (in_array($row['state_id'], $states)
364
                    ? '<listitem value="' . $row['state_id'] . '" selected="true">'
365
                    : '<listitem value="' . $row['state_id'] . '">')
366
              . ustr2html($row['state_name'])
367
              . '</listitem>';
368
    }
369
370
    $xml .= '</listbox>'
371
          . '</control>'
372
          . '</group>';
373
}
374
375
// generate list of submitters
376
377
$xml .= '<group title="' . get_html_resource(RES_SHOW_CREATED_BY_ONLY_ID) . '">'
378
      . '<control name="created_by[]">'
379
      . '<listbox size="10">';
380
381
$rs = ($project_id == 0)
382
    ? dal_query('filters/membersx2.sql', $_SESSION[VAR_USERID], $id, FILTER_FLAG_CREATED_BY)
383
    : dal_query('filters/membersx.sql',  $project_id,           $id, FILTER_FLAG_CREATED_BY);
384
385 View Code Duplication
while (($row = $rs->fetch()))
386
{
387
    $xml .= ($row['is_selected']
388
                ? '<listitem value="' . $row['account_id'] . '" selected="true">'
389
                : '<listitem value="' . $row['account_id'] . '">')
390
          . ustr2html(sprintf('%s (%s)', $row['fullname'], account_get_username($row['username'])))
391
          . '</listitem>';
392
}
393
394
$xml .= '</listbox>'
395
      . '</control>'
396
      . '</group>';
397
398
// generate list of assignees
399
400
$xml .= '<group title="' . get_html_resource(RES_SHOW_ASSIGNED_TO_ONLY_ID) . '">'
401
      . '<control name="assigned_to[]">'
402
      . '<listbox size="10">';
403
404
$xml .= (($filter['filter_flags'] & FILTER_FLAG_UNASSIGNED) == 0
405
            ? '<listitem value="0">'                 . get_html_resource(RES_NONE_ID) . '</listitem>'
406
            : '<listitem value="0" selected="true">' . get_html_resource(RES_NONE_ID) . '</listitem>');
407
408
$rs = ($project_id == 0)
409
    ? dal_query('filters/membersx2.sql', $_SESSION[VAR_USERID], $id, FILTER_FLAG_ASSIGNED_TO)
410
    : dal_query('filters/membersx.sql',  $project_id,           $id, FILTER_FLAG_ASSIGNED_TO);
411
412 View Code Duplication
while (($row = $rs->fetch()))
413
{
414
    $xml .= ($row['is_selected']
415
                ? '<listitem value="' . $row['account_id'] . '" selected="true">'
416
                : '<listitem value="' . $row['account_id'] . '">')
417
          . ustr2html(sprintf('%s (%s)', $row['fullname'], account_get_username($row['username'])))
418
          . '</listitem>';
419
}
420
421
$xml .= '</listbox>'
422
      . '</control>'
423
      . '</group>';
424
425
// generate template-specific options
426
427
if ($template_id != 0)
428
{
429
    $rs = dal_query('states/list.sql', $template_id, 'state_type, state_name');
430
431
    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 _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.

<?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...
432
    {
433
        // generate list of states with dates
434
435
        $xml .= '<group title="' . get_html_resource(RES_SHOW_MOVED_TO_STATES_ONLY_ID) . '">';
436
437
        while (($row = $rs->fetch()))
438
        {
439
            $name = 'state' . $row['state_id'];
440
441
            $rsd = dal_query('filters/ftfndk.sql', $id, $row['state_id']);
442
443 View Code Duplication
            if ($rsd->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 _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.

<?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...
444
            {
445
                $used = isset($_REQUEST[$name]);
446
447
                $date1 = NULL;
448
                $date2 = NULL;
449
            }
450
            else
451
            {
452
                $used = TRUE;
453
                $temp = $rsd->fetch();
454
455
                $date1 = get_date($temp['date1']);
456
                $date2 = get_date($temp['date2']);
457
            }
458
459
            $xml .= '<control name="' . $name . '">'
460
                  . ($used ? '<label checkmark="true" checked="true">' . ustr2html($row['state_name']) . '</label>'
461
                           : '<label checkmark="true">'                . ustr2html($row['state_name']) . '</label>')
462
                  . '<control name="min_' . $name . '">'
463
                  . '<editbox small="true" maxlen="' . ustrlen(get_date(SAMPLE_DATE)) . '">' . try_request('min_' . $name, $date1) . '</editbox>'
464
                  . '</control>'
465
                  . '<control name="max_' . $name . '">'
466
                  . '<editbox small="true" maxlen="' . ustrlen(get_date(SAMPLE_DATE)) . '">' . try_request('max_' . $name, $date2) . '</editbox>'
467
                  . '</control>'
468
                  . '</control>';
469
        }
470
471
        $xml .= '</group>';
472
473
        // generate list of fields with values
474
475
        $rs->seek();
476
477
        while (($row = $rs->fetch()))
478
        {
479
            $rsf = dal_query('filters/flist.sql',
480
                             $row['state_id'],
481
                             $_SESSION[VAR_USERID],
482
                             FIELD_ALLOW_TO_READ);
483
484
            if ($rsf->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 _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.

<?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...
485
            {
486
                $xml .= '<group title="' . ustrprocess(get_html_resource(RES_FIELDS_OF_STATE_X_ID), $row['state_name']) . '">';
487
488
                while (($row = $rsf->fetch()))
489
                {
490
                    $name = 'field' . $row['field_id'];
491
492
                    $rsp = dal_query('filters/fffndk.sql', $id, $row['field_id']);
493
494 View Code Duplication
                    if ($rsp->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 _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.

<?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...
495
                    {
496
                        $used = isset($_REQUEST[$name]);
497
498
                        $param1 = NULL;
499
                        $param2 = NULL;
500
                    }
501
                    else
502
                    {
503
                        $used = TRUE;
504
                        $temp = $rsp->fetch();
505
506
                        $param1 = $temp['param1'];
507
                        $param2 = $temp['param2'];
508
                    }
509
510
                    $xml .= '<control name="' . $name . '">'
511
                          . ($used ? '<label checkmark="true" checked="true">'
512
                                   : '<label checkmark="true">')
513
                          . ustr2html($row['field_name'])
514
                          . '</label>';
515
516
                    switch ($row['field_type'])
517
                    {
518
                        case FIELD_TYPE_NUMBER:
519
520
                            $xml .= '<control name="min_' . $name . '">'
521
                                  . '<editbox small="true" maxlen="' . (ustrlen(MAX_FIELD_INTEGER) + 1) . '">' . try_request('min_' . $name, $param1) . '</editbox>'
522
                                  . '</control>'
523
                                  . '<control name="max_' . $name . '">'
524
                                  . '<editbox small="true" maxlen="' . (ustrlen(MAX_FIELD_INTEGER) + 1) . '">' . try_request('max_' . $name, $param2) . '</editbox>'
525
                                  . '</control>';
526
527
                            break;
528
529
                        case FIELD_TYPE_FLOAT:
530
531
                            $xml .= '<control name="min_' . $name . '">'
532
                                  . '<editbox small="true" maxlen="' . ustrlen(MIN_FIELD_FLOAT) . '">' . try_request('min_' . $name, value_find(FIELD_TYPE_FLOAT, $param1)) . '</editbox>'
533
                                  . '</control>'
534
                                  . '<control name="max_' . $name . '">'
535
                                  . '<editbox small="true" maxlen="' . ustrlen(MAX_FIELD_FLOAT) . '">' . try_request('max_' . $name, value_find(FIELD_TYPE_FLOAT, $param2)) . '</editbox>'
536
                                  . '</control>';
537
538
                            break;
539
540
                        case FIELD_TYPE_STRING:
541 View Code Duplication
                        case FIELD_TYPE_MULTILINED:
542
543
                            $xml .= '<control name="edit_' . $name . '">'
544
                                  . '<editbox maxlen="' . MAX_FIELD_STRING . '">' . try_request('edit_' . $name, value_find(FIELD_TYPE_STRING, $param1)) . '</editbox>'
545
                                  . '</control>';
546
547
                            break;
548
549 View Code Duplication
                        case FIELD_TYPE_CHECKBOX:
550
551
                            $xml .= '<control name="check_' . $name . '">'
552
                                  . '<label/>'
553
                                  . '<radio value="' . 1 . (try_request('check_' . $name, $param1) != 0 ? '" checked="true">' : '">') . get_html_resource(RES_ON_ID)  . '</radio>'
554
                                  . '<radio value="' . 0 . (try_request('check_' . $name, $param1) == 0 ? '" checked="true">' : '">') . get_html_resource(RES_OFF_ID) . '</radio>'
555
                                  . '</control>';
556
557
                            break;
558
559
                        case FIELD_TYPE_LIST:
560
561
                            $value = try_request('list_' . $name, $param1);
562
563
                            $xml .= '<control name="list_' . $name . '">'
564
                                  . '<combobox>';
565
566
                            $rsv = dal_query('values/lvlist.sql', $row['field_id']);
567
568
                            while (($row = $rsv->fetch()))
569
                            {
570
                                $xml .= ($value == $row['int_value']
571
                                            ? '<listitem value="' . $row['int_value'] . '" selected="true">'
572
                                            : '<listitem value="' . $row['int_value'] . '">')
573
                                      . ustr2html($row['str_value'])
574
                                      . '</listitem>';
575
                            }
576
577
                            $xml .= '</combobox>'
578
                                  . '</control>';
579
580
                            break;
581
582 View Code Duplication
                        case FIELD_TYPE_RECORD:
583
584
                            $xml .= '<control name="edit_' . $name . '">'
585
                                  . '<editbox maxlen="' . ustrlen(MAXINT) . '">' . try_request('edit_' . $name, $param1) . '</editbox>'
586
                                  . '</control>';
587
588
                            break;
589
590 View Code Duplication
                        case FIELD_TYPE_DATE:
591
592
                            $xml .= '<control name="min_' . $name . '">'
593
                                  . '<editbox small="true" maxlen="' . ustrlen(get_date(SAMPLE_DATE)) . '">' . try_request('min_' . $name, $param1) . '</editbox>'
594
                                  . '</control>'
595
                                  . '<control name="max_' . $name . '">'
596
                                  . '<editbox small="true" maxlen="' . ustrlen(get_date(SAMPLE_DATE)) . '">' . try_request('max_' . $name, $param2) . '</editbox>'
597
                                  . '</control>';
598
599
                            break;
600
601 View Code Duplication
                        case FIELD_TYPE_DURATION:
602
603
                            $xml .= '<control name="min_' . $name . '">'
604
                                  . '<editbox small="true" maxlen="' . ustrlen(time2ustr(MAX_FIELD_DURATION)) . '">' . try_request('min_' . $name, $param1) . '</editbox>'
605
                                  . '</control>'
606
                                  . '<control name="max_' . $name . '">'
607
                                  . '<editbox small="true" maxlen="' . ustrlen(time2ustr(MAX_FIELD_DURATION)) . '">' . try_request('max_' . $name, $param2) . '</editbox>'
608
                                  . '</control>';
609
610
                            break;
611
612
                        default:
613
614
                            debug_write_log(DEBUG_WARNING, 'Unknown field type = ' . $row['field_type']);
615
                    }
616
617
                    $xml .= '</control>';
618
                }
619
620
                $xml .= '</group>';
621
            }
622
        }
623
    }
624
}
625
626
// generate footer
627
628
$xml .= '<note>' . get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID) . '</note>'
629
      . '</form>';
630
631
echo(xml2html($xml));
632
633
?>
634