-
Notifications
You must be signed in to change notification settings - Fork 25
/
ModuleBase.php
362 lines (305 loc) · 9.06 KB
/
ModuleBase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<?php /** @noinspection PhpUnusedParameterInspection */
namespace app\plugins;
use app\components\ExternalPasswordAuthenticatorInterface;
use app\models\db\{Amendment, Consultation, IMotion, Motion, Site, User, Vote, VotingBlock};
use app\components\LoginProviderInterface;
use app\models\AdminTodoItem;
use app\models\amendmentNumbering\IAmendmentNumbering;
use app\models\http\ResponseInterface;
use app\models\layoutHooks\Hooks;
use app\models\majorityType\IMajorityType;
use app\models\policies\IPolicy;
use app\models\quorumType\IQuorumType;
use app\models\settings\{IMotionStatus, Layout, Privilege, VotingData};
use yii\base\{Action, Module};
use yii\web\{AssetBundle, Controller, View};
class ModuleBase extends Module
{
public function init(): void
{
parent::init();
if (\Yii::$app instanceof \yii\console\Application) {
$ref = new \ReflectionClass($this);
$this->controllerNamespace = $ref->getNamespaceName() . '\\commands';
}
}
/**
* @return AssetBundle[]
*/
public static function getActiveAssetBundles(Controller $controller): array
{
return [];
}
protected static function getMotionUrlRoutes(): array
{
return [];
}
protected static function getAmendmentUrlRoutes(): array
{
return [];
}
public static function getManagerUrlRoutes(string $domainPlain): array
{
return [];
}
public static function getDefaultRouteOverride(): ?string
{
return null;
}
public static function getGeneratedRoute(array $routeParts, string $originallyGeneratedRoute): ?string
{
return null;
}
public static function getAllUrlRoutes(array $urls, string $dom, string $dommotion, string $dommotionOld, string $domamend, string $domamendOld): array
{
foreach (static::getMotionUrlRoutes() as $url => $route) {
$urls[$dommotion . '/' . $url] = $route;
$urls[$dommotionOld . '/' . $url] = $route;
}
foreach (static::getAmendmentUrlRoutes() as $url => $route) {
$urls[$domamend . '/' . $url] = $route;
$urls[$domamendOld . '/' . $url] = $route;
}
return $urls;
}
/**
* Return value needs to be a class name extending from \app\models\settings\Permissions
*/
public static function getPermissionsClass(): ?string
{
return null;
}
/**
* @param Privilege[] $origPrivileges
* @return Privilege[]
*/
public static function addCustomPrivileges(Consultation $consultation, array $origPrivileges): array
{
return $origPrivileges;
}
/**
* @return string[]|IPolicy[]
*/
public static function getCustomPolicies(): array
{
return [];
}
/**
* @return class-string<\app\models\forms\AdminMotionFilterForm>|null
*/
public static function getFullMotionListClassOverride(): ?string
{
return null;
}
/**
* Return values:
* - null does not change default behavior
* - true grants access, even if no access by default. (It does NOT however grant permissions to perform any actions)
* - false denies access, even if the user has access by default. (It does NOT remove the permissions to perform any actions in the motion administration)
*/
public static function canSeeFullMotionList(Consultation $consultation, User $user): ?bool
{
return null;
}
public static function canSeeContactDetails(IMotion $imotion, ?User $user): ?bool
{
return null;
}
/**
* Called if the consultation is protected, and the user (if any) does not have privileges to access.
* Can be used to give grant users read-only access to certain motions.
*/
public static function canAccessConsultationAsUnprivilegedUser(?User $user, Consultation $consultation, string $controllerClass, string $actionId): ?bool
{
return null;
}
/**
* @return AdminTodoItem[]|null
*/
public static function getAdminTodoItems(Consultation $consultation, User $user): ?array
{
return null;
}
public static function preferConsultationSpecificHomeLink(): bool
{
return false;
}
public static function siteHomeIsAlwaysPublic(): bool
{
return false;
}
public static function hasSiteHomePage(): bool
{
return false;
}
public static function getSiteHomePage(): ?ResponseInterface
{
return null;
}
/**
* @return class-string<\app\models\settings\Consultation>|null
*/
public static function getConsultationSettingsClass(Consultation $consultation): ?string
{
return null;
}
public static function getConsultationExtraSettingsForm(Consultation $consultation): string
{
return '';
}
public static function createDefaultUserGroups(Consultation $consultation): void
{
}
/** @return null|int[] */
public static function getSelectableGroupsForUser(Consultation $consultation, User $user): ?array
{
return null;
}
/**
* @phpstan-ignore-next-line
* @return string|\app\models\settings\Site|null
*/
public static function getSiteSettingsClass(Site $site): ?string
{
return null;
}
/**
* @return array<string, array{title: string, preview: string|null, bundle: class-string, hooks?: class-string<Hooks>, odtTemplate?: string}>
*/
public static function getProvidedLayouts(?View $view = null): array
{
return [];
}
public static function overridesDefaultLayout(): ?string
{
return null;
}
public static function getProvidedPdfLayouts(array $default): array
{
return $default;
}
public static function getProvidedTranslations(): array
{
return [];
}
public static function getCustomMotionExports(Motion $motion): array
{
return [];
}
/**
* @return Hooks[]
*/
public static function getForcedLayoutHooks(Layout $layoutSettings, ?Consultation $consultation): array
{
return [];
}
public static function getCustomEmailTemplate(): ?string
{
return null;
}
public static function getRobotsIndexOverride(?Consultation $consultation, Action $action, bool $default): ?bool
{
return null;
}
public static function getDefaultLogo(): ?array
{
return null;
}
public static function getExternalPasswordAuthenticator(): ?ExternalPasswordAuthenticatorInterface
{
return null;
}
public static function getDedicatedLoginProvider(): ?LoginProviderInterface
{
return null;
}
/**
* @return array<class-string<IMajorityType>>
*/
public static function getAdditionalMajorityTypes(): array
{
return [];
}
/**
* @param Vote[] $votes
*
* @return array<int|string, array<string, int>>|null
*/
public static function calculateVoteResultsForApi(VotingBlock $voting, array $votes): ?array
{
return null;
}
/**
* @return class-string<VotingData>|null
*/
public static function getVotingDataClass(Consultation $consultation): ?string
{
return null;
}
/**
* @return IQuorumType[]|string[]
*/
public static function getAdditionalQuorumTypes(): array
{
return [];
}
public static function userIsRelevantForQuorum(VotingBlock $votingBlock, User $user): ?bool
{
return null;
}
public static function getRelevantEligibleVotersCount(VotingBlock $votingBlock): ?int
{
return null;
}
public static function getMotionExtraSettingsForm(Motion $motion): string
{
return '';
}
public static function setMotionExtraSettingsFromForm(Motion $motion, array $post): void
{
}
public static function getAmendmentExtraSettingsForm(Amendment $amendment): string
{
return '';
}
public static function setAmendmentExtraSettingsFromForm(Amendment $amendment, array $post): void
{
}
/**
* @return IMotionStatus[]
*/
public static function getAdditionalIMotionStatuses(Consultation $consultation): array
{
return [];
}
/**
* @return array<string, string>|null
*/
public static function getResolutionStatusOptions(Consultation $consultation): ?array
{
return null;
}
public static function getResolutionProposer(IMotion $imotion): ?string
{
return null;
}
public static function getMotionVersions(Consultation $consultation): ?array
{
return null;
}
/**
* @return string[]|IAmendmentNumbering[]
*/
public static function getCustomAmendmentNumberings(): array
{
return [];
}
public static function getConsultationHomePage(Consultation $consultation): ?ResponseInterface
{
return null;
}
public static function onBeforeProposedProcedureStatusSave(IMotion $imotion): IMotion
{
return $imotion;
}
}