@@ -37,23 +37,23 @@ |
||
37 | 37 | * @since 17.0.0 |
38 | 38 | */ |
39 | 39 | class FeaturePolicy extends EmptyFeaturePolicy { |
40 | - protected $autoplayDomains = [ |
|
41 | - '\'self\'', |
|
42 | - ]; |
|
40 | + protected $autoplayDomains = [ |
|
41 | + '\'self\'', |
|
42 | + ]; |
|
43 | 43 | |
44 | - /** @var string[] of allowed domains that can access the camera */ |
|
45 | - protected $cameraDomains = []; |
|
44 | + /** @var string[] of allowed domains that can access the camera */ |
|
45 | + protected $cameraDomains = []; |
|
46 | 46 | |
47 | - protected $fullscreenDomains = [ |
|
48 | - '\'self\'', |
|
49 | - ]; |
|
47 | + protected $fullscreenDomains = [ |
|
48 | + '\'self\'', |
|
49 | + ]; |
|
50 | 50 | |
51 | - /** @var string[] of allowed domains that can use the geolocation of the device */ |
|
52 | - protected $geolocationDomains = []; |
|
51 | + /** @var string[] of allowed domains that can use the geolocation of the device */ |
|
52 | + protected $geolocationDomains = []; |
|
53 | 53 | |
54 | - /** @var string[] of allowed domains that can use the microphone */ |
|
55 | - protected $microphoneDomains = []; |
|
54 | + /** @var string[] of allowed domains that can use the microphone */ |
|
55 | + protected $microphoneDomains = []; |
|
56 | 56 | |
57 | - /** @var string[] of allowed domains that can use the payment API */ |
|
58 | - protected $paymentDomains = []; |
|
57 | + /** @var string[] of allowed domains that can use the payment API */ |
|
58 | + protected $paymentDomains = []; |
|
59 | 59 | } |
@@ -36,16 +36,16 @@ |
||
36 | 36 | */ |
37 | 37 | class Proxy extends Entity { |
38 | 38 | |
39 | - /** @var string */ |
|
40 | - protected $ownerId; |
|
41 | - /** @var string */ |
|
42 | - protected $proxyId; |
|
43 | - /** @var int */ |
|
44 | - protected $permissions; |
|
39 | + /** @var string */ |
|
40 | + protected $ownerId; |
|
41 | + /** @var string */ |
|
42 | + protected $proxyId; |
|
43 | + /** @var int */ |
|
44 | + protected $permissions; |
|
45 | 45 | |
46 | - public function __construct() { |
|
47 | - $this->addType('ownerId', 'string'); |
|
48 | - $this->addType('proxyId', 'string'); |
|
49 | - $this->addType('permissions', 'int'); |
|
50 | - } |
|
46 | + public function __construct() { |
|
47 | + $this->addType('ownerId', 'string'); |
|
48 | + $this->addType('proxyId', 'string'); |
|
49 | + $this->addType('permissions', 'int'); |
|
50 | + } |
|
51 | 51 | } |
@@ -31,51 +31,51 @@ |
||
31 | 31 | */ |
32 | 32 | class NotificationProviderManager { |
33 | 33 | |
34 | - /** @var INotificationProvider[] */ |
|
35 | - private $providers = []; |
|
34 | + /** @var INotificationProvider[] */ |
|
35 | + private $providers = []; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Checks whether a provider for a given ACTION exists |
|
39 | - * |
|
40 | - * @param string $type |
|
41 | - * @return bool |
|
42 | - */ |
|
43 | - public function hasProvider(string $type):bool { |
|
44 | - return (\in_array($type, ReminderService::REMINDER_TYPES, true) |
|
45 | - && isset($this->providers[$type])); |
|
46 | - } |
|
37 | + /** |
|
38 | + * Checks whether a provider for a given ACTION exists |
|
39 | + * |
|
40 | + * @param string $type |
|
41 | + * @return bool |
|
42 | + */ |
|
43 | + public function hasProvider(string $type):bool { |
|
44 | + return (\in_array($type, ReminderService::REMINDER_TYPES, true) |
|
45 | + && isset($this->providers[$type])); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Get provider for a given ACTION |
|
50 | - * |
|
51 | - * @param string $type |
|
52 | - * @return INotificationProvider |
|
53 | - * @throws NotificationProvider\ProviderNotAvailableException |
|
54 | - * @throws NotificationTypeDoesNotExistException |
|
55 | - */ |
|
56 | - public function getProvider(string $type):INotificationProvider { |
|
57 | - if (in_array($type, ReminderService::REMINDER_TYPES, true)) { |
|
58 | - if (isset($this->providers[$type])) { |
|
59 | - return $this->providers[$type]; |
|
60 | - } |
|
61 | - throw new NotificationProvider\ProviderNotAvailableException($type); |
|
62 | - } |
|
63 | - throw new NotificationTypeDoesNotExistException($type); |
|
64 | - } |
|
48 | + /** |
|
49 | + * Get provider for a given ACTION |
|
50 | + * |
|
51 | + * @param string $type |
|
52 | + * @return INotificationProvider |
|
53 | + * @throws NotificationProvider\ProviderNotAvailableException |
|
54 | + * @throws NotificationTypeDoesNotExistException |
|
55 | + */ |
|
56 | + public function getProvider(string $type):INotificationProvider { |
|
57 | + if (in_array($type, ReminderService::REMINDER_TYPES, true)) { |
|
58 | + if (isset($this->providers[$type])) { |
|
59 | + return $this->providers[$type]; |
|
60 | + } |
|
61 | + throw new NotificationProvider\ProviderNotAvailableException($type); |
|
62 | + } |
|
63 | + throw new NotificationTypeDoesNotExistException($type); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Registers a new provider |
|
68 | - * |
|
69 | - * @param string $providerClassName |
|
70 | - * @throws \OCP\AppFramework\QueryException |
|
71 | - */ |
|
72 | - public function registerProvider(string $providerClassName):void { |
|
73 | - $provider = \OC::$server->query($providerClassName); |
|
66 | + /** |
|
67 | + * Registers a new provider |
|
68 | + * |
|
69 | + * @param string $providerClassName |
|
70 | + * @throws \OCP\AppFramework\QueryException |
|
71 | + */ |
|
72 | + public function registerProvider(string $providerClassName):void { |
|
73 | + $provider = \OC::$server->query($providerClassName); |
|
74 | 74 | |
75 | - if (!$provider instanceof INotificationProvider) { |
|
76 | - throw new \InvalidArgumentException('Invalid notification provider registered'); |
|
77 | - } |
|
75 | + if (!$provider instanceof INotificationProvider) { |
|
76 | + throw new \InvalidArgumentException('Invalid notification provider registered'); |
|
77 | + } |
|
78 | 78 | |
79 | - $this->providers[$provider::NOTIFICATION_TYPE] = $provider; |
|
80 | - } |
|
79 | + $this->providers[$provider::NOTIFICATION_TYPE] = $provider; |
|
80 | + } |
|
81 | 81 | } |
@@ -26,15 +26,15 @@ |
||
26 | 26 | |
27 | 27 | class NotificationTypeDoesNotExistException extends \Exception { |
28 | 28 | |
29 | - /** |
|
30 | - * NotificationTypeDoesNotExistException constructor. |
|
31 | - * |
|
32 | - * @since 16.0.0 |
|
33 | - * |
|
34 | - * @param string $type ReminderType |
|
35 | - */ |
|
36 | - public function __construct(string $type) { |
|
37 | - parent::__construct("Type $type is not an accepted type of notification"); |
|
38 | - } |
|
29 | + /** |
|
30 | + * NotificationTypeDoesNotExistException constructor. |
|
31 | + * |
|
32 | + * @since 16.0.0 |
|
33 | + * |
|
34 | + * @param string $type ReminderType |
|
35 | + */ |
|
36 | + public function __construct(string $type) { |
|
37 | + parent::__construct("Type $type is not an accepted type of notification"); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
@@ -25,15 +25,15 @@ |
||
25 | 25 | |
26 | 26 | class ProviderNotAvailableException extends \Exception { |
27 | 27 | |
28 | - /** |
|
29 | - * ProviderNotAvailableException constructor. |
|
30 | - * |
|
31 | - * @since 16.0.0 |
|
32 | - * |
|
33 | - * @param string $type ReminderType |
|
34 | - */ |
|
35 | - public function __construct(string $type) { |
|
36 | - parent::__construct("No notification provider for type $type available"); |
|
37 | - } |
|
28 | + /** |
|
29 | + * ProviderNotAvailableException constructor. |
|
30 | + * |
|
31 | + * @since 16.0.0 |
|
32 | + * |
|
33 | + * @param string $type ReminderType |
|
34 | + */ |
|
35 | + public function __construct(string $type) { |
|
36 | + parent::__construct("No notification provider for type $type available"); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | } |
@@ -32,6 +32,6 @@ |
||
32 | 32 | */ |
33 | 33 | class AudioProvider extends PushProvider { |
34 | 34 | |
35 | - /** @var string */ |
|
36 | - public const NOTIFICATION_TYPE = 'AUDIO'; |
|
35 | + /** @var string */ |
|
36 | + public const NOTIFICATION_TYPE = 'AUDIO'; |
|
37 | 37 | } |
@@ -31,91 +31,91 @@ |
||
31 | 31 | |
32 | 32 | class FileSize implements ICheck { |
33 | 33 | |
34 | - /** @var int */ |
|
35 | - protected $size; |
|
36 | - |
|
37 | - /** @var IL10N */ |
|
38 | - protected $l; |
|
39 | - |
|
40 | - /** @var IRequest */ |
|
41 | - protected $request; |
|
42 | - |
|
43 | - /** |
|
44 | - * @param IL10N $l |
|
45 | - * @param IRequest $request |
|
46 | - */ |
|
47 | - public function __construct(IL10N $l, IRequest $request) { |
|
48 | - $this->l = $l; |
|
49 | - $this->request = $request; |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @param string $operator |
|
54 | - * @param string $value |
|
55 | - * @return bool |
|
56 | - */ |
|
57 | - public function executeCheck($operator, $value) { |
|
58 | - $size = $this->getFileSizeFromHeader(); |
|
59 | - |
|
60 | - $value = Util::computerFileSize($value); |
|
61 | - if ($size !== false) { |
|
62 | - switch ($operator) { |
|
63 | - case 'less': |
|
64 | - return $size < $value; |
|
65 | - case '!less': |
|
66 | - return $size >= $value; |
|
67 | - case 'greater': |
|
68 | - return $size > $value; |
|
69 | - case '!greater': |
|
70 | - return $size <= $value; |
|
71 | - } |
|
72 | - } |
|
73 | - return false; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * @param string $operator |
|
78 | - * @param string $value |
|
79 | - * @throws \UnexpectedValueException |
|
80 | - */ |
|
81 | - public function validateCheck($operator, $value) { |
|
82 | - if (!in_array($operator, ['less', '!less', 'greater', '!greater'])) { |
|
83 | - throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
84 | - } |
|
85 | - |
|
86 | - if (!preg_match('/^[0-9]+[ ]?[kmgt]?b$/i', $value)) { |
|
87 | - throw new \UnexpectedValueException($this->l->t('The given file size is invalid'), 2); |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - protected function getFileSizeFromHeader() { |
|
95 | - if ($this->size !== null) { |
|
96 | - return $this->size; |
|
97 | - } |
|
98 | - |
|
99 | - $size = $this->request->getHeader('OC-Total-Length'); |
|
100 | - if ($size === '') { |
|
101 | - if (in_array($this->request->getMethod(), ['POST', 'PUT'])) { |
|
102 | - $size = $this->request->getHeader('Content-Length'); |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - if ($size === '') { |
|
107 | - $size = false; |
|
108 | - } |
|
109 | - |
|
110 | - $this->size = $size; |
|
111 | - return $this->size; |
|
112 | - } |
|
113 | - |
|
114 | - public function supportedEntities(): array { |
|
115 | - return [ File::class ]; |
|
116 | - } |
|
117 | - |
|
118 | - public function isAvailableForScope(int $scope): bool { |
|
119 | - return true; |
|
120 | - } |
|
34 | + /** @var int */ |
|
35 | + protected $size; |
|
36 | + |
|
37 | + /** @var IL10N */ |
|
38 | + protected $l; |
|
39 | + |
|
40 | + /** @var IRequest */ |
|
41 | + protected $request; |
|
42 | + |
|
43 | + /** |
|
44 | + * @param IL10N $l |
|
45 | + * @param IRequest $request |
|
46 | + */ |
|
47 | + public function __construct(IL10N $l, IRequest $request) { |
|
48 | + $this->l = $l; |
|
49 | + $this->request = $request; |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @param string $operator |
|
54 | + * @param string $value |
|
55 | + * @return bool |
|
56 | + */ |
|
57 | + public function executeCheck($operator, $value) { |
|
58 | + $size = $this->getFileSizeFromHeader(); |
|
59 | + |
|
60 | + $value = Util::computerFileSize($value); |
|
61 | + if ($size !== false) { |
|
62 | + switch ($operator) { |
|
63 | + case 'less': |
|
64 | + return $size < $value; |
|
65 | + case '!less': |
|
66 | + return $size >= $value; |
|
67 | + case 'greater': |
|
68 | + return $size > $value; |
|
69 | + case '!greater': |
|
70 | + return $size <= $value; |
|
71 | + } |
|
72 | + } |
|
73 | + return false; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * @param string $operator |
|
78 | + * @param string $value |
|
79 | + * @throws \UnexpectedValueException |
|
80 | + */ |
|
81 | + public function validateCheck($operator, $value) { |
|
82 | + if (!in_array($operator, ['less', '!less', 'greater', '!greater'])) { |
|
83 | + throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
84 | + } |
|
85 | + |
|
86 | + if (!preg_match('/^[0-9]+[ ]?[kmgt]?b$/i', $value)) { |
|
87 | + throw new \UnexpectedValueException($this->l->t('The given file size is invalid'), 2); |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + protected function getFileSizeFromHeader() { |
|
95 | + if ($this->size !== null) { |
|
96 | + return $this->size; |
|
97 | + } |
|
98 | + |
|
99 | + $size = $this->request->getHeader('OC-Total-Length'); |
|
100 | + if ($size === '') { |
|
101 | + if (in_array($this->request->getMethod(), ['POST', 'PUT'])) { |
|
102 | + $size = $this->request->getHeader('Content-Length'); |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + if ($size === '') { |
|
107 | + $size = false; |
|
108 | + } |
|
109 | + |
|
110 | + $this->size = $size; |
|
111 | + return $this->size; |
|
112 | + } |
|
113 | + |
|
114 | + public function supportedEntities(): array { |
|
115 | + return [ File::class ]; |
|
116 | + } |
|
117 | + |
|
118 | + public function isAvailableForScope(int $scope): bool { |
|
119 | + return true; |
|
120 | + } |
|
121 | 121 | } |
@@ -31,86 +31,86 @@ |
||
31 | 31 | |
32 | 32 | class UserGroupMembership implements ICheck { |
33 | 33 | |
34 | - /** @var string */ |
|
35 | - protected $cachedUser; |
|
36 | - |
|
37 | - /** @var string[] */ |
|
38 | - protected $cachedGroupMemberships; |
|
39 | - |
|
40 | - /** @var IUserSession */ |
|
41 | - protected $userSession; |
|
42 | - |
|
43 | - /** @var IGroupManager */ |
|
44 | - protected $groupManager; |
|
45 | - |
|
46 | - /** @var IL10N */ |
|
47 | - protected $l; |
|
48 | - |
|
49 | - /** |
|
50 | - * @param IUserSession $userSession |
|
51 | - * @param IGroupManager $groupManager |
|
52 | - * @param IL10N $l |
|
53 | - */ |
|
54 | - public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) { |
|
55 | - $this->userSession = $userSession; |
|
56 | - $this->groupManager = $groupManager; |
|
57 | - $this->l = $l; |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * @param string $operator |
|
62 | - * @param string $value |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - public function executeCheck($operator, $value) { |
|
66 | - $user = $this->userSession->getUser(); |
|
67 | - |
|
68 | - if ($user instanceof IUser) { |
|
69 | - $groupIds = $this->getUserGroups($user); |
|
70 | - return ($operator === 'is') === in_array($value, $groupIds); |
|
71 | - } else { |
|
72 | - return $operator !== 'is'; |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * @param string $operator |
|
79 | - * @param string $value |
|
80 | - * @throws \UnexpectedValueException |
|
81 | - */ |
|
82 | - public function validateCheck($operator, $value) { |
|
83 | - if (!in_array($operator, ['is', '!is'])) { |
|
84 | - throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
85 | - } |
|
86 | - |
|
87 | - if (!$this->groupManager->groupExists($value)) { |
|
88 | - throw new \UnexpectedValueException($this->l->t('The given group does not exist'), 2); |
|
89 | - } |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @param IUser $user |
|
94 | - * @return string[] |
|
95 | - */ |
|
96 | - protected function getUserGroups(IUser $user) { |
|
97 | - $uid = $user->getUID(); |
|
98 | - |
|
99 | - if ($this->cachedUser !== $uid) { |
|
100 | - $this->cachedUser = $uid; |
|
101 | - $this->cachedGroupMemberships = $this->groupManager->getUserGroupIds($user); |
|
102 | - } |
|
103 | - |
|
104 | - return $this->cachedGroupMemberships; |
|
105 | - } |
|
106 | - |
|
107 | - public function supportedEntities(): array { |
|
108 | - // universal by default |
|
109 | - return []; |
|
110 | - } |
|
111 | - |
|
112 | - public function isAvailableForScope(int $scope): bool { |
|
113 | - // admin only by default |
|
114 | - return $scope === IManager::SCOPE_ADMIN; |
|
115 | - } |
|
34 | + /** @var string */ |
|
35 | + protected $cachedUser; |
|
36 | + |
|
37 | + /** @var string[] */ |
|
38 | + protected $cachedGroupMemberships; |
|
39 | + |
|
40 | + /** @var IUserSession */ |
|
41 | + protected $userSession; |
|
42 | + |
|
43 | + /** @var IGroupManager */ |
|
44 | + protected $groupManager; |
|
45 | + |
|
46 | + /** @var IL10N */ |
|
47 | + protected $l; |
|
48 | + |
|
49 | + /** |
|
50 | + * @param IUserSession $userSession |
|
51 | + * @param IGroupManager $groupManager |
|
52 | + * @param IL10N $l |
|
53 | + */ |
|
54 | + public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) { |
|
55 | + $this->userSession = $userSession; |
|
56 | + $this->groupManager = $groupManager; |
|
57 | + $this->l = $l; |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * @param string $operator |
|
62 | + * @param string $value |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | + public function executeCheck($operator, $value) { |
|
66 | + $user = $this->userSession->getUser(); |
|
67 | + |
|
68 | + if ($user instanceof IUser) { |
|
69 | + $groupIds = $this->getUserGroups($user); |
|
70 | + return ($operator === 'is') === in_array($value, $groupIds); |
|
71 | + } else { |
|
72 | + return $operator !== 'is'; |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * @param string $operator |
|
79 | + * @param string $value |
|
80 | + * @throws \UnexpectedValueException |
|
81 | + */ |
|
82 | + public function validateCheck($operator, $value) { |
|
83 | + if (!in_array($operator, ['is', '!is'])) { |
|
84 | + throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
85 | + } |
|
86 | + |
|
87 | + if (!$this->groupManager->groupExists($value)) { |
|
88 | + throw new \UnexpectedValueException($this->l->t('The given group does not exist'), 2); |
|
89 | + } |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @param IUser $user |
|
94 | + * @return string[] |
|
95 | + */ |
|
96 | + protected function getUserGroups(IUser $user) { |
|
97 | + $uid = $user->getUID(); |
|
98 | + |
|
99 | + if ($this->cachedUser !== $uid) { |
|
100 | + $this->cachedUser = $uid; |
|
101 | + $this->cachedGroupMemberships = $this->groupManager->getUserGroupIds($user); |
|
102 | + } |
|
103 | + |
|
104 | + return $this->cachedGroupMemberships; |
|
105 | + } |
|
106 | + |
|
107 | + public function supportedEntities(): array { |
|
108 | + // universal by default |
|
109 | + return []; |
|
110 | + } |
|
111 | + |
|
112 | + public function isAvailableForScope(int $scope): bool { |
|
113 | + // admin only by default |
|
114 | + return $scope === IManager::SCOPE_ADMIN; |
|
115 | + } |
|
116 | 116 | } |
@@ -34,21 +34,21 @@ |
||
34 | 34 | * @since 18.0.0 |
35 | 35 | */ |
36 | 36 | interface IEntityCheck { |
37 | - /** |
|
38 | - * Equips the check with a subject fitting the Entity. For instance, an |
|
39 | - * entity of File will receive an instance of OCP\Files\Node, or a comment |
|
40 | - * entity might get an IComment. |
|
41 | - * |
|
42 | - * The implementing check must be aware of the incoming type. |
|
43 | - * |
|
44 | - * If an unsupported subject is passed the implementation MAY throw an |
|
45 | - * \UnexpectedValueException. |
|
46 | - * |
|
47 | - * @param IEntity $entity |
|
48 | - * @param mixed $subject |
|
49 | - * @throws \UnexpectedValueException |
|
50 | - * @since 18.0.0 |
|
51 | - */ |
|
52 | - public function setEntitySubject(IEntity $entity, $subject): void; |
|
37 | + /** |
|
38 | + * Equips the check with a subject fitting the Entity. For instance, an |
|
39 | + * entity of File will receive an instance of OCP\Files\Node, or a comment |
|
40 | + * entity might get an IComment. |
|
41 | + * |
|
42 | + * The implementing check must be aware of the incoming type. |
|
43 | + * |
|
44 | + * If an unsupported subject is passed the implementation MAY throw an |
|
45 | + * \UnexpectedValueException. |
|
46 | + * |
|
47 | + * @param IEntity $entity |
|
48 | + * @param mixed $subject |
|
49 | + * @throws \UnexpectedValueException |
|
50 | + * @since 18.0.0 |
|
51 | + */ |
|
52 | + public function setEntitySubject(IEntity $entity, $subject): void; |
|
53 | 53 | |
54 | 54 | } |