newbbWelcome()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 13
nc 3
nop 0
dl 0
loc 21
rs 9.8333
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
/**
4
 * NewBB,  the forum module for XOOPS project
5
 *
6
 * @copyright      XOOPS Project (https://xoops.org)
7
 * @license        GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
8
 * @author         Taiwen Jiang (phppp or D.J.) <[email protected]>
9
 * @since          4.00
10
 */
11
12
use XoopsModules\Newbb\{
13
    ForumHandler,
14
    Helper
15
};
16
17
/** @var Helper $helper */
18
/** @var ForumHandler $forumHandler */
19
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
20
define('NEWBB_FUNCTIONS_WELCOME_LOADED', true);
21
22
if (!defined('NEWBB_FUNCTIONS_WELCOME')) {
23
    define('NEWBB_FUNCTIONS_WELCOME', true);
24
25
    /**
26
     * @return false|string
27
     *
28
     * @psalm-return ''|false
29
     */
30
    function newbbWelcome()
31
    {
32
        global $forumObject;
33
        $ret = '';
34
35
        $forumId = @$GLOBALS['xoopsModuleConfig']['welcome_forum'];
36
        if (!$forumId) {
37
            return false;
38
        }
39
        $forumHandler = Helper::getInstance()->getHandler('Forum');
40
        $forumObject  = $forumHandler->get($forumId);
41
        if (!$forumObject || !$forumHandler->getPermission($forumObject)) {
0 ignored issues
show
introduced by
$forumObject is of type XoopsObject, thus it always evaluated to true.
Loading history...
42
            unset($forumObject);
43
44
            return false;
45
        }
46
47
        require_once __DIR__ . '/functions.welcome.inc.php';
48
        unset($forumObject);
49
50
        return $ret;
51
    }
52
53
    newbbWelcome();
54
}
55