XoopsBlock::options()   A
last analyzed

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-2025 XOOPS Project (https://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
    //PHP 8.2 Dynamic properties deprecated
34
    public $bid;
35
    public $mid;
36
    public $func_num;
37
    public $options;
38
    public $name;
39
    //public $position;
40
    public $title;
41
    public $content;
42
    public $side;
43
    public $weight;
44
    public $visible;
45
    public $block_type;
46
    public $c_type;
47
    public $isactive;
48
    public $dirname;
49
    public $func_file;
50
    public $show_func;
51
    public $edit_func;
52
    public $template;
53
    public $bcachetime;
54
    public $last_modified;
55
56
    /**
57
     * constructor
58
     *
59
     * @param mixed $id
60
     **/
61
    public function __construct($id = null)
62
    {
63
        $this->initVar('bid', XOBJ_DTYPE_INT, null, false);
64
        $this->initVar('mid', XOBJ_DTYPE_INT, 0, false);
65
        $this->initVar('func_num', XOBJ_DTYPE_INT, 0, false);
66
        $this->initVar('options', XOBJ_DTYPE_TXTBOX, null, false, 255);
67
        $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, true, 150);
68
        //$this->initVar('position', XOBJ_DTYPE_INT, 0, false);
69
        $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false, 150);
70
        $this->initVar('content', XOBJ_DTYPE_TXTAREA, null, false);
71
        $this->initVar('side', XOBJ_DTYPE_INT, 0, false);
72
        $this->initVar('weight', XOBJ_DTYPE_INT, 0, false);
73
        $this->initVar('visible', XOBJ_DTYPE_INT, 0, false);
74
        $this->initVar('block_type', XOBJ_DTYPE_OTHER, null, false);
75
        $this->initVar('c_type', XOBJ_DTYPE_OTHER, null, false);
76
        $this->initVar('isactive', XOBJ_DTYPE_INT, null, false);
77
        $this->initVar('dirname', XOBJ_DTYPE_TXTBOX, null, false, 50);
78
        $this->initVar('func_file', XOBJ_DTYPE_TXTBOX, null, false, 50);
79
        $this->initVar('show_func', XOBJ_DTYPE_TXTBOX, null, false, 50);
80
        $this->initVar('edit_func', XOBJ_DTYPE_TXTBOX, null, false, 50);
81
        $this->initVar('template', XOBJ_DTYPE_OTHER, null, false);
82
        $this->initVar('bcachetime', XOBJ_DTYPE_INT, 0, false);
83
        $this->initVar('last_modified', XOBJ_DTYPE_INT, 0, false);
84
85
        parent::__construct();
86
87
        // for backward compatibility
88
        if (isset($id)) {
89
            if (is_array($id)) {
90
                $this->assignVars($id);
91
            } else {
92
                $blkhandler = xoops_getHandler('block');
93
                $obj        = $blkhandler->get($id);
94
                foreach (array_keys($obj->getVars()) as $i) {
95
                    $this->assignVar($i, $obj->getVar($i, 'n'));
96
                }
97
            }
98
        }
99
    }
100
101
    /**
102
     * Returns Class Base Variable bid
103
     * @param string $format
104
     * @return mixed
105
     */
106
    public function id($format = 'n')
107
    {
108
        return $this->getVar('bid', $format);
109
    }
110
111
    /**
112
     * Returns Class Base Variable bid
113
     * @param string $format
114
     * @return mixed
115
     */
116
    public function bid($format = '')
117
    {
118
        return $this->getVar('bid', $format);
119
    }
120
121
    /**
122
     * Returns Class Base Variable mid
123
     * @param string $format
124
     * @return mixed
125
     */
126
    public function mid($format = '')
127
    {
128
        return $this->getVar('mid', $format);
129
    }
130
131
    /**
132
     * Returns Class Base Variable func_num
133
     * @param string $format
134
     * @return mixed
135
     */
136
    public function func_num($format = '')
137
    {
138
        return $this->getVar('func_num', $format);
139
    }
140
141
    /**
142
     * Returns Class Base Variable avatar_id
143
     * @param string $format
144
     * @return mixed
145
     */
146
    public function options($format = '')
147
    {
148
        return $this->getVar('options', $format);
149
    }
150
151
    /**
152
     * Returns Class Base Variable name
153
     * @param string $format
154
     * @return mixed
155
     */
156
    public function name($format = '')
157
    {
158
        return $this->getVar('name', $format);
159
    }
160
161
    /**
162
     * Returns Class Base Variable title
163
     * @param string $format
164
     * @return mixed
165
     */
166
    public function title($format = '')
167
    {
168
        return $this->getVar('title', $format);
169
    }
170
171
    /**
172
     * Returns Class Base Variable content
173
     * @param string $format
174
     * @return mixed
175
     */
176
    public function content($format = '')
177
    {
178
        return $this->getVar('content', $format);
179
    }
180
181
    /**
182
     * Returns Class Base Variable side
183
     * @param string $format
184
     * @return mixed
185
     */
186
    public function side($format = '')
187
    {
188
        return $this->getVar('side', $format);
189
    }
190
191
    /**
192
     * Returns Class Base Variable weight
193
     * @param string $format
194
     * @return mixed
195
     */
196
    public function weight($format = '')
197
    {
198
        return $this->getVar('weight', $format);
199
    }
200
201
    /**
202
     * Returns Class Base Variable visible
203
     * @param string $format
204
     * @return mixed
205
     */
206
    public function visible($format = '')
207
    {
208
        return $this->getVar('visible', $format);
209
    }
210
211
    /**
212
     * Returns Class Base Variable block_type
213
     *
214
     * Valid block_type values are:
215
     * S - generated by system module
216
     * M - generated by a non-system module
217
     * C - Custom block
218
     * D - cloned system/module block
219
     * E - cloned custom block, DON'T use it
220
     *
221
     * @param string $format
222
     *
223
     * @return mixed
224
     */
225
    public function block_type($format = '')
226
    {
227
        return $this->getVar('block_type', $format);
228
    }
229
230
    /**
231
     * Returns Class Base Variable c_type
232
     * @param string $format
233
     * @return mixed
234
     */
235
    public function c_type($format = '')
236
    {
237
        return $this->getVar('c_type', $format);
238
    }
239
240
    /**
241
     * Returns Class Base Variable isactive
242
     * @param string $format
243
     * @return mixed
244
     */
245
    public function isactive($format = '')
246
    {
247
        return $this->getVar('isactive', $format);
248
    }
249
250
    /**
251
     * Returns Class Base Variable dirname
252
     * @param string $format
253
     * @return mixed
254
     */
255
    public function dirname($format = '')
256
    {
257
        return $this->getVar('dirname', $format);
258
    }
259
260
    /**
261
     * Returns Class Base Variable func_file
262
     * @param string $format
263
     * @return mixed
264
     */
265
    public function func_file($format = '')
266
    {
267
        return $this->getVar('func_file', $format);
268
    }
269
270
    /**
271
     * Returns Class Base Variable show_func
272
     * @param string $format
273
     * @return mixed
274
     */
275
    public function show_func($format = '')
276
    {
277
        return $this->getVar('show_func', $format);
278
    }
279
280
    /**
281
     * Returns Class Base Variable edit_func
282
     * @param string $format
283
     * @return mixed
284
     */
285
    public function edit_func($format = '')
286
    {
287
        return $this->getVar('edit_func', $format);
288
    }
289
290
    /**
291
     * Returns Class Base Variable template
292
     * @param string $format
293
     * @return mixed
294
     */
295
    public function template($format = '')
296
    {
297
        return $this->getVar('template', $format);
298
    }
299
300
    /**
301
     * Returns Class Base Variable avatar_id
302
     * @param string $format
303
     * @return mixed
304
     */
305
    public function bcachetime($format = '')
306
    {
307
        return $this->getVar('bcachetime', $format);
308
    }
309
310
    /**
311
     * Returns Class Base Variable last_modified
312
     * @param string $format
313
     * @return mixed
314
     */
315
    public function last_modified($format = '')
316
    {
317
        return $this->getVar('last_modified', $format);
318
    }
319
320
    /**
321
     * return the content of the block for output
322
     *
323
     * @param  string $format
324
     * @param  string $c_type type of content
325
     *                        Valid values for the type of content:
326
     *                        H : custom HTML block
327
     *                        P : custom PHP block
328
     *                        S : use text sanitizer (smilies enabled)
329
     *                        T : use text sanitizer (smilies disabled)</ul>
330
     * @return string content for output
331
     */
332
    public function getContent($format = 's', $c_type = 'T')
333
    {
334
        $format = strtolower($format);
335
        $c_type = strtoupper($c_type);
336
        switch ($format) {
337
            case 's':
338
                if ($c_type === 'H') {
339
                    return str_replace('{X_SITEURL}', XOOPS_URL . '/', $this->getVar('content', 'n'));
340
                } elseif ($c_type === 'P') {
341
                    ob_start();
342
                    echo eval($this->getVar('content', 'n'));
0 ignored issues
show
introduced by
The use of eval() is discouraged.
Loading history...
343
                    $content = ob_get_contents();
344
                    ob_end_clean();
345
346
                    return str_replace('{X_SITEURL}', XOOPS_URL . '/', $content);
347
                } elseif ($c_type === 'S') {
348
                    $myts    = \MyTextSanitizer::getInstance();
349
                    $content = str_replace('{X_SITEURL}', XOOPS_URL . '/', $this->getVar('content', 'n'));
350
351
                    return $myts->displayTarea($content, 0, 1);
352
                } else {
353
                    $myts    = \MyTextSanitizer::getInstance();
354
                    $content = str_replace('{X_SITEURL}', XOOPS_URL . '/', $this->getVar('content', 'n'));
355
356
                    return $myts->displayTarea($content, 0, 0);
357
                }
358
                // no break
359
            case 'e':
360
                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...
361
            default:
362
                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...
363
        }
364
    }
365
366
    /**
367
     * (HTML-) form for setting the options of the block
368
     *
369
     * @return string HTML for the form, FALSE if not defined for this block
370
     */
371
    public function getOptions()
372
    {
373
        if (!$this->isCustom()) {
374
            $edit_func = $this->getVar('edit_func');
375
            if (!$edit_func) {
376
                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...
377
            }
378
            if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/blocks/' . $this->getVar('func_file'))) {
379
                if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/blocks.php')) {
380
                    include_once XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/blocks.php';
381
                } elseif (file_exists(XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/language/english/blocks.php')) {
382
                    include_once XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/language/english/blocks.php';
383
                }
384
                include_once XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/blocks/' . $this->getVar('func_file');
385
                $options   = explode('|', $this->getVar('options'));
386
                $edit_form = $edit_func($options);
387
                if (!$edit_form) {
388
                    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...
389
                }
390
391
                return $edit_form;
392
            } else {
393
                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...
394
            }
395
        } else {
396
            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...
397
        }
398
    }
399
400
    /**
401
     * @return bool
402
     */
403
    public function isCustom()
404
    {
405
        return in_array(
406
            $this->getVar('block_type'),
407
            [
408
                'C',
409
                'E',
410
            ],
411
        );
412
    }
413
414
    /**
415
     * These methods are for compatibility with the pre 2.5.11 class/xoopsblock.php
416
     * class/xoopsblock.php defined its own XoopsBlock class, making it impossible
417
     * to use with anything that used the handler provided in kernel/block.php
418
     *
419
     * In addition to the actual data, the old XoopsBlock contained what should be
420
     * considered handler logic.
421
     *
422
     * It appears that class/xoopsblock.php came first, but a conversion to the kernel
423
     * handler was never completed.
424
     *
425
     * These methods should all be considered deprecated.
426
     */
427
428
    /**
429
     * Load $id
430
     *
431
     * @param int $id
432
     *
433
     * @deprecated
434
     */
435
    public function load($id)
436
    {
437
        $id  = (int) $id;
438
        /** @var XoopsBlockHandler $blkhandler */
439
        $blkhandler = xoops_getHandler('block');
440
        $obj        = $blkhandler->get($id);
441
        foreach (array_keys($obj->getVars()) as $i) {
442
            $this->assignVar($i, $obj->getVar($i, 'n'));
443
        }
444
    }
445
446
    /**
447
     * Store Block Data to Database
448
     *
449
     * @return int|false id of inserted block, or false on failure
450
     *
451
     * @deprecated
452
     */
453
    public function store()
454
    {
455
        /** @var XoopsBlockHandler $blkhandler */
456
        $blkhandler = xoops_getHandler('block');
457
        if (false === $blkhandler->insert($this)) {
458
            return false;
459
        }
460
        return (int) $this->bid();
461
    }
462
463
    /**
464
     * Delete an ID from the database
465
     *
466
     * @return bool
467
     *
468
     * @deprecated
469
     */
470
    public function delete()
471
    {
472
        /** @var XoopsBlockHandler $blkhandler */
473
        $blkhandler = xoops_getHandler('block');
474
        return $blkhandler->delete($this);
475
    }
476
477
    /**
478
     * Build Block
479
     *
480
     * @return mixed
481
     *
482
     * @deprecated
483
     */
484
    public function buildBlock()
485
    {
486
        global $xoopsConfig, $xoopsOption, $xoTheme;
487
        $block = [];
488
        if (!$this->isCustom()) {
489
            // get block display function
490
            $show_func = $this->getVar('show_func');
491
            if (!$show_func) {
492
                return false;
493
            }
494
            if (!file_exists($func_file = $GLOBALS['xoops']->path('modules/' . $this->getVar('dirname') . '/blocks/' . $this->getVar('func_file')))) {
495
                return false;
496
            }
497
            // must get lang files b4 including the file
498
            // some modules require it for code that is outside the function
499
            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

499
            xoops_loadLanguage('blocks', /** @scrutinizer ignore-type */ $this->getVar('dirname'));
Loading history...
500
            include_once $func_file;
501
502
            if (function_exists($show_func)) {
503
                // execute the function
504
                $options = explode('|', $this->getVar('options'));
505
                $block   = $show_func($options);
506
                if (!$block) {
507
                    return false;
508
                }
509
            } else {
510
                return false;
511
            }
512
        } else {
513
            // it is a custom block, so just return the contents
514
            $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

514
            $block['content'] = $this->getContent('s', /** @scrutinizer ignore-type */ $this->getVar('c_type'));
Loading history...
515
            if (empty($block['content'])) {
516
                return false;
517
            }
518
        }
519
520
        return $block;
521
    }
522
523
    /*
524
    * Aligns the content of a block
525
    * If position is 0, content in DB is positioned
526
    * before the original content
527
    * If position is 1, content in DB is positioned
528
    * after the original content
529
    */
530
    /**
531
     * @param        $position
532
     * @param string $content
533
     * @param string $contentdb
534
     *
535
     * @return string
536
     *
537
     * @deprecated
538
     */
539
    public function buildContent($position, $content = '', $contentdb = '')
540
    {
541
        $ret = null;
542
        if ($position == 0) {
543
            $ret = $contentdb . $content;
544
        } elseif ($position == 1) {
545
            $ret = $content . $contentdb;
546
        }
547
548
        return $ret;
549
    }
550
551
    /**
552
     * Enter description here...
553
     *
554
     * @param  string $originaltitle
555
     * @param  string $newtitle
556
     * @return string title
557
     *
558
     * @deprecated
559
     */
560
    public function buildTitle($originaltitle, $newtitle = '')
561
    {
562
        $ret = $originaltitle;
563
        if ($newtitle != '') {
564
            $ret = $newtitle;
565
        }
566
567
        return $ret;
568
    }
569
570
    /**
571
     * get all the blocks that match the supplied parameters
572
     * @param int|array $groupid  groupid (can be an array)
573
     * @param bool   $asobject
574
     * @param null|string $side     0: sideblock - left
575
     *                         1: sideblock - right
576
     *                         2: sideblock - left and right
577
     *                         3: centerblock - left
578
     *                         4: centerblock - right
579
     *                         5: centerblock - center
580
     *                         6: centerblock - left, right, center
581
     * @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...
582
     * @param string $orderby  order of the blocks
583
     * @param int    $isactive
584
     * @returns array of block objects
585
     *
586
     * @deprecated
587
     */
588
    public static function getAllBlocksByGroup($groupid, $asobject = true, $side = null, $visible = null, $orderby = 'b.weight,b.bid', $isactive = 1)
589
    {
590
        $db  = XoopsDatabaseFactory::getDatabaseConnection();
591
        $ret = [];
592
        $sql = 'SELECT b.* ';
593
        if (!$asobject) {
594
            $sql = 'SELECT b.bid ';
595
        }
596
        $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";
597
        if (is_array($groupid)) {
598
            $sql .= ' AND (l.gperm_groupid=' . $groupid[0] . '';
599
            $size = count($groupid);
600
            if ($size > 1) {
601
                for ($i = 1; $i < $size; ++$i) {
602
                    $sql .= ' OR l.gperm_groupid=' . $groupid[$i] . '';
603
                }
604
            }
605
            $sql .= ')';
606
        } else {
607
            $sql .= ' AND l.gperm_groupid=' . $groupid . '';
608
        }
609
        $sql .= ' AND b.isactive=' . $isactive;
610
        if (isset($side)) {
611
            // get both sides in sidebox? (some themes need this)
612
            if ($side == XOOPS_SIDEBLOCK_BOTH) {
613
                $side = '(b.side=0 OR b.side=1)';
614
            } elseif ($side == XOOPS_CENTERBLOCK_ALL) {
615
                $side = '(b.side=3 OR b.side=4 OR b.side=5 OR b.side=7 OR b.side=8 OR b.side=9 )';
616
            } elseif ($side == XOOPS_FOOTERBLOCK_ALL) {
617
                $side = '(b.side=10 OR b.side=11 OR b.side=12 )';
618
            } else {
619
                $side = 'b.side=' . $side;
620
            }
621
            $sql .= ' AND ' . $side;
622
        }
623
        if (isset($visible)) {
624
            $sql .= " AND b.visible=$visible";
625
        }
626
        $sql .= " ORDER BY $orderby";
627
        $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

627
        /** @scrutinizer ignore-call */ 
628
        $result = $db->query($sql);
Loading history...
628
        if (!$db->isResultSet($result)) {
629
            throw new \RuntimeException(
630
                \sprintf(_DB_QUERY_ERROR, $sql) . $db->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

630
                \sprintf(_DB_QUERY_ERROR, $sql) . $db->/** @scrutinizer ignore-call */ error(),
Loading history...
631
                E_USER_ERROR,
632
            );
633
        }
634
        $added  = [];
635
        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

635
        while (false !== ($myrow = $db->/** @scrutinizer ignore-call */ fetchArray($result))) {
Loading history...
636
            if (!in_array($myrow['bid'], $added)) {
637
                if (!$asobject) {
638
                    $ret[] = $myrow['bid'];
639
                } else {
640
                    $ret[] = new XoopsBlock($myrow);
641
                }
642
                $added[] = $myrow['bid'];
643
            }
644
        }
645
646
        return $ret;
647
    }
648
649
    /**
650
     * XoopsBlock::getAllBlocks()
651
     *
652
     * @param  string  $rettype
653
     * @param  mixed   $side
654
     * @param  mixed   $visible
655
     * @param  string  $orderby
656
     * @param  integer $isactive
657
     * @return array
658
     *
659
     * @deprecated
660
     */
661
    public function getAllBlocks($rettype = 'object', $side = null, $visible = null, $orderby = 'side,weight,bid', $isactive = 1)
662
    {
663
        $db          = XoopsDatabaseFactory::getDatabaseConnection();
664
        $ret         = [];
665
        $where_query = ' WHERE isactive=' . $isactive;
666
        if (isset($side)) {
667
            // get both sides in sidebox? (some themes need this)
668
            if ($side == XOOPS_SIDEBLOCK_BOTH) {
669
                $side = '(side=0 OR side=1)';
670
            } elseif ($side == XOOPS_CENTERBLOCK_ALL) {
671
                $side = '(side=3 OR side=4 OR side=5 OR side=7 OR side=8 OR side=9)';
672
            } elseif ($side == XOOPS_FOOTERBLOCK_ALL) {
673
                $side = '(side=10 OR side=11 OR side=12)';
674
            } else {
675
                $side = 'side=' . $side;
676
            }
677
            $where_query .= ' AND ' . $side;
678
        }
679
        if (isset($visible)) {
680
            $where_query .= ' AND visible=.' . $visible;
681
        }
682
        $where_query .= ' ORDER BY ' . $orderby;
683
        switch ($rettype) {
684
            case 'object':
685
                $sql    = 'SELECT * FROM ' . $db->prefix('newblocks') . '' . $where_query;
686
                $result = $db->query($sql);
687
                if (!$db->isResultSet($result)) {
688
                    throw new \RuntimeException(
689
                        \sprintf(_DB_QUERY_ERROR, $sql) . $db->error(),
690
                        E_USER_ERROR,
691
                    );
692
                }
693
                while (false !== ($myrow = $db->fetchArray($result))) {
694
                    $ret[] = new XoopsBlock($myrow);
695
                }
696
                break;
697
            case 'list':
698
                $sql    = 'SELECT * FROM ' . $db->prefix('newblocks') . '' . $where_query;
699
                $result = $db->query($sql);
700
                if (!$db->isResultSet($result)) {
701
                    throw new \RuntimeException(
702
                        \sprintf(_DB_QUERY_ERROR, $sql) . $db->error(),
703
                        E_USER_ERROR,
704
                    );
705
                }
706
                while (false !== ($myrow = $db->fetchArray($result))) {
707
                    $block                      = new XoopsBlock($myrow);
708
                    $title                      = $block->getVar('title');
709
                    $title                      = empty($title) ? $block->getVar('name') : $title;
710
                    $ret[$block->getVar('bid')] = $title;
711
                }
712
                break;
713
            case 'id':
714
                $sql    = 'SELECT bid FROM ' . $db->prefix('newblocks') . '' . $where_query;
715
                $result = $db->query($sql);
716
                if (!$db->isResultSet($result)) {
717
                    throw new \RuntimeException(
718
                        \sprintf(_DB_QUERY_ERROR, $sql) . $db->error(),
719
                        E_USER_ERROR,
720
                    );
721
                }
722
                while (false !== ($myrow = $db->fetchArray($result))) {
723
                    $ret[] = $myrow['bid'];
724
                }
725
                break;
726
        }
727
728
        return $ret;
729
    }
730
731
    /**
732
     * XoopsBlock::getByModule()
733
     *
734
     * @param  mixed $moduleid
735
     * @param  mixed $asobject
736
     * @return array
737
     */
738
    public static function getByModule($moduleid, $asobject = true)
739
    {
740
        $moduleid = (int) $moduleid;
741
        $db       = XoopsDatabaseFactory::getDatabaseConnection();
742
        if ($asobject == true) {
743
            $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...
744
        } else {
745
            $sql = 'SELECT bid FROM ' . $db->prefix('newblocks') . ' WHERE mid=' . $moduleid;
746
        }
747
        $result = $db->query($sql);
748
        if (!$db->isResultSet($result)) {
749
            throw new \RuntimeException(
750
                \sprintf(_DB_QUERY_ERROR, $sql) . $db->error(),
751
                E_USER_ERROR,
752
            );
753
        }
754
        $ret    = [];
755
        while (false !== ($myrow = $db->fetchArray($result))) {
756
            if ($asobject) {
757
                $ret[] = new XoopsBlock($myrow);
758
            } else {
759
                $ret[] = $myrow['bid'];
760
            }
761
        }
762
763
        return $ret;
764
    }
765
766
    /**
767
     * XoopsBlock::getAllByGroupModule()
768
     *
769
     * @param  mixed   $groupid
770
     * @param  integer $module_id
771
     * @param  mixed   $toponlyblock
772
     * @param  mixed   $visible
773
     * @param  string  $orderby
774
     * @param  integer $isactive
775
     * @return array
776
     *
777
     * @deprecated (This also appears, dead, in XoopsBlockHandler)
778
     */
779
    public function getAllByGroupModule($groupid, $module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'b.weight, m.block_id', $isactive = 1)
780
    {
781
        $isactive = (int) $isactive;
782
        $db       = XoopsDatabaseFactory::getDatabaseConnection();
783
        $ret      = [];
784
        if (isset($groupid)) {
785
            $sql = 'SELECT DISTINCT gperm_itemid FROM ' . $db->prefix('group_permission') . " WHERE gperm_name = 'block_read' AND gperm_modid = 1";
786
            if (is_array($groupid)) {
787
                $sql .= ' AND gperm_groupid IN (' . implode(',', $groupid) . ')';
788
            } else {
789
                if ((int) $groupid > 0) {
790
                    $sql .= ' AND gperm_groupid=' . (int) $groupid;
791
                }
792
            }
793
            $result   = $db->query($sql);
794
            if (!$db->isResultSet($result)) {
795
                throw new \RuntimeException(
796
                    \sprintf(_DB_QUERY_ERROR, $sql) . $db->error(),
797
                    E_USER_ERROR,
798
                );
799
            }
800
            $blockids = [];
801
            while (false !== ($myrow = $db->fetchArray($result))) {
802
                $blockids[] = $myrow['gperm_itemid'];
803
            }
804
            if (empty($blockids)) {
805
                return $blockids;
806
            }
807
        }
808
        $sql = 'SELECT b.* FROM ' . $db->prefix('newblocks') . ' b
809
            JOIN ' . $db->prefix('block_module_link') . ' m ON m.block_id = b.bid
810
            LEFT JOIN ' . $db->prefix('modules') . ' mo ON mo.mid = b.mid
811
            WHERE b.isactive =' . $isactive . ' AND (mo.isactive =' . $isactive . ' OR b.mid = 0)';
812
        if (isset($visible)) {
813
            $sql .= ' AND b.visible=' . (int) $visible;
814
        }
815
        if (!isset($module_id)) {
816
        } elseif (!empty($module_id)) {
817
            $sql .= ' AND m.module_id IN (0,' . (int) $module_id;
818
            if ($toponlyblock) {
819
                $sql .= ',-1';
820
            }
821
            $sql .= ')';
822
        } else {
823
            if ($toponlyblock) {
824
                $sql .= ' AND m.module_id IN (0,-1)';
825
            } else {
826
                $sql .= ' AND m.module_id=0';
827
            }
828
        }
829
        if (!empty($blockids)) {
830
            $sql .= ' AND b.bid IN (' . implode(',', $blockids) . ')';
831
        }
832
        $sql .= ' ORDER BY ' . $orderby;
833
        $result = $db->query($sql);
834
        if (!$db->isResultSet($result)) {
835
            throw new \RuntimeException(
836
                \sprintf(_DB_QUERY_ERROR, $sql) . $db->error(),
837
                E_USER_ERROR,
838
            );
839
        }
840
        while (false !== ($myrow = $db->fetchArray($result))) {
841
            $block              = new XoopsBlock($myrow);
842
            $ret[$myrow['bid']] = &$block;
843
            unset($block);
844
        }
845
846
        return $ret;
847
    }
848
849
    /**
850
     * XoopsBlock::getNonGroupedBlocks()
851
     *
852
     * @param  integer $module_id
853
     * @param  mixed   $toponlyblock
854
     * @param  mixed   $visible
855
     * @param  string  $orderby
856
     * @param  integer $isactive
857
     * @return array
858
     *
859
     * @deprecated
860
     */
861
    public function getNonGroupedBlocks($module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'b.weight, m.block_id', $isactive = 1)
862
    {
863
        $db   = XoopsDatabaseFactory::getDatabaseConnection();
864
        $ret  = [];
865
        $bids = [];
866
        $sql  = 'SELECT DISTINCT(bid) from ' . $db->prefix('newblocks');
867
        $result = $db->query($sql);
868
        if ($db->isResultSet($result)) {
869
            while (false !== ($myrow = $db->fetchArray($result))) {
870
                $bids[] = $myrow['bid'];
871
            }
872
        }
873
874
        $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'";
875
        $grouped = [];
876
        $result  = $db->query($sql);
877
        if ($db->isResultSet($result)) {
878
            while (false !== ($myrow = $db->fetchArray($result))) {
879
                $grouped[] = $myrow['gperm_itemid'];
880
            }
881
        }
882
883
884
        $non_grouped = array_diff($bids, $grouped);
885
        if (!empty($non_grouped)) {
886
            $sql = 'SELECT b.* FROM ' . $db->prefix('newblocks') . ' b, ' . $db->prefix('block_module_link') . ' m WHERE m.block_id=b.bid';
887
            $sql .= ' AND b.isactive=' . (int) $isactive;
888
            if (isset($visible)) {
889
                $sql .= ' AND b.visible=' . (int) $visible;
890
            }
891
            if (!isset($module_id)) {
892
            } elseif (!empty($module_id)) {
893
                $sql .= ' AND m.module_id IN (0,' . (int) $module_id;
894
                if ($toponlyblock) {
895
                    $sql .= ',-1';
896
                }
897
                $sql .= ')';
898
            } else {
899
                if ($toponlyblock) {
900
                    $sql .= ' AND m.module_id IN (0,-1)';
901
                } else {
902
                    $sql .= ' AND m.module_id=0';
903
                }
904
            }
905
            $sql .= ' AND b.bid IN (' . implode(',', $non_grouped) . ')';
906
            $sql .= ' ORDER BY ' . $orderby;
907
            $result = $db->query($sql);
908
            if (!$db->isResultSet($result)) {
909
                throw new \RuntimeException(
910
                    \sprintf(_DB_QUERY_ERROR, $sql) . $db->error(),
911
                    E_USER_ERROR,
912
                );
913
            }
914
            while (false !== ($myrow = $db->fetchArray($result))) {
915
                $block              = new XoopsBlock($myrow);
916
                $ret[$myrow['bid']] = & $block;
917
                unset($block);
918
            }
919
        }
920
921
        return $ret;
922
    }
923
924
    /**
925
     * XoopsBlock::countSimilarBlocks()
926
     *
927
     * @param  mixed $moduleId
928
     * @param  mixed $funcNum
929
     * @param  mixed $showFunc
930
     * @return int
931
     *
932
     * @deprecated
933
     */
934
    public function countSimilarBlocks($moduleId, $funcNum, $showFunc = null)
935
    {
936
        $funcNum  = (int) $funcNum;
937
        $moduleId = (int) $moduleId;
938
        if ($funcNum < 1 || $moduleId < 1) {
939
            // invalid query
940
            return 0;
941
        }
942
        $db = XoopsDatabaseFactory::getDatabaseConnection();
943
        if (isset($showFunc)) {
944
            // showFunc is set for more strict comparison
945
            $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

945
            $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...
946
        } else {
947
            $sql = sprintf('SELECT COUNT(*) FROM %s WHERE mid = %d AND func_num = %d', $db->prefix('newblocks'), $moduleId, $funcNum);
948
        }
949
        $result = $db->query($sql);
950
        if (!$db->isResultSet($result)) {
951
            return 0;
952
        }
953
        [$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

953
        /** @scrutinizer ignore-call */ 
954
        [$count] = $db->fetchRow($result);
Loading history...
954
955
        return (int) $count;
956
    }
957
}
958
959
/**
960
 * XOOPS block handler class. (Singleton)
961
 *
962
 * This class is responsible for providing data access mechanisms to the data source
963
 * of XOOPS block class objects.
964
 *
965
 * @author              Kazumi Ono <[email protected]>
966
 * @copyright       (c) 2000-2025 XOOPS Project (https://xoops.org)
967
 * @package             kernel
968
 * @subpackage          block
969
 *
970
 * @todo Why is this not a XoopsPersistableObjectHandler?
971
 */
972
class XoopsBlockHandler extends XoopsObjectHandler
973
{
974
    /**
975
     * create a new block
976
     *
977
     * @see XoopsBlock
978
     * @param  bool $isNew is the new block new??
979
     * @return XoopsBlock XoopsBlock reference to the new block
980
     **/
981
    public function create($isNew = true)
982
    {
983
        $block = new XoopsBlock();
984
        if ($isNew) {
985
            $block->setNew();
986
        }
987
988
        return $block;
989
    }
990
991
    /**
992
     * retrieve a specific {@link XoopsBlock}
993
     *
994
     * @see XoopsBlock
995
     * @param  int $id bid of the block to retrieve
996
     * @return XoopsBlock reference to the block
997
     **/
998
    public function get($id)
999
    {
1000
        $block = false;
1001
        $id    = (int) $id;
1002
        if ($id > 0) {
1003
            $sql    = 'SELECT * FROM ' . $this->db->prefix('newblocks') . ' WHERE bid=' . $id;
1004
            $result = $this->db->query($sql);
1005
            if ($this->db->isResultSet($result)) {
1006
                $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

1006
                /** @scrutinizer ignore-call */ 
1007
                $numrows = $this->db->getRowsNum($result);
Loading history...
1007
                if ($numrows == 1) {
1008
                    $block = new XoopsBlock();
1009
                    $block->assignVars($this->db->fetchArray($result));
1010
                }
1011
            }
1012
        }
1013
1014
        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...
1015
    }
1016
1017
    /**
1018
     * write a new block into the database
1019
     *
1020
     * @param XoopsObject|XoopsBlock $block a XoopsBlock object
1021
     *
1022
     * @return bool true on success, otherwise false
1023
     */
1024
    public function insert(XoopsObject $block)
1025
    {
1026
        $className = 'XoopsBlock';
1027
        if (!($block instanceof $className)) {
1028
            return false;
1029
        }
1030
        if (!$block->isDirty()) {
1031
            return true;
1032
        }
1033
        if (!$block->cleanVars()) {
1034
            return false;
1035
        }
1036
1037
        $bid = $block->getVar('bid', 'n');
1038
        $mid = $block->getVar('mid', 'n');
1039
        $func_num = $block->getVar('func_num', 'n');
1040
        $options = $block->getVar('options', 'n');
1041
        $name = $block->getVar('name', 'n');
1042
        $title = $block->getVar('title', 'n');
1043
        $content = $block->getVar('content', 'n');
1044
        $side = $block->getVar('side', 'n');
1045
        $weight = $block->getVar('weight', 'n');
1046
        $visible = $block->getVar('visible', 'n');
1047
        $c_type = $block->getVar('c_type', 'n');
1048
        $isactive = $block->getVar('isactive', 'n');
1049
        $func_file = $block->getVar('func_file', 'n');
1050
        $show_func = $block->getVar('show_func', 'n');
1051
        $edit_func = $block->getVar('edit_func', 'n');
1052
        $template = $block->getVar('template', 'n');
1053
        $bcachetime = $block->getVar('bcachetime', 'n');
1054
        $block_type = $block->getVar('block_type', 'n');
1055
        $dirname = $block->getVar('dirname', 'n');
1056
1057
        if ($block->isNew()) {
1058
            $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

1058
            /** @scrutinizer ignore-call */ 
1059
            $bid = $this->db->genId('newblocks_bid_seq');
Loading history...
1059
            $sql = sprintf(
1060
                'INSERT INTO %s (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type,'
1061
                . ' c_type, isactive, dirname, func_file, show_func, edit_func, template, bcachetime, last_modified)'
1062
                . " VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', %u, %u, %u, '%s', '%s', %u, '%s', '%s', '%s', '%s',"
1063
                . " '%s', %u, %u)",
1064
                $this->db->prefix('newblocks'),
1065
                $bid,
1066
                $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

1066
                /** @scrutinizer ignore-type */ $mid,
Loading history...
1067
                $func_num,
1068
                $options,
1069
                $name,
1070
                $title,
1071
                $content,
1072
                $side,
1073
                $weight,
1074
                $visible,
1075
                $block_type,
1076
                $c_type,
1077
                1,
1078
                $dirname,
1079
                $func_file,
1080
                $show_func,
1081
                $edit_func,
1082
                $template,
1083
                $bcachetime,
1084
                time(),
1085
            );
1086
        } else {
1087
            $sql = sprintf(
1088
                "UPDATE %s SET func_num = %u, options = '%s', name = '%s', title = '%s', content = '%s', side = %u,"
1089
                . " weight = %u, visible = %u, c_type = '%s', isactive = %u, func_file = '%s', show_func = '%s',"
1090
                . " edit_func = '%s', template = '%s', bcachetime = %u, last_modified = %u WHERE bid = %u",
1091
                $this->db->prefix('newblocks'),
1092
                $func_num,
1093
                $options,
1094
                $name,
1095
                $title,
1096
                $content,
1097
                $side,
1098
                $weight,
1099
                $visible,
1100
                $c_type,
1101
                $isactive,
1102
                $func_file,
1103
                $show_func,
1104
                $edit_func,
1105
                $template,
1106
                $bcachetime,
1107
                time(),
1108
                $bid,
1109
            );
1110
        }
1111
        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...
1112
            return false;
1113
        }
1114
        if (empty($bid)) {
1115
            $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

1115
            /** @scrutinizer ignore-call */ 
1116
            $bid = $this->db->getInsertId();
Loading history...
1116
        }
1117
        $block->assignVar('bid', $bid);
1118
1119
        return true;
1120
    }
1121
1122
    /**
1123
     * delete a block from the database
1124
     *
1125
     * @param XoopsObject|XoopsBlock $block a XoopsBlock object
1126
     *
1127
     * @return bool true on success, otherwise false
1128
     */
1129
    public function delete(XoopsObject $block)
1130
    {
1131
        $className = 'XoopsBlock';
1132
        if (!($block instanceof $className)) {
1133
            return false;
1134
        }
1135
        $id  = $block->getVar('bid');
1136
        $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

1136
        $sql = sprintf('DELETE FROM %s WHERE bid = %u', $this->db->prefix('newblocks'), /** @scrutinizer ignore-type */ $id);
Loading history...
1137
        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...
1138
            return false;
1139
        }
1140
        $sql = sprintf('DELETE FROM %s WHERE block_id = %u', $this->db->prefix('block_module_link'), $id);
1141
        $this->db->query($sql);
1142
1143
        return true;
1144
    }
1145
1146
    /**
1147
     * retrieve array of {@link XoopsBlock}s meeting certain conditions
1148
     * @param  CriteriaElement|CriteriaCompo $criteria  {@link CriteriaElement} with conditions for the blocks
1149
     * @param  bool   $id_as_key should the blocks' bid be the key for the returned array?
1150
     * @return array  {@link XoopsBlock}s matching the conditions
1151
     **/
1152
    public function getObjects(?CriteriaElement $criteria = null, $id_as_key = false)
1153
    {
1154
        $ret   = [];
1155
        $limit = $start = 0;
1156
        $sql   = 'SELECT DISTINCT(b.bid), b.* FROM ' . $this->db->prefix('newblocks') . ' b LEFT JOIN '
1157
            . $this->db->prefix('block_module_link') . ' l ON b.bid=l.block_id';
1158
        if (isset($criteria) && \method_exists($criteria, 'renderWhere')) {
1159
            $sql .= ' ' . $criteria->renderWhere();
1160
            $limit = $criteria->getLimit();
1161
            $start = $criteria->getStart();
1162
        }
1163
        $result = $this->db->query($sql, $limit, $start);
1164
        if (!$this->db->isResultSet($result)) {
1165
            return $ret;
1166
        }
1167
        /** @var array $myrow */
1168
        while (false !== ($myrow = $this->db->fetchArray($result))) {
1169
            $block = new XoopsBlock();
1170
            $block->assignVars($myrow);
1171
            if (!$id_as_key) {
1172
                $ret[] = & $block;
1173
            } else {
1174
                $ret[$myrow['bid']] = &$block;
1175
            }
1176
            unset($block);
1177
        }
1178
1179
        return $ret;
1180
    }
1181
1182
    /**
1183
     * get a list of blocks matching certain conditions
1184
     *
1185
     * @param  CriteriaElement $criteria conditions to match
1186
     * @return array  array of blocks matching the conditions
1187
     **/
1188
    public function getList(?CriteriaElement $criteria = null)
1189
    {
1190
        $blocks = $this->getObjects($criteria, true);
1191
        $ret    = [];
1192
        foreach (array_keys($blocks) as $i) {
1193
            $name    = (!$blocks[$i]->isCustom()) ? $blocks[$i]->getVar('name') : $blocks[$i]->getVar('title');
1194
            $ret[$i] = $name;
1195
        }
1196
1197
        return $ret;
1198
    }
1199
1200
    ##################### Deprecated Methods ######################
1201
    /* These are not deprecated, they are dead and should be removed */
1202
    /**
1203
     * @deprecated
1204
     * @param      $moduleid
1205
     * @param bool $asobject
1206
     * @param bool $id_as_key
1207
     * @return bool
1208
     */
1209
    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

1209
    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 $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

1209
    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...
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

1209
    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...
1210
    {
1211
        $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
1212
1213
        return false;
1214
    }
1215
1216
    /**
1217
     * @param        $groupid
1218
     * @param int    $module_id
1219
     * @param bool   $toponlyblock
1220
     * @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...
1221
     * @param string $orderby
1222
     * @param int    $isactive
1223
     *
1224
     * @return bool
1225
     * @deprecated
1226
     */
1227
    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 $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

1227
    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 $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

1227
    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 $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

1227
    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...
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

1227
    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 $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

1227
    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 $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

1227
    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...
1228
    {
1229
        $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
1230
1231
        return false;
1232
    }
1233
1234
    /**
1235
     * @param        $groupid
1236
     * @param string $orderby
1237
     *
1238
     * @return bool
1239
     * @deprecated
1240
     */
1241
    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

1241
    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

1241
    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...
1242
    {
1243
        $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
1244
1245
        return false;
1246
    }
1247
1248
    /**
1249
     * @return bool
1250
     * @deprecated
1251
     */
1252
    public function assignBlocks()
1253
    {
1254
        $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
1255
1256
        return false;
1257
    }
1258
}
1259