newbbWelcome()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

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