Passed
Pull Request — master (#18)
by Michael
02:59
created

UserLanguage   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 39
c 0
b 0
f 0
dl 0
loc 70
rs 10
wmc 11

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getUserbar() 0 56 10
A __construct() 0 3 1
1
<?php
2
3
namespace XoopsModules\Newbb;
4
5
/**
6
 * User Language Class (moved from 'main' language file)
7
 * @package   ::    newbb
8
 * @subpackage:: class
9
 */
10
11
use XoopsModules\Newbb;
12
13
//require_once $GLOBALS['xoops']->path('modules/newbb/class/user.php');
14
15
/**
16
 * Allows setting for user information
17
 * If you have a customized userbar, define it here.
18
 */
19
class UserLanguage extends Newbb\User
20
{
21
    /**
22
     * UserLanguage constructor.
23
     * @param $user
24
     */
25
    public function __construct($user)
26
    {
27
        parent::__construct($user);
0 ignored issues
show
Unused Code introduced by
The call to XoopsModules\Newbb\User::__construct() has too many arguments starting with $user. ( Ignorable by Annotation )

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

27
        parent::/** @scrutinizer ignore-call */ 
28
                __construct($user);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
28
    }
29
30
    /**
31
     * @return array|null
32
     */
33
    public function getUserbar()
34
    {
35
        global $xoopsModuleConfig, $xoopsUser, $isadmin;
36
        if (empty($GLOBALS['xoopsModuleConfig']['userbar_enabled'])) {
37
            return null;
38
        }
39
        $user      = $this->user;
40
        $userbar   = [];
41
        $userbar[] = [
42
            'link' => $GLOBALS['xoops']->url('userinfo.php?uid=' . $user->getVar('uid')),
43
            'name' => PROFILE,
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Newbb\PROFILE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
44
        ];
45
        if (\is_object($xoopsUser)) {
46
            $userbar[] = [
47
                'link' => "javascript:void openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&amp;to_userid=' . $user->getVar('uid') . "','pmlite', 450, 380);",
48
                'name' => _MD_PM,
49
            ];
50
        }
51
        if ($isadmin || $user->getVar('user_viewemail')) {
52
            $userbar[] = [
53
                'link' => "javascript:void window.open('mailto:" . $user->getVar('email') . "','new');",
54
                'name' => _MD_EMAIL,
55
            ];
56
        }
57
        if ($user->getVar('url')) {
58
            $userbar[] = [
59
                'link' => "javascript:void window.open('" . $user->getVar('url') . "','new');",
60
                'name' => _MD_WWW,
61
            ];
62
        }
63
        if ($user->getVar('user_icq')) {
64
            $userbar[] = [
65
                'link' => "javascript:void window.open('http://wwp.icq.com/scripts/search.dll?to=" . $user->getVar('user_icq') . "','new');",
66
                'name' => _MD_ICQ,
67
            ];
68
        }
69
        if ($user->getVar('user_aim')) {
70
            $userbar[] = [
71
                'link' => "javascript:void window.open('aim:goim?screenname=" . $user->getVar('user_aim') . '&amp;message=Hi+' . $user->getVar('user_aim') . '+Are+you+there?' . "','new');",
72
                'name' => _MD_AIM,
73
            ];
74
        }
75
        if ($user->getVar('user_yim')) {
76
            $userbar[] = [
77
                'link' => "javascript:void window.open('http://edit.yahoo.com/config/send_webmesg?.target=" . $user->getVar('user_yim') . '&.src=pg' . "','new');",
78
                'name' => _MD_YIM,
79
            ];
80
        }
81
        if ($user->getVar('user_msnm')) {
82
            $userbar[] = [
83
                'link' => "javascript:void window.open('http://members.msn.com?mem=" . $user->getVar('user_msnm') . "','new');",
84
                'name' => _MD_MSNM,
85
            ];
86
        }
87
88
        return $userbar;
89
    }
90
}
91