@@ -26,30 +26,30 @@ |
||
| 26 | 26 | namespace OCA\DAV\CalDAV; |
| 27 | 27 | |
| 28 | 28 | class Plugin extends \Sabre\CalDAV\Plugin { |
| 29 | - public const SYSTEM_CALENDAR_ROOT = 'system-calendars'; |
|
| 29 | + public const SYSTEM_CALENDAR_ROOT = 'system-calendars'; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Returns the path to a principal's calendar home. |
|
| 33 | - * |
|
| 34 | - * The return url must not end with a slash. |
|
| 35 | - * This function should return null in case a principal did not have |
|
| 36 | - * a calendar home. |
|
| 37 | - * |
|
| 38 | - * @param string $principalUrl |
|
| 39 | - * @return string|null |
|
| 40 | - */ |
|
| 41 | - public function getCalendarHomeForPrincipal($principalUrl) { |
|
| 42 | - if (strrpos($principalUrl, 'principals/users', -strlen($principalUrl)) !== false) { |
|
| 43 | - [, $principalId] = \Sabre\Uri\split($principalUrl); |
|
| 44 | - return self::CALENDAR_ROOT . '/' . $principalId; |
|
| 45 | - } |
|
| 46 | - if (strrpos($principalUrl, 'principals/calendar-resources', -strlen($principalUrl)) !== false) { |
|
| 47 | - [, $principalId] = \Sabre\Uri\split($principalUrl); |
|
| 48 | - return self::SYSTEM_CALENDAR_ROOT . '/calendar-resources/' . $principalId; |
|
| 49 | - } |
|
| 50 | - if (strrpos($principalUrl, 'principals/calendar-rooms', -strlen($principalUrl)) !== false) { |
|
| 51 | - [, $principalId] = \Sabre\Uri\split($principalUrl); |
|
| 52 | - return self::SYSTEM_CALENDAR_ROOT . '/calendar-rooms/' . $principalId; |
|
| 53 | - } |
|
| 54 | - } |
|
| 31 | + /** |
|
| 32 | + * Returns the path to a principal's calendar home. |
|
| 33 | + * |
|
| 34 | + * The return url must not end with a slash. |
|
| 35 | + * This function should return null in case a principal did not have |
|
| 36 | + * a calendar home. |
|
| 37 | + * |
|
| 38 | + * @param string $principalUrl |
|
| 39 | + * @return string|null |
|
| 40 | + */ |
|
| 41 | + public function getCalendarHomeForPrincipal($principalUrl) { |
|
| 42 | + if (strrpos($principalUrl, 'principals/users', -strlen($principalUrl)) !== false) { |
|
| 43 | + [, $principalId] = \Sabre\Uri\split($principalUrl); |
|
| 44 | + return self::CALENDAR_ROOT . '/' . $principalId; |
|
| 45 | + } |
|
| 46 | + if (strrpos($principalUrl, 'principals/calendar-resources', -strlen($principalUrl)) !== false) { |
|
| 47 | + [, $principalId] = \Sabre\Uri\split($principalUrl); |
|
| 48 | + return self::SYSTEM_CALENDAR_ROOT . '/calendar-resources/' . $principalId; |
|
| 49 | + } |
|
| 50 | + if (strrpos($principalUrl, 'principals/calendar-rooms', -strlen($principalUrl)) !== false) { |
|
| 51 | + [, $principalId] = \Sabre\Uri\split($principalUrl); |
|
| 52 | + return self::SYSTEM_CALENDAR_ROOT . '/calendar-rooms/' . $principalId; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -28,11 +28,11 @@ |
||
| 28 | 28 | use OCP\WorkflowEngine\IManager; |
| 29 | 29 | |
| 30 | 30 | class Personal extends ASettings { |
| 31 | - public function getScope(): int { |
|
| 32 | - return IManager::SCOPE_USER; |
|
| 33 | - } |
|
| 31 | + public function getScope(): int { |
|
| 32 | + return IManager::SCOPE_USER; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public function getSection(): ?string { |
|
| 36 | - return $this->manager->isUserScopeEnabled() ? 'workflow' : null; |
|
| 37 | - } |
|
| 35 | + public function getSection(): ?string { |
|
| 36 | + return $this->manager->isUserScopeEnabled() ? 'workflow' : null; |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -32,70 +32,70 @@ |
||
| 32 | 32 | use OCP\Remote\Api\IUserApi; |
| 33 | 33 | |
| 34 | 34 | class OCS extends ApiBase implements ICapabilitiesApi, IUserApi { |
| 35 | - /** |
|
| 36 | - * @param string $method |
|
| 37 | - * @param string $url |
|
| 38 | - * @param array $body |
|
| 39 | - * @param array $query |
|
| 40 | - * @param array $headers |
|
| 41 | - * @return array |
|
| 42 | - * @throws ForbiddenException |
|
| 43 | - * @throws NotFoundException |
|
| 44 | - * @throws \Exception |
|
| 45 | - */ |
|
| 46 | - protected function request($method, $url, array $body = [], array $query = [], array $headers = []) { |
|
| 47 | - try { |
|
| 48 | - $response = json_decode(parent::request($method, 'ocs/v2.php/' . $url, $body, $query, $headers), true); |
|
| 49 | - } catch (ClientException $e) { |
|
| 50 | - if ($e->getResponse()->getStatusCode() === 404) { |
|
| 51 | - throw new NotFoundException(); |
|
| 52 | - } elseif ($e->getResponse()->getStatusCode() === 403 || $e->getResponse()->getStatusCode() === 401) { |
|
| 53 | - throw new ForbiddenException(); |
|
| 54 | - } else { |
|
| 55 | - throw $e; |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - if (!isset($response['ocs']) || !isset($response['ocs']['meta'])) { |
|
| 59 | - throw new \Exception('Invalid ocs response'); |
|
| 60 | - } |
|
| 61 | - if ($response['ocs']['meta']['statuscode'] === OCSController::RESPOND_UNAUTHORISED) { |
|
| 62 | - throw new ForbiddenException(); |
|
| 63 | - } |
|
| 64 | - if ($response['ocs']['meta']['statuscode'] === OCSController::RESPOND_NOT_FOUND) { |
|
| 65 | - throw new NotFoundException(); |
|
| 66 | - } |
|
| 67 | - if ($response['ocs']['meta']['status'] !== 'ok') { |
|
| 68 | - throw new \Exception('Unknown ocs error ' . $response['ocs']['meta']['message']); |
|
| 69 | - } |
|
| 35 | + /** |
|
| 36 | + * @param string $method |
|
| 37 | + * @param string $url |
|
| 38 | + * @param array $body |
|
| 39 | + * @param array $query |
|
| 40 | + * @param array $headers |
|
| 41 | + * @return array |
|
| 42 | + * @throws ForbiddenException |
|
| 43 | + * @throws NotFoundException |
|
| 44 | + * @throws \Exception |
|
| 45 | + */ |
|
| 46 | + protected function request($method, $url, array $body = [], array $query = [], array $headers = []) { |
|
| 47 | + try { |
|
| 48 | + $response = json_decode(parent::request($method, 'ocs/v2.php/' . $url, $body, $query, $headers), true); |
|
| 49 | + } catch (ClientException $e) { |
|
| 50 | + if ($e->getResponse()->getStatusCode() === 404) { |
|
| 51 | + throw new NotFoundException(); |
|
| 52 | + } elseif ($e->getResponse()->getStatusCode() === 403 || $e->getResponse()->getStatusCode() === 401) { |
|
| 53 | + throw new ForbiddenException(); |
|
| 54 | + } else { |
|
| 55 | + throw $e; |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + if (!isset($response['ocs']) || !isset($response['ocs']['meta'])) { |
|
| 59 | + throw new \Exception('Invalid ocs response'); |
|
| 60 | + } |
|
| 61 | + if ($response['ocs']['meta']['statuscode'] === OCSController::RESPOND_UNAUTHORISED) { |
|
| 62 | + throw new ForbiddenException(); |
|
| 63 | + } |
|
| 64 | + if ($response['ocs']['meta']['statuscode'] === OCSController::RESPOND_NOT_FOUND) { |
|
| 65 | + throw new NotFoundException(); |
|
| 66 | + } |
|
| 67 | + if ($response['ocs']['meta']['status'] !== 'ok') { |
|
| 68 | + throw new \Exception('Unknown ocs error ' . $response['ocs']['meta']['message']); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - return $response['ocs']['data']; |
|
| 72 | - } |
|
| 71 | + return $response['ocs']['data']; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @param array $data |
|
| 76 | - * @param string $type |
|
| 77 | - * @param string[] $keys |
|
| 78 | - * @throws \Exception |
|
| 79 | - */ |
|
| 80 | - private function checkResponseArray(array $data, $type, array $keys) { |
|
| 81 | - foreach ($keys as $key) { |
|
| 82 | - if (!array_key_exists($key, $data)) { |
|
| 83 | - throw new \Exception('Invalid ' . $type . ' response, expected field ' . $key . ' not found'); |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - } |
|
| 74 | + /** |
|
| 75 | + * @param array $data |
|
| 76 | + * @param string $type |
|
| 77 | + * @param string[] $keys |
|
| 78 | + * @throws \Exception |
|
| 79 | + */ |
|
| 80 | + private function checkResponseArray(array $data, $type, array $keys) { |
|
| 81 | + foreach ($keys as $key) { |
|
| 82 | + if (!array_key_exists($key, $data)) { |
|
| 83 | + throw new \Exception('Invalid ' . $type . ' response, expected field ' . $key . ' not found'); |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - public function getUser($userId) { |
|
| 89 | - $result = $this->request('get', 'cloud/users/' . $userId); |
|
| 90 | - $this->checkResponseArray($result, 'user', User::EXPECTED_KEYS); |
|
| 91 | - return new User($result); |
|
| 92 | - } |
|
| 88 | + public function getUser($userId) { |
|
| 89 | + $result = $this->request('get', 'cloud/users/' . $userId); |
|
| 90 | + $this->checkResponseArray($result, 'user', User::EXPECTED_KEYS); |
|
| 91 | + return new User($result); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @return array The capabilities in the form of [$appId => [$capability => $value]] |
|
| 96 | - */ |
|
| 97 | - public function getCapabilities() { |
|
| 98 | - $result = $this->request('get', 'cloud/capabilities'); |
|
| 99 | - return $result['capabilities']; |
|
| 100 | - } |
|
| 94 | + /** |
|
| 95 | + * @return array The capabilities in the form of [$appId => [$capability => $value]] |
|
| 96 | + */ |
|
| 97 | + public function getCapabilities() { |
|
| 98 | + $result = $this->request('get', 'cloud/capabilities'); |
|
| 99 | + return $result['capabilities']; |
|
| 100 | + } |
|
| 101 | 101 | } |
@@ -29,39 +29,39 @@ |
||
| 29 | 29 | * @since 8.2.0 |
| 30 | 30 | */ |
| 31 | 31 | interface ICompositeExpression { |
| 32 | - /** |
|
| 33 | - * Adds multiple parts to composite expression. |
|
| 34 | - * |
|
| 35 | - * @param array $parts |
|
| 36 | - * |
|
| 37 | - * @return ICompositeExpression |
|
| 38 | - * @since 8.2.0 |
|
| 39 | - */ |
|
| 40 | - public function addMultiple(array $parts = []): ICompositeExpression; |
|
| 32 | + /** |
|
| 33 | + * Adds multiple parts to composite expression. |
|
| 34 | + * |
|
| 35 | + * @param array $parts |
|
| 36 | + * |
|
| 37 | + * @return ICompositeExpression |
|
| 38 | + * @since 8.2.0 |
|
| 39 | + */ |
|
| 40 | + public function addMultiple(array $parts = []): ICompositeExpression; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Adds an expression to composite expression. |
|
| 44 | - * |
|
| 45 | - * @param mixed $part |
|
| 46 | - * |
|
| 47 | - * @return ICompositeExpression |
|
| 48 | - * @since 8.2.0 |
|
| 49 | - */ |
|
| 50 | - public function add($part): ICompositeExpression; |
|
| 42 | + /** |
|
| 43 | + * Adds an expression to composite expression. |
|
| 44 | + * |
|
| 45 | + * @param mixed $part |
|
| 46 | + * |
|
| 47 | + * @return ICompositeExpression |
|
| 48 | + * @since 8.2.0 |
|
| 49 | + */ |
|
| 50 | + public function add($part): ICompositeExpression; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Retrieves the amount of expressions on composite expression. |
|
| 54 | - * |
|
| 55 | - * @return integer |
|
| 56 | - * @since 8.2.0 |
|
| 57 | - */ |
|
| 58 | - public function count(): int; |
|
| 52 | + /** |
|
| 53 | + * Retrieves the amount of expressions on composite expression. |
|
| 54 | + * |
|
| 55 | + * @return integer |
|
| 56 | + * @since 8.2.0 |
|
| 57 | + */ |
|
| 58 | + public function count(): int; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Returns the type of this composite expression (AND/OR). |
|
| 62 | - * |
|
| 63 | - * @return string |
|
| 64 | - * @since 8.2.0 |
|
| 65 | - */ |
|
| 66 | - public function getType(): string; |
|
| 60 | + /** |
|
| 61 | + * Returns the type of this composite expression (AND/OR). |
|
| 62 | + * |
|
| 63 | + * @return string |
|
| 64 | + * @since 8.2.0 |
|
| 65 | + */ |
|
| 66 | + public function getType(): string; |
|
| 67 | 67 | } |
@@ -29,15 +29,15 @@ |
||
| 29 | 29 | namespace OCA\AdminAudit\Actions; |
| 30 | 30 | |
| 31 | 31 | class Trashbin extends Action { |
| 32 | - public function delete(array $params): void { |
|
| 33 | - $this->log('File "%s" deleted from trash bin.', |
|
| 34 | - ['path' => $params['path']], ['path'] |
|
| 35 | - ); |
|
| 36 | - } |
|
| 32 | + public function delete(array $params): void { |
|
| 33 | + $this->log('File "%s" deleted from trash bin.', |
|
| 34 | + ['path' => $params['path']], ['path'] |
|
| 35 | + ); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public function restore(array $params): void { |
|
| 39 | - $this->log('File "%s" restored from trash bin.', |
|
| 40 | - ['path' => $params['filePath']], ['path'] |
|
| 41 | - ); |
|
| 42 | - } |
|
| 38 | + public function restore(array $params): void { |
|
| 39 | + $this->log('File "%s" restored from trash bin.', |
|
| 40 | + ['path' => $params['filePath']], ['path'] |
|
| 41 | + ); |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -29,22 +29,22 @@ |
||
| 29 | 29 | * @since 22.0.0 |
| 30 | 30 | */ |
| 31 | 31 | class AlreadySharedException extends GenericShareException { |
| 32 | - /** @var IShare */ |
|
| 33 | - private $existingShare; |
|
| 32 | + /** @var IShare */ |
|
| 33 | + private $existingShare; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @since 22.0.0 |
|
| 37 | - */ |
|
| 38 | - public function __construct(string $message, IShare $existingShare) { |
|
| 39 | - parent::__construct($message); |
|
| 35 | + /** |
|
| 36 | + * @since 22.0.0 |
|
| 37 | + */ |
|
| 38 | + public function __construct(string $message, IShare $existingShare) { |
|
| 39 | + parent::__construct($message); |
|
| 40 | 40 | |
| 41 | - $this->existingShare = $existingShare; |
|
| 42 | - } |
|
| 41 | + $this->existingShare = $existingShare; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @since 22.0.0 |
|
| 46 | - */ |
|
| 47 | - public function getExistingShare(): IShare { |
|
| 48 | - return $this->existingShare; |
|
| 49 | - } |
|
| 44 | + /** |
|
| 45 | + * @since 22.0.0 |
|
| 46 | + */ |
|
| 47 | + public function getExistingShare(): IShare { |
|
| 48 | + return $this->existingShare; |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -30,31 +30,31 @@ |
||
| 30 | 30 | * Fallback implementation for moveFromCache |
| 31 | 31 | */ |
| 32 | 32 | trait MoveFromCacheTrait { |
| 33 | - /** |
|
| 34 | - * store meta data for a file or folder |
|
| 35 | - * |
|
| 36 | - * @param string $file |
|
| 37 | - * @param array $data |
|
| 38 | - * |
|
| 39 | - * @return int file id |
|
| 40 | - * @throws \RuntimeException |
|
| 41 | - */ |
|
| 42 | - abstract public function put($file, array $data); |
|
| 33 | + /** |
|
| 34 | + * store meta data for a file or folder |
|
| 35 | + * |
|
| 36 | + * @param string $file |
|
| 37 | + * @param array $data |
|
| 38 | + * |
|
| 39 | + * @return int file id |
|
| 40 | + * @throws \RuntimeException |
|
| 41 | + */ |
|
| 42 | + abstract public function put($file, array $data); |
|
| 43 | 43 | |
| 44 | - abstract public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int; |
|
| 44 | + abstract public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Move a file or folder in the cache |
|
| 48 | - * |
|
| 49 | - * @param \OCP\Files\Cache\ICache $sourceCache |
|
| 50 | - * @param string $sourcePath |
|
| 51 | - * @param string $targetPath |
|
| 52 | - */ |
|
| 53 | - public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
|
| 54 | - $sourceEntry = $sourceCache->get($sourcePath); |
|
| 46 | + /** |
|
| 47 | + * Move a file or folder in the cache |
|
| 48 | + * |
|
| 49 | + * @param \OCP\Files\Cache\ICache $sourceCache |
|
| 50 | + * @param string $sourcePath |
|
| 51 | + * @param string $targetPath |
|
| 52 | + */ |
|
| 53 | + public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
|
| 54 | + $sourceEntry = $sourceCache->get($sourcePath); |
|
| 55 | 55 | |
| 56 | - $this->copyFromCache($sourceCache, $sourceEntry, $targetPath); |
|
| 56 | + $this->copyFromCache($sourceCache, $sourceEntry, $targetPath); |
|
| 57 | 57 | |
| 58 | - $sourceCache->remove($sourcePath); |
|
| 59 | - } |
|
| 58 | + $sourceCache->remove($sourcePath); |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -31,22 +31,22 @@ |
||
| 31 | 31 | use OCP\Migration\SimpleMigrationStep; |
| 32 | 32 | |
| 33 | 33 | class Version21000Date20210309185127 extends SimpleMigrationStep { |
| 34 | - /** |
|
| 35 | - * @param IOutput $output |
|
| 36 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 37 | - * @param array $options |
|
| 38 | - * @return null|ISchemaWrapper |
|
| 39 | - */ |
|
| 40 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 41 | - /** @var ISchemaWrapper $schema */ |
|
| 42 | - $schema = $schemaClosure(); |
|
| 34 | + /** |
|
| 35 | + * @param IOutput $output |
|
| 36 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 37 | + * @param array $options |
|
| 38 | + * @return null|ISchemaWrapper |
|
| 39 | + */ |
|
| 40 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 41 | + /** @var ISchemaWrapper $schema */ |
|
| 42 | + $schema = $schemaClosure(); |
|
| 43 | 43 | |
| 44 | - $table = $schema->getTable('known_users'); |
|
| 45 | - if (!$table->hasIndex('ku_known_user')) { |
|
| 46 | - $table->addIndex(['known_user'], 'ku_known_user'); |
|
| 47 | - return $schema; |
|
| 48 | - } |
|
| 44 | + $table = $schema->getTable('known_users'); |
|
| 45 | + if (!$table->hasIndex('ku_known_user')) { |
|
| 46 | + $table->addIndex(['known_user'], 'ku_known_user'); |
|
| 47 | + return $schema; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return null; |
|
| 51 | - } |
|
| 50 | + return null; |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -54,48 +54,48 @@ |
||
| 54 | 54 | use Psr\Container\ContainerInterface; |
| 55 | 55 | |
| 56 | 56 | class Application extends App implements IBootstrap { |
| 57 | - public function __construct(array $urlParams = []) { |
|
| 58 | - parent::__construct('provisioning_api', $urlParams); |
|
| 59 | - } |
|
| 57 | + public function __construct(array $urlParams = []) { |
|
| 58 | + parent::__construct('provisioning_api', $urlParams); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function register(IRegistrationContext $context): void { |
|
| 62 | - $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); |
|
| 61 | + public function register(IRegistrationContext $context): void { |
|
| 62 | + $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); |
|
| 63 | 63 | |
| 64 | - $context->registerService(NewUserMailHelper::class, function (ContainerInterface $c) { |
|
| 65 | - return new NewUserMailHelper( |
|
| 66 | - $c->get(Defaults::class), |
|
| 67 | - $c->get(IURLGenerator::class), |
|
| 68 | - $c->get(IFactory::class), |
|
| 69 | - $c->get(IMailer::class), |
|
| 70 | - $c->get(ISecureRandom::class), |
|
| 71 | - $c->get(ITimeFactory::class), |
|
| 72 | - $c->get(IConfig::class), |
|
| 73 | - $c->get(ICrypto::class), |
|
| 74 | - Util::getDefaultEmailAddress('no-reply') |
|
| 75 | - ); |
|
| 76 | - }); |
|
| 77 | - $context->registerService(ProvisioningApiMiddleware::class, function (ContainerInterface $c) { |
|
| 78 | - $user = $c->get(IUserManager::class)->get($c->get('UserId')); |
|
| 79 | - $isAdmin = false; |
|
| 80 | - $isSubAdmin = false; |
|
| 64 | + $context->registerService(NewUserMailHelper::class, function (ContainerInterface $c) { |
|
| 65 | + return new NewUserMailHelper( |
|
| 66 | + $c->get(Defaults::class), |
|
| 67 | + $c->get(IURLGenerator::class), |
|
| 68 | + $c->get(IFactory::class), |
|
| 69 | + $c->get(IMailer::class), |
|
| 70 | + $c->get(ISecureRandom::class), |
|
| 71 | + $c->get(ITimeFactory::class), |
|
| 72 | + $c->get(IConfig::class), |
|
| 73 | + $c->get(ICrypto::class), |
|
| 74 | + Util::getDefaultEmailAddress('no-reply') |
|
| 75 | + ); |
|
| 76 | + }); |
|
| 77 | + $context->registerService(ProvisioningApiMiddleware::class, function (ContainerInterface $c) { |
|
| 78 | + $user = $c->get(IUserManager::class)->get($c->get('UserId')); |
|
| 79 | + $isAdmin = false; |
|
| 80 | + $isSubAdmin = false; |
|
| 81 | 81 | |
| 82 | - if ($user instanceof IUser) { |
|
| 83 | - $groupManager = $c->get(IGroupManager::class); |
|
| 84 | - assert($groupManager instanceof GroupManager); |
|
| 85 | - $isAdmin = $groupManager->isAdmin($user->getUID()); |
|
| 86 | - $isSubAdmin = $groupManager->getSubAdmin()->isSubAdmin($user); |
|
| 87 | - } |
|
| 82 | + if ($user instanceof IUser) { |
|
| 83 | + $groupManager = $c->get(IGroupManager::class); |
|
| 84 | + assert($groupManager instanceof GroupManager); |
|
| 85 | + $isAdmin = $groupManager->isAdmin($user->getUID()); |
|
| 86 | + $isSubAdmin = $groupManager->getSubAdmin()->isSubAdmin($user); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - return new ProvisioningApiMiddleware( |
|
| 90 | - $c->get(IControllerMethodReflector::class), |
|
| 91 | - $isAdmin, |
|
| 92 | - $isSubAdmin |
|
| 93 | - ); |
|
| 94 | - }); |
|
| 95 | - $context->registerMiddleware(ProvisioningApiMiddleware::class); |
|
| 96 | - $context->registerCapability(Capabilities::class); |
|
| 97 | - } |
|
| 89 | + return new ProvisioningApiMiddleware( |
|
| 90 | + $c->get(IControllerMethodReflector::class), |
|
| 91 | + $isAdmin, |
|
| 92 | + $isSubAdmin |
|
| 93 | + ); |
|
| 94 | + }); |
|
| 95 | + $context->registerMiddleware(ProvisioningApiMiddleware::class); |
|
| 96 | + $context->registerCapability(Capabilities::class); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - public function boot(IBootContext $context): void { |
|
| 100 | - } |
|
| 99 | + public function boot(IBootContext $context): void { |
|
| 100 | + } |
|
| 101 | 101 | } |