|
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-2019, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hipanel\modules\server\models\query; |
|
12
|
|
|
|
|
13
|
|
|
use hiqdev\hiart\ActiveQuery; |
|
14
|
|
|
use Yii; |
|
15
|
|
|
|
|
16
|
|
|
class ServerQuery extends ActiveQuery |
|
17
|
|
|
{ |
|
18
|
|
|
public function withSales(): self |
|
19
|
|
|
{ |
|
20
|
|
|
$this->joinWith('sales'); |
|
21
|
|
|
$this->andWhere(['with_sales' => true]); |
|
22
|
|
|
|
|
23
|
|
|
return $this; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function withBindings(): self |
|
27
|
|
|
{ |
|
28
|
|
|
if (Yii::$app->user->can('hub.read')) { |
|
|
|
|
|
|
29
|
|
|
$this->joinWith('bindings'); |
|
30
|
|
|
$this->andWhere(['with_bindings' => true]); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
return $this; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function withUses(): self |
|
37
|
|
|
{ |
|
38
|
|
|
$this->joinWith('uses'); |
|
39
|
|
|
$this->andWhere(['with_uses' => true]); |
|
40
|
|
|
|
|
41
|
|
|
return $this; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function withBlocking(): self |
|
45
|
|
|
{ |
|
46
|
|
|
$this->joinWith('blocking'); |
|
47
|
|
|
$this->andWhere(['with_blocking' => true]); |
|
48
|
|
|
|
|
49
|
|
|
return $this; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function withMailSettings(): self |
|
53
|
|
|
{ |
|
54
|
|
|
if (Yii::$app->user->can('part.read')) { |
|
55
|
|
|
$this->joinWith(['mailSettings']); |
|
56
|
|
|
$this->andWhere(['with_mailSettings' => 1]); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
return $this; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function withHardwareSettings(): self |
|
63
|
|
|
{ |
|
64
|
|
|
if (Yii::$app->user->can('part.read')) { |
|
65
|
|
|
$this->joinWith(['hardwareSettings']); |
|
66
|
|
|
$this->andWhere(['with_hardwareSettings' => 1]); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return $this; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function withSoftwareSettings(): self |
|
73
|
|
|
{ |
|
74
|
|
|
if (Yii::$app->user->can('server.manage-settings')) { |
|
75
|
|
|
$this->joinWith(['softwareSettings']); |
|
76
|
|
|
$this->andWhere(['with_softwareSettings' => 1]); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
return $this; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function withMonitoringSettings(): self |
|
83
|
|
|
{ |
|
84
|
|
|
if (Yii::$app->user->can('server.manage-settings')) { |
|
85
|
|
|
$this->joinWith(['monitoringSettings']); |
|
86
|
|
|
$this->andWhere(['with_monitoringSettings' => 1]); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function withConsumptions(): self |
|
93
|
|
|
{ |
|
94
|
|
|
$this->joinWith('consumptions'); |
|
95
|
|
|
$this->andWhere(['with_consumptions' => true]); |
|
96
|
|
|
|
|
97
|
|
|
return $this; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function withHardwareSales(): self |
|
101
|
|
|
{ |
|
102
|
|
|
$this->joinWith('hardwareSales'); |
|
103
|
|
|
$this->andWhere(['with_hardwareSales' => true]); |
|
104
|
|
|
|
|
105
|
|
|
return $this; |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|
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.