@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | class FormBuilderAsset extends \yii\web\AssetBundle |
14 | 14 | { |
15 | - public $sourcePath = __DIR__ . '/publish'; |
|
15 | + public $sourcePath = __DIR__.'/publish'; |
|
16 | 16 | |
17 | 17 | public $js = [ |
18 | 18 | 'store.js', |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | class AppFormBuilderAsset extends \yii\web\AssetBundle |
15 | 15 | { |
16 | - public $sourcePath = __DIR__ . '/publish'; |
|
16 | + public $sourcePath = __DIR__.'/publish'; |
|
17 | 17 | |
18 | 18 | public $js = [ |
19 | 19 | 'manifest.js', |
@@ -7,11 +7,11 @@ |
||
7 | 7 | */ |
8 | 8 | class m171011_143735_forms_phoebe extends Migration |
9 | 9 | { |
10 | - public function safeUp() |
|
11 | - { |
|
12 | - } |
|
10 | + public function safeUp() |
|
11 | + { |
|
12 | + } |
|
13 | 13 | |
14 | - public function safeDown() |
|
15 | - { |
|
16 | - } |
|
14 | + public function safeDown() |
|
15 | + { |
|
16 | + } |
|
17 | 17 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | /** |
92 | 92 | * @inheritdoc |
93 | 93 | */ |
94 | - public function getDataMap($key, $query='', $filters=[], $fields=[], $start=0, $length=100) |
|
94 | + public function getDataMap($key, $query = '', $filters = [], $fields = [], $start = 0, $length = 100) |
|
95 | 95 | { |
96 | 96 | // convert generic form builder filters to phoebe class ones |
97 | 97 | $filters = Arr::replaceKeys($filters, ['uuid'=> 'class_type']); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * that you want to display and in what order |
174 | 174 | * @return array |
175 | 175 | */ |
176 | - public function getFormDefinition($phoebeType, $classType, array $fields=[]) |
|
176 | + public function getFormDefinition($phoebeType, $classType, array $fields = []) |
|
177 | 177 | { |
178 | 178 | $cacheKey = md5(serialize(func_get_args())); |
179 | 179 | return neon()->cacheArray->getOrSet($cacheKey, function() use ($classType, $phoebeType, $fields) { |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @return bool - returns true if saved correctly or the set of errors if the |
427 | 427 | * form couldn't validate |
428 | 428 | */ |
429 | - public function saveForm($phoebeType, $classType, $form=null, $formName=null, $metaInfo=null, &$uuid=null, &$changeLogUuids=[]) |
|
429 | + public function saveForm($phoebeType, $classType, $form = null, $formName = null, $metaInfo = null, &$uuid = null, &$changeLogUuids = []) |
|
430 | 430 | { |
431 | 431 | $changeLogUuids = []; |
432 | 432 | if (!$form) { |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | $itemKey = substr($key, strlen($this->formMetaDataSourceString)); |
510 | 510 | if (empty($meta['dataSources'][$itemKey])) |
511 | 511 | $meta['dataSources'][$itemKey] = $v; |
512 | - } else if ($key==$this->formMetaReturnUrlString && empty($meta['returnUrl'])) { |
|
512 | + } else if ($key == $this->formMetaReturnUrlString && empty($meta['returnUrl'])) { |
|
513 | 513 | $meta['returnUrl'] = $v; |
514 | 514 | } |
515 | 515 | } |
@@ -252,16 +252,18 @@ discard block |
||
252 | 252 | $formDefinition = []; |
253 | 253 | if (!empty($options['uuid'])) { |
254 | 254 | $object = $phoebe->getObject($options['uuid']); |
255 | - if (!$object) |
|
256 | - throw new \RuntimeException('The requested form object was not found. Uuid='.$options['uuid']); |
|
255 | + if (!$object) { |
|
256 | + throw new \RuntimeException('The requested form object was not found. Uuid='.$options['uuid']); |
|
257 | + } |
|
257 | 258 | $class = $object->getIPhoebeClass(); |
258 | 259 | $formDefinition = $class->getClassFormDefinition($fields); |
259 | 260 | } else { |
260 | 261 | // otherwise get a clean class |
261 | 262 | if ($classType) { |
262 | 263 | $formDefinition = $this->getFormDefinition($phoebeType, $classType, $fields); |
263 | - if (!count($formDefinition)) |
|
264 | - throw new \RuntimeException('The requested form type was not found. Type='.$classType); |
|
264 | + if (!count($formDefinition)) { |
|
265 | + throw new \RuntimeException('The requested form type was not found. Type='.$classType); |
|
266 | + } |
|
265 | 267 | } |
266 | 268 | } |
267 | 269 | $fieldCount = count($formDefinition['fields']); |
@@ -269,16 +271,19 @@ discard block |
||
269 | 271 | |
270 | 272 | |
271 | 273 | // temporary code to cover problems with differences between appForms and ddsForms |
272 | - if ($phoebeType !== 'applicationForm' && !empty($options['initialiseFromDds'])) |
|
273 | - throw new \RuntimeException('Only applicationForms work with initialiseFromDds'); |
|
274 | + if ($phoebeType !== 'applicationForm' && !empty($options['initialiseFromDds'])) { |
|
275 | + throw new \RuntimeException('Only applicationForms work with initialiseFromDds'); |
|
276 | + } |
|
274 | 277 | |
275 | 278 | // set the form class |
276 | - if (!empty($options['cssClass'])) |
|
277 | - $form->setAttributes(['class'=>$options['cssClass']]); |
|
279 | + if (!empty($options['cssClass'])) { |
|
280 | + $form->setAttributes(['class'=>$options['cssClass']]); |
|
281 | + } |
|
278 | 282 | |
279 | 283 | // set the form id |
280 | - if (!empty($options['id'])) |
|
281 | - $form->setId($options['id']); |
|
284 | + if (!empty($options['id'])) { |
|
285 | + $form->setId($options['id']); |
|
286 | + } |
|
282 | 287 | $formId = $form->getId(); |
283 | 288 | if ($printOnly) { |
284 | 289 | $form->printOnly = true; |
@@ -289,17 +294,20 @@ discard block |
||
289 | 294 | } |
290 | 295 | |
291 | 296 | // set the forms label - allow clearing of it via empty string |
292 | - if (isset($options['label'])) |
|
293 | - $form->setLabel($options['label']); |
|
297 | + if (isset($options['label'])) { |
|
298 | + $form->setLabel($options['label']); |
|
299 | + } |
|
294 | 300 | |
295 | 301 | |
296 | 302 | // check to see if we are not posting from the client, populate it from the database |
297 | 303 | // !set the form name before checking data set! |
298 | - if (!empty($options['name'])) |
|
299 | - $form->setName($options['name']); |
|
304 | + if (!empty($options['name'])) { |
|
305 | + $form->setName($options['name']); |
|
306 | + } |
|
300 | 307 | if (!empty($options['initialiseFromDds']) && (!$object || !$object->data)) { |
301 | - if (!$object) |
|
302 | - $object = $phoebe->createStubObject($classType); |
|
308 | + if (!$object) { |
|
309 | + $object = $phoebe->createStubObject($classType); |
|
310 | + } |
|
303 | 311 | $object->initialiseFromDds($options['initialiseFromDds']); |
304 | 312 | } |
305 | 313 | if ($object && !$form->hasRequestData()) { |
@@ -307,8 +315,9 @@ discard block |
||
307 | 315 | } |
308 | 316 | |
309 | 317 | if (!($printOnly || $readOnly)) { |
310 | - if (!empty($options['uuid'])) |
|
311 | - $form->addFieldHidden("{$this->formMetaPrefix}{$this->formMetaUuidString}", ['value'=>$options['uuid']]); |
|
318 | + if (!empty($options['uuid'])) { |
|
319 | + $form->addFieldHidden("{$this->formMetaPrefix}{$this->formMetaUuidString}", ['value'=>$options['uuid']]); |
|
320 | + } |
|
312 | 321 | |
313 | 322 | // set any additional data sources |
314 | 323 | if (!empty($options['dataSources'])) { |
@@ -316,8 +325,9 @@ discard block |
||
316 | 325 | $form->addFieldHidden("{$this->formMetaPrefix}{$this->formMetaDataSourceString}$key", ['value'=>$value]); |
317 | 326 | // for dds forms, set the values on the form too for initial display |
318 | 327 | if ($phoebeType == 'daedalus') { |
319 | - if ($form->hasField($key)) |
|
320 | - $form->getField($key)->setValue($value); |
|
328 | + if ($form->hasField($key)) { |
|
329 | + $form->getField($key)->setValue($value); |
|
330 | + } |
|
321 | 331 | } |
322 | 332 | } |
323 | 333 | } |
@@ -328,8 +338,9 @@ discard block |
||
328 | 338 | if (!empty($options['mapFilters'])) { |
329 | 339 | foreach ($options['mapFilters'] as $key=>$filters) { |
330 | 340 | $f = $form->getField($key); |
331 | - if ($f && isset($f->dataMapFilters)) |
|
332 | - $f->dataMapFilters = $filters; |
|
341 | + if ($f && isset($f->dataMapFilters)) { |
|
342 | + $f->dataMapFilters = $filters; |
|
343 | + } |
|
333 | 344 | } |
334 | 345 | } |
335 | 346 | |
@@ -339,8 +350,9 @@ discard block |
||
339 | 350 | if (!empty($options['mapFields'])) { |
340 | 351 | foreach ($options['mapFields'] as $key=>$mapFields) { |
341 | 352 | $f = $form->getField($key); |
342 | - if ($f && isset($f->dataMapFields)) |
|
343 | - $f->dataMapFields = $mapFields; |
|
353 | + if ($f && isset($f->dataMapFields)) { |
|
354 | + $f->dataMapFields = $mapFields; |
|
355 | + } |
|
344 | 356 | } |
345 | 357 | } |
346 | 358 | |
@@ -365,20 +377,24 @@ discard block |
||
365 | 377 | } |
366 | 378 | |
367 | 379 | // set the forms action |
368 | - if (!empty($options['action'])) |
|
369 | - $form->setAction($options['action']); |
|
380 | + if (!empty($options['action'])) { |
|
381 | + $form->setAction($options['action']); |
|
382 | + } |
|
370 | 383 | |
371 | 384 | // set whether or not ajax validation is required |
372 | - if (isset($options['enableAjaxValidation'])) |
|
373 | - $form->enableAjaxValidation = (boolean) $options['enableAjaxValidation']; |
|
385 | + if (isset($options['enableAjaxValidation'])) { |
|
386 | + $form->enableAjaxValidation = (boolean) $options['enableAjaxValidation']; |
|
387 | + } |
|
374 | 388 | |
375 | 389 | // set whether or not ajax submission is required |
376 | - if (isset($options['enableAjaxSubmission'])) |
|
377 | - $form->enableAjaxSubmission = (boolean) $options['enableAjaxSubmission']; |
|
390 | + if (isset($options['enableAjaxSubmission'])) { |
|
391 | + $form->enableAjaxSubmission = (boolean) $options['enableAjaxSubmission']; |
|
392 | + } |
|
378 | 393 | |
379 | 394 | // set where the form will check itself via ajaxValidation |
380 | - if (!empty($options['ajaxValidationUrl'])) |
|
381 | - $form->validationUrl = $options['ajaxValidationUrl']; |
|
395 | + if (!empty($options['ajaxValidationUrl'])) { |
|
396 | + $form->validationUrl = $options['ajaxValidationUrl']; |
|
397 | + } |
|
382 | 398 | |
383 | 399 | // set where the browser will go to after completion of the form |
384 | 400 | if (!empty($options['returnUrl'])) { |
@@ -438,8 +454,9 @@ discard block |
||
438 | 454 | $definition = $this->getFormDefinition($phoebeType, $classType); |
439 | 455 | $form = new \neon\core\form\Form($definition); |
440 | 456 | } |
441 | - if (!empty($formName)) |
|
442 | - $form->setName($formName); |
|
457 | + if (!empty($formName)) { |
|
458 | + $form->setName($formName); |
|
459 | + } |
|
443 | 460 | if ($form->processRequest()) { |
444 | 461 | $data = $form->getData(); |
445 | 462 | // prevent multiple renders resulting in multiple saves of the form |
@@ -461,13 +478,15 @@ discard block |
||
461 | 478 | $changeLogUuids['add'] = $object->getChangeLogUuid(); |
462 | 479 | } |
463 | 480 | $uuid = $object->uuid; |
464 | - if (!empty($meta['dataSources'])) |
|
465 | - $object->setDataSources($meta['dataSources']); |
|
481 | + if (!empty($meta['dataSources'])) { |
|
482 | + $object->setDataSources($meta['dataSources']); |
|
483 | + } |
|
466 | 484 | if ($object->editObject($data) === true) { |
467 | 485 | $alreadySubmitted[$submittedCheck] = $uuid; |
468 | 486 | $changeLogUuids['edit'] = $object->getChangeLogUuid(); |
469 | - if (!empty($meta['returnUrl'])) |
|
470 | - neon()->response->redirect(html_entity_decode($meta['returnUrl'])); |
|
487 | + if (!empty($meta['returnUrl'])) { |
|
488 | + neon()->response->redirect(html_entity_decode($meta['returnUrl'])); |
|
489 | + } |
|
471 | 490 | return true; |
472 | 491 | } |
473 | 492 | } else { |
@@ -512,8 +531,9 @@ discard block |
||
512 | 531 | $meta['uuid'] = $v; |
513 | 532 | } else if (strpos($key, $this->formMetaDataSourceString) === 0) { |
514 | 533 | $itemKey = substr($key, strlen($this->formMetaDataSourceString)); |
515 | - if (empty($meta['dataSources'][$itemKey])) |
|
516 | - $meta['dataSources'][$itemKey] = $v; |
|
534 | + if (empty($meta['dataSources'][$itemKey])) { |
|
535 | + $meta['dataSources'][$itemKey] = $v; |
|
536 | + } |
|
517 | 537 | } else if ($key==$this->formMetaReturnUrlString && empty($meta['returnUrl'])) { |
518 | 538 | $meta['returnUrl'] = $v; |
519 | 539 | } |
@@ -80,5 +80,5 @@ |
||
80 | 80 | * @param string $role |
81 | 81 | * @return null | string the url if found |
82 | 82 | */ |
83 | - public function getHomeUrl($role=null); |
|
83 | + public function getHomeUrl($role = null); |
|
84 | 84 | } |
85 | 85 | \ No newline at end of file |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @return array users as |
38 | 38 | * [['uuid'=>'username']...] |
39 | 39 | */ |
40 | - public function listUsers(Iterator &$iterator=null); |
|
40 | + public function listUsers(Iterator &$iterator = null); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Find a set of users based on a partial search string |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @return array users as |
48 | 48 | * [['uuid'=>'username']...] |
49 | 49 | */ |
50 | - public function searchUsers($search, Iterator &$iterator=null); |
|
50 | + public function searchUsers($search, Iterator &$iterator = null); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Create a new User |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * calling this must also be a superuser |
60 | 60 | * @return string - the users uuid |
61 | 61 | */ |
62 | - public function addUser($username, $email, $password, $roles=[], $superuser=false); |
|
62 | + public function addUser($username, $email, $password, $roles = [], $superuser = false); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * Get hold of an User given the user uuid |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | /** |
166 | 166 | * @inheritdoc |
167 | 167 | */ |
168 | - public function getHomeUrl($role=null) |
|
168 | + public function getHomeUrl($role = null) |
|
169 | 169 | { |
170 | 170 | $userRoles = $this->getRoles(); |
171 | 171 | $availableRoles = neon('user')->getRoles(true); |
@@ -333,14 +333,14 @@ discard block |
||
333 | 333 | * @see getUserListUncached for details |
334 | 334 | * @return array |
335 | 335 | */ |
336 | - public static function getUserList($query='', $filters=[], $fields=[], $start=0, $length=100) |
|
336 | + public static function getUserList($query = '', $filters = [], $fields = [], $start = 0, $length = 100) |
|
337 | 337 | { |
338 | 338 | // because we need to cache according to the args we cannot store |
339 | 339 | // results in cache rather cacheArray. This is so we can clear cache |
340 | 340 | // appropriately in other calls such as edit and delete. Also user |
341 | 341 | // information should not be available in cached files |
342 | 342 | return neon()->cacheArray->getOrSet( |
343 | - [static::CACHE_KEY_USER_LIST,func_get_args()], |
|
343 | + [static::CACHE_KEY_USER_LIST, func_get_args()], |
|
344 | 344 | function() use ($query, $filters, $fields, $start, $length) { |
345 | 345 | return self::getUserListUncached($query, $filters, $fields, $start, $length); |
346 | 346 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * @param int $length - the total number of rows to return |
360 | 360 | * @return array |
361 | 361 | */ |
362 | - public static function getUserListUncached($query='',$filters=[], $fields=[], $start=0, $length=100) |
|
362 | + public static function getUserListUncached($query = '', $filters = [], $fields = [], $start = 0, $length = 100) |
|
363 | 363 | { |
364 | 364 | $q = self::find()->select(array_merge(['uuid', 'username', 'email'], $fields)); |
365 | 365 | if ($q !== '') |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | { |
385 | 385 | return collect($userRows)->mapWithKeys(function($row, $key) use($fields) { |
386 | 386 | if (empty($fields)) |
387 | - return [$row['uuid'] => $row['username'] ? $row['username'] . ' - ' . $row['email'] : $row['email']]; |
|
387 | + return [$row['uuid'] => $row['username'] ? $row['username'].' - '.$row['email'] : $row['email']]; |
|
388 | 388 | return [$row['uuid'] => $row]; |
389 | 389 | })->all(); |
390 | 390 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | */ |
505 | 505 | public function generatePasswordResetToken() |
506 | 506 | { |
507 | - $this->password_reset_token = neon()->security->generateRandomString() . '_' . time(); |
|
507 | + $this->password_reset_token = neon()->security->generateRandomString().'_'.time(); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | /** |
622 | 622 | * @inheritDoc |
623 | 623 | */ |
624 | - public function getImageUrl($size=40) |
|
624 | + public function getImageUrl($size = 40) |
|
625 | 625 | { |
626 | 626 | return Html::gravatar($this->email, $size, 'mm', 'g'); |
627 | 627 | } |
@@ -125,8 +125,9 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function getRoles() |
127 | 127 | { |
128 | - if (!isset(static::$_userRoles[$this->id])) |
|
129 | - static::$_userRoles[$this->id] = array_keys(neon()->authManager->getRolesByUser($this->id)); |
|
128 | + if (!isset(static::$_userRoles[$this->id])) { |
|
129 | + static::$_userRoles[$this->id] = array_keys(neon()->authManager->getRolesByUser($this->id)); |
|
130 | + } |
|
130 | 131 | return is_array(static::$_userRoles[$this->id]) ? static::$_userRoles[$this->id] : []; |
131 | 132 | } |
132 | 133 | |
@@ -139,8 +140,9 @@ discard block |
||
139 | 140 | $authManager->revokeAll($this->id); |
140 | 141 | foreach ($roles as $role) { |
141 | 142 | $r = $authManager->getRole($role); |
142 | - if ($r) |
|
143 | - $authManager->assign($r, $this->id); |
|
143 | + if ($r) { |
|
144 | + $authManager->assign($r, $this->id); |
|
145 | + } |
|
144 | 146 | } |
145 | 147 | unset(static::$_userRoles[$this->id]); |
146 | 148 | } |
@@ -172,12 +174,14 @@ discard block |
||
172 | 174 | |
173 | 175 | // searching in a specific role? |
174 | 176 | if (!empty($role)) { |
175 | - if (isset($availableRoles[$role]['homeUrl'])) |
|
176 | - return $availableRoles[$role]['homeUrl']; |
|
177 | + if (isset($availableRoles[$role]['homeUrl'])) { |
|
178 | + return $availableRoles[$role]['homeUrl']; |
|
179 | + } |
|
177 | 180 | } else { // or finding any one? |
178 | 181 | foreach ($userRoles as $role) { |
179 | - if (isset($availableRoles[$role]['homeUrl'])) |
|
180 | - return $availableRoles[$role]['homeUrl']; |
|
182 | + if (isset($availableRoles[$role]['homeUrl'])) { |
|
183 | + return $availableRoles[$role]['homeUrl']; |
|
184 | + } |
|
181 | 185 | |
182 | 186 | } |
183 | 187 | } |
@@ -204,8 +208,9 @@ discard block |
||
204 | 208 | public static function findIdentity($id) |
205 | 209 | { |
206 | 210 | // The id must be a uuid64 |
207 | - if (!Hash::isUuid64($id)) |
|
208 | - return null; |
|
211 | + if (!Hash::isUuid64($id)) { |
|
212 | + return null; |
|
213 | + } |
|
209 | 214 | // The string conversion here is important to ensure the id is correctly quoted as a string |
210 | 215 | // otherwise if the $id is a number it will match uuid's that start with that number! |
211 | 216 | return self::findOne(['uuid' => (string) $id, 'status' => self::STATUS_ACTIVE]); |
@@ -231,8 +236,9 @@ discard block |
||
231 | 236 | public static function findIdentityByInviteToken($token) |
232 | 237 | { |
233 | 238 | $invite = UserInvite::findInviteByInviteToken($token); |
234 | - if (!$invite) |
|
235 | - return null; |
|
239 | + if (!$invite) { |
|
240 | + return null; |
|
241 | + } |
|
236 | 242 | return User::findOne(['uuid' => $invite->user_id, 'status' => [User::STATUS_PENDING]]); |
237 | 243 | } |
238 | 244 | |
@@ -362,10 +368,12 @@ discard block |
||
362 | 368 | public static function getUserListUncached($query='',$filters=[], $fields=[], $start=0, $length=100) |
363 | 369 | { |
364 | 370 | $q = self::find()->select(array_merge(['uuid', 'username', 'email'], $fields)); |
365 | - if ($q !== '') |
|
366 | - $q->where(['or', ['like', 'username', $query], ['like', 'email', $query]]); |
|
367 | - if (!empty($filters)) |
|
368 | - $q->andWhere($filters); |
|
371 | + if ($q !== '') { |
|
372 | + $q->where(['or', ['like', 'username', $query], ['like', 'email', $query]]); |
|
373 | + } |
|
374 | + if (!empty($filters)) { |
|
375 | + $q->andWhere($filters); |
|
376 | + } |
|
369 | 377 | $q->offset($start) |
370 | 378 | ->limit($length) |
371 | 379 | ->orderBy(['username' => SORT_ASC, 'email' => SORT_ASC]) |
@@ -383,8 +391,9 @@ discard block |
||
383 | 391 | public static function formatDataMapItems($userRows, $fields) |
384 | 392 | { |
385 | 393 | return collect($userRows)->mapWithKeys(function($row, $key) use($fields) { |
386 | - if (empty($fields)) |
|
387 | - return [$row['uuid'] => $row['username'] ? $row['username'] . ' - ' . $row['email'] : $row['email']]; |
|
394 | + if (empty($fields)) { |
|
395 | + return [$row['uuid'] => $row['username'] ? $row['username'] . ' - ' . $row['email'] : $row['email']]; |
|
396 | + } |
|
388 | 397 | return [$row['uuid'] => $row]; |
389 | 398 | })->all(); |
390 | 399 | } |
@@ -538,8 +547,9 @@ discard block |
||
538 | 547 | { |
539 | 548 | // remove any caches and authorisations against the user |
540 | 549 | neon()->cacheArray->delete(static::CACHE_KEY_USER_LIST); |
541 | - if ($this->id) |
|
542 | - neon()->authManager->revokeAll($this->id); |
|
550 | + if ($this->id) { |
|
551 | + neon()->authManager->revokeAll($this->id); |
|
552 | + } |
|
543 | 553 | return parent::beforeDelete(); |
544 | 554 | } |
545 | 555 |
@@ -140,7 +140,7 @@ |
||
140 | 140 | public static function getInvite($token) |
141 | 141 | { |
142 | 142 | static $_invite; |
143 | - if ($_invite === null){ |
|
143 | + if ($_invite === null) { |
|
144 | 144 | $_invite = self::findOne(['token' => $token]); |
145 | 145 | } |
146 | 146 | return $_invite; |
@@ -110,8 +110,9 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public static function findInviteByInviteToken($token, $ignoreExpiry = false) |
112 | 112 | { |
113 | - if (!$ignoreExpiry && self::hasInviteTokenExpired($token)) |
|
114 | - return null; |
|
113 | + if (!$ignoreExpiry && self::hasInviteTokenExpired($token)) { |
|
114 | + return null; |
|
115 | + } |
|
115 | 116 | |
116 | 117 | return self::findOne(['token' => $token]); |
117 | 118 | } |
@@ -154,7 +155,9 @@ discard block |
||
154 | 155 | public static function hasInviteTokenExpired($token) |
155 | 156 | { |
156 | 157 | $invite = self::getInvite($token); |
157 | - if (!$invite) return false; |
|
158 | + if (!$invite) { |
|
159 | + return false; |
|
160 | + } |
|
158 | 161 | return strtotime($invite->expires_at) <= time(); |
159 | 162 | } |
160 | 163 |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | $this->addTextColumn('impersonate')->setFilter(false); |
46 | 46 | // scopes |
47 | 47 | // $this->addScope('all','All'); |
48 | - $this->addScope('active','Active'); |
|
49 | - $this->addScope('pending','Pending'); |
|
50 | - $this->addScope('suspended','Suspended'); |
|
51 | - $this->addScope('banned','Banned'); |
|
48 | + $this->addScope('active', 'Active'); |
|
49 | + $this->addScope('pending', 'Pending'); |
|
50 | + $this->addScope('suspended', 'Suspended'); |
|
51 | + $this->addScope('banned', 'Banned'); |
|
52 | 52 | $this->addScope('super', 'Super'); |
53 | 53 | |
54 | 54 | $this->setPageSize(100); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | */ |
197 | 197 | private function getRoles() |
198 | 198 | { |
199 | - static $roles=null; |
|
199 | + static $roles = null; |
|
200 | 200 | if (is_null($roles)) { |
201 | 201 | $roles = neon('user')->getRoles(true); |
202 | 202 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | */ |
211 | 211 | private function getRoleLabels() |
212 | 212 | { |
213 | - static $labels=null; |
|
213 | + static $labels = null; |
|
214 | 214 | if (is_null($labels)) { |
215 | 215 | $roles = $this->getRoles(); |
216 | 216 | foreach ($roles as $role => $details) |
@@ -41,8 +41,9 @@ discard block |
||
41 | 41 | $this->addTextColumn('created_at'); |
42 | 42 | $this->addTextColumn('updated_at', ['title'=>'Updated At']); |
43 | 43 | // action |
44 | - if (neon()->user->isSuper()) |
|
45 | - $this->addTextColumn('impersonate')->setFilter(false); |
|
44 | + if (neon()->user->isSuper()) { |
|
45 | + $this->addTextColumn('impersonate')->setFilter(false); |
|
46 | + } |
|
46 | 47 | // scopes |
47 | 48 | // $this->addScope('all','All'); |
48 | 49 | $this->addScope('active','Active'); |
@@ -104,8 +105,9 @@ discard block |
||
104 | 105 | $userRoles = explode('|', $column->getCellData($model)); |
105 | 106 | $displayRoles = []; |
106 | 107 | foreach ($userRoles as $ur) { |
107 | - if (isset($roles[$ur])) |
|
108 | - $displayRoles[] = $column->highlight($roles[$ur]['label'], $search); |
|
108 | + if (isset($roles[$ur])) { |
|
109 | + $displayRoles[] = $column->highlight($roles[$ur]['label'], $search); |
|
110 | + } |
|
109 | 111 | } |
110 | 112 | return implode(', ', $displayRoles); |
111 | 113 | } |
@@ -213,8 +215,9 @@ discard block |
||
213 | 215 | static $labels=null; |
214 | 216 | if (is_null($labels)) { |
215 | 217 | $roles = $this->getRoles(); |
216 | - foreach ($roles as $role => $details) |
|
217 | - $labels[$details['label']] = $role; |
|
218 | + foreach ($roles as $role => $details) { |
|
219 | + $labels[$details['label']] = $role; |
|
220 | + } |
|
218 | 221 | } |
219 | 222 | return $labels; |
220 | 223 | } |
@@ -230,8 +233,9 @@ discard block |
||
230 | 233 | $labels = $this->getRoleLabels(); |
231 | 234 | $roles = []; |
232 | 235 | foreach ($labels as $label => $role) { |
233 | - if (stripos($label, $filter) !== false) |
|
234 | - $roles[] = $role; |
|
236 | + if (stripos($label, $filter) !== false) { |
|
237 | + $roles[] = $role; |
|
238 | + } |
|
235 | 239 | } |
236 | 240 | return $roles; |
237 | 241 | } |