Passed
Push — master ( 065ef3...823023 )
by Andrii
04:24
created

src/menus/ServerDetailMenu.php (2 issues)

Labels
Severity
1
<?php
2
/**
3
 * Server module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-server
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\server\menus;
12
13
use hipanel\widgets\BlockModalButton;
14
use hipanel\widgets\SimpleOperation;
15
use Yii;
16
17
class ServerDetailMenu extends \hipanel\menus\AbstractDetailMenu
18
{
19
    public $model;
20
21
    public $blockReasons;
22
23
    public function items()
24
    {
25
        $actions = ServerActionsMenu::create([
26
            'model' => $this->model,
27
        ])->items();
28
29
        $user = Yii::$app->user;
30
31
        $items = array_merge($actions, [
32
            [
33
                'label' => Yii::t('hipanel:server', 'Resources'),
34
                'icon' => 'fa-area-chart',
35
                'url' => ['resources', 'id' => $this->model->id],
36
                'linkOptions' => [
37
                    'data-pjax' => 0,
38
                ],
39
            ],
40
            [
41
                'label' => SimpleOperation::widget([
42
                    'model' => $this->model,
43
                    'scenario' => 'reset-password',
44
                    'buttonLabel' => '<i class="fa fa-refresh"></i>' . Yii::t('hipanel:server', 'Reset root password'),
45
                    'buttonClass' => '',
46
                    'body' => Yii::t('hipanel:server', 'Are you sure you want to reset the root password on {name} server? You will get your new root password on the e-mail.'),
47
                    'modalHeaderLabel' => Yii::t('hipanel:server', 'Confirm root password resetting'),
48
                    'modalHeaderOptions' => ['class' => 'label-danger'],
49
                    'modalFooterLabel' => Yii::t('hipanel:server', 'Reset root password'),
50
                    'modalFooterLoading' => Yii::t('hipanel:server', 'Resetting...'),
51
                    'modalFooterClass' => 'btn btn-danger',
52
                ]),
53
                'visible' => $this->model->isPwChangeSupported() && $user->can('server.control-system'),
0 ignored issues
show
The method can() does not exist on null. ( Ignorable by Annotation )

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

53
                'visible' => $this->model->isPwChangeSupported() && $user->/** @scrutinizer ignore-call */ can('server.control-system'),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
54
                'encode' => false,
55
            ],
56
            [
57
                'label' => BlockModalButton::widget(['model' => $this->model]),
58
                'visible' => ($user->can('server.enable-block') || ($user->can('server.disable-block'))) && $user->not($this->model->client_id),
59
                'encode' => false,
60
            ],
61
            [
62
                'label' => SimpleOperation::widget([
63
                    'model' => $this->model,
64
                    'scenario' => 'delete',
65
                    'buttonLabel' => '<i class="fa fa-fw fa-trash-o"></i>' . Yii::t('hipanel', 'Delete'),
66
                    'buttonClass' => '',
67
                    'body' => Yii::t('hipanel:server', 'Are you sure you want to delete server {name}? You will loose everything!', ['name' => $this->model->name]),
68
                    'modalHeaderLabel' => Yii::t('hipanel:server', 'Confirm server deleting'),
69
                    'modalHeaderOptions' => ['class' => 'label-danger'],
70
                    'modalFooterLabel' => Yii::t('hipanel:server', 'Delete server'),
71
                    'modalFooterLoading' => Yii::t('hipanel:server', 'Deleting server'),
72
                    'modalFooterClass' => 'btn btn-danger',
73
                ]),
74
                'encode' => false,
75
                'visible' => Yii::$app->user->can('server.delete'),
0 ignored issues
show
The method can() does not exist on null. ( Ignorable by Annotation )

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

75
                'visible' => Yii::$app->user->/** @scrutinizer ignore-call */ can('server.delete'),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
76
            ],
77
        ]);
78
        unset($items['view']);
79
80
        return $items;
81
    }
82
83
    public function getViewPath()
84
    {
85
        return '@vendor/hiqdev/hipanel-module-server/src/views/server';
86
    }
87
}
88