@@ -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 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | public function getChildren(): array { |
| 33 | 33 | $entries = $this->trashManager->listTrashFolder($this->data); |
| 34 | 34 | |
| 35 | - $children = array_map(function (ITrashItem $entry) { |
|
| 35 | + $children = array_map(function(ITrashItem $entry) { |
|
| 36 | 36 | if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
| 37 | 37 | return new TrashFolderFolder($this->trashManager, $entry); |
| 38 | 38 | } |
@@ -15,49 +15,49 @@ |
||
| 15 | 15 | use Sabre\DAV\ICollection; |
| 16 | 16 | |
| 17 | 17 | abstract class AbstractTrashFolder extends AbstractTrash implements ICollection, ITrash { |
| 18 | - public function getChildren(): array { |
|
| 19 | - $entries = $this->trashManager->listTrashFolder($this->data); |
|
| 20 | - |
|
| 21 | - $children = array_map(function (ITrashItem $entry) { |
|
| 22 | - if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
| 23 | - return new TrashFolderFolder($this->trashManager, $entry); |
|
| 24 | - } |
|
| 25 | - return new TrashFolderFile($this->trashManager, $entry); |
|
| 26 | - }, $entries); |
|
| 27 | - |
|
| 28 | - return $children; |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - public function getChild($name): ITrash { |
|
| 32 | - $entries = $this->getChildren(); |
|
| 33 | - |
|
| 34 | - foreach ($entries as $entry) { |
|
| 35 | - if ($entry->getName() === $name) { |
|
| 36 | - return $entry; |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - throw new NotFound(); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - public function childExists($name): bool { |
|
| 44 | - try { |
|
| 45 | - $this->getChild($name); |
|
| 46 | - return true; |
|
| 47 | - } catch (NotFound $e) { |
|
| 48 | - return false; |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - public function setName($name) { |
|
| 53 | - throw new Forbidden(); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - public function createFile($name, $data = null) { |
|
| 57 | - throw new Forbidden(); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - public function createDirectory($name) { |
|
| 61 | - throw new Forbidden(); |
|
| 62 | - } |
|
| 18 | + public function getChildren(): array { |
|
| 19 | + $entries = $this->trashManager->listTrashFolder($this->data); |
|
| 20 | + |
|
| 21 | + $children = array_map(function (ITrashItem $entry) { |
|
| 22 | + if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
| 23 | + return new TrashFolderFolder($this->trashManager, $entry); |
|
| 24 | + } |
|
| 25 | + return new TrashFolderFile($this->trashManager, $entry); |
|
| 26 | + }, $entries); |
|
| 27 | + |
|
| 28 | + return $children; |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + public function getChild($name): ITrash { |
|
| 32 | + $entries = $this->getChildren(); |
|
| 33 | + |
|
| 34 | + foreach ($entries as $entry) { |
|
| 35 | + if ($entry->getName() === $name) { |
|
| 36 | + return $entry; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + throw new NotFound(); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + public function childExists($name): bool { |
|
| 44 | + try { |
|
| 45 | + $this->getChild($name); |
|
| 46 | + return true; |
|
| 47 | + } catch (NotFound $e) { |
|
| 48 | + return false; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + public function setName($name) { |
|
| 53 | + throw new Forbidden(); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + public function createFile($name, $data = null) { |
|
| 57 | + throw new Forbidden(); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + public function createDirectory($name) { |
|
| 61 | + throw new Forbidden(); |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | public function getChildren(): array { |
| 79 | 79 | $versions = $this->versionManager->getVersionsForFile($this->user, $this->file); |
| 80 | 80 | |
| 81 | - return array_map(function (IVersion $version) { |
|
| 81 | + return array_map(function(IVersion $version) { |
|
| 82 | 82 | return new VersionFile($version, $this->versionManager); |
| 83 | 83 | }, $versions); |
| 84 | 84 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | public function getName(): string { |
| 100 | - return (string)$this->file->getId(); |
|
| 100 | + return (string) $this->file->getId(); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | public function setName($name) { |
@@ -18,64 +18,64 @@ |
||
| 18 | 18 | |
| 19 | 19 | class VersionCollection implements ICollection { |
| 20 | 20 | |
| 21 | - public function __construct( |
|
| 22 | - private File $file, |
|
| 23 | - private IUser $user, |
|
| 24 | - private IVersionManager $versionManager, |
|
| 25 | - ) { |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - public function createFile($name, $data = null) { |
|
| 29 | - throw new Forbidden(); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - public function createDirectory($name) { |
|
| 33 | - throw new Forbidden(); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - public function getChild($name) { |
|
| 37 | - /** @var VersionFile[] $versions */ |
|
| 38 | - $versions = $this->getChildren(); |
|
| 39 | - |
|
| 40 | - foreach ($versions as $version) { |
|
| 41 | - if ($version->getName() === $name) { |
|
| 42 | - return $version; |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - throw new NotFound(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - public function getChildren(): array { |
|
| 50 | - $versions = $this->versionManager->getVersionsForFile($this->user, $this->file); |
|
| 51 | - |
|
| 52 | - return array_map(function (IVersion $version) { |
|
| 53 | - return new VersionFile($version, $this->versionManager); |
|
| 54 | - }, $versions); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - public function childExists($name): bool { |
|
| 58 | - try { |
|
| 59 | - $this->getChild($name); |
|
| 60 | - return true; |
|
| 61 | - } catch (NotFound $e) { |
|
| 62 | - return false; |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - public function delete() { |
|
| 67 | - throw new Forbidden(); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - public function getName(): string { |
|
| 71 | - return (string)$this->file->getId(); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - public function setName($name) { |
|
| 75 | - throw new Forbidden(); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - public function getLastModified(): int { |
|
| 79 | - return 0; |
|
| 80 | - } |
|
| 21 | + public function __construct( |
|
| 22 | + private File $file, |
|
| 23 | + private IUser $user, |
|
| 24 | + private IVersionManager $versionManager, |
|
| 25 | + ) { |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + public function createFile($name, $data = null) { |
|
| 29 | + throw new Forbidden(); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + public function createDirectory($name) { |
|
| 33 | + throw new Forbidden(); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + public function getChild($name) { |
|
| 37 | + /** @var VersionFile[] $versions */ |
|
| 38 | + $versions = $this->getChildren(); |
|
| 39 | + |
|
| 40 | + foreach ($versions as $version) { |
|
| 41 | + if ($version->getName() === $name) { |
|
| 42 | + return $version; |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + throw new NotFound(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + public function getChildren(): array { |
|
| 50 | + $versions = $this->versionManager->getVersionsForFile($this->user, $this->file); |
|
| 51 | + |
|
| 52 | + return array_map(function (IVersion $version) { |
|
| 53 | + return new VersionFile($version, $this->versionManager); |
|
| 54 | + }, $versions); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + public function childExists($name): bool { |
|
| 58 | + try { |
|
| 59 | + $this->getChild($name); |
|
| 60 | + return true; |
|
| 61 | + } catch (NotFound $e) { |
|
| 62 | + return false; |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + public function delete() { |
|
| 67 | + throw new Forbidden(); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + public function getName(): string { |
|
| 71 | + return (string)$this->file->getId(); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + public function setName($name) { |
|
| 75 | + throw new Forbidden(); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + public function getLastModified(): int { |
|
| 79 | + return 0; |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -32,18 +32,18 @@ |
||
| 32 | 32 | |
| 33 | 33 | class Version1008Date20181105112049 extends SimpleMigrationStep { |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param IOutput $output |
|
| 37 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 38 | - * @param array $options |
|
| 39 | - * @return null|ISchemaWrapper |
|
| 40 | - */ |
|
| 41 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 42 | - /** @var ISchemaWrapper $schema */ |
|
| 43 | - $schema = $schemaClosure(); |
|
| 44 | - $table = $schema->getTable('calendarsubscriptions'); |
|
| 45 | - $table->dropColumn('source_copy'); |
|
| 35 | + /** |
|
| 36 | + * @param IOutput $output |
|
| 37 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 38 | + * @param array $options |
|
| 39 | + * @return null|ISchemaWrapper |
|
| 40 | + */ |
|
| 41 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 42 | + /** @var ISchemaWrapper $schema */ |
|
| 43 | + $schema = $schemaClosure(); |
|
| 44 | + $table = $schema->getTable('calendarsubscriptions'); |
|
| 45 | + $table->dropColumn('source_copy'); |
|
| 46 | 46 | |
| 47 | - return $schema; |
|
| 48 | - } |
|
| 47 | + return $schema; |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -32,18 +32,18 @@ |
||
| 32 | 32 | |
| 33 | 33 | class Version1008Date20181105104833 extends SimpleMigrationStep { |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param IOutput $output |
|
| 37 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 38 | - * @param array $options |
|
| 39 | - * @return null|ISchemaWrapper |
|
| 40 | - */ |
|
| 41 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 42 | - /** @var ISchemaWrapper $schema */ |
|
| 43 | - $schema = $schemaClosure(); |
|
| 44 | - $table = $schema->getTable('calendarsubscriptions'); |
|
| 45 | - $table->dropColumn('source'); |
|
| 35 | + /** |
|
| 36 | + * @param IOutput $output |
|
| 37 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 38 | + * @param array $options |
|
| 39 | + * @return null|ISchemaWrapper |
|
| 40 | + */ |
|
| 41 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 42 | + /** @var ISchemaWrapper $schema */ |
|
| 43 | + $schema = $schemaClosure(); |
|
| 44 | + $table = $schema->getTable('calendarsubscriptions'); |
|
| 45 | + $table->dropColumn('source'); |
|
| 46 | 46 | |
| 47 | - return $schema; |
|
| 48 | - } |
|
| 47 | + return $schema; |
|
| 48 | + } |
|
| 49 | 49 | } |