@@ -370,18 +370,18 @@ discard block |
||
| 370 | 370 | private function findFileWithExtension($class, $ext) |
| 371 | 371 | { |
| 372 | 372 | // PSR-4 lookup |
| 373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
| 374 | 374 | |
| 375 | 375 | $first = $class[0]; |
| 376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
| 377 | 377 | $subPath = $class; |
| 378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
| 379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
| 380 | - $search = $subPath . '\\'; |
|
| 380 | + $search = $subPath.'\\'; |
|
| 381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
| 382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
| 382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
| 383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
| 384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
| 384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
| 385 | 385 | return $file; |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | // PSR-4 fallback dirs |
| 393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
| 395 | 395 | return $file; |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
| 403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 404 | 404 | } else { |
| 405 | 405 | // PEAR-like class name |
| 406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
| 410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
| 411 | 411 | if (0 === strpos($class, $prefix)) { |
| 412 | 412 | foreach ($dirs as $dir) { |
| 413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 414 | 414 | return $file; |
| 415 | 415 | } |
| 416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | // PSR-0 fallback dirs |
| 422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 424 | 424 | return $file; |
| 425 | 425 | } |
| 426 | 426 | } |
@@ -370,18 +370,18 @@ discard block |
||
| 370 | 370 | private function findFileWithExtension($class, $ext) |
| 371 | 371 | { |
| 372 | 372 | // PSR-4 lookup |
| 373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
| 374 | 374 | |
| 375 | 375 | $first = $class[0]; |
| 376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
| 377 | 377 | $subPath = $class; |
| 378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
| 379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
| 380 | - $search = $subPath . '\\'; |
|
| 380 | + $search = $subPath.'\\'; |
|
| 381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
| 382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
| 382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
| 383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
| 384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
| 384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
| 385 | 385 | return $file; |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | // PSR-4 fallback dirs |
| 393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
| 395 | 395 | return $file; |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
| 403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 404 | 404 | } else { |
| 405 | 405 | // PEAR-like class name |
| 406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
| 410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
| 411 | 411 | if (0 === strpos($class, $prefix)) { |
| 412 | 412 | foreach ($dirs as $dir) { |
| 413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 414 | 414 | return $file; |
| 415 | 415 | } |
| 416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | // PSR-0 fallback dirs |
| 422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 424 | 424 | return $file; |
| 425 | 425 | } |
| 426 | 426 | } |
@@ -370,18 +370,18 @@ discard block |
||
| 370 | 370 | private function findFileWithExtension($class, $ext) |
| 371 | 371 | { |
| 372 | 372 | // PSR-4 lookup |
| 373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
| 374 | 374 | |
| 375 | 375 | $first = $class[0]; |
| 376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
| 377 | 377 | $subPath = $class; |
| 378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
| 379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
| 380 | - $search = $subPath . '\\'; |
|
| 380 | + $search = $subPath.'\\'; |
|
| 381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
| 382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
| 382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
| 383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
| 384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
| 384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
| 385 | 385 | return $file; |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | // PSR-4 fallback dirs |
| 393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
| 395 | 395 | return $file; |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
| 403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 404 | 404 | } else { |
| 405 | 405 | // PEAR-like class name |
| 406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
| 410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
| 411 | 411 | if (0 === strpos($class, $prefix)) { |
| 412 | 412 | foreach ($dirs as $dir) { |
| 413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 414 | 414 | return $file; |
| 415 | 415 | } |
| 416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | // PSR-0 fallback dirs |
| 422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 424 | 424 | return $file; |
| 425 | 425 | } |
| 426 | 426 | } |
@@ -8,6 +8,6 @@ |
||
| 8 | 8 | </p> |
| 9 | 9 | <br /> |
| 10 | 10 | <p> |
| 11 | - <?php print_unescaped($l->t('Further information how to configure this can be found in the %1$sdocumentation%2$s.', ['<a href="' . $_['docUrl'] . '" target="blank">', '</a>'])); ?> |
|
| 11 | + <?php print_unescaped($l->t('Further information how to configure this can be found in the %1$sdocumentation%2$s.', ['<a href="'.$_['docUrl'].'" target="blank">', '</a>'])); ?> |
|
| 12 | 12 | </p> |
| 13 | 13 | </div> |
@@ -98,10 +98,10 @@ |
||
| 98 | 98 | if (empty($state->getEnforcedGroups())) { |
| 99 | 99 | $message = 'Two-factor authentication is enforced for all users'; |
| 100 | 100 | } else { |
| 101 | - $message = 'Two-factor authentication is enforced for members of the group(s) ' . implode(', ', $state->getEnforcedGroups()); |
|
| 101 | + $message = 'Two-factor authentication is enforced for members of the group(s) '.implode(', ', $state->getEnforcedGroups()); |
|
| 102 | 102 | } |
| 103 | 103 | if (!empty($state->getExcludedGroups())) { |
| 104 | - $message .= ', except members of ' . implode(', ', $state->getExcludedGroups()); |
|
| 104 | + $message .= ', except members of '.implode(', ', $state->getExcludedGroups()); |
|
| 105 | 105 | } |
| 106 | 106 | $output->writeln($message); |
| 107 | 107 | } |
@@ -17,72 +17,72 @@ |
||
| 17 | 17 | use function implode; |
| 18 | 18 | |
| 19 | 19 | class Enforce extends Command { |
| 20 | - public function __construct( |
|
| 21 | - private MandatoryTwoFactor $mandatoryTwoFactor, |
|
| 22 | - ) { |
|
| 23 | - parent::__construct(); |
|
| 24 | - } |
|
| 20 | + public function __construct( |
|
| 21 | + private MandatoryTwoFactor $mandatoryTwoFactor, |
|
| 22 | + ) { |
|
| 23 | + parent::__construct(); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - protected function configure() { |
|
| 27 | - $this->setName('twofactorauth:enforce'); |
|
| 28 | - $this->setDescription('Enabled/disable enforced two-factor authentication'); |
|
| 29 | - $this->addOption( |
|
| 30 | - 'on', |
|
| 31 | - null, |
|
| 32 | - InputOption::VALUE_NONE, |
|
| 33 | - 'enforce two-factor authentication' |
|
| 34 | - ); |
|
| 35 | - $this->addOption( |
|
| 36 | - 'off', |
|
| 37 | - null, |
|
| 38 | - InputOption::VALUE_NONE, |
|
| 39 | - 'don\'t enforce two-factor authenticaton' |
|
| 40 | - ); |
|
| 41 | - $this->addOption( |
|
| 42 | - 'group', |
|
| 43 | - null, |
|
| 44 | - InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
| 45 | - 'enforce only for the given group(s)' |
|
| 46 | - ); |
|
| 47 | - $this->addOption( |
|
| 48 | - 'exclude', |
|
| 49 | - null, |
|
| 50 | - InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
| 51 | - 'exclude mandatory two-factor auth for the given group(s)' |
|
| 52 | - ); |
|
| 53 | - } |
|
| 26 | + protected function configure() { |
|
| 27 | + $this->setName('twofactorauth:enforce'); |
|
| 28 | + $this->setDescription('Enabled/disable enforced two-factor authentication'); |
|
| 29 | + $this->addOption( |
|
| 30 | + 'on', |
|
| 31 | + null, |
|
| 32 | + InputOption::VALUE_NONE, |
|
| 33 | + 'enforce two-factor authentication' |
|
| 34 | + ); |
|
| 35 | + $this->addOption( |
|
| 36 | + 'off', |
|
| 37 | + null, |
|
| 38 | + InputOption::VALUE_NONE, |
|
| 39 | + 'don\'t enforce two-factor authenticaton' |
|
| 40 | + ); |
|
| 41 | + $this->addOption( |
|
| 42 | + 'group', |
|
| 43 | + null, |
|
| 44 | + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
| 45 | + 'enforce only for the given group(s)' |
|
| 46 | + ); |
|
| 47 | + $this->addOption( |
|
| 48 | + 'exclude', |
|
| 49 | + null, |
|
| 50 | + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
| 51 | + 'exclude mandatory two-factor auth for the given group(s)' |
|
| 52 | + ); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 56 | - if ($input->getOption('on')) { |
|
| 57 | - $enforcedGroups = $input->getOption('group'); |
|
| 58 | - $excludedGroups = $input->getOption('exclude'); |
|
| 59 | - $this->mandatoryTwoFactor->setState(new EnforcementState(true, $enforcedGroups, $excludedGroups)); |
|
| 60 | - } elseif ($input->getOption('off')) { |
|
| 61 | - $this->mandatoryTwoFactor->setState(new EnforcementState(false)); |
|
| 62 | - } |
|
| 55 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 56 | + if ($input->getOption('on')) { |
|
| 57 | + $enforcedGroups = $input->getOption('group'); |
|
| 58 | + $excludedGroups = $input->getOption('exclude'); |
|
| 59 | + $this->mandatoryTwoFactor->setState(new EnforcementState(true, $enforcedGroups, $excludedGroups)); |
|
| 60 | + } elseif ($input->getOption('off')) { |
|
| 61 | + $this->mandatoryTwoFactor->setState(new EnforcementState(false)); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $state = $this->mandatoryTwoFactor->getState(); |
|
| 65 | - if ($state->isEnforced()) { |
|
| 66 | - $this->writeEnforced($output, $state); |
|
| 67 | - } else { |
|
| 68 | - $this->writeNotEnforced($output); |
|
| 69 | - } |
|
| 70 | - return 0; |
|
| 71 | - } |
|
| 64 | + $state = $this->mandatoryTwoFactor->getState(); |
|
| 65 | + if ($state->isEnforced()) { |
|
| 66 | + $this->writeEnforced($output, $state); |
|
| 67 | + } else { |
|
| 68 | + $this->writeNotEnforced($output); |
|
| 69 | + } |
|
| 70 | + return 0; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - protected function writeEnforced(OutputInterface $output, EnforcementState $state) { |
|
| 74 | - if (empty($state->getEnforcedGroups())) { |
|
| 75 | - $message = 'Two-factor authentication is enforced for all users'; |
|
| 76 | - } else { |
|
| 77 | - $message = 'Two-factor authentication is enforced for members of the group(s) ' . implode(', ', $state->getEnforcedGroups()); |
|
| 78 | - } |
|
| 79 | - if (!empty($state->getExcludedGroups())) { |
|
| 80 | - $message .= ', except members of ' . implode(', ', $state->getExcludedGroups()); |
|
| 81 | - } |
|
| 82 | - $output->writeln($message); |
|
| 83 | - } |
|
| 73 | + protected function writeEnforced(OutputInterface $output, EnforcementState $state) { |
|
| 74 | + if (empty($state->getEnforcedGroups())) { |
|
| 75 | + $message = 'Two-factor authentication is enforced for all users'; |
|
| 76 | + } else { |
|
| 77 | + $message = 'Two-factor authentication is enforced for members of the group(s) ' . implode(', ', $state->getEnforcedGroups()); |
|
| 78 | + } |
|
| 79 | + if (!empty($state->getExcludedGroups())) { |
|
| 80 | + $message .= ', except members of ' . implode(', ', $state->getExcludedGroups()); |
|
| 81 | + } |
|
| 82 | + $output->writeln($message); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - protected function writeNotEnforced(OutputInterface $output) { |
|
| 86 | - $output->writeln('Two-factor authentication is not enforced'); |
|
| 87 | - } |
|
| 85 | + protected function writeNotEnforced(OutputInterface $output) { |
|
| 86 | + $output->writeln('Two-factor authentication is not enforced'); |
|
| 87 | + } |
|
| 88 | 88 | } |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | ], |
| 75 | 75 | [ |
| 76 | 76 | 'privilege' => '{DAV:}read', |
| 77 | - 'principal' => $this->getOwner() . '/calendar-proxy-read', |
|
| 77 | + 'principal' => $this->getOwner().'/calendar-proxy-read', |
|
| 78 | 78 | 'protected' => true, |
| 79 | 79 | ], |
| 80 | 80 | [ |
| 81 | 81 | 'privilege' => '{DAV:}read', |
| 82 | - 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
| 82 | + 'principal' => $this->getOwner().'/calendar-proxy-write', |
|
| 83 | 83 | 'protected' => true, |
| 84 | 84 | ], |
| 85 | 85 | ]; |
@@ -94,23 +94,23 @@ discard block |
||
| 94 | 94 | if ($this->disableFreeBusy) { |
| 95 | 95 | return array_merge($commonAcl, [ |
| 96 | 96 | [ |
| 97 | - 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send-invite', |
|
| 97 | + 'privilege' => '{'.CalDAVPlugin::NS_CALDAV.'}schedule-send-invite', |
|
| 98 | 98 | 'principal' => $this->getOwner(), |
| 99 | 99 | 'protected' => true, |
| 100 | 100 | ], |
| 101 | 101 | [ |
| 102 | - 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send-invite', |
|
| 103 | - 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
| 102 | + 'privilege' => '{'.CalDAVPlugin::NS_CALDAV.'}schedule-send-invite', |
|
| 103 | + 'principal' => $this->getOwner().'/calendar-proxy-write', |
|
| 104 | 104 | 'protected' => true, |
| 105 | 105 | ], |
| 106 | 106 | [ |
| 107 | - 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send-reply', |
|
| 107 | + 'privilege' => '{'.CalDAVPlugin::NS_CALDAV.'}schedule-send-reply', |
|
| 108 | 108 | 'principal' => $this->getOwner(), |
| 109 | 109 | 'protected' => true, |
| 110 | 110 | ], |
| 111 | 111 | [ |
| 112 | - 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send-reply', |
|
| 113 | - 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
| 112 | + 'privilege' => '{'.CalDAVPlugin::NS_CALDAV.'}schedule-send-reply', |
|
| 113 | + 'principal' => $this->getOwner().'/calendar-proxy-write', |
|
| 114 | 114 | 'protected' => true, |
| 115 | 115 | ], |
| 116 | 116 | ]); |
@@ -118,13 +118,13 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | return array_merge($commonAcl, [ |
| 120 | 120 | [ |
| 121 | - 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send', |
|
| 121 | + 'privilege' => '{'.CalDAVPlugin::NS_CALDAV.'}schedule-send', |
|
| 122 | 122 | 'principal' => $this->getOwner(), |
| 123 | 123 | 'protected' => true, |
| 124 | 124 | ], |
| 125 | 125 | [ |
| 126 | - 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send', |
|
| 127 | - 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
| 126 | + 'privilege' => '{'.CalDAVPlugin::NS_CALDAV.'}schedule-send', |
|
| 127 | + 'principal' => $this->getOwner().'/calendar-proxy-write', |
|
| 128 | 128 | 'protected' => true, |
| 129 | 129 | ], |
| 130 | 130 | ]); |
@@ -15,101 +15,101 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class Outbox extends \Sabre\CalDAV\Schedule\Outbox { |
| 17 | 17 | |
| 18 | - /** @var null|bool */ |
|
| 19 | - private $disableFreeBusy = null; |
|
| 18 | + /** @var null|bool */ |
|
| 19 | + private $disableFreeBusy = null; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Outbox constructor. |
|
| 23 | - * |
|
| 24 | - * @param IConfig $config |
|
| 25 | - * @param string $principalUri |
|
| 26 | - */ |
|
| 27 | - public function __construct( |
|
| 28 | - private IConfig $config, |
|
| 29 | - string $principalUri, |
|
| 30 | - ) { |
|
| 31 | - parent::__construct($principalUri); |
|
| 32 | - } |
|
| 21 | + /** |
|
| 22 | + * Outbox constructor. |
|
| 23 | + * |
|
| 24 | + * @param IConfig $config |
|
| 25 | + * @param string $principalUri |
|
| 26 | + */ |
|
| 27 | + public function __construct( |
|
| 28 | + private IConfig $config, |
|
| 29 | + string $principalUri, |
|
| 30 | + ) { |
|
| 31 | + parent::__construct($principalUri); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Returns a list of ACE's for this node. |
|
| 36 | - * |
|
| 37 | - * Each ACE has the following properties: |
|
| 38 | - * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
| 39 | - * currently the only supported privileges |
|
| 40 | - * * 'principal', a url to the principal who owns the node |
|
| 41 | - * * 'protected' (optional), indicating that this ACE is not allowed to |
|
| 42 | - * be updated. |
|
| 43 | - * |
|
| 44 | - * @return array |
|
| 45 | - */ |
|
| 46 | - public function getACL() { |
|
| 47 | - // getACL is called so frequently that we cache the config result |
|
| 48 | - if ($this->disableFreeBusy === null) { |
|
| 49 | - $this->disableFreeBusy = ($this->config->getAppValue('dav', 'disableFreeBusy', 'no') === 'yes'); |
|
| 50 | - } |
|
| 34 | + /** |
|
| 35 | + * Returns a list of ACE's for this node. |
|
| 36 | + * |
|
| 37 | + * Each ACE has the following properties: |
|
| 38 | + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
| 39 | + * currently the only supported privileges |
|
| 40 | + * * 'principal', a url to the principal who owns the node |
|
| 41 | + * * 'protected' (optional), indicating that this ACE is not allowed to |
|
| 42 | + * be updated. |
|
| 43 | + * |
|
| 44 | + * @return array |
|
| 45 | + */ |
|
| 46 | + public function getACL() { |
|
| 47 | + // getACL is called so frequently that we cache the config result |
|
| 48 | + if ($this->disableFreeBusy === null) { |
|
| 49 | + $this->disableFreeBusy = ($this->config->getAppValue('dav', 'disableFreeBusy', 'no') === 'yes'); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - $commonAcl = [ |
|
| 53 | - [ |
|
| 54 | - 'privilege' => '{DAV:}read', |
|
| 55 | - 'principal' => $this->getOwner(), |
|
| 56 | - 'protected' => true, |
|
| 57 | - ], |
|
| 58 | - [ |
|
| 59 | - 'privilege' => '{DAV:}read', |
|
| 60 | - 'principal' => $this->getOwner() . '/calendar-proxy-read', |
|
| 61 | - 'protected' => true, |
|
| 62 | - ], |
|
| 63 | - [ |
|
| 64 | - 'privilege' => '{DAV:}read', |
|
| 65 | - 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
| 66 | - 'protected' => true, |
|
| 67 | - ], |
|
| 68 | - ]; |
|
| 52 | + $commonAcl = [ |
|
| 53 | + [ |
|
| 54 | + 'privilege' => '{DAV:}read', |
|
| 55 | + 'principal' => $this->getOwner(), |
|
| 56 | + 'protected' => true, |
|
| 57 | + ], |
|
| 58 | + [ |
|
| 59 | + 'privilege' => '{DAV:}read', |
|
| 60 | + 'principal' => $this->getOwner() . '/calendar-proxy-read', |
|
| 61 | + 'protected' => true, |
|
| 62 | + ], |
|
| 63 | + [ |
|
| 64 | + 'privilege' => '{DAV:}read', |
|
| 65 | + 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
| 66 | + 'protected' => true, |
|
| 67 | + ], |
|
| 68 | + ]; |
|
| 69 | 69 | |
| 70 | - // schedule-send is an aggregate privilege for: |
|
| 71 | - // - schedule-send-invite |
|
| 72 | - // - schedule-send-reply |
|
| 73 | - // - schedule-send-freebusy |
|
| 74 | - // |
|
| 75 | - // If FreeBusy is disabled, we have to remove the latter privilege |
|
| 70 | + // schedule-send is an aggregate privilege for: |
|
| 71 | + // - schedule-send-invite |
|
| 72 | + // - schedule-send-reply |
|
| 73 | + // - schedule-send-freebusy |
|
| 74 | + // |
|
| 75 | + // If FreeBusy is disabled, we have to remove the latter privilege |
|
| 76 | 76 | |
| 77 | - if ($this->disableFreeBusy) { |
|
| 78 | - return array_merge($commonAcl, [ |
|
| 79 | - [ |
|
| 80 | - 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send-invite', |
|
| 81 | - 'principal' => $this->getOwner(), |
|
| 82 | - 'protected' => true, |
|
| 83 | - ], |
|
| 84 | - [ |
|
| 85 | - 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send-invite', |
|
| 86 | - 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
| 87 | - 'protected' => true, |
|
| 88 | - ], |
|
| 89 | - [ |
|
| 90 | - 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send-reply', |
|
| 91 | - 'principal' => $this->getOwner(), |
|
| 92 | - 'protected' => true, |
|
| 93 | - ], |
|
| 94 | - [ |
|
| 95 | - 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send-reply', |
|
| 96 | - 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
| 97 | - 'protected' => true, |
|
| 98 | - ], |
|
| 99 | - ]); |
|
| 100 | - } |
|
| 77 | + if ($this->disableFreeBusy) { |
|
| 78 | + return array_merge($commonAcl, [ |
|
| 79 | + [ |
|
| 80 | + 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send-invite', |
|
| 81 | + 'principal' => $this->getOwner(), |
|
| 82 | + 'protected' => true, |
|
| 83 | + ], |
|
| 84 | + [ |
|
| 85 | + 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send-invite', |
|
| 86 | + 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
| 87 | + 'protected' => true, |
|
| 88 | + ], |
|
| 89 | + [ |
|
| 90 | + 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send-reply', |
|
| 91 | + 'principal' => $this->getOwner(), |
|
| 92 | + 'protected' => true, |
|
| 93 | + ], |
|
| 94 | + [ |
|
| 95 | + 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send-reply', |
|
| 96 | + 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
| 97 | + 'protected' => true, |
|
| 98 | + ], |
|
| 99 | + ]); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - return array_merge($commonAcl, [ |
|
| 103 | - [ |
|
| 104 | - 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send', |
|
| 105 | - 'principal' => $this->getOwner(), |
|
| 106 | - 'protected' => true, |
|
| 107 | - ], |
|
| 108 | - [ |
|
| 109 | - 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send', |
|
| 110 | - 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
| 111 | - 'protected' => true, |
|
| 112 | - ], |
|
| 113 | - ]); |
|
| 114 | - } |
|
| 102 | + return array_merge($commonAcl, [ |
|
| 103 | + [ |
|
| 104 | + 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send', |
|
| 105 | + 'principal' => $this->getOwner(), |
|
| 106 | + 'protected' => true, |
|
| 107 | + ], |
|
| 108 | + [ |
|
| 109 | + 'privilege' => '{' . CalDAVPlugin::NS_CALDAV . '}schedule-send', |
|
| 110 | + 'principal' => $this->getOwner() . '/calendar-proxy-write', |
|
| 111 | + 'protected' => true, |
|
| 112 | + ], |
|
| 113 | + ]); |
|
| 114 | + } |
|
| 115 | 115 | } |
@@ -24,33 +24,33 @@ |
||
| 24 | 24 | use OCP\IUser; |
| 25 | 25 | |
| 26 | 26 | interface ITrashManager extends ITrashBackend { |
| 27 | - /** |
|
| 28 | - * Add a backend for the trashbin |
|
| 29 | - * |
|
| 30 | - * @param string $storageType |
|
| 31 | - * @param ITrashBackend $backend |
|
| 32 | - * @since 15.0.0 |
|
| 33 | - */ |
|
| 34 | - public function registerBackend(string $storageType, ITrashBackend $backend); |
|
| 27 | + /** |
|
| 28 | + * Add a backend for the trashbin |
|
| 29 | + * |
|
| 30 | + * @param string $storageType |
|
| 31 | + * @param ITrashBackend $backend |
|
| 32 | + * @since 15.0.0 |
|
| 33 | + */ |
|
| 34 | + public function registerBackend(string $storageType, ITrashBackend $backend); |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * List all trash items in the root of the trashbin |
|
| 38 | - * |
|
| 39 | - * @param IUser $user |
|
| 40 | - * @return ITrashItem[] |
|
| 41 | - * @since 15.0.0 |
|
| 42 | - */ |
|
| 43 | - public function listTrashRoot(IUser $user): array; |
|
| 36 | + /** |
|
| 37 | + * List all trash items in the root of the trashbin |
|
| 38 | + * |
|
| 39 | + * @param IUser $user |
|
| 40 | + * @return ITrashItem[] |
|
| 41 | + * @since 15.0.0 |
|
| 42 | + */ |
|
| 43 | + public function listTrashRoot(IUser $user): array; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Temporally prevent files from being moved to the trash |
|
| 47 | - * |
|
| 48 | - * @since 15.0.0 |
|
| 49 | - */ |
|
| 50 | - public function pauseTrash(); |
|
| 45 | + /** |
|
| 46 | + * Temporally prevent files from being moved to the trash |
|
| 47 | + * |
|
| 48 | + * @since 15.0.0 |
|
| 49 | + */ |
|
| 50 | + public function pauseTrash(); |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @since 15.0.0 |
|
| 54 | - */ |
|
| 55 | - public function resumeTrash(); |
|
| 52 | + /** |
|
| 53 | + * @since 15.0.0 |
|
| 54 | + */ |
|
| 55 | + public function resumeTrash(); |
|
| 56 | 56 | } |
@@ -31,54 +31,54 @@ |
||
| 31 | 31 | * @since 15.0.0 |
| 32 | 32 | */ |
| 33 | 33 | interface ITrashBackend { |
| 34 | - /** |
|
| 35 | - * List all trash items in the root of the trashbin |
|
| 36 | - * |
|
| 37 | - * @param IUser $user |
|
| 38 | - * @return ITrashItem[] |
|
| 39 | - * @since 15.0.0 |
|
| 40 | - */ |
|
| 41 | - public function listTrashRoot(IUser $user): array; |
|
| 34 | + /** |
|
| 35 | + * List all trash items in the root of the trashbin |
|
| 36 | + * |
|
| 37 | + * @param IUser $user |
|
| 38 | + * @return ITrashItem[] |
|
| 39 | + * @since 15.0.0 |
|
| 40 | + */ |
|
| 41 | + public function listTrashRoot(IUser $user): array; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * List all trash items in a subfolder in the trashbin |
|
| 45 | - * |
|
| 46 | - * @param ITrashItem $folder |
|
| 47 | - * @return ITrashItem[] |
|
| 48 | - * @since 15.0.0 |
|
| 49 | - */ |
|
| 50 | - public function listTrashFolder(ITrashItem $folder): array; |
|
| 43 | + /** |
|
| 44 | + * List all trash items in a subfolder in the trashbin |
|
| 45 | + * |
|
| 46 | + * @param ITrashItem $folder |
|
| 47 | + * @return ITrashItem[] |
|
| 48 | + * @since 15.0.0 |
|
| 49 | + */ |
|
| 50 | + public function listTrashFolder(ITrashItem $folder): array; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Restore a trashbin item |
|
| 54 | - * |
|
| 55 | - * @param ITrashItem $item |
|
| 56 | - * @since 15.0.0 |
|
| 57 | - */ |
|
| 58 | - public function restoreItem(ITrashItem $item); |
|
| 52 | + /** |
|
| 53 | + * Restore a trashbin item |
|
| 54 | + * |
|
| 55 | + * @param ITrashItem $item |
|
| 56 | + * @since 15.0.0 |
|
| 57 | + */ |
|
| 58 | + public function restoreItem(ITrashItem $item); |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Permanently remove an item from trash |
|
| 62 | - * |
|
| 63 | - * @param ITrashItem $item |
|
| 64 | - * @since 15.0.0 |
|
| 65 | - */ |
|
| 66 | - public function removeItem(ITrashItem $item); |
|
| 60 | + /** |
|
| 61 | + * Permanently remove an item from trash |
|
| 62 | + * |
|
| 63 | + * @param ITrashItem $item |
|
| 64 | + * @since 15.0.0 |
|
| 65 | + */ |
|
| 66 | + public function removeItem(ITrashItem $item); |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Move a file or folder to trash |
|
| 70 | - * |
|
| 71 | - * @param IStorage $storage |
|
| 72 | - * @param string $internalPath |
|
| 73 | - * @return boolean whether or not the file was moved to trash, if false then the file should be deleted normally |
|
| 74 | - * @since 15.0.0 |
|
| 75 | - */ |
|
| 76 | - public function moveToTrash(IStorage $storage, string $internalPath): bool; |
|
| 68 | + /** |
|
| 69 | + * Move a file or folder to trash |
|
| 70 | + * |
|
| 71 | + * @param IStorage $storage |
|
| 72 | + * @param string $internalPath |
|
| 73 | + * @return boolean whether or not the file was moved to trash, if false then the file should be deleted normally |
|
| 74 | + * @since 15.0.0 |
|
| 75 | + */ |
|
| 76 | + public function moveToTrash(IStorage $storage, string $internalPath): bool; |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @param IUser $user |
|
| 80 | - * @param int $fileId |
|
| 81 | - * @return Node|null |
|
| 82 | - */ |
|
| 83 | - public function getTrashNodeById(IUser $user, int $fileId); |
|
| 78 | + /** |
|
| 79 | + * @param IUser $user |
|
| 80 | + * @param int $fileId |
|
| 81 | + * @return Node|null |
|
| 82 | + */ |
|
| 83 | + public function getTrashNodeById(IUser $user, int $fileId); |
|
| 84 | 84 | } |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | public function getChildren(): array { |
| 68 | 68 | $entries = $this->trashManager->listTrashRoot($this->user); |
| 69 | 69 | |
| 70 | - $children = array_map(function (ITrashItem $entry) { |
|
| 70 | + $children = array_map(function(ITrashItem $entry) { |
|
| 71 | 71 | if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
| 72 | 72 | return new TrashFolder($this->trashManager, $entry); |
| 73 | 73 | } |
@@ -20,74 +20,74 @@ |
||
| 20 | 20 | |
| 21 | 21 | class TrashRoot implements ICollection { |
| 22 | 22 | |
| 23 | - public function __construct( |
|
| 24 | - private IUser $user, |
|
| 25 | - private ITrashManager $trashManager, |
|
| 26 | - ) { |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public function delete() { |
|
| 30 | - if (!ConfigService::getDeleteFromTrashEnabled()) { |
|
| 31 | - throw new Forbidden('Not allowed to delete items from the trash bin'); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - Trashbin::deleteAll(); |
|
| 35 | - foreach ($this->trashManager->listTrashRoot($this->user) as $trashItem) { |
|
| 36 | - $this->trashManager->removeItem($trashItem); |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - public function getName(): string { |
|
| 41 | - return 'trash'; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - public function setName($name) { |
|
| 45 | - throw new Forbidden('Permission denied to rename this trashbin'); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - public function createFile($name, $data = null) { |
|
| 49 | - throw new Forbidden('Not allowed to create files in the trashbin'); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - public function createDirectory($name) { |
|
| 53 | - throw new Forbidden('Not allowed to create folders in the trashbin'); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - public function getChildren(): array { |
|
| 57 | - $entries = $this->trashManager->listTrashRoot($this->user); |
|
| 58 | - |
|
| 59 | - $children = array_map(function (ITrashItem $entry) { |
|
| 60 | - if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
| 61 | - return new TrashFolder($this->trashManager, $entry); |
|
| 62 | - } |
|
| 63 | - return new TrashFile($this->trashManager, $entry); |
|
| 64 | - }, $entries); |
|
| 65 | - |
|
| 66 | - return $children; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - public function getChild($name): ITrash { |
|
| 70 | - $entries = $this->getChildren(); |
|
| 71 | - |
|
| 72 | - foreach ($entries as $entry) { |
|
| 73 | - if ($entry->getName() === $name) { |
|
| 74 | - return $entry; |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - throw new NotFound(); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - public function childExists($name): bool { |
|
| 82 | - try { |
|
| 83 | - $this->getChild($name); |
|
| 84 | - return true; |
|
| 85 | - } catch (NotFound $e) { |
|
| 86 | - return false; |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - public function getLastModified(): int { |
|
| 91 | - return 0; |
|
| 92 | - } |
|
| 23 | + public function __construct( |
|
| 24 | + private IUser $user, |
|
| 25 | + private ITrashManager $trashManager, |
|
| 26 | + ) { |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public function delete() { |
|
| 30 | + if (!ConfigService::getDeleteFromTrashEnabled()) { |
|
| 31 | + throw new Forbidden('Not allowed to delete items from the trash bin'); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + Trashbin::deleteAll(); |
|
| 35 | + foreach ($this->trashManager->listTrashRoot($this->user) as $trashItem) { |
|
| 36 | + $this->trashManager->removeItem($trashItem); |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + public function getName(): string { |
|
| 41 | + return 'trash'; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + public function setName($name) { |
|
| 45 | + throw new Forbidden('Permission denied to rename this trashbin'); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + public function createFile($name, $data = null) { |
|
| 49 | + throw new Forbidden('Not allowed to create files in the trashbin'); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + public function createDirectory($name) { |
|
| 53 | + throw new Forbidden('Not allowed to create folders in the trashbin'); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + public function getChildren(): array { |
|
| 57 | + $entries = $this->trashManager->listTrashRoot($this->user); |
|
| 58 | + |
|
| 59 | + $children = array_map(function (ITrashItem $entry) { |
|
| 60 | + if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
| 61 | + return new TrashFolder($this->trashManager, $entry); |
|
| 62 | + } |
|
| 63 | + return new TrashFile($this->trashManager, $entry); |
|
| 64 | + }, $entries); |
|
| 65 | + |
|
| 66 | + return $children; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + public function getChild($name): ITrash { |
|
| 70 | + $entries = $this->getChildren(); |
|
| 71 | + |
|
| 72 | + foreach ($entries as $entry) { |
|
| 73 | + if ($entry->getName() === $name) { |
|
| 74 | + return $entry; |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + throw new NotFound(); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + public function childExists($name): bool { |
|
| 82 | + try { |
|
| 83 | + $this->getChild($name); |
|
| 84 | + return true; |
|
| 85 | + } catch (NotFound $e) { |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + public function getLastModified(): int { |
|
| 91 | + return 0; |
|
| 92 | + } |
|
| 93 | 93 | } |