@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } |
287 | 287 | $this->headerAdded = true; |
288 | 288 | |
289 | - $logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo()) . '?v='. $this->themingDefaults->getCacheBusterCounter(); |
|
289 | + $logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo()).'?v='.$this->themingDefaults->getCacheBusterCounter(); |
|
290 | 290 | $this->htmlBody .= vsprintf($this->header, [$this->themingDefaults->getColorPrimary(), $logoUrl]); |
291 | 291 | } |
292 | 292 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | } |
302 | 302 | |
303 | 303 | $this->htmlBody .= vsprintf($this->heading, [$title]); |
304 | - $this->plainBody .= $title . PHP_EOL . PHP_EOL; |
|
304 | + $this->plainBody .= $title.PHP_EOL.PHP_EOL; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | } |
321 | 321 | |
322 | 322 | $this->htmlBody .= vsprintf($this->bodyText, [$text]); |
323 | - $this->plainBody .= $text . PHP_EOL . PHP_EOL; |
|
323 | + $this->plainBody .= $text.PHP_EOL.PHP_EOL; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | |
344 | 344 | $color = $this->themingDefaults->getColorPrimary(); |
345 | 345 | $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textLeft, $urlRight, $textRight]); |
346 | - $this->plainBody .= $textLeft . ': ' . $urlLeft . PHP_EOL; |
|
347 | - $this->plainBody .= $textRight . ': ' . $urlRight . PHP_EOL . PHP_EOL; |
|
346 | + $this->plainBody .= $textLeft.': '.$urlLeft.PHP_EOL; |
|
347 | + $this->plainBody .= $textRight.': '.$urlRight.PHP_EOL.PHP_EOL; |
|
348 | 348 | |
349 | 349 | } |
350 | 350 | |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * @param string $text |
355 | 355 | */ |
356 | 356 | public function addFooter($text = '') { |
357 | - if($text === '') { |
|
358 | - $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically generated email, please do not reply.'); |
|
357 | + if ($text === '') { |
|
358 | + $text = $this->themingDefaults->getName().' - '.$this->themingDefaults->getSlogan().'<br>'.$this->l10n->t('This is an automatically generated email, please do not reply.'); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | if ($this->footerAdded) { |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | |
371 | 371 | $this->htmlBody .= vsprintf($this->footer, [$text]); |
372 | 372 | $this->htmlBody .= $this->tail; |
373 | - $this->plainBody .= '--' . PHP_EOL; |
|
373 | + $this->plainBody .= '--'.PHP_EOL; |
|
374 | 374 | $this->plainBody .= str_replace('<br>', PHP_EOL, $text); |
375 | 375 | } |
376 | 376 |
@@ -102,13 +102,13 @@ |
||
102 | 102 | if ($generatePasswordResetToken) { |
103 | 103 | $token = $this->secureRandom->generate( |
104 | 104 | 21, |
105 | - ISecureRandom::CHAR_DIGITS . |
|
106 | - ISecureRandom::CHAR_LOWER . |
|
105 | + ISecureRandom::CHAR_DIGITS. |
|
106 | + ISecureRandom::CHAR_LOWER. |
|
107 | 107 | ISecureRandom::CHAR_UPPER |
108 | 108 | ); |
109 | - $tokenValue = $this->timeFactory->getTime() . ':' . $token; |
|
109 | + $tokenValue = $this->timeFactory->getTime().':'.$token; |
|
110 | 110 | $mailAddress = (null !== $user->getEMailAddress()) ? $user->getEMailAddress() : ''; |
111 | - $encryptedValue = $this->crypto->encrypt($tokenValue, $mailAddress . $this->config->getSystemValue('secret')); |
|
111 | + $encryptedValue = $this->crypto->encrypt($tokenValue, $mailAddress.$this->config->getSystemValue('secret')); |
|
112 | 112 | $this->config->setUserValue($user->getUID(), 'core', 'lostpassword', $encryptedValue); |
113 | 113 | $link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', ['userId' => $user->getUID(), 'token' => $token]); |
114 | 114 | } else { |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | // check for encryption state - TODO see formatUserForIndex |
135 | 135 | $this->isEncryptionAppEnabled = $appManager->isEnabledForUser('encryption'); |
136 | - if($this->isEncryptionAppEnabled) { |
|
136 | + if ($this->isEncryptionAppEnabled) { |
|
137 | 137 | // putting this directly in empty is possible in PHP 5.5+ |
138 | 138 | $result = $config->getAppValue('encryption', 'recoveryAdminEnabled', 0); |
139 | 139 | $this->isRestoreEnabled = !empty($result); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | $subAdminGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user); |
176 | - foreach($subAdminGroups as $key => $subAdminGroup) { |
|
176 | + foreach ($subAdminGroups as $key => $subAdminGroup) { |
|
177 | 177 | $subAdminGroups[$key] = $subAdminGroup->getGID(); |
178 | 178 | } |
179 | 179 | |
@@ -230,16 +230,16 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public function index($offset = 0, $limit = 10, $gid = '', $pattern = '', $backend = '') { |
232 | 232 | // FIXME: The JS sends the group '_everyone' instead of no GID for the "all users" group. |
233 | - if($gid === '_everyone') { |
|
233 | + if ($gid === '_everyone') { |
|
234 | 234 | $gid = ''; |
235 | 235 | } |
236 | 236 | |
237 | 237 | // Remove backends |
238 | - if(!empty($backend)) { |
|
238 | + if (!empty($backend)) { |
|
239 | 239 | $activeBackends = $this->userManager->getBackends(); |
240 | 240 | $this->userManager->clearBackends(); |
241 | - foreach($activeBackends as $singleActiveBackend) { |
|
242 | - if($backend === get_class($singleActiveBackend)) { |
|
241 | + foreach ($activeBackends as $singleActiveBackend) { |
|
242 | + if ($backend === get_class($singleActiveBackend)) { |
|
243 | 243 | $this->userManager->registerBackend($singleActiveBackend); |
244 | 244 | break; |
245 | 245 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $users = []; |
250 | 250 | if ($this->isAdmin) { |
251 | 251 | |
252 | - if($gid !== '') { |
|
252 | + if ($gid !== '') { |
|
253 | 253 | $batch = $this->getUsersForUID($this->groupManager->displayNamesInGroup($gid, $pattern, $limit, $offset)); |
254 | 254 | } else { |
255 | 255 | $batch = $this->userManager->search($pattern, $limit, $offset); |
@@ -269,17 +269,17 @@ discard block |
||
269 | 269 | $subAdminOfGroups = $gids; |
270 | 270 | |
271 | 271 | // Set the $gid parameter to an empty value if the subadmin has no rights to access a specific group |
272 | - if($gid !== '' && !in_array($gid, $subAdminOfGroups)) { |
|
272 | + if ($gid !== '' && !in_array($gid, $subAdminOfGroups)) { |
|
273 | 273 | $gid = ''; |
274 | 274 | } |
275 | 275 | |
276 | 276 | // Batch all groups the user is subadmin of when a group is specified |
277 | 277 | $batch = []; |
278 | - if($gid === '') { |
|
279 | - foreach($subAdminOfGroups as $group) { |
|
278 | + if ($gid === '') { |
|
279 | + foreach ($subAdminOfGroups as $group) { |
|
280 | 280 | $groupUsers = $this->groupManager->displayNamesInGroup($group, $pattern, $limit, $offset); |
281 | 281 | |
282 | - foreach($groupUsers as $uid => $displayName) { |
|
282 | + foreach ($groupUsers as $uid => $displayName) { |
|
283 | 283 | $batch[$uid] = $displayName; |
284 | 284 | } |
285 | 285 | } |
@@ -311,11 +311,11 @@ discard block |
||
311 | 311 | * @param string $email |
312 | 312 | * @return DataResponse |
313 | 313 | */ |
314 | - public function create($username, $password, array $groups=array(), $email='') { |
|
315 | - if($email !== '' && !$this->mailer->validateMailAddress($email)) { |
|
314 | + public function create($username, $password, array $groups = array(), $email = '') { |
|
315 | + if ($email !== '' && !$this->mailer->validateMailAddress($email)) { |
|
316 | 316 | return new DataResponse( |
317 | 317 | array( |
318 | - 'message' => (string)$this->l10n->t('Invalid mail address') |
|
318 | + 'message' => (string) $this->l10n->t('Invalid mail address') |
|
319 | 319 | ), |
320 | 320 | Http::STATUS_UNPROCESSABLE_ENTITY |
321 | 321 | ); |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | if (!empty($groups)) { |
328 | 328 | foreach ($groups as $key => $group) { |
329 | 329 | $groupObject = $this->groupManager->get($group); |
330 | - if($groupObject === null) { |
|
330 | + if ($groupObject === null) { |
|
331 | 331 | unset($groups[$key]); |
332 | 332 | continue; |
333 | 333 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | if ($this->userManager->userExists($username)) { |
352 | 352 | return new DataResponse( |
353 | 353 | array( |
354 | - 'message' => (string)$this->l10n->t('A user with that name already exists.') |
|
354 | + 'message' => (string) $this->l10n->t('A user with that name already exists.') |
|
355 | 355 | ), |
356 | 356 | Http::STATUS_CONFLICT |
357 | 357 | ); |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | if ($email === '') { |
363 | 363 | return new DataResponse( |
364 | 364 | array( |
365 | - 'message' => (string)$this->l10n->t('To send a password link to the user an email address is required.') |
|
365 | + 'message' => (string) $this->l10n->t('To send a password link to the user an email address is required.') |
|
366 | 366 | ), |
367 | 367 | Http::STATUS_UNPROCESSABLE_ENTITY |
368 | 368 | ); |
@@ -387,12 +387,12 @@ discard block |
||
387 | 387 | ); |
388 | 388 | } |
389 | 389 | |
390 | - if($user instanceof IUser) { |
|
391 | - if($groups !== null) { |
|
392 | - foreach($groups as $groupName) { |
|
390 | + if ($user instanceof IUser) { |
|
391 | + if ($groups !== null) { |
|
392 | + foreach ($groups as $groupName) { |
|
393 | 393 | $group = $this->groupManager->get($groupName); |
394 | 394 | |
395 | - if(empty($group)) { |
|
395 | + if (empty($group)) { |
|
396 | 396 | $group = $this->groupManager->createGroup($groupName); |
397 | 397 | } |
398 | 398 | $group->addUser($user); |
@@ -401,13 +401,13 @@ discard block |
||
401 | 401 | /** |
402 | 402 | * Send new user mail only if a mail is set |
403 | 403 | */ |
404 | - if($email !== '') { |
|
404 | + if ($email !== '') { |
|
405 | 405 | $user->setEMailAddress($email); |
406 | 406 | try { |
407 | 407 | $emailTemplate = $this->newUserMailHelper->generateTemplate($user, $generatePasswordResetToken); |
408 | 408 | $this->newUserMailHelper->sendMail($user, $emailTemplate); |
409 | - } catch(\Exception $e) { |
|
410 | - $this->log->error("Can't send new user mail to $email: " . $e->getMessage(), array('app' => 'settings')); |
|
409 | + } catch (\Exception $e) { |
|
410 | + $this->log->error("Can't send new user mail to $email: ".$e->getMessage(), array('app' => 'settings')); |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 | // fetch users groups |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | |
422 | 422 | return new DataResponse( |
423 | 423 | array( |
424 | - 'message' => (string)$this->l10n->t('Unable to create user.') |
|
424 | + 'message' => (string) $this->l10n->t('Unable to create user.') |
|
425 | 425 | ), |
426 | 426 | Http::STATUS_FORBIDDEN |
427 | 427 | ); |
@@ -439,32 +439,32 @@ discard block |
||
439 | 439 | $userId = $this->userSession->getUser()->getUID(); |
440 | 440 | $user = $this->userManager->get($id); |
441 | 441 | |
442 | - if($userId === $id) { |
|
442 | + if ($userId === $id) { |
|
443 | 443 | return new DataResponse( |
444 | 444 | array( |
445 | 445 | 'status' => 'error', |
446 | 446 | 'data' => array( |
447 | - 'message' => (string)$this->l10n->t('Unable to delete user.') |
|
447 | + 'message' => (string) $this->l10n->t('Unable to delete user.') |
|
448 | 448 | ) |
449 | 449 | ), |
450 | 450 | Http::STATUS_FORBIDDEN |
451 | 451 | ); |
452 | 452 | } |
453 | 453 | |
454 | - if(!$this->isAdmin && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) { |
|
454 | + if (!$this->isAdmin && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) { |
|
455 | 455 | return new DataResponse( |
456 | 456 | array( |
457 | 457 | 'status' => 'error', |
458 | 458 | 'data' => array( |
459 | - 'message' => (string)$this->l10n->t('Authentication error') |
|
459 | + 'message' => (string) $this->l10n->t('Authentication error') |
|
460 | 460 | ) |
461 | 461 | ), |
462 | 462 | Http::STATUS_FORBIDDEN |
463 | 463 | ); |
464 | 464 | } |
465 | 465 | |
466 | - if($user) { |
|
467 | - if($user->delete()) { |
|
466 | + if ($user) { |
|
467 | + if ($user->delete()) { |
|
468 | 468 | return new DataResponse( |
469 | 469 | array( |
470 | 470 | 'status' => 'success', |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | array( |
482 | 482 | 'status' => 'error', |
483 | 483 | 'data' => array( |
484 | - 'message' => (string)$this->l10n->t('Unable to delete user.') |
|
484 | + 'message' => (string) $this->l10n->t('Unable to delete user.') |
|
485 | 485 | ) |
486 | 486 | ), |
487 | 487 | Http::STATUS_FORBIDDEN |
@@ -523,12 +523,12 @@ discard block |
||
523 | 523 | $twitterScope |
524 | 524 | ) { |
525 | 525 | |
526 | - if(!empty($email) && !$this->mailer->validateMailAddress($email)) { |
|
526 | + if (!empty($email) && !$this->mailer->validateMailAddress($email)) { |
|
527 | 527 | return new DataResponse( |
528 | 528 | array( |
529 | 529 | 'status' => 'error', |
530 | 530 | 'data' => array( |
531 | - 'message' => (string)$this->l10n->t('Invalid mail address') |
|
531 | + 'message' => (string) $this->l10n->t('Invalid mail address') |
|
532 | 532 | ) |
533 | 533 | ), |
534 | 534 | Http::STATUS_UNPROCESSABLE_ENTITY |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | 'websiteScope' => $websiteScope, |
564 | 564 | 'address' => $address, |
565 | 565 | 'addressScope' => $addressScope, |
566 | - 'message' => (string)$this->l10n->t('Settings saved') |
|
566 | + 'message' => (string) $this->l10n->t('Settings saved') |
|
567 | 567 | ) |
568 | 568 | ), |
569 | 569 | Http::STATUS_OK |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | |
641 | 641 | $uniqueUsers = []; |
642 | 642 | foreach ($groups as $group) { |
643 | - foreach($group->getUsers() as $uid => $displayName) { |
|
643 | + foreach ($group->getUsers() as $uid => $displayName) { |
|
644 | 644 | $uniqueUsers[$uid] = true; |
645 | 645 | } |
646 | 646 | } |
@@ -734,19 +734,19 @@ discard block |
||
734 | 734 | array( |
735 | 735 | 'status' => 'error', |
736 | 736 | 'data' => array( |
737 | - 'message' => (string)$this->l10n->t('Forbidden') |
|
737 | + 'message' => (string) $this->l10n->t('Forbidden') |
|
738 | 738 | ) |
739 | 739 | ), |
740 | 740 | Http::STATUS_FORBIDDEN |
741 | 741 | ); |
742 | 742 | } |
743 | 743 | |
744 | - if($mailAddress !== '' && !$this->mailer->validateMailAddress($mailAddress)) { |
|
744 | + if ($mailAddress !== '' && !$this->mailer->validateMailAddress($mailAddress)) { |
|
745 | 745 | return new DataResponse( |
746 | 746 | array( |
747 | 747 | 'status' => 'error', |
748 | 748 | 'data' => array( |
749 | - 'message' => (string)$this->l10n->t('Invalid mail address') |
|
749 | + 'message' => (string) $this->l10n->t('Invalid mail address') |
|
750 | 750 | ) |
751 | 751 | ), |
752 | 752 | Http::STATUS_UNPROCESSABLE_ENTITY |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | array( |
759 | 759 | 'status' => 'error', |
760 | 760 | 'data' => array( |
761 | - 'message' => (string)$this->l10n->t('Invalid user') |
|
761 | + 'message' => (string) $this->l10n->t('Invalid user') |
|
762 | 762 | ) |
763 | 763 | ), |
764 | 764 | Http::STATUS_UNPROCESSABLE_ENTITY |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | array( |
772 | 772 | 'status' => 'error', |
773 | 773 | 'data' => array( |
774 | - 'message' => (string)$this->l10n->t('Unable to change mail address') |
|
774 | + 'message' => (string) $this->l10n->t('Unable to change mail address') |
|
775 | 775 | ) |
776 | 776 | ), |
777 | 777 | Http::STATUS_FORBIDDEN |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | 'data' => array( |
790 | 790 | 'username' => $id, |
791 | 791 | 'mailAddress' => $mailAddress, |
792 | - 'message' => (string)$this->l10n->t('Email saved') |
|
792 | + 'message' => (string) $this->l10n->t('Email saved') |
|
793 | 793 | ) |
794 | 794 | ), |
795 | 795 | Http::STATUS_OK |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @param array $urlParams |
55 | 55 | */ |
56 | - public function __construct(array $urlParams=[]){ |
|
56 | + public function __construct(array $urlParams = []) { |
|
57 | 57 | parent::__construct('settings', $urlParams); |
58 | 58 | |
59 | 59 | $container = $this->getContainer(); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $container->registerService('isSubAdmin', function(IContainer $c) { |
74 | 74 | $userObject = \OC::$server->getUserSession()->getUser(); |
75 | 75 | $isSubAdmin = false; |
76 | - if($userObject !== null) { |
|
76 | + if ($userObject !== null) { |
|
77 | 77 | $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
78 | 78 | } |
79 | 79 | return $isSubAdmin; |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | $container->registerService('userCertificateManager', function(IContainer $c) { |
82 | 82 | return $c->query('ServerContainer')->getCertificateManager(); |
83 | 83 | }, false); |
84 | - $container->registerService('systemCertificateManager', function (IContainer $c) { |
|
84 | + $container->registerService('systemCertificateManager', function(IContainer $c) { |
|
85 | 85 | return $c->query('ServerContainer')->getCertificateManager(null); |
86 | 86 | }, false); |
87 | - $container->registerService(IProvider::class, function (IContainer $c) { |
|
87 | + $container->registerService(IProvider::class, function(IContainer $c) { |
|
88 | 88 | return $c->query('ServerContainer')->query(IProvider::class); |
89 | 89 | }); |
90 | - $container->registerService(IManager::class, function (IContainer $c) { |
|
90 | + $container->registerService(IManager::class, function(IContainer $c) { |
|
91 | 91 | return $c->query('ServerContainer')->getSettingsManager(); |
92 | 92 | }); |
93 | 93 | |
94 | - $container->registerService(NewUserMailHelper::class, function (IContainer $c) { |
|
94 | + $container->registerService(NewUserMailHelper::class, function(IContainer $c) { |
|
95 | 95 | /** @var Server $server */ |
96 | 96 | $server = $c->query('ServerContainer'); |
97 | 97 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | Util::getDefaultEmailAddress('no-reply') |
108 | 108 | ); |
109 | 109 | }); |
110 | - $container->registerService(AppFetcher::class, function (IContainer $c) { |
|
110 | + $container->registerService(AppFetcher::class, function(IContainer $c) { |
|
111 | 111 | /** @var Server $server */ |
112 | 112 | $server = $c->query('ServerContainer'); |
113 | 113 | return new AppFetcher( |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $server->getConfig() |
118 | 118 | ); |
119 | 119 | }); |
120 | - $container->registerService(CategoryFetcher::class, function (IContainer $c) { |
|
120 | + $container->registerService(CategoryFetcher::class, function(IContainer $c) { |
|
121 | 121 | /** @var Server $server */ |
122 | 122 | $server = $c->query('ServerContainer'); |
123 | 123 | return new CategoryFetcher( |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | // Admin? Or SubAdmin? |
140 | 140 | $uid = $user->getUID(); |
141 | 141 | $subAdminManager = $this->groupManager->getSubAdmin(); |
142 | - if($this->groupManager->isAdmin($uid)){ |
|
142 | + if ($this->groupManager->isAdmin($uid)) { |
|
143 | 143 | $users = $this->userManager->search($search, $limit, $offset); |
144 | 144 | } else if ($subAdminManager->isSubAdmin($user)) { |
145 | 145 | $subAdminOfGroups = $subAdminManager->getSubAdminsGroups($user); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $subAdminOfGroups[$key] = $group->getGID(); |
148 | 148 | } |
149 | 149 | |
150 | - if($offset === null) { |
|
150 | + if ($offset === null) { |
|
151 | 151 | $offset = 0; |
152 | 152 | } |
153 | 153 | |
@@ -181,22 +181,22 @@ discard block |
||
181 | 181 | $isAdmin = $this->groupManager->isAdmin($user->getUID()); |
182 | 182 | $subAdminManager = $this->groupManager->getSubAdmin(); |
183 | 183 | |
184 | - if($this->userManager->userExists($userid)) { |
|
184 | + if ($this->userManager->userExists($userid)) { |
|
185 | 185 | $this->logger->error('Failed addUser attempt: User already exists.', ['app' => 'ocs_api']); |
186 | 186 | throw new OCSException('User already exists', 102); |
187 | 187 | } |
188 | 188 | |
189 | - if(is_array($groups)) { |
|
189 | + if (is_array($groups)) { |
|
190 | 190 | foreach ($groups as $group) { |
191 | - if(!$this->groupManager->groupExists($group)) { |
|
191 | + if (!$this->groupManager->groupExists($group)) { |
|
192 | 192 | throw new OCSException('group '.$group.' does not exist', 104); |
193 | 193 | } |
194 | - if(!$isAdmin && !$subAdminManager->isSubAdminofGroup($user, $this->groupManager->get($group))) { |
|
195 | - throw new OCSException('insufficient privileges for group '. $group, 105); |
|
194 | + if (!$isAdmin && !$subAdminManager->isSubAdminofGroup($user, $this->groupManager->get($group))) { |
|
195 | + throw new OCSException('insufficient privileges for group '.$group, 105); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | } else { |
199 | - if(!$isAdmin) { |
|
199 | + if (!$isAdmin) { |
|
200 | 200 | throw new OCSException('no group specified (required for subadmins)', 106); |
201 | 201 | } |
202 | 202 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | public function getCurrentUser() { |
246 | 246 | $user = $this->userSession->getUser(); |
247 | 247 | if ($user) { |
248 | - $data = $this->getUserData($user->getUID()); |
|
248 | + $data = $this->getUserData($user->getUID()); |
|
249 | 249 | // rename "displayname" to "display-name" only for this call to keep |
250 | 250 | // the API stable. |
251 | 251 | $data['display-name'] = $data['displayname']; |
@@ -271,17 +271,17 @@ discard block |
||
271 | 271 | |
272 | 272 | // Check if the target user exists |
273 | 273 | $targetUserObject = $this->userManager->get($userId); |
274 | - if($targetUserObject === null) { |
|
274 | + if ($targetUserObject === null) { |
|
275 | 275 | throw new OCSException('The requested user could not be found', \OCP\API::RESPOND_NOT_FOUND); |
276 | 276 | } |
277 | 277 | |
278 | 278 | // Admin? Or SubAdmin? |
279 | - if($this->groupManager->isAdmin($currentLoggedInUser->getUID()) |
|
279 | + if ($this->groupManager->isAdmin($currentLoggedInUser->getUID()) |
|
280 | 280 | || $this->groupManager->getSubAdmin()->isUserAccessible($currentLoggedInUser, $targetUserObject)) { |
281 | 281 | $data['enabled'] = $this->config->getUserValue($userId, 'core', 'enabled', 'true'); |
282 | 282 | } else { |
283 | 283 | // Check they are looking up themselves |
284 | - if($currentLoggedInUser->getUID() !== $userId) { |
|
284 | + if ($currentLoggedInUser->getUID() !== $userId) { |
|
285 | 285 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
286 | 286 | } |
287 | 287 | } |
@@ -325,24 +325,24 @@ discard block |
||
325 | 325 | $currentLoggedInUser = $this->userSession->getUser(); |
326 | 326 | |
327 | 327 | $targetUser = $this->userManager->get($userId); |
328 | - if($targetUser === null) { |
|
328 | + if ($targetUser === null) { |
|
329 | 329 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
330 | 330 | } |
331 | 331 | |
332 | 332 | $permittedFields = []; |
333 | - if($userId === $currentLoggedInUser->getUID()) { |
|
333 | + if ($userId === $currentLoggedInUser->getUID()) { |
|
334 | 334 | // Editing self (display, email) |
335 | 335 | $permittedFields[] = 'display'; |
336 | 336 | $permittedFields[] = 'email'; |
337 | 337 | $permittedFields[] = 'password'; |
338 | 338 | // If admin they can edit their own quota |
339 | - if($this->groupManager->isAdmin($currentLoggedInUser->getUID())) { |
|
339 | + if ($this->groupManager->isAdmin($currentLoggedInUser->getUID())) { |
|
340 | 340 | $permittedFields[] = 'quota'; |
341 | 341 | } |
342 | 342 | } else { |
343 | 343 | // Check if admin / subadmin |
344 | 344 | $subAdminManager = $this->groupManager->getSubAdmin(); |
345 | - if($subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser) |
|
345 | + if ($subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser) |
|
346 | 346 | || $this->groupManager->isAdmin($currentLoggedInUser->getUID())) { |
347 | 347 | // They have permissions over the user |
348 | 348 | $permittedFields[] = 'display'; |
@@ -355,17 +355,17 @@ discard block |
||
355 | 355 | } |
356 | 356 | } |
357 | 357 | // Check if permitted to edit this field |
358 | - if(!in_array($key, $permittedFields)) { |
|
358 | + if (!in_array($key, $permittedFields)) { |
|
359 | 359 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
360 | 360 | } |
361 | 361 | // Process the edit |
362 | - switch($key) { |
|
362 | + switch ($key) { |
|
363 | 363 | case 'display': |
364 | 364 | $targetUser->setDisplayName($value); |
365 | 365 | break; |
366 | 366 | case 'quota': |
367 | 367 | $quota = $value; |
368 | - if($quota !== 'none' && $quota !== 'default') { |
|
368 | + if ($quota !== 'none' && $quota !== 'default') { |
|
369 | 369 | if (is_numeric($quota)) { |
370 | 370 | $quota = (float) $quota; |
371 | 371 | } else { |
@@ -374,9 +374,9 @@ discard block |
||
374 | 374 | if ($quota === false) { |
375 | 375 | throw new OCSException('Invalid quota value '.$value, 103); |
376 | 376 | } |
377 | - if($quota === 0) { |
|
377 | + if ($quota === 0) { |
|
378 | 378 | $quota = 'default'; |
379 | - }else if($quota === -1) { |
|
379 | + } else if ($quota === -1) { |
|
380 | 380 | $quota = 'none'; |
381 | 381 | } else { |
382 | 382 | $quota = \OCP\Util::humanFileSize($quota); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $targetUser->setPassword($value); |
389 | 389 | break; |
390 | 390 | case 'email': |
391 | - if(filter_var($value, FILTER_VALIDATE_EMAIL)) { |
|
391 | + if (filter_var($value, FILTER_VALIDATE_EMAIL)) { |
|
392 | 392 | $targetUser->setEMailAddress($value); |
393 | 393 | } else { |
394 | 394 | throw new OCSException('', 102); |
@@ -414,18 +414,18 @@ discard block |
||
414 | 414 | |
415 | 415 | $targetUser = $this->userManager->get($userId); |
416 | 416 | |
417 | - if($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) { |
|
417 | + if ($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) { |
|
418 | 418 | throw new OCSException('', 101); |
419 | 419 | } |
420 | 420 | |
421 | 421 | // If not permitted |
422 | 422 | $subAdminManager = $this->groupManager->getSubAdmin(); |
423 | - if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) { |
|
423 | + if (!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) { |
|
424 | 424 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
425 | 425 | } |
426 | 426 | |
427 | 427 | // Go ahead with the delete |
428 | - if($targetUser->delete()) { |
|
428 | + if ($targetUser->delete()) { |
|
429 | 429 | return new DataResponse(); |
430 | 430 | } else { |
431 | 431 | throw new OCSException('', 101); |
@@ -469,13 +469,13 @@ discard block |
||
469 | 469 | $currentLoggedInUser = $this->userSession->getUser(); |
470 | 470 | |
471 | 471 | $targetUser = $this->userManager->get($userId); |
472 | - if($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) { |
|
472 | + if ($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) { |
|
473 | 473 | throw new OCSException('', 101); |
474 | 474 | } |
475 | 475 | |
476 | 476 | // If not permitted |
477 | 477 | $subAdminManager = $this->groupManager->getSubAdmin(); |
478 | - if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) { |
|
478 | + if (!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) { |
|
479 | 479 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
480 | 480 | } |
481 | 481 | |
@@ -496,11 +496,11 @@ discard block |
||
496 | 496 | $loggedInUser = $this->userSession->getUser(); |
497 | 497 | |
498 | 498 | $targetUser = $this->userManager->get($userId); |
499 | - if($targetUser === null) { |
|
499 | + if ($targetUser === null) { |
|
500 | 500 | throw new OCSException('', \OCP\API::RESPOND_NOT_FOUND); |
501 | 501 | } |
502 | 502 | |
503 | - if($targetUser->getUID() === $loggedInUser->getUID() || $this->groupManager->isAdmin($loggedInUser->getUID())) { |
|
503 | + if ($targetUser->getUID() === $loggedInUser->getUID() || $this->groupManager->isAdmin($loggedInUser->getUID())) { |
|
504 | 504 | // Self lookup or admin lookup |
505 | 505 | return new DataResponse([ |
506 | 506 | 'groups' => $this->groupManager->getUserGroupIds($targetUser) |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | $subAdminManager = $this->groupManager->getSubAdmin(); |
510 | 510 | |
511 | 511 | // Looking up someone else |
512 | - if($subAdminManager->isUserAccessible($loggedInUser, $targetUser)) { |
|
512 | + if ($subAdminManager->isUserAccessible($loggedInUser, $targetUser)) { |
|
513 | 513 | // Return the group that the method caller is subadmin of for the user in question |
514 | 514 | /** @var IGroup[] $getSubAdminsGroups */ |
515 | 515 | $getSubAdminsGroups = $subAdminManager->getSubAdminsGroups($loggedInUser); |
@@ -539,16 +539,16 @@ discard block |
||
539 | 539 | * @throws OCSException |
540 | 540 | */ |
541 | 541 | public function addToGroup($userId, $groupid = '') { |
542 | - if($groupid === '') { |
|
542 | + if ($groupid === '') { |
|
543 | 543 | throw new OCSException('', 101); |
544 | 544 | } |
545 | 545 | |
546 | 546 | $group = $this->groupManager->get($groupid); |
547 | 547 | $targetUser = $this->userManager->get($userId); |
548 | - if($group === null) { |
|
548 | + if ($group === null) { |
|
549 | 549 | throw new OCSException('', 102); |
550 | 550 | } |
551 | - if($targetUser === null) { |
|
551 | + if ($targetUser === null) { |
|
552 | 552 | throw new OCSException('', 103); |
553 | 553 | } |
554 | 554 | |
@@ -576,17 +576,17 @@ discard block |
||
576 | 576 | public function removeFromGroup($userId, $groupid) { |
577 | 577 | $loggedInUser = $this->userSession->getUser(); |
578 | 578 | |
579 | - if($groupid === null) { |
|
579 | + if ($groupid === null) { |
|
580 | 580 | throw new OCSException('', 101); |
581 | 581 | } |
582 | 582 | |
583 | 583 | $group = $this->groupManager->get($groupid); |
584 | - if($group === null) { |
|
584 | + if ($group === null) { |
|
585 | 585 | throw new OCSException('', 102); |
586 | 586 | } |
587 | 587 | |
588 | 588 | $targetUser = $this->userManager->get($userId); |
589 | - if($targetUser === null) { |
|
589 | + if ($targetUser === null) { |
|
590 | 590 | throw new OCSException('', 103); |
591 | 591 | } |
592 | 592 | |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | } else if (!$this->groupManager->isAdmin($loggedInUser->getUID())) { |
611 | 611 | /** @var IGroup[] $subAdminGroups */ |
612 | 612 | $subAdminGroups = $subAdminManager->getSubAdminsGroups($loggedInUser); |
613 | - $subAdminGroups = array_map(function (IGroup $subAdminGroup) { |
|
613 | + $subAdminGroups = array_map(function(IGroup $subAdminGroup) { |
|
614 | 614 | return $subAdminGroup->getGID(); |
615 | 615 | }, $subAdminGroups); |
616 | 616 | $userGroups = $this->groupManager->getUserGroupIds($targetUser); |
@@ -642,15 +642,15 @@ discard block |
||
642 | 642 | $user = $this->userManager->get($userId); |
643 | 643 | |
644 | 644 | // Check if the user exists |
645 | - if($user === null) { |
|
645 | + if ($user === null) { |
|
646 | 646 | throw new OCSException('User does not exist', 101); |
647 | 647 | } |
648 | 648 | // Check if group exists |
649 | - if($group === null) { |
|
650 | - throw new OCSException('Group:'.$groupid.' does not exist', 102); |
|
649 | + if ($group === null) { |
|
650 | + throw new OCSException('Group:'.$groupid.' does not exist', 102); |
|
651 | 651 | } |
652 | 652 | // Check if trying to make subadmin of admin group |
653 | - if(strtolower($groupid) === 'admin') { |
|
653 | + if (strtolower($groupid) === 'admin') { |
|
654 | 654 | throw new OCSException('Cannot create subadmins for admin group', 103); |
655 | 655 | } |
656 | 656 | |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | return new DataResponse(); |
662 | 662 | } |
663 | 663 | // Go |
664 | - if($subAdminManager->createSubAdmin($user, $group)) { |
|
664 | + if ($subAdminManager->createSubAdmin($user, $group)) { |
|
665 | 665 | return new DataResponse(); |
666 | 666 | } else { |
667 | 667 | throw new OCSException('Unknown error occurred', 103); |
@@ -684,20 +684,20 @@ discard block |
||
684 | 684 | $subAdminManager = $this->groupManager->getSubAdmin(); |
685 | 685 | |
686 | 686 | // Check if the user exists |
687 | - if($user === null) { |
|
687 | + if ($user === null) { |
|
688 | 688 | throw new OCSException('User does not exist', 101); |
689 | 689 | } |
690 | 690 | // Check if the group exists |
691 | - if($group === null) { |
|
691 | + if ($group === null) { |
|
692 | 692 | throw new OCSException('Group does not exist', 101); |
693 | 693 | } |
694 | 694 | // Check if they are a subadmin of this said group |
695 | - if(!$subAdminManager->isSubAdminofGroup($user, $group)) { |
|
695 | + if (!$subAdminManager->isSubAdminofGroup($user, $group)) { |
|
696 | 696 | throw new OCSException('User is not a subadmin of this group', 102); |
697 | 697 | } |
698 | 698 | |
699 | 699 | // Go |
700 | - if($subAdminManager->deleteSubAdmin($user, $group)) { |
|
700 | + if ($subAdminManager->deleteSubAdmin($user, $group)) { |
|
701 | 701 | return new DataResponse(); |
702 | 702 | } else { |
703 | 703 | throw new OCSException('Unknown error occurred', 103); |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | public function getUserSubAdminGroups($userId) { |
715 | 715 | $user = $this->userManager->get($userId); |
716 | 716 | // Check if the user exists |
717 | - if($user === null) { |
|
717 | + if ($user === null) { |
|
718 | 718 | throw new OCSException('User does not exist', 101); |
719 | 719 | } |
720 | 720 | |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | $groups[$key] = $group->getGID(); |
725 | 725 | } |
726 | 726 | |
727 | - if(!$groups) { |
|
727 | + if (!$groups) { |
|
728 | 728 | throw new OCSException('Unknown error occurred', 102); |
729 | 729 | } else { |
730 | 730 | return new DataResponse($groups); |
@@ -768,13 +768,13 @@ discard block |
||
768 | 768 | $currentLoggedInUser = $this->userSession->getUser(); |
769 | 769 | |
770 | 770 | $targetUser = $this->userManager->get($userId); |
771 | - if($targetUser === null) { |
|
771 | + if ($targetUser === null) { |
|
772 | 772 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
773 | 773 | } |
774 | 774 | |
775 | 775 | // Check if admin / subadmin |
776 | 776 | $subAdminManager = $this->groupManager->getSubAdmin(); |
777 | - if(!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser) |
|
777 | + if (!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser) |
|
778 | 778 | && !$this->groupManager->isAdmin($currentLoggedInUser->getUID())) { |
779 | 779 | // No rights |
780 | 780 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
@@ -796,8 +796,8 @@ discard block |
||
796 | 796 | $this->newUserMailHelper->setL10N($l10n); |
797 | 797 | $emailTemplate = $this->newUserMailHelper->generateTemplate($targetUser, false); |
798 | 798 | $this->newUserMailHelper->sendMail($targetUser, $emailTemplate); |
799 | - } catch(\Exception $e) { |
|
800 | - $this->logger->error("Can't send new user mail to $email: " . $e->getMessage(), array('app' => 'settings')); |
|
799 | + } catch (\Exception $e) { |
|
800 | + $this->logger->error("Can't send new user mail to $email: ".$e->getMessage(), array('app' => 'settings')); |
|
801 | 801 | throw new OCSException('Sending email failed', 102); |
802 | 802 | } |
803 | 803 |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | |
108 | 108 | public function getShortFooter() { |
109 | 109 | $slogan = $this->getSlogan(); |
110 | - $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
111 | - ' rel="noreferrer">' .$this->getEntity() . '</a>'. |
|
112 | - ($slogan !== '' ? ' – ' . $slogan : ''); |
|
110 | + $footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'. |
|
111 | + ' rel="noreferrer">'.$this->getEntity().'</a>'. |
|
112 | + ($slogan !== '' ? ' – '.$slogan : ''); |
|
113 | 113 | |
114 | 114 | return $footer; |
115 | 115 | } |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | $logoExists = false; |
139 | 139 | } |
140 | 140 | |
141 | - if(!$logo || !$logoExists) { |
|
142 | - return $this->urlGenerator->imagePath('core','logo.svg'); |
|
141 | + if (!$logo || !$logoExists) { |
|
142 | + return $this->urlGenerator->imagePath('core', 'logo.svg'); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return $this->urlGenerator->linkToRoute('theming.Theming.getLogo'); |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | $backgroundExists = false; |
161 | 161 | } |
162 | 162 | |
163 | - if(!$backgroundLogo || !$backgroundExists) { |
|
164 | - return $this->urlGenerator->imagePath('core','background.jpg'); |
|
163 | + if (!$backgroundLogo || !$backgroundExists) { |
|
164 | + return $this->urlGenerator->imagePath('core', 'background.jpg'); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground'); |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function shouldReplaceIcons() { |
177 | 177 | $cache = $this->cacheFactory->create('theming'); |
178 | - if($value = $cache->get('shouldReplaceIcons')) { |
|
179 | - return (bool)$value; |
|
178 | + if ($value = $cache->get('shouldReplaceIcons')) { |
|
179 | + return (bool) $value; |
|
180 | 180 | } |
181 | 181 | $value = false; |
182 | - if(extension_loaded('imagick')) { |
|
182 | + if (extension_loaded('imagick')) { |
|
183 | 183 | $checkImagick = new \Imagick(); |
184 | 184 | if (count($checkImagick->queryFormats('SVG')) >= 1) { |
185 | 185 | $value = true; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | private function increaseCacheBuster() { |
206 | 206 | $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); |
207 | - $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); |
|
207 | + $this->config->setAppValue('theming', 'cachebuster', (int) $cacheBusterKey + 1); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |