Forum::dispForumModerators()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 11
rs 10
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Newbb;
4
5
/**
6
 * Newbb module
7
 *
8
 * You may not change or alter any portion of this comment or credits
9
 * of supporting developers from this source code or any supporting source code
10
 * which is considered copyrighted (c) material of the original comment or credit authors.
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 *
15
 * @copyright       XOOPS Project (https://xoops.org)
16
 * @license         GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
17
 * @since           4.0
18
 * @author          Taiwen Jiang <[email protected]>
19
 */
20
class Forum extends \XoopsObject
21
{
22
    public int $forum_id;
23
    public string $forum_name;
24
    public string $forum_desc;
25
    public array $forum_moderator;
26
    public int $forum_topics;
27
    public int $forum_posts;
28
    public int $forum_last_post_id;
29
    public int $cat_id;
30
    public int $parent_forum;
31
    public int $hot_threshold;
32
    public int $attach_maxkb;
33
    public string $attach_ext;
34
    public int $forum_order;
35
    public int $dohtml;
36
37
    public function __construct()
38
    {
39
        parent::__construct();
40
        $this->initVar('forum_id', \XOBJ_DTYPE_INT);
41
        $this->initVar('forum_name', \XOBJ_DTYPE_TXTBOX);
42
        $this->initVar('forum_desc', \XOBJ_DTYPE_TXTAREA);
43
        $this->initVar('forum_moderator', \XOBJ_DTYPE_ARRAY, \serialize([]));
44
        $this->initVar('forum_topics', \XOBJ_DTYPE_INT);
45
        $this->initVar('forum_posts', \XOBJ_DTYPE_INT);
46
        $this->initVar('forum_last_post_id', \XOBJ_DTYPE_INT);
47
        $this->initVar('cat_id', \XOBJ_DTYPE_INT);
48
        $this->initVar('parent_forum', \XOBJ_DTYPE_INT);
49
        $this->initVar('hot_threshold', \XOBJ_DTYPE_INT, 20);
50
        $this->initVar('attach_maxkb', \XOBJ_DTYPE_INT, 500);
51
        $this->initVar('attach_ext', \XOBJ_DTYPE_SOURCE, 'zip|jpg|gif|png');
52
        $this->initVar('forum_order', \XOBJ_DTYPE_INT, 99);
53
        $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1);
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function dispForumModerators(): string
60
    {
61
        $ret = '';
62
        if (!$valid_moderators = $this->getVar('forum_moderator')) {
63
            return $ret;
64
        }
65
        require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.user.php');
66
        $moderators = \newbbGetUnameFromIds($valid_moderators, !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true);
0 ignored issues
show
Bug introduced by
It seems like $valid_moderators can also be of type string and true; however, parameter $uid of newbbGetUnameFromIds() does only seem to accept array<mixed,mixed>|integer, 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

66
        $moderators = \newbbGetUnameFromIds(/** @scrutinizer ignore-type */ $valid_moderators, !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true);
Loading history...
67
        $ret        = \implode(', ', $moderators);
68
69
        return $ret;
70
    }
71
}
72