|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace Canvas\Models; |
|
5
|
|
|
|
|
6
|
|
|
use Canvas\Traits\UsersAssociatedTrait; |
|
7
|
|
|
use Baka\Database\Contracts\HashTableTrait; |
|
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
class Apps extends \Baka\Database\Apps |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* |
|
13
|
|
|
* @var integer |
|
14
|
|
|
*/ |
|
15
|
|
|
public $id; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* |
|
19
|
|
|
* @var string |
|
20
|
|
|
*/ |
|
21
|
|
|
public $key; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
public $name; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
public $description; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
public $url; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* |
|
43
|
|
|
* @var integer |
|
44
|
|
|
*/ |
|
45
|
|
|
public $default_apps_plan_id; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* |
|
49
|
|
|
* @var integer |
|
50
|
|
|
*/ |
|
51
|
|
|
public $is_actived; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var integer |
|
55
|
|
|
*/ |
|
56
|
|
|
public $ecosystem_auth; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @var integer |
|
60
|
|
|
*/ |
|
61
|
|
|
public $payments_active; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* |
|
65
|
|
|
* @var string |
|
66
|
|
|
*/ |
|
67
|
|
|
public $created_at; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* |
|
71
|
|
|
* @var string |
|
72
|
|
|
*/ |
|
73
|
|
|
public $updated_at; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* |
|
77
|
|
|
* @var integer |
|
78
|
|
|
*/ |
|
79
|
|
|
public $is_deleted; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Ecosystem default app. |
|
83
|
|
|
* @var string |
|
84
|
|
|
*/ |
|
85
|
|
|
const CANVAS_DEFAULT_APP_ID = 1; |
|
86
|
|
|
const CANVAS_DEFAULT_APP_NAME = 'Default'; |
|
87
|
|
|
const APP_DEFAULT_ROLE_SETTING = 'default_admin_role'; |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Users Associated Trait. |
|
91
|
|
|
*/ |
|
92
|
|
|
use UsersAssociatedTrait; |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Model Settings Trait. |
|
96
|
|
|
*/ |
|
97
|
|
|
use HashTableTrait; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Initialize method for model. |
|
101
|
|
|
*/ |
|
102
|
|
|
public function initialize() |
|
103
|
|
|
{ |
|
104
|
|
|
$this->setSource('apps'); |
|
105
|
|
|
|
|
106
|
|
|
$this->hasOne( |
|
107
|
|
|
'default_apps_plan_id', |
|
108
|
|
|
'Canvas\Models\AppsPlans', |
|
109
|
|
|
'id', |
|
110
|
|
|
['alias' => 'plan'] |
|
111
|
|
|
); |
|
112
|
|
|
|
|
113
|
|
|
$this->hasMany( |
|
114
|
|
|
'id', |
|
115
|
|
|
'Canvas\Models\AppsPlans', |
|
116
|
|
|
'apps_id', |
|
117
|
|
|
['alias' => 'plans'] |
|
118
|
|
|
); |
|
119
|
|
|
|
|
120
|
|
|
$this->hasMany( |
|
121
|
|
|
'id', |
|
122
|
|
|
'Canvas\Models\UserWebhooks', |
|
123
|
|
|
'apps_id', |
|
124
|
|
|
['alias' => 'user-webhooks'] |
|
125
|
|
|
); |
|
126
|
|
|
|
|
127
|
|
|
$this->hasMany( |
|
128
|
|
|
'id', |
|
129
|
|
|
'Canvas\Models\AppsSettings', |
|
130
|
|
|
'apps_id', |
|
131
|
|
|
['alias' => 'settingsApp'] |
|
132
|
|
|
); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* You can only get 2 variations or default in DB or the api app. |
|
137
|
|
|
* |
|
138
|
|
|
* @param string $name |
|
139
|
|
|
* @return Apps |
|
140
|
|
|
*/ |
|
141
|
|
|
public static function getACLApp(string $name): Apps |
|
142
|
|
|
{ |
|
143
|
|
|
if (trim($name) == self::CANVAS_DEFAULT_APP_NAME) { |
|
144
|
|
|
$app = self::findFirst(1); |
|
145
|
|
|
} else { |
|
146
|
|
|
$app = self::findFirstByKey(\Phalcon\DI::getDefault()->getConfig()->app->id); |
|
|
|
|
|
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
return $app; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Is active? |
|
154
|
|
|
* |
|
155
|
|
|
* @return boolean |
|
156
|
|
|
*/ |
|
157
|
|
|
public function isActive(): bool |
|
158
|
|
|
{ |
|
159
|
|
|
return (bool) $this->is_actived; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Returns table name mapped in the model. |
|
164
|
|
|
* |
|
165
|
|
|
* @return string |
|
166
|
|
|
*/ |
|
167
|
|
|
public function getSource() : string |
|
168
|
|
|
{ |
|
169
|
|
|
return 'apps'; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* Those this app use ecosystem login or |
|
174
|
|
|
* the its own local login? |
|
175
|
|
|
* |
|
176
|
|
|
* @return boolean |
|
177
|
|
|
*/ |
|
178
|
|
|
public function ecosystemAuth(): bool |
|
179
|
|
|
{ |
|
180
|
|
|
return (bool) $this->ecosystem_auth; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* Is this app subscription based? |
|
185
|
|
|
* |
|
186
|
|
|
* @return boolean |
|
187
|
|
|
*/ |
|
188
|
|
|
public function subscriptioBased(): bool |
|
189
|
|
|
{ |
|
190
|
|
|
return (bool) $this->payments_active; |
|
191
|
|
|
} |
|
192
|
|
|
} |
|
193
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths