Completed
Push — master ( 9d3fbd...af269e )
by Michael
09:48
created

incrementListViews()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
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 29 and the first side effect is on line 24.

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
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * oledrion
14
 *
15
 * @copyright   {@link https://xoops.org/ XOOPS Project}
16
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @author      Hervé Thouzard (http://www.herve-thouzard.com/)
18
 */
19
/**
20
 * Gestion des listes utilisateurs
21
 *
22
 * @since 2.3.2009.06.13
23
 */
24
require_once __DIR__ . '/classheader.php';
25
26
/**
27
 * Définition des types de listes
28
 */
29
define('OLEDRION_LISTS_ALL_PUBLIC', -2); // Que les publiques
30
define('OLEDRION_LISTS_ALL', -1); // Toutes sans distinction
31
define('OLEDRION_LISTS_PRIVATE', 0);
32
define('OLEDRION_LISTS_WISH', 1);
33
define('OLEDRION_LISTS_RECOMMEND', 2);
34
35
/**
36
 * Class Oledrion_lists
37
 */
38
class Oledrion_lists extends Oledrion_Object
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...
39
{
40
    /**
41
     * constructor
42
     *
43
     * normally, this is called from child classes only
44
     *
45
     * @access public
46
     */
47
    public function __construct()
48
    {
49
        $this->initVar('list_id', XOBJ_DTYPE_INT, null, false);
50
        $this->initVar('list_uid', XOBJ_DTYPE_INT, null, false);
51
        $this->initVar('list_title', XOBJ_DTYPE_TXTBOX, null, false);
52
        $this->initVar('list_date', XOBJ_DTYPE_INT, null, false);
53
        $this->initVar('list_productscount', XOBJ_DTYPE_INT, null, false);
54
        $this->initVar('list_views', XOBJ_DTYPE_INT, null, false);
55
        $this->initVar('list_password', XOBJ_DTYPE_TXTBOX, null, false);
56
        $this->initVar('list_type', XOBJ_DTYPE_INT, null, false);
57
        $this->initVar('list_description', XOBJ_DTYPE_TXTAREA, null, false);
58
    }
59
60
    /**
61
     * Indique si la liste courante est accessible de l'utilisateur courant
62
     *
63
     * @return boolean
64
     */
65
    public function isSuitableForCurrentUser()
66
    {
67
        $uid = OledrionUtility::getCurrentUserID();
68
        if ($this->getVar('list_type') == OLEDRION_LISTS_PRIVATE) {
69
            if ($uid == 0 || $uid != $this->getVar('list_uid')) {
70
                return false;
71
            }
72
        }
73
74
        return true;
75
    }
76
77
    /**
78
     * Retourne un tableau associatif qui pour chaque type de liste indique son type sous forme de texte
79
     *
80
     * @return array
81
     */
82
    public static function getTypesArray()
83
    {
84
        return array(
85
            OLEDRION_LISTS_PRIVATE   => _OLEDRION_LIST_PRIVATE,
86
            OLEDRION_LISTS_WISH      => _OLEDRION_LIST_PUBLIC_WISH_LIST,
87
            OLEDRION_LISTS_RECOMMEND => _OLEDRION_LIST_PUBLIC_RECOMMENDED_LIST
88
        );
89
    }
90
91
    /**
92
     * Retourne la description de la liste courante
93
     *
94
     * @return string
95
     */
96
    public function getListTypeDescription()
97
    {
98
        $description = static::getTypesArray();
99
100
        return $description[$this->list_type];
101
    }
102
103
    /**
104
     * Retourne l'url à utiliser pour accéder à la liste en tenant compte des préférences du module
105
     *
106
     * @return string L'url à utiliser
107
     */
108 View Code Duplication
    public function getLink()
0 ignored issues
show
Duplication introduced by
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...
109
    {
110
        $url = '';
0 ignored issues
show
Unused Code introduced by
$url 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...
111
        if (OledrionUtility::getModuleOption('urlrewriting') == 1) { // On utilise l'url rewriting
112
            $url = OLEDRION_URL . 'list-' . $this->getVar('list_id') . OledrionUtility::makeSeoUrl($this->getVar('list_title', 'n')) . '.html';
113
        } else { // Pas d'utilisation de l'url rewriting
114
            $url = OLEDRION_URL . 'list.php?list_id=' . $this->getVar('list_id');
115
        }
116
117
        return $url;
118
    }
119
120
    /**
121
     * Retourne la date de création de la liste formatée
122
     *
123
     * @param  string $format
124
     * @return string
125
     */
126
    public function getFormatedDate($format = 's')
127
    {
128
        return formatTimestamp($this->list_date, $format);
129
    }
130
131
    /**
132
     * Rentourne la chaine à utiliser dans une balise <a> pour l'attribut href
133
     *
134
     * @return string
135
     */
136
    public function getHrefTitle()
137
    {
138
        return OledrionUtility::makeHrefTitle($this->getVar('list_title'));
139
    }
140
141
    /**
142
     * Retourne le nom de l'auteur de la liste courante
143
     *
144
     * @return string
145
     */
146
    public function getListAuthorName()
147
    {
148
        return XoopsUser::getUnameFromId($this->getVar('list_uid', true));
149
    }
150
151
    /**
152
     * Retourne les éléments formatés pour affichage (en général)
153
     *
154
     * @param  string $format
155
     * @return array
156
     */
157
    public function toArray($format = 's')
158
    {
159
        $ret                          = array();
0 ignored issues
show
Unused Code introduced by
$ret 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...
160
        $ret                          = parent::toArray($format);
161
        $ret['list_type_description'] = $this->getListTypeDescription();
162
        $ret['list_href_title']       = $this->getHrefTitle();
163
        $ret['list_url_rewrited']     = $this->getLink();
164
        $ret['list_formated_date']    = $this->getFormatedDate();
165
        $ret['list_username']         = $this->getListAuthorName();
166
        $ret['list_formated_count']   = sprintf(_OLEDRION_PRODUCTS_COUNT, $this->getVar('list_productscount'));
167
168
        return $ret;
169
    }
170
}
171
172
/**
173
 * Class OledrionOledrion_listsHandler
174
 */
175
class OledrionOledrion_listsHandler extends Oledrion_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...
176
{
177
    /**
178
     * OledrionOledrion_listsHandler constructor.
179
     * @param XoopsDatabase|null $db
180
     */
181
    public function __construct(XoopsDatabase $db)
182
    { //                            Table               Classe           Id       Identifiant
183
        parent::__construct($db, 'oledrion_lists', 'oledrion_lists', 'list_id', 'list_title');
184
    }
185
186
    /**
187
     * Incrémente le compteur de vues d'une liste
188
     *
189
     * @param  oledrion_lists $list
190
     * @return boolean
191
     */
192 View Code Duplication
    public function incrementListViews(Oledrion_lists $list)
0 ignored issues
show
Duplication introduced by
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...
193
    {
194
        $res = true;
195
        if (OledrionUtility::getCurrentUserID() != $list->getVar('list_uid')) {
196
            $sql = 'UPDATE ' . $this->table . ' SET list_views = list_views + 1 WHERE list_id = ' . $list->getVar('list_id');
197
            $res = $this->db->queryF($sql);
198
            $this->forceCacheClean();
199
        }
200
201
        return $res;
202
    }
203
204
    /**
205
     * Incrémente le nombre de produits dans une liste
206
     *
207
     * @param  oledrion_lists $list
208
     * @return boolean
209
     */
210
    public function incrementListProductsCount(Oledrion_lists $list)
211
    {
212
        $res = true;
0 ignored issues
show
Unused Code introduced by
$res 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...
213
        $sql = 'UPDATE ' . $this->table . ' SET list_productscount = list_productscount + 1 WHERE list_id = ' . $list->getVar('list_id');
214
        $res = $this->db->queryF($sql);
215
        $this->forceCacheClean();
216
217
        return $res;
218
    }
219
220
    /**
221
     * Décrémente le nombre de produits dans une liste
222
     *
223
     * @param  oledrion_lists $list
224
     * @param  int            $value
225
     * @return bool
226
     */
227 View Code Duplication
    public function decrementListProductsCount(Oledrion_lists $list, $value = 1)
0 ignored issues
show
Duplication introduced by
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...
228
    {
229
        $value = (int)$value;
0 ignored issues
show
Unused Code introduced by
$value 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...
230
        $res   = true;
0 ignored issues
show
Unused Code introduced by
$res 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...
231
        $sql   = 'UPDATE ' . $this->table . ' SET list_productscount = list_productscount - $value WHERE list_id = ' . $list->getVar('list_id');
232
        $res   = $this->db->queryF($sql);
233
        $this->forceCacheClean();
234
235
        return $res;
236
    }
237
238
    /**
239
     * Retourne la liste des listes récentes
240
     *
241
     * @param  Oledrion_parameters $parameters
242
     * @return array               Tableau d'objets de type oledrion_lists [clé] = id liste
243
     * @internal param int $start
244
     * @internal param int $limit
245
     * @internal param string $sort
246
     * @internal param string $order
247
     * @internal param bool $idAsKey
248
     * @internal param int $listType
249
     * @internal param int $list_uid
250
     */
251
    public function getRecentLists(Oledrion_parameters $parameters)
252
    {
253
        $parameters = $parameters->extend(new Oledrion_parameters(array(
0 ignored issues
show
Documentation introduced by
new \Oledrion_parameters..._ALL, 'list_uid' => 0)) is of type object<Oledrion_parameters>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
254
                                                                      'start'    => 0,
255
                                                                      'limit'    => 0,
256
                                                                      'sort'     => 'list_date',
257
                                                                      'order'    => 'DESC',
258
                                                                      'idAsKey'  => true,
259
                                                                      'listType' => OLEDRION_LISTS_ALL,
260
                                                                      'list_uid' => 0
261
                                                                  )));
262
        $criteria   = new CriteriaCompo();
263 View Code Duplication
        switch ($parameters['listType']) {
0 ignored issues
show
Duplication introduced by
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...
264
            case OLEDRION_LISTS_ALL:
265
                $criteria->add(new Criteria('list_id', 0, '<>'));
266
                break;
267
            case OLEDRION_LISTS_ALL_PUBLIC:
268
                $criteria->add(new Criteria('list_type', OLEDRION_LISTS_WISH, '='));
269
                $criteria->add(new Criteria('list_type', OLEDRION_LISTS_RECOMMEND, '='), 'OR');
270
                break;
271
            default:
272
                $criteria->add(new Criteria('list_type', $parameters['listType'], '='));
273
                break;
274
        }
275
        if ($parameters['list_uid'] > 0) {
276
            $criteria->add(new Criteria('list_uid', $parameters['list_uid'], '='));
277
        }
278
        $criteria->setSort($parameters['sort']);
279
        $criteria->setOrder($parameters['order']);
280
        $criteria->setStart($parameters['start']);
281
        $criteria->setLimit($parameters['limit']);
282
283
        return $this->getObjects($criteria, $parameters['idAsKey']);
284
    }
285
286
    /**
287
     * Retourne le nombre de listes d'un certain type
288
     *
289
     * @param  integer $listType
290
     * @param  integer $list_uid
291
     * @return integer
292
     */
293
    public function getRecentListsCount($listType = OLEDRION_LISTS_ALL, $list_uid = 0)
294
    {
295
        $criteria = new CriteriaCompo();
296 View Code Duplication
        switch ($listType) {
0 ignored issues
show
Duplication introduced by
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...
297
            case OLEDRION_LISTS_ALL:
298
                $criteria->add(new Criteria('list_id', 0, '<>'));
299
                break;
300
            case OLEDRION_LISTS_ALL_PUBLIC:
301
                $criteria->add(new Criteria('list_type', OLEDRION_LISTS_WISH, '='));
302
                $criteria->add(new Criteria('list_type', OLEDRION_LISTS_RECOMMEND, '='), 'OR');
303
                break;
304
            default:
305
                $criteria->add(new Criteria('list_type', $listType, '='));
306
                break;
307
        }
308
        if ($list_uid > 0) {
309
            $criteria->add(new Criteria('list_uid', $list_uid, '='));
310
        }
311
312
        return $this->getCount($criteria);
313
    }
314
315
    /**
316
     * Retourne une liste d'utilisateurs Xoops en fonction d'une liste de listes
317
     *
318
     * @param  array $oledrion_lists
319
     * @return array [clé] = id utilisateur
320
     */
321
    public function getUsersFromLists($oledrion_lists)
322
    {
323
        $usersList = array();
324
        foreach ($oledrion_lists as $list) {
325
            $usersList[] = $list->list_uid;
326
        }
327
        if (count($usersList) > 0) {
328
            return OledrionUtility::getUsersFromIds($usersList);
329
        } else {
330
            return array();
331
        }
332
    }
333
334
    /**
335
     * Suppression d'une liste (et des produits qui lui sont rattachés)
336
     *
337
     * @param  oledrion_lists $list
338
     * @return boolean
339
     */
340
    public function deleteList(Oledrion_lists $list)
341
    {
342
        $handlers = OledrionHandler::getInstance();
343
        $handlers->h_oledrion_products_list->deleteListProducts($list);
344
345
        return $this->delete($list, true);
346
    }
347
348
    /**
349
     * Retourne les produits d'une liste
350
     *
351
     * @param  oledrion_lists $list
352
     * @return array          Objets de type oledrion_products
353
     */
354
    public function getListProducts(Oledrion_lists $list)
355
    {
356
        $productsInList = $ret = $productsIds = array();
0 ignored issues
show
Unused Code introduced by
$productsInList 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...
357
        $handlers       = OledrionHandler::getInstance();
358
        $productsInList = $handlers->h_oledrion_products_list->getProductsFromList($list);
359
        if (count($productsInList) == 0) {
360
            return $ret;
361
        }
362
        foreach ($productsInList as $product) {
363
            $productsIds[] = $product->getVar('productlist_product_id');
364
        }
365
        if (count($productsIds) > 0) {
366
            $ret = $handlers->h_oledrion_products->getProductsFromIDs($productsIds);
367
        }
368
369
        return $ret;
370
    }
371
372
    /**
373
     * Indique si une liste appartient bien à un utilisateur
374
     *
375
     * @param  integer $list_id
376
     * @param  integer $list_uid
377
     * @return boolean
378
     */
379
    public function isThisMyList($list_id, $list_uid = 0)
380
    {
381
        if ($list_uid == 0) {
382
            $list_uid = OledrionUtility::getCurrentUserID();
383
        }
384
        $list = null;
0 ignored issues
show
Unused Code introduced by
$list 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...
385
        $list = $this->get((int)$list_id);
386
        if (!is_object($list)) {
387
            return false;
388
        }
389
        if ($list->getVar('list_uid') == $list_uid) {
390
            return true;
391
        } else {
392
            return false;
393
        }
394
    }
395
396
    /**
397
     * Indique si un produit est dans une liste d'un utilisateur
398
     *
399
     * @param  integer $productlist_product_id
400
     * @param  integer $list_uid
401
     * @return boolean
402
     */
403
    public function isProductInUserList($productlist_product_id, $list_uid = 0)
404
    {
405
        //require_once __DIR__ . '/lite.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...
406
        if ($list_uid == 0) {
407
            $list_uid = OledrionUtility::getCurrentUserID();
408
        }
409
        if ($list_uid == 0) {
410
            return true;
411
        }
412
        $ret                    = false;
413
        $start                  = $limit = 0;
414
        $list_uid               = (int)$list_uid;
415
        $productlist_product_id = (int)$productlist_product_id;
416
        $sql                    = 'SELECT Count(*) FROM ' . $this->table . ' l, ' . $this->db->prefix('oledrion_products_list') . ' p WHERE (p.productlist_list_id = l.list_id) AND (l.list_uid = ' . $list_uid . ') AND (p.productlist_product_id =' . $productlist_product_id . ')';
417
        //$Cache_Lite = new oledrion_Cache_Lite($this->cacheOptions);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% 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...
418
        $id = $this->_getIdForCache($sql, $start, $limit);
0 ignored issues
show
Unused Code introduced by
$id 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...
419
        //$cacheData = $Cache_Lite->get($id);
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...
420
        //if ($cacheData === false) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% 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...
421
        $result = $this->db->query($sql, $limit, $start);
422
        if ($result) {
423
            list($count) = $this->db->fetchRow($result);
424
            if ($count > 0) {
425
                $ret = true;
426
            }
427
        }
428
429
        //$Cache_Lite->save($ret);
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% 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...
430
        return $ret;
431
        //} else {
432
        //return $cacheData;
433
        //}
434
    }
435
436
    /**
437
     * Retourne les x dernières listes qui contiennent des produits dans une certaine catégorie
438
     *
439
     * @param          $categoryId
440
     * @param  integer $list_type Le type de liste
441
     * @param  integer $limit     Le nombre maximum de listes à retourner
442
     * @return array   Objets de type oledrion_lists, [clé] = id liste
443
     * @internal param int $cateGoryId L'identifiant de la catégorie
444
     */
445
    public function listsFromCurrentCategory($categoryId, $list_type, $limit)
446
    {
447
        //require_once __DIR__ . '/lite.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...
448
        $ret        = array();
449
        $start      = 0;
450
        $categoryId = (int)$categoryId;
451
        $list_type  = (int)$list_type;
452
        $limit      = (int)$limit;
453
        $sql        = 'SELECT DISTINCT(z.productlist_list_id) FROM '
454
                      . $this->db->prefix('oledrion_products_list')
455
                      . ' z, '
456
                      . $this->db->prefix('oledrion_products')
457
                      . ' p, '
458
                      . $this->db->prefix('oledrion_lists')
459
                      . ' l WHERE (l.list_type = '
460
                      . $list_type
461
                      . ') AND (p.product_cid = '
462
                      . $categoryId
463
                      . ') AND (l.list_id = z.productlist_list_id) AND (z.productlist_product_id = p.product_id) AND (p.product_online = 1) ORDER BY l.list_date DESC';
464
        //$Cache_Lite = new oledrion_Cache_Lite($this->cacheOptions);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% 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...
465
        $id = $this->_getIdForCache($sql, $start, $limit);
0 ignored issues
show
Unused Code introduced by
$id 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...
466
        //$cacheData = $Cache_Lite->get($id);
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...
467
        //if ($cacheData === false) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% 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...
468
        $result = $this->db->query($sql, $limit, $start);
469
        if ($result) {
470
            while ($row = $this->db->fetchArray($result)) {
471
                $ret[] = $row['productlist_list_id'];
472
            }
473
            $ret = $this->getItemsFromIds($ret);
474
        }
475
476
        //$Cache_Lite->save($ret);
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% 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...
477
        return $ret;
478
        //} else {
479
        //  return $cacheData;
480
        //}
481
    }
482
}
483