AccountMenu   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 0
cbo 0
dl 0
loc 67
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B init() 0 62 5
1
<?php
2
/**
3
 * @link https://www.humhub.org/
4
 * @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
5
 * @license https://www.humhub.com/licences
6
 */
7
namespace humhub\modules\user\widgets;
8
use Yii;
9
use \humhub\widgets\BaseMenu;
10
use \yii\helpers\Url;
11
/**
12
 * AccountMenuWidget as (usally left) navigation on users account options.
13
 *
14
 * @package humhub.modules_core.user.widgets
15
 * @since 0.5
16
 * @author Luke
17
 */
18
class AccountMenu extends BaseMenu
19
{
20
    public $template = "@humhub/widgets/views/leftNavigation";
21
    public $type = "accountNavigation";
22
    public function init()
23
    {
24
        $controllerAction = Yii::$app->controller->action->id;
25
        $this->addItemGroup(array(
26
            'id' => 'account',
27
            'label' => Yii::t('UserModule.widgets_AccountMenuWidget', '<strong>Account</strong> settings'),
28
            'sortOrder' => 100,
29
        ));
30
        $this->addItem(array(
31
            'label' => Yii::t('UserModule.widgets_AccountMenuWidget', 'Profile'),
32
            'icon' => '<i class="fa fa-user"></i>',
33
            'group' => 'account',
34
            'url' => Url::toRoute('/user/account/edit'),
35
            'sortOrder' => 100,
36
            'isActive' => ($controllerAction == "edit" || $controllerAction == "change-email" || $controllerAction == "change-password" || $controllerAction == "delete"),
37
        ));
38
        $this->addItem(array(
39
            'label' => Yii::t('UserModule.account', 'E-Mail Summaries'),
40
            'icon' => '<i class="fa fa-envelope"></i>',
41
            'group' => 'account',
42
            'url' => Url::toRoute('/activity/user'),
43
            'sortOrder' => 105,
44
            'isActive' => (Yii::$app->controller->module->id == 'activity'),
45
        ));
46
        
47
        $this->addItem(array(
48
            'label' => Yii::t('UserModule.account', 'Notifications'),
49
            'icon' => '<i class="fa fa-bell"></i>',
50
            'group' => 'account',
51
            'url' => Url::toRoute('/notification/user'),
52
            'sortOrder' => 106,
53
            'isActive' => (Yii::$app->controller->module->id == 'notification'),
54
        ));
55
        $this->addItem(array(
56
            'label' => Yii::t('UserModule.widgets_AccountMenuWidget', 'Settings'),
57
            'icon' => '<i class="fa fa-wrench"></i>',
58
            'group' => 'account',
59
            'url' => Url::toRoute('/user/account/edit-settings'),
60
            'sortOrder' => 110,
61
            'isActive' => ($controllerAction == "edit-settings"),
62
        ));
63
        $this->addItem(array(
64
            'label' => Yii::t('UserModule.widgets_AccountMenuWidget', 'Security'),
65
            'icon' => '<i class="fa fa-lock"></i>',
66
            'group' => 'account',
67
            'url' => Url::toRoute('/user/account/security'),
68
            'sortOrder' => 115,
69
            'isActive' => (Yii::$app->controller->action->id == "security"),
70
        ));
71
        // Only show this page when really user specific modules available
72
        if (count(Yii::$app->user->getIdentity()->getAvailableModules()) != 0) {
73
            $this->addItem(array(
74
                'label' => Yii::t('UserModule.widgets_AccountMenuWidget', 'Modules'),
75
                'icon' => '<i class="fa fa-rocket"></i>',
76
                'group' => 'account',
77
                'url' => Url::toRoute('//user/account/edit-modules'),
78
                'sortOrder' => 120,
79
                'isActive' => (Yii::$app->controller->action->id == "edit-modules"),
80
            ));
81
        }
82
        parent::init();
83
    }
84
}
85
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
86