Passed
Pull Request — master (#1270)
by Michael
05:36
created

XoopsBlock::edit_func()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
/**
3
 * XOOPS Kernel Class
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright       (c) 2000-2021 XOOPS Project (www.xoops.org)
13
 * @license             GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
14
 * @package             kernel
15
 * @since               2.0.0
16
 * @author              Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/
17
 */
18
defined('XOOPS_ROOT_PATH') || exit('Restricted access');
19
20
/**
21
 * A block
22
 *
23
 * @author  Kazumi Ono <[email protected]>
24
 *
25
 * @package kernel
26
 *
27
 * @todo reconcile the two XoopsBlock classes.
28
 * @internal This handler appears to only be loaded by system/class/group.php
29
 * @internal The other, in class/xoopsblock.php is loaded all over
30
 */
31
class XoopsBlock extends XoopsObject
32
{
33
    /**
34
     * constructor
35
     *
36
     * @param mixed $id
37
     **/
38
    public function __construct($id = null)
39
    {
40
        $this->initVar('bid', XOBJ_DTYPE_INT, null, false);
41
        $this->initVar('mid', XOBJ_DTYPE_INT, 0, false);
42
        $this->initVar('func_num', XOBJ_DTYPE_INT, 0, false);
43
        $this->initVar('options', XOBJ_DTYPE_TXTBOX, null, false, 255);
44
        $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, true, 150);
45
        //$this->initVar('position', XOBJ_DTYPE_INT, 0, false);
46
        $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false, 150);
47
        $this->initVar('content', XOBJ_DTYPE_TXTAREA, null, false);
48
        $this->initVar('side', XOBJ_DTYPE_INT, 0, false);
49
        $this->initVar('weight', XOBJ_DTYPE_INT, 0, false);
50
        $this->initVar('visible', XOBJ_DTYPE_INT, 0, false);
51
        $this->initVar('block_type', XOBJ_DTYPE_OTHER, null, false);
52
        $this->initVar('c_type', XOBJ_DTYPE_OTHER, null, false);
53
        $this->initVar('isactive', XOBJ_DTYPE_INT, null, false);
54
        $this->initVar('dirname', XOBJ_DTYPE_TXTBOX, null, false, 50);
55
        $this->initVar('func_file', XOBJ_DTYPE_TXTBOX, null, false, 50);
56
        $this->initVar('show_func', XOBJ_DTYPE_TXTBOX, null, false, 50);
57
        $this->initVar('edit_func', XOBJ_DTYPE_TXTBOX, null, false, 50);
58
        $this->initVar('template', XOBJ_DTYPE_OTHER, null, false);
59
        $this->initVar('bcachetime', XOBJ_DTYPE_INT, 0, false);
60
        $this->initVar('last_modified', XOBJ_DTYPE_INT, 0, false);
61
62
        parent::__construct();
63
64
        // for backward compatibility
65
        if (isset($id)) {
66
            if (is_array($id)) {
67
                $this->assignVars($id);
68
            } else {
69
                $blkhandler = xoops_getHandler('block');
70
                $obj        = $blkhandler->get($id);
71
                foreach (array_keys($obj->getVars()) as $i) {
72
                    $this->assignVar($i, $obj->getVar($i, 'n'));
73
                }
74
            }
75
        }
76
    }
77
78
    /**
79
     * Returns Class Base Variable bid
80
     * @param string $format
81
     * @return mixed
82
     */
83
    public function id($format = 'n')
84
    {
85
        return $this->getVar('bid', $format);
86
    }
87
88
    /**
89
     * Returns Class Base Variable bid
90
     * @param string $format
91
     * @return mixed
92
     */
93
    public function bid($format = '')
94
    {
95
        return $this->getVar('bid', $format);
96
    }
97
98
    /**
99
     * Returns Class Base Variable mid
100
     * @param string $format
101
     * @return mixed
102
     */
103
    public function mid($format = '')
104
    {
105
        return $this->getVar('mid', $format);
106
    }
107
108
    /**
109
     * Returns Class Base Variable func_num
110
     * @param string $format
111
     * @return mixed
112
     */
113
    public function func_num($format = '')
114
    {
115
        return $this->getVar('func_num', $format);
116
    }
117
118
    /**
119
     * Returns Class Base Variable avatar_id
120
     * @param string $format
121
     * @return mixed
122
     */
123
    public function options($format = '')
124
    {
125
        return $this->getVar('options', $format);
126
    }
127
128
    /**
129
     * Returns Class Base Variable name
130
     * @param string $format
131
     * @return mixed
132
     */
133
    public function name($format = '')
134
    {
135
        return $this->getVar('name', $format);
136
    }
137
138
    /**
139
     * Returns Class Base Variable title
140
     * @param string $format
141
     * @return mixed
142
     */
143
    public function title($format = '')
144
    {
145
        return $this->getVar('title', $format);
146
    }
147
148
    /**
149
     * Returns Class Base Variable content
150
     * @param string $format
151
     * @return mixed
152
     */
153
    public function content($format = '')
154
    {
155
        return $this->getVar('content', $format);
156
    }
157
158
    /**
159
     * Returns Class Base Variable side
160
     * @param string $format
161
     * @return mixed
162
     */
163
    public function side($format = '')
164
    {
165
        return $this->getVar('side', $format);
166
    }
167
168
    /**
169
     * Returns Class Base Variable weight
170
     * @param string $format
171
     * @return mixed
172
     */
173
    public function weight($format = '')
174
    {
175
        return $this->getVar('weight', $format);
176
    }
177
178
    /**
179
     * Returns Class Base Variable visible
180
     * @param string $format
181
     * @return mixed
182
     */
183
    public function visible($format = '')
184
    {
185
        return $this->getVar('visible', $format);
186
    }
187
188
    /**
189
     * Returns Class Base Variable block_type
190
     *
191
     * Vaild block_type values are:
192
     * S - generated by system module
193
     * M - generated by a non-system module
194
     * C - Custom block
195
     * D - cloned system/module block
196
     * E - cloned custom block, DON'T use it
197
     *
198
     * @param string $format
199
     *
200
     * @return mixed
201
     */
202
    public function block_type($format = '')
203
    {
204
        return $this->getVar('block_type', $format);
205
    }
206
207
    /**
208
     * Returns Class Base Variable c_type
209
     * @param string $format
210
     * @return mixed
211
     */
212
    public function c_type($format = '')
213
    {
214
        return $this->getVar('c_type', $format);
215
    }
216
217
    /**
218
     * Returns Class Base Variable isactive
219
     * @param string $format
220
     * @return mixed
221
     */
222
    public function isactive($format = '')
223
    {
224
        return $this->getVar('isactive', $format);
225
    }
226
227
    /**
228
     * Returns Class Base Variable dirname
229
     * @param string $format
230
     * @return mixed
231
     */
232
    public function dirname($format = '')
233
    {
234
        return $this->getVar('dirname', $format);
235
    }
236
237
    /**
238
     * Returns Class Base Variable func_file
239
     * @param string $format
240
     * @return mixed
241
     */
242
    public function func_file($format = '')
243
    {
244
        return $this->getVar('func_file', $format);
245
    }
246
247
    /**
248
     * Returns Class Base Variable show_func
249
     * @param string $format
250
     * @return mixed
251
     */
252
    public function show_func($format = '')
253
    {
254
        return $this->getVar('show_func', $format);
255
    }
256
257
    /**
258
     * Returns Class Base Variable edit_func
259
     * @param string $format
260
     * @return mixed
261
     */
262
    public function edit_func($format = '')
263
    {
264
        return $this->getVar('edit_func', $format);
265
    }
266
267
    /**
268
     * Returns Class Base Variable template
269
     * @param string $format
270
     * @return mixed
271
     */
272
    public function template($format = '')
273
    {
274
        return $this->getVar('template', $format);
275
    }
276
277
    /**
278
     * Returns Class Base Variable avatar_id
279
     * @param string $format
280
     * @return mixed
281
     */
282
    public function bcachetime($format = '')
283
    {
284
        return $this->getVar('bcachetime', $format);
285
    }
286
287
    /**
288
     * Returns Class Base Variable last_modified
289
     * @param string $format
290
     * @return mixed
291
     */
292
    public function last_modified($format = '')
293
    {
294
        return $this->getVar('last_modified', $format);
295
    }
296
297
    /**
298
     * return the content of the block for output
299
     *
300
     * @param  string $format
301
     * @param  string $c_type type of content
302
     *                        Valid values for the type of content:
303
     *                        H : custom HTML block
304
     *                        P : custom PHP block
305
     *                        S : use text sanitizer (smilies enabled)
306
     *                        T : use text sanitizer (smilies disabled)</ul>
307
     * @return string content for output
308
     */
309
    public function getContent($format = 's', $c_type = 'T')
310
    {
311
        $format = strtolower($format);
312
        $c_type = strtoupper($c_type);
313
        switch ($format) {
314
            case 's':
315
                if ($c_type === 'H') {
316
                    return str_replace('{X_SITEURL}', XOOPS_URL . '/', $this->getVar('content', 'n'));
317
                } elseif ($c_type === 'P') {
318
                    ob_start();
319
                    echo eval($this->getVar('content', 'n'));
0 ignored issues
show
introduced by
The use of eval() is discouraged.
Loading history...
320
                    $content = ob_get_contents();
321
                    ob_end_clean();
322
323
                    return str_replace('{X_SITEURL}', XOOPS_URL . '/', $content);
324
                } elseif ($c_type === 'S') {
325
                    $myts    = MyTextSanitizer::getInstance();
326
                    $content = str_replace('{X_SITEURL}', XOOPS_URL . '/', $this->getVar('content', 'n'));
327
328
                    return $myts->displayTarea($content, 0, 1);
329
                } else {
330
                    $myts    = MyTextSanitizer::getInstance();
331
                    $content = str_replace('{X_SITEURL}', XOOPS_URL . '/', $this->getVar('content', 'n'));
332
333
                    return $myts->displayTarea($content, 0, 0);
334
                }
335
                break;
336
            case 'e':
337
                return $this->getVar('content', 'e');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getVar('content', 'e') also could return the type array|boolean which is incompatible with the documented return type string.
Loading history...
338
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
339
            default:
340
                return $this->getVar('content', 'n');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getVar('content', 'n') also could return the type array|boolean which is incompatible with the documented return type string.
Loading history...
341
                break;
342
        }
343
    }
344
345
    /**
346
     * (HTML-) form for setting the options of the block
347
     *
348
     * @return string HTML for the form, FALSE if not defined for this block
349
     */
350
    public function getOptions()
351
    {
352
        if (!$this->isCustom()) {
353
            $edit_func = $this->getVar('edit_func');
354
            if (!$edit_func) {
355
                return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
356
            }
357
            if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/blocks/' . $this->getVar('func_file'))) {
358
                if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/blocks.php')) {
359
                    include_once XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/blocks.php';
360
                } elseif (file_exists(XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/language/english/blocks.php')) {
361
                    include_once XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/language/english/blocks.php';
362
                }
363
                include_once XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/blocks/' . $this->getVar('func_file');
364
                $options   = explode('|', $this->getVar('options'));
365
                $edit_form = $edit_func($options);
366
                if (!$edit_form) {
367
                    return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
368
                }
369
370
                return $edit_form;
371
            } else {
372
                return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
373
            }
374
        } else {
375
            return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
376
        }
377
    }
378
379
    /**
380
     * @return bool
381
     */
382
    public function isCustom()
383
    {
384
        return in_array($this->getVar('block_type'), array(
385
            'C',
386
            'E'));
387
    }
388
389
    /**
390
     * These methods are for compatibility with the pre 2.5.11 class/xoopsblock.php
391
     * class/xoopsblock.php defined its own XoopsBlock class, making it impossible
392
     * to use with anything that used the handler provided in kernel/block.php
393
     *
394
     * In addition to the actual data, the old XoopsBlock contained what should be
395
     * considered handler logic.
396
     *
397
     * It appears that class/xoopsblock.php came first, but a conversion to the kernel
398
     * handler was never completed.
399
     *
400
     * These methods should all be considered deprecated.
401
     */
402
403
    /**
404
     * Load $id
405
     *
406
     * @param int $id
407
     *
408
     * @deprecated
409
     */
410
    public function load($id)
411
    {
412
        $id  = (int)$id;
413
        /** @var XoopsBlockHandler $blkhandler */
414
        $blkhandler = xoops_getHandler('block');
415
        $obj        = $blkhandler->get($id);
416
        foreach (array_keys($obj->getVars()) as $i) {
417
            $this->assignVar($i, $obj->getVar($i, 'n'));
418
        }
419
    }
420
421
    /**
422
     * Store Block Data to Database
423
     *
424
     * @return int|false id of inserted block, or false on failure
425
     *
426
     * @deprecated
427
     */
428
    public function store()
429
    {
430
        /** @var XoopsBlockHandler $blkhandler */
431
        $blkhandler = xoops_getHandler('block');
432
        if (false === $blkhandler->insert($this)) {
433
            return false;
434
        }
435
        return (int) $this->bid();
436
    }
437
438
    /**
439
     * Delete a ID from the database
440
     *
441
     * @return bool
442
     *
443
     * @deprecated
444
     */
445
    public function delete()
446
    {
447
        /** @var XoopsBlockHandler $blkhandler */
448
        $blkhandler = xoops_getHandler('block');
449
        return $blkhandler->delete($this);
450
    }
451
452
    /**
453
     * Build Block
454
     *
455
     * @return mixed
456
     *
457
     * @deprecated
458
     */
459
    public function buildBlock()
460
    {
461
        global $xoopsConfig, $xoopsOption, $xoTheme;
462
        $block = array();
463
        if (!$this->isCustom()) {
464
            // get block display function
465
            $show_func = $this->getVar('show_func');
466
            if (!$show_func) {
467
                return false;
468
            }
469
            if (!file_exists($func_file = $GLOBALS['xoops']->path('modules/' . $this->getVar('dirname') . '/blocks/' . $this->getVar('func_file')))) {
470
                return false;
471
            }
472
            // must get lang files b4 including the file
473
            // some modules require it for code that is outside the function
474
            xoops_loadLanguage('blocks', $this->getVar('dirname'));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('dirname') can also be of type array and array; however, parameter $domain of xoops_loadLanguage() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

474
            xoops_loadLanguage('blocks', /** @scrutinizer ignore-type */ $this->getVar('dirname'));
Loading history...
475
            include_once $func_file;
476
477
            if (function_exists($show_func)) {
478
                // execute the function
479
                $options = explode('|', $this->getVar('options'));
480
                $block   = $show_func($options);
481
                if (!$block) {
482
                    return false;
483
                }
484
            } else {
485
                return false;
486
            }
487
        } else {
488
            // it is a custom block, so just return the contents
489
            $block['content'] = $this->getContent('s', $this->getVar('c_type'));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('c_type') can also be of type array and array; however, parameter $c_type of XoopsBlock::getContent() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

489
            $block['content'] = $this->getContent('s', /** @scrutinizer ignore-type */ $this->getVar('c_type'));
Loading history...
490
            if (empty($block['content'])) {
491
                return false;
492
            }
493
        }
494
495
        return $block;
496
    }
497
498
    /*
499
    * Aligns the content of a block
500
    * If position is 0, content in DB is positioned
501
    * before the original content
502
    * If position is 1, content in DB is positioned
503
    * after the original content
504
    */
505
    /**
506
     * @param        $position
507
     * @param string $content
508
     * @param string $contentdb
509
     *
510
     * @return string
511
     *
512
     * @deprecated
513
     */
514
    public function buildContent($position, $content = '', $contentdb = '')
515
    {
516
        $ret = null;
517
        if ($position == 0) {
518
            $ret = $contentdb . $content;
519
        } elseif ($position == 1) {
520
            $ret = $content . $contentdb;
521
        }
522
523
        return $ret;
524
    }
525
526
    /**
527
     * Enter description here...
528
     *
529
     * @param  string $originaltitle
530
     * @param  string $newtitle
531
     * @return string title
532
     *
533
     * @deprecated
534
     */
535
    public function buildTitle($originaltitle, $newtitle = '')
536
    {
537
        $ret = $originaltitle;
538
        if ($newtitle != '') {
539
            $ret = $newtitle;
540
        }
541
542
        return $ret;
543
    }
544
545
    /**
546
     * get all the blocks that match the supplied parameters
547
     * @param int|array $groupid  groupid (can be an array)
548
     * @param bool   $asobject
549
     * @param null|string $side     0: sideblock - left
550
     *                         1: sideblock - right
551
     *                         2: sideblock - left and right
552
     *                         3: centerblock - left
553
     *                         4: centerblock - right
554
     *                         5: centerblock - center
555
     *                         6: centerblock - left, right, center
556
     * @param        $visible  0: not visible 1: visible
0 ignored issues
show
Documentation Bug introduced by
The doc comment 0: not at position 0 could not be parsed: Unknown type name '0' at position 0 in 0: not.
Loading history...
557
     * @param string $orderby  order of the blocks
558
     * @param int    $isactive
559
     * @returns array of block objects
560
     *
561
     * @deprecated
562
     */
563
    public static function getAllBlocksByGroup($groupid, $asobject = true, $side = null, $visible = null, $orderby = 'b.weight,b.bid', $isactive = 1)
564
    {
565
        $db  = XoopsDatabaseFactory::getDatabaseConnection();
566
        $ret = array();
567
        $sql = 'SELECT b.* ';
568
        if (!$asobject) {
569
            $sql = 'SELECT b.bid ';
570
        }
571
        $sql .= 'FROM ' . $db->prefix('newblocks') . ' b LEFT JOIN ' . $db->prefix('group_permission') . " l ON l.gperm_itemid=b.bid WHERE gperm_name = 'block_read' AND gperm_modid = 1";
572
        if (is_array($groupid)) {
573
            $sql .= ' AND (l.gperm_groupid=' . $groupid[0] . '';
574
            $size = count($groupid);
575
            if ($size > 1) {
576
                for ($i = 1; $i < $size; ++$i) {
577
                    $sql .= ' OR l.gperm_groupid=' . $groupid[$i] . '';
578
                }
579
            }
580
            $sql .= ')';
581
        } else {
582
            $sql .= ' AND l.gperm_groupid=' . $groupid . '';
583
        }
584
        $sql .= ' AND b.isactive=' . $isactive;
585
        if (isset($side)) {
586
            // get both sides in sidebox? (some themes need this)
587
            if ($side == XOOPS_SIDEBLOCK_BOTH) {
588
                $side = '(b.side=0 OR b.side=1)';
589
            } elseif ($side == XOOPS_CENTERBLOCK_ALL) {
590
                $side = '(b.side=3 OR b.side=4 OR b.side=5 OR b.side=7 OR b.side=8 OR b.side=9 )';
591
            } elseif ($side == XOOPS_FOOTERBLOCK_ALL) {
592
                $side = '(b.side=10 OR b.side=11 OR b.side=12 )';
593
            } else {
594
                $side = 'b.side=' . $side;
595
            }
596
            $sql .= ' AND ' . $side;
597
        }
598
        if (isset($visible)) {
599
            $sql .= " AND b.visible=$visible";
600
        }
601
        $sql .= " ORDER BY $orderby";
602
        $result = $db->query($sql);
0 ignored issues
show
Bug introduced by
The method query() does not exist on XoopsDatabase. Since it exists in all sub-types, consider adding an abstract or default implementation to XoopsDatabase. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

602
        /** @scrutinizer ignore-call */ 
603
        $result = $db->query($sql);
Loading history...
603
        if (!$db->isResultSet($result)) {
604
            \trigger_error("Query Failed! SQL: $sql- Error: " . $db->error(), E_USER_ERROR);
0 ignored issues
show
Bug introduced by
The method error() does not exist on XoopsDatabase. Since it exists in all sub-types, consider adding an abstract or default implementation to XoopsDatabase. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

604
            \trigger_error("Query Failed! SQL: $sql- Error: " . $db->/** @scrutinizer ignore-call */ error(), E_USER_ERROR);
Loading history...
605
        }
606
        $added  = array();
607
        while (false !== ($myrow = $db->fetchArray($result))) {
0 ignored issues
show
Bug introduced by
The method fetchArray() does not exist on XoopsDatabase. Since it exists in all sub-types, consider adding an abstract or default implementation to XoopsDatabase. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

607
        while (false !== ($myrow = $db->/** @scrutinizer ignore-call */ fetchArray($result))) {
Loading history...
608
            if (!in_array($myrow['bid'], $added)) {
609
                if (!$asobject) {
610
                    $ret[] = $myrow['bid'];
611
                } else {
612
                    $ret[] = new XoopsBlock($myrow);
613
                }
614
                $added[] = $myrow['bid'];
615
            }
616
        }
617
618
        return $ret;
619
    }
620
621
    /**
622
     * XoopsBlock::getAllBlocks()
623
     *
624
     * @param  string  $rettype
625
     * @param  mixed   $side
626
     * @param  mixed   $visible
627
     * @param  string  $orderby
628
     * @param  integer $isactive
629
     * @return array
630
     *
631
     * @deprecated
632
     */
633
    public function getAllBlocks($rettype = 'object', $side = null, $visible = null, $orderby = 'side,weight,bid', $isactive = 1)
634
    {
635
        $db          = XoopsDatabaseFactory::getDatabaseConnection();
636
        $ret         = array();
637
        $where_query = ' WHERE isactive=' . $isactive;
638
        if (isset($side)) {
639
            // get both sides in sidebox? (some themes need this)
640
            if ($side == XOOPS_SIDEBLOCK_BOTH) {
641
                $side = '(side=0 OR side=1)';
642
            } elseif ($side == XOOPS_CENTERBLOCK_ALL) {
643
                $side = '(side=3 OR side=4 OR side=5 OR side=7 OR side=8 OR side=9)';
644
            } elseif ($side == XOOPS_FOOTERBLOCK_ALL) {
645
                $side = '(side=10 OR side=11 OR side=12)';
646
            } else {
647
                $side = 'side=' . $side;
648
            }
649
            $where_query .= ' AND ' . $side;
650
        }
651
        if (isset($visible)) {
652
            $where_query .= ' AND visible=.' . $visible;
653
        }
654
        $where_query .= ' ORDER BY ' . $orderby;
655
        switch ($rettype) {
656
            case 'object':
657
                $sql    = 'SELECT * FROM ' . $db->prefix('newblocks') . '' . $where_query;
658
                $result = $db->query($sql);
659
                if (!$db->isResultSet($result)) {
660
                    \trigger_error("Query Failed! SQL: $sql- Error: " . $db->error(), E_USER_ERROR);
661
                }
662
                while (false !== ($myrow = $db->fetchArray($result))) {
663
                    $ret[] = new XoopsBlock($myrow);
664
                }
665
                break;
666
            case 'list':
667
                $sql    = 'SELECT * FROM ' . $db->prefix('newblocks') . '' . $where_query;
668
                $result = $db->query($sql);
669
                if (!$db->isResultSet($result)) {
670
                    \trigger_error("Query Failed! SQL: $sql- Error: " . $db->error(), E_USER_ERROR);
671
                }
672
                while (false !== ($myrow = $db->fetchArray($result))) {
673
                    $block                      = new XoopsBlock($myrow);
674
                    $title                      = $block->getVar('title');
675
                    $title                      = empty($title) ? $block->getVar('name') : $title;
676
                    $ret[$block->getVar('bid')] = $title;
677
                }
678
                break;
679
            case 'id':
680
                $sql    = 'SELECT bid FROM ' . $db->prefix('newblocks') . '' . $where_query;
681
                $result = $db->query($sql);
682
                if (!$db->isResultSet($result)) {
683
                    \trigger_error("Query Failed! SQL: $sql- Error: " . $db->error(), E_USER_ERROR);
684
                }
685
                while (false !== ($myrow = $db->fetchArray($result))) {
686
                    $ret[] = $myrow['bid'];
687
                }
688
                break;
689
        }
690
691
        return $ret;
692
    }
693
694
    /**
695
     * XoopsBlock::getByModule()
696
     *
697
     * @param  mixed $moduleid
698
     * @param  mixed $asobject
699
     * @return array
700
     *
701
     * @deprecated (This also appears, dead, in XoopsBlockHandler)
702
     */
703
    public static function getByModule($moduleid, $asobject = true)
704
    {
705
        $moduleid = (int)$moduleid;
706
        $db       = XoopsDatabaseFactory::getDatabaseConnection();
707
        if ($asobject == true) {
708
            $sql = $sql = 'SELECT * FROM ' . $db->prefix('newblocks') . ' WHERE mid=' . $moduleid;
0 ignored issues
show
Unused Code introduced by
The assignment to $sql is dead and can be removed.
Loading history...
709
        } else {
710
            $sql = 'SELECT bid FROM ' . $db->prefix('newblocks') . ' WHERE mid=' . $moduleid;
711
        }
712
        $result = $db->query($sql);
713
        if (!$db->isResultSet($result)) {
714
            \trigger_error("Query Failed! SQL: $sql- Error: " . $db->error(), E_USER_ERROR);
715
        }
716
        $ret    = array();
717
        while (false !== ($myrow = $db->fetchArray($result))) {
718
            if ($asobject) {
719
                $ret[] = new XoopsBlock($myrow);
720
            } else {
721
                $ret[] = $myrow['bid'];
722
            }
723
        }
724
725
        return $ret;
726
    }
727
728
    /**
729
     * XoopsBlock::getAllByGroupModule()
730
     *
731
     * @param  mixed   $groupid
732
     * @param  integer $module_id
733
     * @param  mixed   $toponlyblock
734
     * @param  mixed   $visible
735
     * @param  string  $orderby
736
     * @param  integer $isactive
737
     * @return array
738
     *
739
     * @deprecated (This also appears, dead, in XoopsBlockHandler)
740
     */
741
    public function getAllByGroupModule($groupid, $module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'b.weight, m.block_id', $isactive = 1)
742
    {
743
        $isactive = (int)$isactive;
744
        $db       = XoopsDatabaseFactory::getDatabaseConnection();
745
        $ret      = array();
746
        if (isset($groupid)) {
747
            $sql = 'SELECT DISTINCT gperm_itemid FROM ' . $db->prefix('group_permission') . " WHERE gperm_name = 'block_read' AND gperm_modid = 1";
748
            if (is_array($groupid)) {
749
                $sql .= ' AND gperm_groupid IN (' . implode(',', $groupid) . ')';
750
            } else {
751
                if ((int)$groupid > 0) {
752
                    $sql .= ' AND gperm_groupid=' . (int)$groupid;
753
                }
754
            }
755
            $result   = $db->query($sql);
756
            if (!$db->isResultSet($result)) {
757
                \trigger_error("Query Failed! SQL: $sql- Error: " . $db->error(), E_USER_ERROR);
758
            }
759
            $blockids = array();
760
            while (false !== ($myrow = $db->fetchArray($result))) {
761
                $blockids[] = $myrow['gperm_itemid'];
762
            }
763
            if (empty($blockids)) {
764
                return $blockids;
765
            }
766
        }
767
        $sql = 'SELECT b.* FROM ' . $db->prefix('newblocks') . ' b, ' . $db->prefix('block_module_link') . ' m WHERE m.block_id=b.bid';
768
        $sql .= ' AND b.isactive=' . $isactive;
769
        if (isset($visible)) {
770
            $sql .= ' AND b.visible=' . (int)$visible;
771
        }
772
        if (!isset($module_id)) {
773
        } elseif (!empty($module_id)) {
774
            $sql .= ' AND m.module_id IN (0,' . (int)$module_id;
775
            if ($toponlyblock) {
776
                $sql .= ',-1';
777
            }
778
            $sql .= ')';
779
        } else {
780
            if ($toponlyblock) {
781
                $sql .= ' AND m.module_id IN (0,-1)';
782
            } else {
783
                $sql .= ' AND m.module_id=0';
784
            }
785
        }
786
        if (!empty($blockids)) {
787
            $sql .= ' AND b.bid IN (' . implode(',', $blockids) . ')';
788
        }
789
        $sql .= ' ORDER BY ' . $orderby;
790
        $result = $db->query($sql);
791
        if (!$db->isResultSet($result)) {
792
            \trigger_error("Query Failed! SQL: $sql- Error: " . $db->error(), E_USER_ERROR);
793
        }
794
        while (false !== ($myrow = $db->fetchArray($result))) {
795
            $block              = new XoopsBlock($myrow);
796
            $ret[$myrow['bid']] = &$block;
797
            unset($block);
798
        }
799
800
        return $ret;
801
    }
802
803
    /**
804
     * XoopsBlock::getNonGroupedBlocks()
805
     *
806
     * @param  integer $module_id
807
     * @param  mixed   $toponlyblock
808
     * @param  mixed   $visible
809
     * @param  string  $orderby
810
     * @param  integer $isactive
811
     * @return array
812
     *
813
     * @deprecated
814
     */
815
    public function getNonGroupedBlocks($module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'b.weight, m.block_id', $isactive = 1)
816
    {
817
        $db   = XoopsDatabaseFactory::getDatabaseConnection();
818
        $ret  = array();
819
        $bids = array();
820
        $sql  = 'SELECT DISTINCT(bid) from ' . $db->prefix('newblocks');
821
        $result = $db->query($sql);
822
        if (!$db->isResultSet($result)) {
823
            \trigger_error("Query Failed! SQL: $sql- Error: " . $db->error(), E_USER_ERROR);
824
        }
825
            while (false !== ($myrow = $db->fetchArray($result))) {
826
                $bids[] = $myrow['bid'];
827
            }
828
829
        $sql     = 'SELECT DISTINCT(p.gperm_itemid) from ' . $db->prefix('group_permission') . ' p, ' . $db->prefix('groups') . " g WHERE g.groupid=p.gperm_groupid AND p.gperm_name='block_read'";
830
        $grouped = array();
831
        $result = $db->query($sql);
832
        if (!$db->isResultSet($result)) {
833
            \trigger_error("Query Failed! SQL: $sql- Error: " . $db->error(), E_USER_ERROR);
834
        }
835
            while (false !== ($myrow = $db->fetchArray($result))) {
836
                $grouped[] = $myrow['gperm_itemid'];
837
            }
838
839
        $non_grouped = array_diff($bids, $grouped);
840
        if (!empty($non_grouped)) {
841
            $sql = 'SELECT b.* FROM ' . $db->prefix('newblocks') . ' b, ' . $db->prefix('block_module_link') . ' m WHERE m.block_id=b.bid';
842
            $sql .= ' AND b.isactive=' . (int)$isactive;
843
            if (isset($visible)) {
844
                $sql .= ' AND b.visible=' . (int)$visible;
845
            }
846
            if (!isset($module_id)) {
847
            } elseif (!empty($module_id)) {
848
                $sql .= ' AND m.module_id IN (0,' . (int)$module_id;
849
                if ($toponlyblock) {
850
                    $sql .= ',-1';
851
                }
852
                $sql .= ')';
853
            } else {
854
                if ($toponlyblock) {
855
                    $sql .= ' AND m.module_id IN (0,-1)';
856
                } else {
857
                    $sql .= ' AND m.module_id=0';
858
                }
859
            }
860
            $sql .= ' AND b.bid IN (' . implode(',', $non_grouped) . ')';
861
            $sql .= ' ORDER BY ' . $orderby;
862
            $result = $db->query($sql);
863
            if (!$db->isResultSet($result)) {
864
                \trigger_error("Query Failed! SQL: $sql- Error: " . $db->error(), E_USER_ERROR);
865
            }
866
            while (false !== ($myrow = $db->fetchArray($result))) {
867
                $block              = new XoopsBlock($myrow);
868
                $ret[$myrow['bid']] =& $block;
869
                unset($block);
870
            }
871
        }
872
873
        return $ret;
874
    }
875
876
    /**
877
     * XoopsBlock::countSimilarBlocks()
878
     *
879
     * @param  mixed $moduleId
880
     * @param  mixed $funcNum
881
     * @param  mixed $showFunc
882
     * @return int
883
     *
884
     * @deprecated
885
     */
886
    public function countSimilarBlocks($moduleId, $funcNum, $showFunc = null)
887
    {
888
        $funcNum  = (int)$funcNum;
889
        $moduleId = (int)$moduleId;
890
        if ($funcNum < 1 || $moduleId < 1) {
891
            // invalid query
892
            return 0;
893
        }
894
        $db = XoopsDatabaseFactory::getDatabaseConnection();
895
        if (isset($showFunc)) {
896
            // showFunc is set for more strict comparison
897
            $sql = sprintf('SELECT COUNT(*) FROM %s WHERE mid = %d AND func_num = %d AND show_func = %s', $db->prefix('newblocks'), $moduleId, $funcNum, $db->quoteString(trim($showFunc)));
0 ignored issues
show
Bug introduced by
The method quoteString() does not exist on XoopsDatabase. Since it exists in all sub-types, consider adding an abstract or default implementation to XoopsDatabase. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

897
            $sql = sprintf('SELECT COUNT(*) FROM %s WHERE mid = %d AND func_num = %d AND show_func = %s', $db->prefix('newblocks'), $moduleId, $funcNum, $db->/** @scrutinizer ignore-call */ quoteString(trim($showFunc)));
Loading history...
898
        } else {
899
            $sql = sprintf('SELECT COUNT(*) FROM %s WHERE mid = %d AND func_num = %d', $db->prefix('newblocks'), $moduleId, $funcNum);
900
        }
901
        $result = $db->query($sql);
902
        if (!$db->isResultSet($result)) {
903
            //            \trigger_error("Query Failed! SQL: $sql- Error: " . $db->error(), E_USER_ERROR);
904
            return 0;
905
        }
906
        list($count) = $db->fetchRow($result);
0 ignored issues
show
Bug introduced by
The method fetchRow() does not exist on XoopsDatabase. Since it exists in all sub-types, consider adding an abstract or default implementation to XoopsDatabase. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

906
        /** @scrutinizer ignore-call */ 
907
        list($count) = $db->fetchRow($result);
Loading history...
907
908
        return $count;
909
    }
910
}
911
912
/**
913
 * XOOPS block handler class. (Singelton)
914
 *
915
 * This class is responsible for providing data access mechanisms to the data source
916
 * of XOOPS block class objects.
917
 *
918
 * @author              Kazumi Ono <[email protected]>
919
 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
920
 * @package             kernel
921
 * @subpackage          block
922
 *
923
 * @todo Why is this not a XoopsPersistableObjectHandler?
924
 */
925
class XoopsBlockHandler extends XoopsObjectHandler
926
{
927
    /**
928
     * create a new block
929
     *
930
     * @see XoopsBlock
931
     * @param  bool $isNew is the new block new??
932
     * @return XoopsBlock XoopsBlock reference to the new block
933
     **/
934
    public function create($isNew = true)
935
    {
936
        $block = new XoopsBlock();
937
        if ($isNew) {
938
            $block->setNew();
939
        }
940
941
        return $block;
942
    }
943
944
    /**
945
     * retrieve a specific {@link XoopsBlock}
946
     *
947
     * @see XoopsBlock
948
     * @param  int $id bid of the block to retrieve
949
     * @return XoopsBlock reference to the block
950
     **/
951
    public function get($id)
952
    {
953
        $block = false;
954
        $id    = (int)$id;
955
        if ($id > 0) {
956
            $sql = 'SELECT * FROM ' . $this->db->prefix('newblocks') . ' WHERE bid=' . $id;
957
            $result = $this->db->query($sql);
958
            if (!$this->db->isResultSet($result)) {
959
                \trigger_error("Query Failed! SQL: $sql- Error: " . $this->db->error(), E_USER_ERROR);
960
            }
961
                $numrows = $this->db->getRowsNum($result);
0 ignored issues
show
Bug introduced by
The method getRowsNum() does not exist on XoopsDatabase. Since it exists in all sub-types, consider adding an abstract or default implementation to XoopsDatabase. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

961
                /** @scrutinizer ignore-call */ 
962
                $numrows = $this->db->getRowsNum($result);
Loading history...
962
                if ($numrows == 1) {
963
                    $block = new XoopsBlock();
964
                    $block->assignVars($this->db->fetchArray($result));
965
                }
966
967
        }
968
969
        return $block;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $block could also return false which is incompatible with the documented return type XoopsBlock. Did you maybe forget to handle an error condition?

If the returned type also contains false, it is an indicator that maybe an error condition leading to the specific return statement remains unhandled.

Loading history...
970
    }
971
972
    /**
973
     * write a new block into the database
974
     *
975
     * @param XoopsObject|XoopsBlock $block a XoopsBlock object
976
     *
977
     * @return bool true on success, otherwise false
978
     */
979
    public function insert(XoopsObject $block)
980
    {
981
        $className = 'XoopsBlock';
982
        if (!($block instanceof $className)) {
983
            return false;
984
        }
985
        if (!$block->isDirty()) {
986
            return true;
987
        }
988
        if (!$block->cleanVars()) {
989
            return false;
990
        }
991
992
        $bid = $block->getVar('bid', 'n');
993
        $mid = $block->getVar('mid', 'n');
994
        $func_num = $block->getVar('func_num', 'n');
995
        $options = $block->getVar('options', 'n');
996
        $name = $block->getVar('name', 'n');
997
        $title = $block->getVar('title', 'n');
998
        $content = $block->getVar('content', 'n');
999
        $side = $block->getVar('side', 'n');
1000
        $weight = $block->getVar('weight', 'n');
1001
        $visible = $block->getVar('visible', 'n');
1002
        $c_type = $block->getVar('c_type', 'n');
1003
        $isactive = $block->getVar('isactive', 'n');
1004
        $func_file = $block->getVar('func_file', 'n');
1005
        $show_func = $block->getVar('show_func', 'n');
1006
        $edit_func = $block->getVar('edit_func', 'n');
1007
        $template = $block->getVar('template', 'n');
1008
        $bcachetime = $block->getVar('bcachetime', 'n');
1009
        $block_type = $block->getVar('block_type', 'n');
1010
        $dirname = $block->getVar('dirname', 'n');
1011
1012
        if ($block->isNew()) {
1013
            $bid = $this->db->genId('newblocks_bid_seq');
0 ignored issues
show
Bug introduced by
The method genId() does not exist on XoopsDatabase. Since it exists in all sub-types, consider adding an abstract or default implementation to XoopsDatabase. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1013
            /** @scrutinizer ignore-call */ 
1014
            $bid = $this->db->genId('newblocks_bid_seq');
Loading history...
1014
            $sql = sprintf(
1015
                'INSERT INTO %s (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type,'
1016
                . ' c_type, isactive, dirname, func_file, show_func, edit_func, template, bcachetime, last_modified)'
1017
                . " VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', %u, %u, %u, '%s', '%s', %u, '%s', '%s', '%s', '%s',"
1018
                . " '%s', %u, %u)",
1019
                $this->db->prefix('newblocks'),
1020
                $bid,
1021
                $mid,
0 ignored issues
show
Bug introduced by
It seems like $mid can also be of type array and array; however, parameter $values of sprintf() does only seem to accept double|integer|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1021
                /** @scrutinizer ignore-type */ $mid,
Loading history...
1022
                $func_num,
1023
                $options,
1024
                $name,
1025
                $title,
1026
                $content,
1027
                $side,
1028
                $weight,
1029
                $visible,
1030
                $block_type,
1031
                $c_type,
1032
                1,
1033
                $dirname,
1034
                $func_file,
1035
                $show_func,
1036
                $edit_func,
1037
                $template,
1038
                $bcachetime,
1039
                time()
1040
            );
1041
        } else {
1042
            $sql = sprintf(
1043
                "UPDATE %s SET func_num = %u, options = '%s', name = '%s', title = '%s', content = '%s', side = %u,"
1044
                . " weight = %u, visible = %u, c_type = '%s', isactive = %u, func_file = '%s', show_func = '%s',"
1045
                . " edit_func = '%s', template = '%s', bcachetime = %u, last_modified = %u WHERE bid = %u",
1046
                $this->db->prefix('newblocks'),
1047
                $func_num,
1048
                $options,
1049
                $name,
1050
                $title,
1051
                $content,
1052
                $side,
1053
                $weight,
1054
                $visible,
1055
                $c_type,
1056
                $isactive,
1057
                $func_file,
1058
                $show_func,
1059
                $edit_func,
1060
                $template,
1061
                $bcachetime,
1062
                time(),
1063
                $bid
1064
            );
1065
        }
1066
        if (!$result = $this->db->query($sql)) {
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
1067
            return false;
1068
        }
1069
        if (empty($bid)) {
1070
            $bid = $this->db->getInsertId();
0 ignored issues
show
Bug introduced by
The method getInsertId() does not exist on XoopsDatabase. Since it exists in all sub-types, consider adding an abstract or default implementation to XoopsDatabase. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1070
            /** @scrutinizer ignore-call */ 
1071
            $bid = $this->db->getInsertId();
Loading history...
1071
        }
1072
        $block->assignVar('bid', $bid);
1073
1074
        return true;
1075
    }
1076
1077
    /**
1078
     * delete a block from the database
1079
     *
1080
     * @param XoopsObject|XoopsBlock $block a XoopsBlock object
1081
     *
1082
     * @return bool true on success, otherwise false
1083
     */
1084
    public function delete(XoopsObject $block)
1085
    {
1086
        $className = 'XoopsBlock';
1087
        if (!($block instanceof $className)) {
1088
            return false;
1089
        }
1090
        $id  = $block->getVar('bid');
1091
        $sql = sprintf('DELETE FROM %s WHERE bid = %u', $this->db->prefix('newblocks'), $id);
0 ignored issues
show
Bug introduced by
It seems like $id can also be of type array and array; however, parameter $values of sprintf() does only seem to accept double|integer|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1091
        $sql = sprintf('DELETE FROM %s WHERE bid = %u', $this->db->prefix('newblocks'), /** @scrutinizer ignore-type */ $id);
Loading history...
1092
        if (!$result = $this->db->query($sql)) {
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
1093
            return false;
1094
        }
1095
        $sql = sprintf('DELETE FROM %s WHERE block_id = %u', $this->db->prefix('block_module_link'), $id);
1096
        $this->db->query($sql);
1097
1098
        return true;
1099
    }
1100
1101
    /**
1102
     * retrieve array of {@link XoopsBlock}s meeting certain conditions
1103
     * @param  CriteriaElement|CriteriaCompo $criteria  {@link CriteriaElement} with conditions for the blocks
1104
     * @param  bool   $id_as_key should the blocks' bid be the key for the returned array?
1105
     * @return array  {@link XoopsBlock}s matching the conditions
1106
     **/
1107
    public function getObjects(CriteriaElement $criteria = null, $id_as_key = false)
1108
    {
1109
        $ret   = array();
1110
        $limit = $start = 0;
1111
        $sql   = 'SELECT DISTINCT(b.bid), b.* FROM ' . $this->db->prefix('newblocks') . ' b LEFT JOIN '
1112
            . $this->db->prefix('block_module_link') . ' l ON b.bid=l.block_id';
1113
        if (isset($criteria) && is_subclass_of($criteria, 'CriteriaElement')) {
1114
            $sql .= ' ' . $criteria->renderWhere();
0 ignored issues
show
Bug introduced by
The method renderWhere() does not exist on CriteriaElement. Did you maybe mean render()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1114
            $sql .= ' ' . $criteria->/** @scrutinizer ignore-call */ renderWhere();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1115
            $limit = $criteria->getLimit();
1116
            $start = $criteria->getStart();
1117
        }
1118
        $result = $this->db->query($sql, $limit, $start);
1119
        if (!$this->db->isResultSet($result)) {
1120
            \trigger_error("Query Failed! SQL: $sql- Error: " . $this->db->error(), E_USER_ERROR);
1121
        }
1122
        while (false !== ($myrow = $this->db->fetchArray($result))) {
1123
            $block = new XoopsBlock();
1124
            $block->assignVars($myrow);
1125
            if (!$id_as_key) {
1126
                $ret[] =& $block;
1127
            } else {
1128
                $ret[$myrow['bid']] = &$block;
1129
            }
1130
            unset($block);
1131
        }
1132
1133
        return $ret;
1134
    }
1135
1136
    /**
1137
     * get a list of blocks matchich certain conditions
1138
     *
1139
     * @param  CriteriaElement $criteria conditions to match
1140
     * @return array  array of blocks matching the conditions
1141
     **/
1142
    public function getList(CriteriaElement $criteria = null)
1143
    {
1144
        $blocks = $this->getObjects($criteria, true);
1145
        $ret    = array();
1146
        foreach (array_keys($blocks) as $i) {
1147
            $name    = (!$blocks[$i]->isCustom()) ? $blocks[$i]->getVar('name') : $blocks[$i]->getVar('title');
1148
            $ret[$i] = $name;
1149
        }
1150
1151
        return $ret;
1152
    }
1153
1154
    ##################### Deprecated Methods ######################
1155
    /* These are not deprecated, they are dead and should be removed */
1156
    /**
1157
     * @deprecated
1158
     * @param      $moduleid
1159
     * @param bool $asobject
1160
     * @param bool $id_as_key
1161
     * @return bool
1162
     */
1163
    public function getByModule($moduleid, $asobject = true, $id_as_key = false)
0 ignored issues
show
Unused Code introduced by
The parameter $id_as_key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1163
    public function getByModule($moduleid, $asobject = true, /** @scrutinizer ignore-unused */ $id_as_key = false)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $asobject is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1163
    public function getByModule($moduleid, /** @scrutinizer ignore-unused */ $asobject = true, $id_as_key = false)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $moduleid is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1163
    public function getByModule(/** @scrutinizer ignore-unused */ $moduleid, $asobject = true, $id_as_key = false)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1164
    {
1165
        trigger_error(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated', E_USER_WARNING);
1166
1167
        return false;
1168
    }
1169
1170
    /**
1171
     * @param        $groupid
1172
     * @param int    $module_id
1173
     * @param bool   $toponlyblock
1174
     * @param null   $visible
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $visible is correct as it would always require null to be passed?
Loading history...
1175
     * @param string $orderby
1176
     * @param int    $isactive
1177
     *
1178
     * @return bool
1179
     * @deprecated
1180
     */
1181
    public function getAllByGroupModule($groupid, $module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'i.weight,i.instanceid', $isactive = 1)
0 ignored issues
show
Unused Code introduced by
The parameter $orderby is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1181
    public function getAllByGroupModule($groupid, $module_id = 0, $toponlyblock = false, $visible = null, /** @scrutinizer ignore-unused */ $orderby = 'i.weight,i.instanceid', $isactive = 1)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $module_id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1181
    public function getAllByGroupModule($groupid, /** @scrutinizer ignore-unused */ $module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'i.weight,i.instanceid', $isactive = 1)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $toponlyblock is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1181
    public function getAllByGroupModule($groupid, $module_id = 0, /** @scrutinizer ignore-unused */ $toponlyblock = false, $visible = null, $orderby = 'i.weight,i.instanceid', $isactive = 1)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $groupid is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1181
    public function getAllByGroupModule(/** @scrutinizer ignore-unused */ $groupid, $module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'i.weight,i.instanceid', $isactive = 1)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $visible is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1181
    public function getAllByGroupModule($groupid, $module_id = 0, $toponlyblock = false, /** @scrutinizer ignore-unused */ $visible = null, $orderby = 'i.weight,i.instanceid', $isactive = 1)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $isactive is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1181
    public function getAllByGroupModule($groupid, $module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'i.weight,i.instanceid', /** @scrutinizer ignore-unused */ $isactive = 1)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1182
    {
1183
        trigger_error(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated', E_USER_WARNING);
1184
1185
        return false;
1186
    }
1187
1188
    /**
1189
     * @param        $groupid
1190
     * @param string $orderby
1191
     *
1192
     * @return bool
1193
     * @deprecated
1194
     */
1195
    public function getAdminBlocks($groupid, $orderby = 'i.weight,i.instanceid')
0 ignored issues
show
Unused Code introduced by
The parameter $orderby is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1195
    public function getAdminBlocks($groupid, /** @scrutinizer ignore-unused */ $orderby = 'i.weight,i.instanceid')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $groupid is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1195
    public function getAdminBlocks(/** @scrutinizer ignore-unused */ $groupid, $orderby = 'i.weight,i.instanceid')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1196
    {
1197
        trigger_error(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated', E_USER_WARNING);
1198
1199
        return false;
1200
    }
1201
1202
    /**
1203
     * @return bool
1204
     * @deprecated
1205
     */
1206
    public function assignBlocks()
1207
    {
1208
        trigger_error(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated', E_USER_WARNING);
1209
1210
        return false;
1211
    }
1212
}
1213