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

User_language   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 80
rs 10
c 0
b 0
f 0
wmc 12
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
B getUserbar() 0 56 10
1
<?php
2
/**
3
 * User Language Class (moved from 'main' language file)
4
 * @package   ::    newbb
5
 * @subpackage:: class
6
 */
7
8
require_once $GLOBALS['xoops']->path('modules/newbb/class/user.php');
9
10
/**
11
 *
12
 * Allows setting for user information
13
 * If you have a customized userbar, define it here.
14
 *
15
 */
16
class User_language extends User
17
{
18
19
    /**
20
     * User_language constructor.
21
     * @param $user
22
     */
23
    public function __construct($user)
24
    {
25
        parent::__construct($user);
26
    }
27
28
    /**
29
     * @return array|null
30
     */
31
    public function getUserbar()
32
    {
33
        global $xoopsModuleConfig, $xoopsUser, $isadmin;
34
        if (empty($GLOBALS['xoopsModuleConfig']['userbar_enabled'])) {
35
            return null;
36
        }
37
        $user      = $this->user;
38
        $userbar   = [];
39
        $userbar[] = [
40
            'link' => $GLOBALS['xoops']->url('userinfo.php?uid=' . $user->getVar('uid')),
41
            'name' => PROFILE
0 ignored issues
show
Bug introduced by
The constant PROFILE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
42
        ];
43
        if (is_object($xoopsUser)) {
44
            $userbar[] = [
45
                'link' => "javascript:void openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&amp;to_userid=' . $user->getVar('uid') . "','pmlite', 450, 380);",
46
                'name' => _MD_PM
47
            ];
48
        }
49
        if ($user->getVar('user_viewemail') || $isadmin) {
50
            $userbar[] = [
51
                'link' => "javascript:void window.open('mailto:" . $user->getVar('email') . "','new');",
52
                'name' => _MD_EMAIL
53
            ];
54
        }
55
        if ($user->getVar('url')) {
56
            $userbar[] = [
57
                'link' => "javascript:void window.open('" . $user->getVar('url') . "','new');",
58
                'name' => _MD_WWW
59
            ];
60
        }
61
        if ($user->getVar('user_icq')) {
62
            $userbar[] = [
63
                'link' => "javascript:void window.open('http://wwp.icq.com/scripts/search.dll?to=" . $user->getVar('user_icq') . "','new');",
64
                'name' => _MD_ICQ
65
            ];
66
        }
67
        if ($user->getVar('user_aim')) {
68
            $userbar[] = [
69
                'link' => "javascript:void window.open('aim:goim?screenname=" . $user->getVar('user_aim') . '&amp;message=Hi+' . $user->getVar('user_aim') . '+Are+you+there?' . "','new');",
70
                'name' => _MD_AIM
71
            ];
72
        }
73
        if ($user->getVar('user_yim')) {
74
            $userbar[] = [
75
                'link' => "javascript:void window.open('http://edit.yahoo.com/config/send_webmesg?.target=" . $user->getVar('user_yim') . '&.src=pg' . "','new');",
76
                'name' => _MD_YIM
77
            ];
78
        }
79
        if ($user->getVar('user_msnm')) {
80
            $userbar[] = [
81
                'link' => "javascript:void window.open('http://members.msn.com?mem=" . $user->getVar('user_msnm') . "','new');",
82
                'name' => _MD_MSNM
83
            ];
84
        }
85
86
        return $userbar;
87
    }
88
}
89