Issues (379)

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.

class/assessment_documentos.php (58 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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 49 and the first side effect is on line 32.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
// $Id: assessment_documentos.php,v 1.10 2007/03/24 17:50:52 marcellobrandao Exp $
3
//  ------------------------------------------------------------------------ //
4
//                XOOPS - PHP Content Management System                      //
5
//                    Copyright (c) 2000 XOOPS.org                           //
6
//                       <http://www.xoops.org/>                             //
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 2 of the License, or        //
11
//  (at your option) any later version.                                      //
12
//                                                                           //
13
//  You may not change or alter any portion of this comment or credits       //
14
//  of supporting developers from this source code or any supporting         //
15
//  source code which is considered copyrighted (c) material of the          //
16
//  original comment or credit authors.                                      //
17
//                                                                           //
18
//  This program is distributed in the hope that it will be useful,          //
19
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21
//  GNU General Public License for more details.                             //
22
//                                                                           //
23
//  You should have received a copy of the GNU General Public License        //
24
//  along with this program; if not, write to the Free Software              //
25
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26
//  ------------------------------------------------------------------------ //
27
// assessment_documentos.php,v 1
28
//  ---------------------------------------------------------------- //
29
//                                             //
30
// ----------------------------------------------------------------- //
31
32
include_once XOOPS_ROOT_PATH . '/kernel/object.php';
33
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
34
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php';
35
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.inc.php';
36
//include_once XOOPS_ROOT_PATH."/class/xoopseditor/mastop_publish/formmpublishtextarea.php";
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
37
include_once XOOPS_ROOT_PATH . '/class/xoopsform/formselecteditor.php';
38
include_once XOOPS_ROOT_PATH . '/class/xoopsform/formeditor.php';
39
//include_once XOOPS_ROOT_PATH."/Frameworks/art/functions.sanitizer.php";
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
40
//include_once XOOPS_ROOT_PATH."/Frameworks/xoops22/class/xoopsform/xoopsformloader.php";
41
42
include_once __DIR__ . '/assessment_perguntas.php';
43
44
/**
45
 * assessment_documentos class.
46
 * $this class is responsible for providing data access mechanisms to the data source
47
 * of XOOPS user class objects.
48
 */
49
class assessment_documentos extends XoopsObject
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
50
{
51
    public $db;
52
53
    // constructor
54
55
    /**
56
     * @param null $id
57
     * @return assessment_documentos
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
58
     */
59
    public function __construct($id = null)
60
    {
61
        $this->db = XoopsDatabaseFactory::getDatabaseConnection();
62
        $this->initVar('cod_documento', XOBJ_DTYPE_INT, null, false, 10);
63
        $this->initVar('titulo', XOBJ_DTYPE_TXTBOX, null, false);
64
        $this->initVar('tipo', XOBJ_DTYPE_INT, null, false, 10);
65
        $this->initVar('cod_prova', XOBJ_DTYPE_INT, null, false, 10);
66
        $this->initVar('cods_perguntas', XOBJ_DTYPE_TXTBOX, null, false);
67
        $this->initVar('documento', XOBJ_DTYPE_TXTAREA, null, false);
68
        $this->initVar('uid_elaborador', XOBJ_DTYPE_INT, null, false, 10);
69
        $this->initVar('fonte', XOBJ_DTYPE_TXTBOX, null, false);
70
        $this->initVar('html', XOBJ_DTYPE_INT, null, false, 10);
71 View Code Duplication
        if (!empty($id)) {
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...
72
            if (is_array($id)) {
73
                $this->assignVars($id);
74
            } else {
75
                $this->load((int)$id);
76
            }
77
        } else {
78
            $this->setNew();
79
        }
80
    }
81
82
    /**
83
     * @param $id
84
     */
85 View Code Duplication
    public function load($id)
0 ignored issues
show
This method 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...
86
    {
87
        $sql   = 'SELECT * FROM ' . $this->db->prefix('assessment_documentos') . ' WHERE cod_documento=' . $id;
88
        $myrow = $this->db->fetchArray($this->db->query($sql));
89
        $this->assignVars($myrow);
90
        if (!$myrow) {
91
            $this->setNew();
92
        }
93
    }
94
95
    /**
96
     * @param array  $criteria
97
     * @param bool   $asobject
98
     * @param string $sort
99
     * @param string $order
100
     * @param int    $limit
101
     * @param int    $start
102
     *
103
     * @return array
104
     */
105 View Code Duplication
    public function getAllassessment_documentoss($criteria = array(), $asobject = false, $sort = 'cod_documento', $order = 'ASC', $limit = 0, $start = 0)
0 ignored issues
show
This method 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...
106
    {
107
        $db          = XoopsDatabaseFactory::getDatabaseConnection();
108
        $ret         = array();
109
        $where_query = '';
110
        if (is_array($criteria) && count($criteria) > 0) {
111
            $where_query = ' WHERE';
112
            foreach ($criteria as $c) {
113
                $where_query .= " $c AND";
114
            }
115
            $where_query = substr($where_query, 0, -4);
116
        } elseif (!is_array($criteria) && $criteria) {
117
            $where_query = ' WHERE ' . $criteria;
118
        }
119
        if (!$asobject) {
120
            $sql    = 'SELECT cod_documento FROM ' . $db->prefix('assessment_documentos') . "$where_query ORDER BY $sort $order";
121
            $result = $db->query($sql, $limit, $start);
122
            while ($myrow = $db->fetchArray($result)) {
123
                $ret[] = $myrow['assessment_documentos_id'];
124
            }
125
        } else {
126
            $sql    = 'SELECT * FROM ' . $db->prefix('assessment_documentos') . "$where_query ORDER BY $sort $order";
127
            $result = $db->query($sql, $limit, $start);
128
            while ($myrow = $db->fetchArray($result)) {
129
                $ret[] = new assessment_documentos($myrow);
130
            }
131
        }
132
133
        return $ret;
134
    }
135
}
136
137
// -------------------------------------------------------------------------
138
// ------------------assessment_documentos user handler class -------------------
139
// -------------------------------------------------------------------------
140
141
/**
142
 * assessment_documentoshandler class.
143
 * This class provides simple mecanisme for assessment_documentos object
144
 */
145
class Xoopsassessment_documentosHandler extends XoopsPersistableObjectHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
146
{
147
    /**
148
     * create a new assessment_documentos
149
     *
150
     * @param bool $isNew flag the new objects as "new"?
151
     *
152
     * @return object assessment_documentos
153
     */
154
    public function &create($isNew = true)
155
    {
156
        $assessment_documentos = new assessment_documentos();
157
        if ($isNew) {
158
            $assessment_documentos->setNew();
159
        } else {
160
            $assessment_documentos->unsetNew();
161
        }
162
163
        return $assessment_documentos;
164
    }
165
166
    /**
167
     * retrieve a assessment_documentos
168
     *
169
     * @param  mixed $id     ID
170
     * @param  array $fields fields to fetch
0 ignored issues
show
Should the type for parameter $fields not be array|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
171
     * @return XoopsObject {@link XoopsObject}
0 ignored issues
show
Should the return type not be false|assessment_documentos?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
172
     */
173 View Code Duplication
    public function get($id = null, $fields = null)
0 ignored issues
show
This method 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...
174
    {
175
        $sql = 'SELECT * FROM ' . $this->db->prefix('assessment_documentos') . ' WHERE cod_documento=' . $id;
176
        if (!$result = $this->db->query($sql)) {
177
            return false;
178
        }
179
        $numrows = $this->db->getRowsNum($result);
180
        if ($numrows == 1) {
181
            $assessment_documentos = new assessment_documentos();
182
            $assessment_documentos->assignVars($this->db->fetchArray($result));
183
184
            return $assessment_documentos;
185
        }
186
187
        return false;
188
    }
189
190
    /**
191
     * insert a new assessment_documentos in the database
192
     *
193
     * @param XoopsObject $assessment_documentos reference to the {@link assessment_documentos} object
194
     * @param  bool       $force                 flag to force the query execution despite security settings
195
     *
196
     * @return bool FALSE if failed, TRUE if already present and unchanged or successful
197
     */
198
    public function insert(XoopsObject $assessment_documentos, $force = false)
199
    {
200
        global $xoopsConfig;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
201
        if (get_class($assessment_documentos) != 'assessment_documentos') {
202
            return false;
203
        }
204
        if (!$assessment_documentos->isDirty()) {
205
            return true;
206
        }
207
        if (!$assessment_documentos->cleanVars()) {
208
            return false;
209
        }
210
        foreach ($assessment_documentos->cleanVars as $k => $v) {
211
            ${$k} = $v;
212
        }
213
        $now = 'date_add(now(), interval ' . $xoopsConfig['server_TZ'] . ' hour)';
0 ignored issues
show
$now is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
214
        if ($assessment_documentos->isNew()) {
215
            // ajout/modification d'un assessment_documentos
216
            $assessment_documentos = new assessment_documentos();
217
            $format                = 'INSERT INTO %s (cod_documento, titulo, tipo, cod_prova, cods_perguntas, documento, uid_elaborador, fonte, html)';
218
            $format                .= 'VALUES (%u, %s, %u, %u, %s, %s, %u, %s, %u)';
219
            $sql                   = sprintf($format, $this->db->prefix('assessment_documentos'), $cod_documento, $this->db->quoteString($titulo), $tipo, $cod_prova, $this->db->quoteString($cods_perguntas), $this->db->quoteString($documento),
0 ignored issues
show
The variable $cod_documento seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
The variable $titulo does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
The variable $tipo does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
The variable $cod_prova does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
The variable $cods_perguntas does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
The variable $documento does not exist. Did you mean $assessment_documentos?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
220
                                             $uid_elaborador, $this->db->quoteString($fonte), $html);
0 ignored issues
show
The variable $uid_elaborador does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
The variable $fonte does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
The variable $html does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
221
            $force                 = true;
222
        } else {
223
            $format = 'UPDATE %s SET ';
224
            $format .= 'cod_documento=%u, titulo=%s, tipo=%u, cod_prova=%u, cods_perguntas=%s, documento=%s, uid_elaborador=%u, fonte=%s, html=%u';
225
            $format .= ' WHERE cod_documento = %u';
226
            $sql    = sprintf($format, $this->db->prefix('assessment_documentos'), $cod_documento, $this->db->quoteString($titulo), $tipo, $cod_prova, $this->db->quoteString($cods_perguntas), $this->db->quoteString($documento), $uid_elaborador,
0 ignored issues
show
The variable $cod_documento seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
The variable $documento does not exist. Did you mean $assessment_documentos?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
227
                              $this->db->quoteString($fonte), $html, $cod_documento);
0 ignored issues
show
The variable $cod_documento seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
228
        }
229
        if (false != $force) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
230
            $result = $this->db->queryF($sql);
231
        } else {
232
            $result = $this->db->query($sql);
233
        }
234
        if (!$result) {
235
            return false;
236
        }
237
        if (empty($cod_documento)) {
0 ignored issues
show
The variable $cod_documento seems only to be defined at a later point. As such the call to empty() seems to always evaluate to true.

This check marks calls to isset(...) or empty(...) that are found before the variable itself is defined. These will always have the same result.

This is likely the result of code being shifted around. Consider removing these calls.

Loading history...
238
            $cod_documento = $this->db->getInsertId();
239
        }
240
        $assessment_documentos->assignVar('cod_documento', $cod_documento);
241
242
        return true;
243
    }
244
245
    /**
246
     * delete a assessment_documentos from the database
247
     *
248
     * @param XoopsObject $assessment_documentos reference to the assessment_documentos to delete
249
     * @param bool        $force
250
     *
251
     * @return bool FALSE if failed.
252
     */
253 View Code Duplication
    public function delete(XoopsObject $assessment_documentos, $force = false)
0 ignored issues
show
This method 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...
254
    {
255
        if (get_class($assessment_documentos) != 'assessment_documentos') {
256
            return false;
257
        }
258
        $sql = sprintf('DELETE FROM %s WHERE cod_documento = %u', $this->db->prefix('assessment_documentos'), $assessment_documentos->getVar('cod_documento'));
259
        if (false != $force) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
260
            $result = $this->db->queryF($sql);
261
        } else {
262
            $result = $this->db->query($sql);
263
        }
264
        if (!$result) {
265
            return false;
266
        }
267
268
        return true;
269
    }
270
271
    /**
272
     * retrieve assessment_documentoss from the database
273
     *
274
     * @param CriteriaElement $criteria  {@link CriteriaElement} conditions to be met
0 ignored issues
show
Should the type for parameter $criteria not be null|CriteriaElement?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
275
     * @param bool            $id_as_key use the UID as key for the array?
276
     *
277
     * @param bool            $as_object
278
     * @return array array of <a href='psi_element://$assessment_documentos'>$assessment_documentos</a> objects
279
     *                                   objects
280
     */
281 View Code Duplication
    public function &getObjects(CriteriaElement $criteria = null, $id_as_key = false, $as_object = true)
0 ignored issues
show
This method 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...
282
    {
283
        $ret   = array();
284
        $limit = $start = 0;
285
        $sql   = 'SELECT * FROM ' . $this->db->prefix('assessment_documentos');
286
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
0 ignored issues
show
Due to PHP Bug #53727, is_subclass_of returns inconsistent results on some PHP versions for interfaces; you could instead use ReflectionClass::implementsInterface.
Loading history...
287
            $sql .= ' ' . $criteria->renderWhere();
288
            if ($criteria->getSort() != '') {
289
                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
290
            }
291
            $limit = $criteria->getLimit();
292
            $start = $criteria->getStart();
293
        }
294
        $result = $this->db->query($sql, $limit, $start);
295
        if (!$result) {
296
            return $ret;
297
        }
298
        while ($myrow = $this->db->fetchArray($result)) {
299
            $assessment_documentos = new assessment_documentos();
300
            $assessment_documentos->assignVars($myrow);
301
            if (!$id_as_key) {
302
                $ret[] =& $assessment_documentos;
303
            } else {
304
                $ret[$myrow['cod_documento']] =& $assessment_documentos;
305
            }
306
            unset($assessment_documentos);
307
        }
308
309
        return $ret;
310
    }
311
312
    /**
313
     * retrieve assessment_documentoss from the database
314
     *
315
     * @param $cod_prova
316
     * @param $cod_pergunta
317
     * @return array array of <a href='psi_element://assessment_documentos'>assessment_documentos</a> objects
318
     * objects
319
     * @internal param object $criteria <a href='psi_element://CriteriaElement'>CriteriaElement</a> conditions to be met conditions to be met conditions to be met conditions to be met
320
     * @internal param bool $id_as_key use the UID as key for the array?
321
     *
322
     */
323
    public function &getDocumentosProvaPergunta($cod_prova, $cod_pergunta)
324
    {
325
        $criteria         = new criteria('cod_prova', $cod_prova);
326
        $cod_documentos   = array();
0 ignored issues
show
$cod_documentos is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
327
        $documentos_prova = $this->getObjects($criteria);
328
        $i                = 0;
329
        foreach ($documentos_prova as $documento_prova) {
330
            $cods_perguntas = explode(',', $documento_prova->getVar('cods_perguntas'));
331
            if (in_array($cod_pergunta, $cods_perguntas)) {
332
                $documentos[$i]['titulo'] = $documento_prova->getVar('titulo');
0 ignored issues
show
Coding Style Comprehensibility introduced by
$documentos was never initialized. Although not strictly required by PHP, it is generally a good practice to add $documentos = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
333
                $documentos[$i]['fonte']  = $documento_prova->getVar('fonte');
0 ignored issues
show
The variable $documentos does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
334
                /*if ($xoopsModuleConfig['editorpadrao']=="dhtmlext"||$xoopsModuleConfig['editorpadrao']=="textarea") {
0 ignored issues
show
Unused Code Comprehensibility introduced by
78% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
335
                $documentos[$i]['documento']= text_filter($documento_prova->getVar('documento',"s"),true);} else {
336
                $documentos[$i]['documento']= text_filter($documento_prova->getVar('documento',"n"),true);
337
                    }*/
338
                if ($documento_prova->getVar('html') == 1) {
339
                    //$documentos[$i]['documento']= text_filter($documento_prova->getVar('documento',"n"),true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
83% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
340
                    $documentos[$i]['documento'] = $documento_prova->getVar('documento', 'n');
341
                } else {
342
                    $documentos[$i]['documento'] = text_filter($documento_prova->getVar('documento', 's'), true);
343
                }
344
                ++$i;
345
            }
346
        }
347
348
        return $documentos;
349
    }
350
351
    /**
352
     * count assessment_documentoss matching a condition
353
     *
354
     * @param CriteriaElement $criteria {@link CriteriaElement} to match
0 ignored issues
show
Should the type for parameter $criteria not be null|CriteriaElement?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
355
     *
356
     * @return int count of assessment_documentoss
357
     */
358 View Code Duplication
    public function getCount(CriteriaElement $criteria = null)
0 ignored issues
show
This method 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...
359
    {
360
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('assessment_documentos');
361
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
0 ignored issues
show
Due to PHP Bug #53727, is_subclass_of returns inconsistent results on some PHP versions for interfaces; you could instead use ReflectionClass::implementsInterface.
Loading history...
362
            $sql .= ' ' . $criteria->renderWhere();
363
        }
364
        $result = $this->db->query($sql);
365
        if (!$result) {
366
            return 0;
367
        }
368
        list($count) = $this->db->fetchRow($result);
369
370
        return $count;
371
    }
372
373
    /**
374
     * delete assessment_documentoss matching a set of conditions
375
     *
376
     * @param CriteriaElement $criteria {@link CriteriaElement}
0 ignored issues
show
Should the type for parameter $criteria not be null|CriteriaElement?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
377
     *
378
     * @param bool            $force
379
     * @param bool            $asObject
380
     * @return bool FALSE if deletion failed
381
     */
382 View Code Duplication
    public function deleteAll(CriteriaElement $criteria = null, $force = true, $asObject = false)
0 ignored issues
show
This method 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...
383
    {
384
        $sql = 'DELETE FROM ' . $this->db->prefix('assessment_documentos');
385
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
0 ignored issues
show
Due to PHP Bug #53727, is_subclass_of returns inconsistent results on some PHP versions for interfaces; you could instead use ReflectionClass::implementsInterface.
Loading history...
386
            $sql .= ' ' . $criteria->renderWhere();
387
        }
388
        if (!$result = $this->db->query($sql)) {
389
            return false;
390
        }
391
392
        return true;
393
    }
394
395
    /* cria form de inser��o e edi��o de pergunta
396
    *
397
    * @param string $action caminho para arquivo que ...
398
    * @param object $assessment_perguntas {@link assessment_perguntas}
399
    * @return bool FALSE if deletion failed
400
    */
401
    /**
402
     * @param $action
403
     * @param $cod_prova
404
     *
405
     * @return bool
406
     */
407
    public function renderFormCadastrar($action, $cod_prova)
0 ignored issues
show
renderFormCadastrar uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
renderFormCadastrar uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
408
    {
409
        global $xoopsDB, $xoopsUser;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
410
411
        $fabrica_de_perguntas = new Xoopsassessment_perguntasHandler($xoopsDB);
412
        $criteria             = new criteria('cod_prova', $cod_prova);
413
414
        $vetor_perguntas = $fabrica_de_perguntas->getObjects($criteria);
415
        $campo_perguntas = new XoopsFormSelect(_AM_ASSESSMENT_PERGASSOC, 'campo_perguntas', null, 10, true);
416
417
        foreach ($vetor_perguntas as $pergunta) {
418
            $campo_perguntas->addOption($pergunta->getVar('cod_pergunta'), $pergunta->getVar('titulo'));
419
        }
420
421
        $form           = new XoopsThemeForm(_AM_ASSESSMENT_CADASTRAR . ' ' . _AM_ASSESSMENT_DOCUMENTO, 'form_documento', $action, 'post', true);
422
        $campo_titulo   = new XoopsFormTextArea(_AM_ASSESSMENT_TITULO, 'campo_titulo', '', 2, 50);
423
        $campo_fonte    = new XoopsFormText(_AM_ASSESSMENT_FONTE, 'campo_fonte', 35, 20);
424
        $campo_codprova = new XoopsFormHidden('campo_codprova', $cod_prova);
425
426
        $form->setExtra('enctype="multipart/form-data"');
427
428
        if (!is_object($GLOBALS['xoopsModule']) || $GLOBALS['xoopsModule']->getVar('dirname') != 'assessment') {
429
            $modhandler    = &xoops_getHandler('module');
430
            $module        = &$modhandler->getByDirname('assessment');
431
            $configHandler = &xoops_getHandler('config');
432
            $moduleConfig  = &$configHandler->getConfigsByCat(0, $module->getVar('mid'));
433
        } else {
434
            $moduleConfig =& $GLOBALS['xoopsModuleConfig'];
435
        }
436
        $editor = $moduleConfig['editorpadrao'];
437
438
        // Add the editor selection box
439
        // If dohtml is disabled, set $noHtml = true
440
        //$form->addElement(new XoopsFormSelectEditor($form, "editor", $editor, $noHtml = false));
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
441
442
        // options for the editor
443
        //required configs
444
        $options['name']  = 'campo_documento';
0 ignored issues
show
Coding Style Comprehensibility introduced by
$options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $options = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
445
        $options['value'] = empty($_REQUEST['message']) ? '' : $_REQUEST['message'];
446
        //optional configs
447
        $options['rows']   = 25; // default value = 5
448
        $options['cols']   = 60; // default value = 50
449
        $options['width']  = '100%'; // default value = 100%
450
        $options['height'] = '400px'; // default value = 400px
451
452
        // "textarea": if the selected editor with name of $editor can not be created, the editor "textarea" will be used
453
        // if no $onFailure is set, then the first available editor will be used
454
        // If dohtml is disabled, set $noHtml to true
455
        $campo_documento = new XoopsFormEditor(_AM_ASSESSMENT_DOCUMENTO, $editor, $options, $nohtml = false, $onfailure = 'textarea');
456
        $botao_enviar    = new XoopsFormButton(_AM_ASSESSMENT_CADASTRAR, 'botao_submit', _SUBMIT, 'submit');
457
458
        $form->addElement($campo_codprova);
459
        $form->addElement($campo_titulo, true);
460
        $form->addElement($campo_documento, true);
461
        $form->addElement($campo_fonte, true);
462
        $form->addElement($campo_perguntas, true);
463
        $form->addElement($botao_enviar);
464
        $form->display();
465
466
        return true;
467
    }
468
469
    /**
470
     * @param $action
471
     * @param $cod_documento
472
     *
473
     * @return bool
474
     */
475
    public function renderFormEditar($action, $cod_documento)
0 ignored issues
show
renderFormEditar uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
476
    {
477
        global $xoopsDB, $xoopsUser, $xoopsModuleConfig;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
478
479
        $documento = $this->get($cod_documento);
480
        $titulo    = $documento->getVar('titulo', 's');
481
        //$textodocumento = text_filter($documento->getVar('documento',"f"),true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
482
        $textodocumento               = $documento->getVar('documento', 'f');
483
        $fonte                        = $documento->getVar('fonte', 's');
484
        $uid_elaborador               = $documento->getVar('uid_elaborador', 's');
0 ignored issues
show
$uid_elaborador is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
485
        $cod_prova                    = $documento->getVar('cod_prova', 's');
486
        $vetor_perguntas_selecionadas = explode(',', $documento->getVar('cods_perguntas', 's'));
487
488
        $fabrica_de_perguntas = new Xoopsassessment_perguntasHandler($xoopsDB);
489
        $criteria             = new criteria('cod_prova', $cod_prova);
490
491
        $vetor_perguntas = $fabrica_de_perguntas->getObjects($criteria);
492
        $campo_perguntas = new XoopsFormSelect('Perguntas associadas', 'campo_perguntas', $vetor_perguntas_selecionadas, 10, true);
493
494
        foreach ($vetor_perguntas as $pergunta) {
495
            $campo_perguntas->addOption($pergunta->getVar('cod_pergunta'), $pergunta->getVar('titulo'));
496
        }
497
498
        $form               = new XoopsThemeForm(_AM_ASSESSMENT_EDITAR . ' ' . _AM_ASSESSMENT_DOCUMENTO, 'form_documento', $action, 'post', true);
499
        $campo_titulo       = new XoopsFormTextArea(_AM_ASSESSMENT_TITULO, 'campo_titulo', $titulo, 2, 50);
500
        $campo_fonte        = new XoopsFormText(_AM_ASSESSMENT_FONTE, 'campo_fonte', 35, 20, $fonte);
501
        $campo_coddocumento = new XoopsFormHidden('campo_coddocumento', $cod_documento);
502
        $campo_codprova     = new XoopsFormHidden('campo_codprova', $cod_prova);
503
        $form->setExtra('enctype="multipart/form-data"');
504
505
        $editor = $xoopsModuleConfig['editorpadrao'];
506
507
        // Add the editor selection box
508
        // If dohtml is disabled, set $noHtml = true
509
        //$form->addElement(new XoopsFormSelectEditor($form, "editor", $editor, $noHtml = false));
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
510
511
        // options for the editor
512
        //required configs
513
        $options['name']  = 'campo_documento';
0 ignored issues
show
Coding Style Comprehensibility introduced by
$options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $options = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
514
        $options['value'] = empty($_REQUEST['message']) ? $textodocumento : $_REQUEST['message'];
515
        //optional configs
516
        $options['rows']   = 25; // default value = 5
517
        $options['cols']   = 60; // default value = 50
518
        $options['width']  = '100%'; // default value = 100%
519
        $options['height'] = '400px'; // default value = 400px
520
521
        // "textarea": if the selected editor with name of $editor can not be created, the editor "textarea" will be used
522
        // if no $onFailure is set, then the first available editor will be used
523
        // If dohtml is disabled, set $noHtml to true
524
        $campo_documento = new XoopsFormEditor(_AM_ASSESSMENT_DOCUMENTO, $editor, $options, $nohtml = false, $onfailure = 'textarea');
525
        $botao_enviar    = new XoopsFormButton(_AM_ASSESSMENT_EDITAR, 'botao_submit', _SUBMIT, 'submit');
526
527
        $form->addElement($campo_coddocumento);
528
        $form->addElement($campo_titulo, true);
529
        $form->addElement($campo_documento, true);
530
        $form->addElement($campo_fonte, true);
531
        $form->addElement($campo_perguntas, true);
532
        $form->addElement($campo_codprova);
533
        $form->addElement($botao_enviar);
534
        $form->display();
535
536
        return true;
537
    }
538
539
    /**
540
     * Copia os documentos e salva eles ligados � prova clone
541
     *
542
     * @param object $criteria {@link CriteriaElement} to match
543
     *
544
     * @param        $cod_prova
545
     * @return int count of assessment_perguntass
0 ignored issues
show
Should the return type not be integer|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
546
     */
547
    public function clonarDocumentos($criteria, $cod_prova)
548
    {
549
        global $xoopsDB;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
550
551
        $documentos = $this->getObjects($criteria);
552
        foreach ($documentos as $documento) {
553
            $documento->setVar('cod_prova', $cod_prova);
554
            $documento->setVar('cod_documento', 0);
555
            $documento->setNew();
556
            $this->insert($documento);
557
        }
558
    }
559
}
560