@@ -61,5 +61,5 @@ |
||
61 | 61 | * @return string|null - The value stored for the key, null if no value stored |
62 | 62 | * @since 17.0.0 |
63 | 63 | */ |
64 | - public function getMetadataForKey(string $key):?string; |
|
64 | + public function getMetadataForKey(string $key): ?string; |
|
65 | 65 | } |
@@ -30,33 +30,33 @@ |
||
30 | 30 | * @since 17.0.0 |
31 | 31 | */ |
32 | 32 | interface IMetadataProvider { |
33 | - /** |
|
34 | - * Get a list of all metadata keys available for this room |
|
35 | - * |
|
36 | - * Room backends are allowed to return custom keys, beyond the ones |
|
37 | - * defined in this class. If they do, they should make sure to use their |
|
38 | - * own namespace. |
|
39 | - * |
|
40 | - * @return String[] - A list of available keys |
|
41 | - * @since 17.0.0 |
|
42 | - */ |
|
43 | - public function getAllAvailableMetadataKeys():array; |
|
33 | + /** |
|
34 | + * Get a list of all metadata keys available for this room |
|
35 | + * |
|
36 | + * Room backends are allowed to return custom keys, beyond the ones |
|
37 | + * defined in this class. If they do, they should make sure to use their |
|
38 | + * own namespace. |
|
39 | + * |
|
40 | + * @return String[] - A list of available keys |
|
41 | + * @since 17.0.0 |
|
42 | + */ |
|
43 | + public function getAllAvailableMetadataKeys():array; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Get whether or not a metadata key is set for this room |
|
47 | - * |
|
48 | - * @param string $key - The key to check for |
|
49 | - * @return bool - Whether or not key is available |
|
50 | - * @since 17.0.0 |
|
51 | - */ |
|
52 | - public function hasMetadataForKey(string $key):bool; |
|
45 | + /** |
|
46 | + * Get whether or not a metadata key is set for this room |
|
47 | + * |
|
48 | + * @param string $key - The key to check for |
|
49 | + * @return bool - Whether or not key is available |
|
50 | + * @since 17.0.0 |
|
51 | + */ |
|
52 | + public function hasMetadataForKey(string $key):bool; |
|
53 | 53 | |
54 | - /** |
|
55 | - * Get the value for a metadata key |
|
56 | - * |
|
57 | - * @param string $key - The key to check for |
|
58 | - * @return string|null - The value stored for the key, null if no value stored |
|
59 | - * @since 17.0.0 |
|
60 | - */ |
|
61 | - public function getMetadataForKey(string $key):?string; |
|
54 | + /** |
|
55 | + * Get the value for a metadata key |
|
56 | + * |
|
57 | + * @param string $key - The key to check for |
|
58 | + * @return string|null - The value stored for the key, null if no value stored |
|
59 | + * @since 17.0.0 |
|
60 | + */ |
|
61 | + public function getMetadataForKey(string $key):?string; |
|
62 | 62 | } |
@@ -139,42 +139,42 @@ |
||
139 | 139 | if (empty($this->autoplayDomains)) { |
140 | 140 | $policy .= "autoplay 'none';"; |
141 | 141 | } else { |
142 | - $policy .= 'autoplay ' . implode(' ', $this->autoplayDomains); |
|
142 | + $policy .= 'autoplay '.implode(' ', $this->autoplayDomains); |
|
143 | 143 | $policy .= ';'; |
144 | 144 | } |
145 | 145 | |
146 | 146 | if (empty($this->cameraDomains)) { |
147 | 147 | $policy .= "camera 'none';"; |
148 | 148 | } else { |
149 | - $policy .= 'camera ' . implode(' ', $this->cameraDomains); |
|
149 | + $policy .= 'camera '.implode(' ', $this->cameraDomains); |
|
150 | 150 | $policy .= ';'; |
151 | 151 | } |
152 | 152 | |
153 | 153 | if (empty($this->fullscreenDomains)) { |
154 | 154 | $policy .= "fullscreen 'none';"; |
155 | 155 | } else { |
156 | - $policy .= 'fullscreen ' . implode(' ', $this->fullscreenDomains); |
|
156 | + $policy .= 'fullscreen '.implode(' ', $this->fullscreenDomains); |
|
157 | 157 | $policy .= ';'; |
158 | 158 | } |
159 | 159 | |
160 | 160 | if (empty($this->geolocationDomains)) { |
161 | 161 | $policy .= "geolocation 'none';"; |
162 | 162 | } else { |
163 | - $policy .= 'geolocation ' . implode(' ', $this->geolocationDomains); |
|
163 | + $policy .= 'geolocation '.implode(' ', $this->geolocationDomains); |
|
164 | 164 | $policy .= ';'; |
165 | 165 | } |
166 | 166 | |
167 | 167 | if (empty($this->microphoneDomains)) { |
168 | 168 | $policy .= "microphone 'none';"; |
169 | 169 | } else { |
170 | - $policy .= 'microphone ' . implode(' ', $this->microphoneDomains); |
|
170 | + $policy .= 'microphone '.implode(' ', $this->microphoneDomains); |
|
171 | 171 | $policy .= ';'; |
172 | 172 | } |
173 | 173 | |
174 | 174 | if (empty($this->paymentDomains)) { |
175 | 175 | $policy .= "payment 'none';"; |
176 | 176 | } else { |
177 | - $policy .= 'payment ' . implode(' ', $this->paymentDomains); |
|
177 | + $policy .= 'payment '.implode(' ', $this->paymentDomains); |
|
178 | 178 | $policy .= ';'; |
179 | 179 | } |
180 | 180 |
@@ -36,147 +36,147 @@ |
||
36 | 36 | * @since 17.0.0 |
37 | 37 | */ |
38 | 38 | class EmptyFeaturePolicy { |
39 | - /** @var string[] of allowed domains to autoplay media */ |
|
40 | - protected $autoplayDomains = null; |
|
41 | - |
|
42 | - /** @var string[] of allowed domains that can access the camera */ |
|
43 | - protected $cameraDomains = null; |
|
44 | - |
|
45 | - /** @var string[] of allowed domains that can use fullscreen */ |
|
46 | - protected $fullscreenDomains = null; |
|
47 | - |
|
48 | - /** @var string[] of allowed domains that can use the geolocation of the device */ |
|
49 | - protected $geolocationDomains = null; |
|
50 | - |
|
51 | - /** @var string[] of allowed domains that can use the microphone */ |
|
52 | - protected $microphoneDomains = null; |
|
53 | - |
|
54 | - /** @var string[] of allowed domains that can use the payment API */ |
|
55 | - protected $paymentDomains = null; |
|
56 | - |
|
57 | - /** |
|
58 | - * Allows to use autoplay from a specific domain. Use * to allow from all domains. |
|
59 | - * |
|
60 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
61 | - * @return $this |
|
62 | - * @since 17.0.0 |
|
63 | - */ |
|
64 | - public function addAllowedAutoplayDomain(string $domain): self { |
|
65 | - $this->autoplayDomains[] = $domain; |
|
66 | - return $this; |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * Allows to use the camera on a specific domain. Use * to allow from all domains |
|
71 | - * |
|
72 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
73 | - * @return $this |
|
74 | - * @since 17.0.0 |
|
75 | - */ |
|
76 | - public function addAllowedCameraDomain(string $domain): self { |
|
77 | - $this->cameraDomains[] = $domain; |
|
78 | - return $this; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Allows the full screen functionality to be used on a specific domain. Use * to allow from all domains |
|
83 | - * |
|
84 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
85 | - * @return $this |
|
86 | - * @since 17.0.0 |
|
87 | - */ |
|
88 | - public function addAllowedFullScreenDomain(string $domain): self { |
|
89 | - $this->fullscreenDomains[] = $domain; |
|
90 | - return $this; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Allows to use the geolocation on a specific domain. Use * to allow from all domains |
|
95 | - * |
|
96 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
97 | - * @return $this |
|
98 | - * @since 17.0.0 |
|
99 | - */ |
|
100 | - public function addAllowedGeoLocationDomain(string $domain): self { |
|
101 | - $this->geolocationDomains[] = $domain; |
|
102 | - return $this; |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * Allows to use the microphone on a specific domain. Use * to allow from all domains |
|
107 | - * |
|
108 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
109 | - * @return $this |
|
110 | - * @since 17.0.0 |
|
111 | - */ |
|
112 | - public function addAllowedMicrophoneDomain(string $domain): self { |
|
113 | - $this->microphoneDomains[] = $domain; |
|
114 | - return $this; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * Allows to use the payment API on a specific domain. Use * to allow from all domains |
|
119 | - * |
|
120 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
121 | - * @return $this |
|
122 | - * @since 17.0.0 |
|
123 | - */ |
|
124 | - public function addAllowedPaymentDomain(string $domain): self { |
|
125 | - $this->paymentDomains[] = $domain; |
|
126 | - return $this; |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Get the generated Feature-Policy as a string |
|
131 | - * |
|
132 | - * @return string |
|
133 | - * @since 17.0.0 |
|
134 | - */ |
|
135 | - public function buildPolicy(): string { |
|
136 | - $policy = ''; |
|
137 | - |
|
138 | - if (empty($this->autoplayDomains)) { |
|
139 | - $policy .= "autoplay 'none';"; |
|
140 | - } else { |
|
141 | - $policy .= 'autoplay ' . implode(' ', $this->autoplayDomains); |
|
142 | - $policy .= ';'; |
|
143 | - } |
|
144 | - |
|
145 | - if (empty($this->cameraDomains)) { |
|
146 | - $policy .= "camera 'none';"; |
|
147 | - } else { |
|
148 | - $policy .= 'camera ' . implode(' ', $this->cameraDomains); |
|
149 | - $policy .= ';'; |
|
150 | - } |
|
151 | - |
|
152 | - if (empty($this->fullscreenDomains)) { |
|
153 | - $policy .= "fullscreen 'none';"; |
|
154 | - } else { |
|
155 | - $policy .= 'fullscreen ' . implode(' ', $this->fullscreenDomains); |
|
156 | - $policy .= ';'; |
|
157 | - } |
|
158 | - |
|
159 | - if (empty($this->geolocationDomains)) { |
|
160 | - $policy .= "geolocation 'none';"; |
|
161 | - } else { |
|
162 | - $policy .= 'geolocation ' . implode(' ', $this->geolocationDomains); |
|
163 | - $policy .= ';'; |
|
164 | - } |
|
165 | - |
|
166 | - if (empty($this->microphoneDomains)) { |
|
167 | - $policy .= "microphone 'none';"; |
|
168 | - } else { |
|
169 | - $policy .= 'microphone ' . implode(' ', $this->microphoneDomains); |
|
170 | - $policy .= ';'; |
|
171 | - } |
|
172 | - |
|
173 | - if (empty($this->paymentDomains)) { |
|
174 | - $policy .= "payment 'none';"; |
|
175 | - } else { |
|
176 | - $policy .= 'payment ' . implode(' ', $this->paymentDomains); |
|
177 | - $policy .= ';'; |
|
178 | - } |
|
179 | - |
|
180 | - return rtrim($policy, ';'); |
|
181 | - } |
|
39 | + /** @var string[] of allowed domains to autoplay media */ |
|
40 | + protected $autoplayDomains = null; |
|
41 | + |
|
42 | + /** @var string[] of allowed domains that can access the camera */ |
|
43 | + protected $cameraDomains = null; |
|
44 | + |
|
45 | + /** @var string[] of allowed domains that can use fullscreen */ |
|
46 | + protected $fullscreenDomains = null; |
|
47 | + |
|
48 | + /** @var string[] of allowed domains that can use the geolocation of the device */ |
|
49 | + protected $geolocationDomains = null; |
|
50 | + |
|
51 | + /** @var string[] of allowed domains that can use the microphone */ |
|
52 | + protected $microphoneDomains = null; |
|
53 | + |
|
54 | + /** @var string[] of allowed domains that can use the payment API */ |
|
55 | + protected $paymentDomains = null; |
|
56 | + |
|
57 | + /** |
|
58 | + * Allows to use autoplay from a specific domain. Use * to allow from all domains. |
|
59 | + * |
|
60 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
61 | + * @return $this |
|
62 | + * @since 17.0.0 |
|
63 | + */ |
|
64 | + public function addAllowedAutoplayDomain(string $domain): self { |
|
65 | + $this->autoplayDomains[] = $domain; |
|
66 | + return $this; |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * Allows to use the camera on a specific domain. Use * to allow from all domains |
|
71 | + * |
|
72 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
73 | + * @return $this |
|
74 | + * @since 17.0.0 |
|
75 | + */ |
|
76 | + public function addAllowedCameraDomain(string $domain): self { |
|
77 | + $this->cameraDomains[] = $domain; |
|
78 | + return $this; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Allows the full screen functionality to be used on a specific domain. Use * to allow from all domains |
|
83 | + * |
|
84 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
85 | + * @return $this |
|
86 | + * @since 17.0.0 |
|
87 | + */ |
|
88 | + public function addAllowedFullScreenDomain(string $domain): self { |
|
89 | + $this->fullscreenDomains[] = $domain; |
|
90 | + return $this; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Allows to use the geolocation on a specific domain. Use * to allow from all domains |
|
95 | + * |
|
96 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
97 | + * @return $this |
|
98 | + * @since 17.0.0 |
|
99 | + */ |
|
100 | + public function addAllowedGeoLocationDomain(string $domain): self { |
|
101 | + $this->geolocationDomains[] = $domain; |
|
102 | + return $this; |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * Allows to use the microphone on a specific domain. Use * to allow from all domains |
|
107 | + * |
|
108 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
109 | + * @return $this |
|
110 | + * @since 17.0.0 |
|
111 | + */ |
|
112 | + public function addAllowedMicrophoneDomain(string $domain): self { |
|
113 | + $this->microphoneDomains[] = $domain; |
|
114 | + return $this; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * Allows to use the payment API on a specific domain. Use * to allow from all domains |
|
119 | + * |
|
120 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
121 | + * @return $this |
|
122 | + * @since 17.0.0 |
|
123 | + */ |
|
124 | + public function addAllowedPaymentDomain(string $domain): self { |
|
125 | + $this->paymentDomains[] = $domain; |
|
126 | + return $this; |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Get the generated Feature-Policy as a string |
|
131 | + * |
|
132 | + * @return string |
|
133 | + * @since 17.0.0 |
|
134 | + */ |
|
135 | + public function buildPolicy(): string { |
|
136 | + $policy = ''; |
|
137 | + |
|
138 | + if (empty($this->autoplayDomains)) { |
|
139 | + $policy .= "autoplay 'none';"; |
|
140 | + } else { |
|
141 | + $policy .= 'autoplay ' . implode(' ', $this->autoplayDomains); |
|
142 | + $policy .= ';'; |
|
143 | + } |
|
144 | + |
|
145 | + if (empty($this->cameraDomains)) { |
|
146 | + $policy .= "camera 'none';"; |
|
147 | + } else { |
|
148 | + $policy .= 'camera ' . implode(' ', $this->cameraDomains); |
|
149 | + $policy .= ';'; |
|
150 | + } |
|
151 | + |
|
152 | + if (empty($this->fullscreenDomains)) { |
|
153 | + $policy .= "fullscreen 'none';"; |
|
154 | + } else { |
|
155 | + $policy .= 'fullscreen ' . implode(' ', $this->fullscreenDomains); |
|
156 | + $policy .= ';'; |
|
157 | + } |
|
158 | + |
|
159 | + if (empty($this->geolocationDomains)) { |
|
160 | + $policy .= "geolocation 'none';"; |
|
161 | + } else { |
|
162 | + $policy .= 'geolocation ' . implode(' ', $this->geolocationDomains); |
|
163 | + $policy .= ';'; |
|
164 | + } |
|
165 | + |
|
166 | + if (empty($this->microphoneDomains)) { |
|
167 | + $policy .= "microphone 'none';"; |
|
168 | + } else { |
|
169 | + $policy .= 'microphone ' . implode(' ', $this->microphoneDomains); |
|
170 | + $policy .= ';'; |
|
171 | + } |
|
172 | + |
|
173 | + if (empty($this->paymentDomains)) { |
|
174 | + $policy .= "payment 'none';"; |
|
175 | + } else { |
|
176 | + $policy .= 'payment ' . implode(' ', $this->paymentDomains); |
|
177 | + $policy .= ';'; |
|
178 | + } |
|
179 | + |
|
180 | + return rtrim($policy, ';'); |
|
181 | + } |
|
182 | 182 | } |
@@ -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 | } |
@@ -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 | } |
@@ -36,11 +36,11 @@ |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | public function getMimeType(): string { |
39 | - return (string)$this->providerV1->getMimeType(); |
|
39 | + return (string) $this->providerV1->getMimeType(); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function isAvailable(FileInfo $file): bool { |
43 | - return (bool)$this->providerV1->isAvailable($file); |
|
43 | + return (bool) $this->providerV1->isAvailable($file); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { |
@@ -34,30 +34,30 @@ |
||
34 | 34 | use OCP\Preview\IProviderV2; |
35 | 35 | |
36 | 36 | class ProviderV1Adapter implements IProviderV2 { |
37 | - private $providerV1; |
|
37 | + private $providerV1; |
|
38 | 38 | |
39 | - public function __construct(IProvider $providerV1) { |
|
40 | - $this->providerV1 = $providerV1; |
|
41 | - } |
|
39 | + public function __construct(IProvider $providerV1) { |
|
40 | + $this->providerV1 = $providerV1; |
|
41 | + } |
|
42 | 42 | |
43 | - public function getMimeType(): string { |
|
44 | - return (string)$this->providerV1->getMimeType(); |
|
45 | - } |
|
43 | + public function getMimeType(): string { |
|
44 | + return (string)$this->providerV1->getMimeType(); |
|
45 | + } |
|
46 | 46 | |
47 | - public function isAvailable(FileInfo $file): bool { |
|
48 | - return (bool)$this->providerV1->isAvailable($file); |
|
49 | - } |
|
47 | + public function isAvailable(FileInfo $file): bool { |
|
48 | + return (bool)$this->providerV1->isAvailable($file); |
|
49 | + } |
|
50 | 50 | |
51 | - public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { |
|
52 | - [$view, $path] = $this->getViewAndPath($file); |
|
53 | - $thumbnail = $this->providerV1->getThumbnail($path, $maxX, $maxY, false, $view); |
|
54 | - return $thumbnail === false ? null: $thumbnail; |
|
55 | - } |
|
51 | + public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { |
|
52 | + [$view, $path] = $this->getViewAndPath($file); |
|
53 | + $thumbnail = $this->providerV1->getThumbnail($path, $maxX, $maxY, false, $view); |
|
54 | + return $thumbnail === false ? null: $thumbnail; |
|
55 | + } |
|
56 | 56 | |
57 | - private function getViewAndPath(File $file) { |
|
58 | - $view = new View(dirname($file->getPath())); |
|
59 | - $path = $file->getName(); |
|
57 | + private function getViewAndPath(File $file) { |
|
58 | + $view = new View(dirname($file->getPath())); |
|
59 | + $path = $file->getName(); |
|
60 | 60 | |
61 | - return [$view, $path]; |
|
62 | - } |
|
61 | + return [$view, $path]; |
|
62 | + } |
|
63 | 63 | } |
@@ -155,7 +155,7 @@ |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | public function supportedEntities(): array { |
158 | - return [ File::class ]; |
|
158 | + return [File::class]; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | public function isAvailableForScope(int $scope): bool { |
@@ -21,138 +21,138 @@ |
||
21 | 21 | use OCP\WorkflowEngine\IFileCheck; |
22 | 22 | |
23 | 23 | class FileSystemTags implements ICheck, IFileCheck { |
24 | - use TFileCheck; |
|
25 | - |
|
26 | - /** @var array */ |
|
27 | - protected $fileIds; |
|
28 | - |
|
29 | - /** @var array */ |
|
30 | - protected $fileSystemTags; |
|
31 | - |
|
32 | - public function __construct( |
|
33 | - protected IL10N $l, |
|
34 | - protected ISystemTagManager $systemTagManager, |
|
35 | - protected ISystemTagObjectMapper $systemTagObjectMapper, |
|
36 | - protected IUserSession $userSession, |
|
37 | - protected IGroupManager $groupManager, |
|
38 | - ) { |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @param string $operator |
|
43 | - * @param string $value |
|
44 | - * @return bool |
|
45 | - */ |
|
46 | - public function executeCheck($operator, $value) { |
|
47 | - $systemTags = $this->getSystemTags(); |
|
48 | - return ($operator === 'is') === in_array($value, $systemTags); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * @param string $operator |
|
53 | - * @param string $value |
|
54 | - * @throws \UnexpectedValueException |
|
55 | - */ |
|
56 | - public function validateCheck($operator, $value) { |
|
57 | - if (!in_array($operator, ['is', '!is'])) { |
|
58 | - throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
59 | - } |
|
60 | - |
|
61 | - try { |
|
62 | - $tags = $this->systemTagManager->getTagsByIds($value); |
|
63 | - |
|
64 | - $user = $this->userSession->getUser(); |
|
65 | - $isAdmin = $user instanceof IUser && $this->groupManager->isAdmin($user->getUID()); |
|
66 | - |
|
67 | - if (!$isAdmin) { |
|
68 | - foreach ($tags as $tag) { |
|
69 | - if (!$tag->isUserVisible()) { |
|
70 | - throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 4); |
|
71 | - } |
|
72 | - } |
|
73 | - } |
|
74 | - } catch (TagNotFoundException $e) { |
|
75 | - throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 2); |
|
76 | - } catch (\InvalidArgumentException $e) { |
|
77 | - throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 3); |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Get the ids of the assigned system tags |
|
83 | - * @return string[] |
|
84 | - */ |
|
85 | - protected function getSystemTags() { |
|
86 | - $cache = $this->storage->getCache(); |
|
87 | - $fileIds = $this->getFileIds($cache, $this->path, !$this->storage->instanceOfStorage(IHomeStorage::class) || $this->storage->instanceOfStorage(SharedStorage::class)); |
|
88 | - |
|
89 | - $systemTags = []; |
|
90 | - foreach ($fileIds as $i => $fileId) { |
|
91 | - if (isset($this->fileSystemTags[$fileId])) { |
|
92 | - $systemTags[] = $this->fileSystemTags[$fileId]; |
|
93 | - unset($fileIds[$i]); |
|
94 | - } |
|
95 | - } |
|
96 | - |
|
97 | - if (!empty($fileIds)) { |
|
98 | - $mappedSystemTags = $this->systemTagObjectMapper->getTagIdsForObjects($fileIds, 'files'); |
|
99 | - foreach ($mappedSystemTags as $fileId => $fileSystemTags) { |
|
100 | - $this->fileSystemTags[$fileId] = $fileSystemTags; |
|
101 | - $systemTags[] = $fileSystemTags; |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - $systemTags = call_user_func_array('array_merge', $systemTags); |
|
106 | - $systemTags = array_unique($systemTags); |
|
107 | - return $systemTags; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Get the file ids of the given path and its parents |
|
112 | - * @param ICache $cache |
|
113 | - * @param string $path |
|
114 | - * @param bool $isExternalStorage |
|
115 | - * @return int[] |
|
116 | - */ |
|
117 | - protected function getFileIds(ICache $cache, $path, $isExternalStorage) { |
|
118 | - $cacheId = $cache->getNumericStorageId(); |
|
119 | - if ($this->storage->instanceOfStorage(Jail::class)) { |
|
120 | - $absolutePath = $this->storage->getUnjailedPath($path); |
|
121 | - } else { |
|
122 | - $absolutePath = $path; |
|
123 | - } |
|
124 | - |
|
125 | - if (isset($this->fileIds[$cacheId][$absolutePath])) { |
|
126 | - return $this->fileIds[$cacheId][$absolutePath]; |
|
127 | - } |
|
128 | - |
|
129 | - $parentIds = []; |
|
130 | - if ($path !== $this->dirname($path)) { |
|
131 | - $parentIds = $this->getFileIds($cache, $this->dirname($path), $isExternalStorage); |
|
132 | - } elseif (!$isExternalStorage) { |
|
133 | - return []; |
|
134 | - } |
|
135 | - |
|
136 | - $fileId = $cache->getId($path); |
|
137 | - if ($fileId !== -1) { |
|
138 | - $parentIds[] = $fileId; |
|
139 | - } |
|
140 | - |
|
141 | - $this->fileIds[$cacheId][$absolutePath] = $parentIds; |
|
142 | - |
|
143 | - return $parentIds; |
|
144 | - } |
|
145 | - |
|
146 | - protected function dirname($path) { |
|
147 | - $dir = dirname($path); |
|
148 | - return $dir === '.' ? '' : $dir; |
|
149 | - } |
|
150 | - |
|
151 | - public function supportedEntities(): array { |
|
152 | - return [ File::class ]; |
|
153 | - } |
|
154 | - |
|
155 | - public function isAvailableForScope(int $scope): bool { |
|
156 | - return true; |
|
157 | - } |
|
24 | + use TFileCheck; |
|
25 | + |
|
26 | + /** @var array */ |
|
27 | + protected $fileIds; |
|
28 | + |
|
29 | + /** @var array */ |
|
30 | + protected $fileSystemTags; |
|
31 | + |
|
32 | + public function __construct( |
|
33 | + protected IL10N $l, |
|
34 | + protected ISystemTagManager $systemTagManager, |
|
35 | + protected ISystemTagObjectMapper $systemTagObjectMapper, |
|
36 | + protected IUserSession $userSession, |
|
37 | + protected IGroupManager $groupManager, |
|
38 | + ) { |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @param string $operator |
|
43 | + * @param string $value |
|
44 | + * @return bool |
|
45 | + */ |
|
46 | + public function executeCheck($operator, $value) { |
|
47 | + $systemTags = $this->getSystemTags(); |
|
48 | + return ($operator === 'is') === in_array($value, $systemTags); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * @param string $operator |
|
53 | + * @param string $value |
|
54 | + * @throws \UnexpectedValueException |
|
55 | + */ |
|
56 | + public function validateCheck($operator, $value) { |
|
57 | + if (!in_array($operator, ['is', '!is'])) { |
|
58 | + throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
59 | + } |
|
60 | + |
|
61 | + try { |
|
62 | + $tags = $this->systemTagManager->getTagsByIds($value); |
|
63 | + |
|
64 | + $user = $this->userSession->getUser(); |
|
65 | + $isAdmin = $user instanceof IUser && $this->groupManager->isAdmin($user->getUID()); |
|
66 | + |
|
67 | + if (!$isAdmin) { |
|
68 | + foreach ($tags as $tag) { |
|
69 | + if (!$tag->isUserVisible()) { |
|
70 | + throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 4); |
|
71 | + } |
|
72 | + } |
|
73 | + } |
|
74 | + } catch (TagNotFoundException $e) { |
|
75 | + throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 2); |
|
76 | + } catch (\InvalidArgumentException $e) { |
|
77 | + throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 3); |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Get the ids of the assigned system tags |
|
83 | + * @return string[] |
|
84 | + */ |
|
85 | + protected function getSystemTags() { |
|
86 | + $cache = $this->storage->getCache(); |
|
87 | + $fileIds = $this->getFileIds($cache, $this->path, !$this->storage->instanceOfStorage(IHomeStorage::class) || $this->storage->instanceOfStorage(SharedStorage::class)); |
|
88 | + |
|
89 | + $systemTags = []; |
|
90 | + foreach ($fileIds as $i => $fileId) { |
|
91 | + if (isset($this->fileSystemTags[$fileId])) { |
|
92 | + $systemTags[] = $this->fileSystemTags[$fileId]; |
|
93 | + unset($fileIds[$i]); |
|
94 | + } |
|
95 | + } |
|
96 | + |
|
97 | + if (!empty($fileIds)) { |
|
98 | + $mappedSystemTags = $this->systemTagObjectMapper->getTagIdsForObjects($fileIds, 'files'); |
|
99 | + foreach ($mappedSystemTags as $fileId => $fileSystemTags) { |
|
100 | + $this->fileSystemTags[$fileId] = $fileSystemTags; |
|
101 | + $systemTags[] = $fileSystemTags; |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + $systemTags = call_user_func_array('array_merge', $systemTags); |
|
106 | + $systemTags = array_unique($systemTags); |
|
107 | + return $systemTags; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Get the file ids of the given path and its parents |
|
112 | + * @param ICache $cache |
|
113 | + * @param string $path |
|
114 | + * @param bool $isExternalStorage |
|
115 | + * @return int[] |
|
116 | + */ |
|
117 | + protected function getFileIds(ICache $cache, $path, $isExternalStorage) { |
|
118 | + $cacheId = $cache->getNumericStorageId(); |
|
119 | + if ($this->storage->instanceOfStorage(Jail::class)) { |
|
120 | + $absolutePath = $this->storage->getUnjailedPath($path); |
|
121 | + } else { |
|
122 | + $absolutePath = $path; |
|
123 | + } |
|
124 | + |
|
125 | + if (isset($this->fileIds[$cacheId][$absolutePath])) { |
|
126 | + return $this->fileIds[$cacheId][$absolutePath]; |
|
127 | + } |
|
128 | + |
|
129 | + $parentIds = []; |
|
130 | + if ($path !== $this->dirname($path)) { |
|
131 | + $parentIds = $this->getFileIds($cache, $this->dirname($path), $isExternalStorage); |
|
132 | + } elseif (!$isExternalStorage) { |
|
133 | + return []; |
|
134 | + } |
|
135 | + |
|
136 | + $fileId = $cache->getId($path); |
|
137 | + if ($fileId !== -1) { |
|
138 | + $parentIds[] = $fileId; |
|
139 | + } |
|
140 | + |
|
141 | + $this->fileIds[$cacheId][$absolutePath] = $parentIds; |
|
142 | + |
|
143 | + return $parentIds; |
|
144 | + } |
|
145 | + |
|
146 | + protected function dirname($path) { |
|
147 | + $dir = dirname($path); |
|
148 | + return $dir === '.' ? '' : $dir; |
|
149 | + } |
|
150 | + |
|
151 | + public function supportedEntities(): array { |
|
152 | + return [ File::class ]; |
|
153 | + } |
|
154 | + |
|
155 | + public function isAvailableForScope(int $scope): bool { |
|
156 | + return true; |
|
157 | + } |
|
158 | 158 | } |
@@ -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 | } |