@@ -37,87 +37,87 @@ |
||
37 | 37 | */ |
38 | 38 | class FutureFile implements \Sabre\DAV\IFile { |
39 | 39 | |
40 | - /** @var Directory */ |
|
41 | - private $root; |
|
42 | - /** @var string */ |
|
43 | - private $name; |
|
40 | + /** @var Directory */ |
|
41 | + private $root; |
|
42 | + /** @var string */ |
|
43 | + private $name; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param Directory $root |
|
47 | - * @param string $name |
|
48 | - */ |
|
49 | - function __construct(Directory $root, $name) { |
|
50 | - $this->root = $root; |
|
51 | - $this->name = $name; |
|
52 | - } |
|
45 | + /** |
|
46 | + * @param Directory $root |
|
47 | + * @param string $name |
|
48 | + */ |
|
49 | + function __construct(Directory $root, $name) { |
|
50 | + $this->root = $root; |
|
51 | + $this->name = $name; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @inheritdoc |
|
56 | - */ |
|
57 | - function put($data) { |
|
58 | - throw new Forbidden('Permission denied to put into this file'); |
|
59 | - } |
|
54 | + /** |
|
55 | + * @inheritdoc |
|
56 | + */ |
|
57 | + function put($data) { |
|
58 | + throw new Forbidden('Permission denied to put into this file'); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @inheritdoc |
|
63 | - */ |
|
64 | - function get() { |
|
65 | - $nodes = $this->root->getChildren(); |
|
66 | - return AssemblyStream::wrap($nodes); |
|
67 | - } |
|
61 | + /** |
|
62 | + * @inheritdoc |
|
63 | + */ |
|
64 | + function get() { |
|
65 | + $nodes = $this->root->getChildren(); |
|
66 | + return AssemblyStream::wrap($nodes); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @inheritdoc |
|
71 | - */ |
|
72 | - function getContentType() { |
|
73 | - return 'application/octet-stream'; |
|
74 | - } |
|
69 | + /** |
|
70 | + * @inheritdoc |
|
71 | + */ |
|
72 | + function getContentType() { |
|
73 | + return 'application/octet-stream'; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @inheritdoc |
|
78 | - */ |
|
79 | - function getETag() { |
|
80 | - return $this->root->getETag(); |
|
81 | - } |
|
76 | + /** |
|
77 | + * @inheritdoc |
|
78 | + */ |
|
79 | + function getETag() { |
|
80 | + return $this->root->getETag(); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @inheritdoc |
|
85 | - */ |
|
86 | - function getSize() { |
|
87 | - $children = $this->root->getChildren(); |
|
88 | - $sizes = array_map(function($node) { |
|
89 | - /** @var IFile $node */ |
|
90 | - return $node->getSize(); |
|
91 | - }, $children); |
|
83 | + /** |
|
84 | + * @inheritdoc |
|
85 | + */ |
|
86 | + function getSize() { |
|
87 | + $children = $this->root->getChildren(); |
|
88 | + $sizes = array_map(function($node) { |
|
89 | + /** @var IFile $node */ |
|
90 | + return $node->getSize(); |
|
91 | + }, $children); |
|
92 | 92 | |
93 | - return array_sum($sizes); |
|
94 | - } |
|
93 | + return array_sum($sizes); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @inheritdoc |
|
98 | - */ |
|
99 | - function delete() { |
|
100 | - $this->root->delete(); |
|
101 | - } |
|
96 | + /** |
|
97 | + * @inheritdoc |
|
98 | + */ |
|
99 | + function delete() { |
|
100 | + $this->root->delete(); |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * @inheritdoc |
|
105 | - */ |
|
106 | - function getName() { |
|
107 | - return $this->name; |
|
108 | - } |
|
103 | + /** |
|
104 | + * @inheritdoc |
|
105 | + */ |
|
106 | + function getName() { |
|
107 | + return $this->name; |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * @inheritdoc |
|
112 | - */ |
|
113 | - function setName($name) { |
|
114 | - throw new Forbidden('Permission denied to rename this file'); |
|
115 | - } |
|
110 | + /** |
|
111 | + * @inheritdoc |
|
112 | + */ |
|
113 | + function setName($name) { |
|
114 | + throw new Forbidden('Permission denied to rename this file'); |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * @inheritdoc |
|
119 | - */ |
|
120 | - function getLastModified() { |
|
121 | - return $this->root->getLastModified(); |
|
122 | - } |
|
117 | + /** |
|
118 | + * @inheritdoc |
|
119 | + */ |
|
120 | + function getLastModified() { |
|
121 | + return $this->root->getLastModified(); |
|
122 | + } |
|
123 | 123 | } |
@@ -35,243 +35,243 @@ |
||
35 | 35 | */ |
36 | 36 | class AssemblyStream implements \Icewind\Streams\File { |
37 | 37 | |
38 | - /** @var resource */ |
|
39 | - private $context; |
|
40 | - |
|
41 | - /** @var IFile[] */ |
|
42 | - private $nodes; |
|
43 | - |
|
44 | - /** @var int */ |
|
45 | - private $pos = 0; |
|
46 | - |
|
47 | - /** @var array */ |
|
48 | - private $sortedNodes; |
|
49 | - |
|
50 | - /** @var int */ |
|
51 | - private $size; |
|
52 | - |
|
53 | - /** @var resource */ |
|
54 | - private $currentStream = null; |
|
55 | - |
|
56 | - /** |
|
57 | - * @param string $path |
|
58 | - * @param string $mode |
|
59 | - * @param int $options |
|
60 | - * @param string &$opened_path |
|
61 | - * @return bool |
|
62 | - */ |
|
63 | - public function stream_open($path, $mode, $options, &$opened_path) { |
|
64 | - $this->loadContext('assembly'); |
|
65 | - |
|
66 | - // sort the nodes |
|
67 | - $nodes = $this->nodes; |
|
68 | - // http://stackoverflow.com/a/10985500 |
|
69 | - @usort($nodes, function(IFile $a, IFile $b) { |
|
70 | - return strcmp($a->getName(), $b->getName()); |
|
71 | - }); |
|
72 | - $this->nodes = $nodes; |
|
73 | - |
|
74 | - // build additional information |
|
75 | - $this->sortedNodes = []; |
|
76 | - $start = 0; |
|
77 | - foreach($this->nodes as $node) { |
|
78 | - $size = $node->getSize(); |
|
79 | - $name = $node->getName(); |
|
80 | - $this->sortedNodes[$name] = ['node' => $node, 'start' => $start, 'end' => $start + $size]; |
|
81 | - $start += $size; |
|
82 | - $this->size = $start; |
|
83 | - } |
|
84 | - return true; |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * @param string $offset |
|
89 | - * @param int $whence |
|
90 | - * @return bool |
|
91 | - */ |
|
92 | - public function stream_seek($offset, $whence = SEEK_SET) { |
|
93 | - return false; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * @return int |
|
98 | - */ |
|
99 | - public function stream_tell() { |
|
100 | - return $this->pos; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * @param int $count |
|
105 | - * @return string |
|
106 | - */ |
|
107 | - public function stream_read($count) { |
|
108 | - do { |
|
109 | - if ($this->currentStream === null) { |
|
110 | - list($node, $posInNode) = $this->getNodeForPosition($this->pos); |
|
111 | - if (is_null($node)) { |
|
112 | - // reached last node, no more data |
|
113 | - return ''; |
|
114 | - } |
|
115 | - $this->currentStream = $this->getStream($node); |
|
116 | - fseek($this->currentStream, $posInNode); |
|
117 | - } |
|
118 | - |
|
119 | - $data = fread($this->currentStream, $count); |
|
120 | - // isset is faster than strlen |
|
121 | - if (isset($data[$count - 1])) { |
|
122 | - // we read the full count |
|
123 | - $read = $count; |
|
124 | - } else { |
|
125 | - // reaching end of stream, which happens less often so strlen is ok |
|
126 | - $read = strlen($data); |
|
127 | - } |
|
128 | - |
|
129 | - if (feof($this->currentStream)) { |
|
130 | - fclose($this->currentStream); |
|
131 | - $this->currentNode = null; |
|
132 | - $this->currentStream = null; |
|
133 | - } |
|
134 | - // if no data read, try again with the next node because |
|
135 | - // returning empty data can make the caller think there is no more |
|
136 | - // data left to read |
|
137 | - } while ($read === 0); |
|
138 | - |
|
139 | - // update position |
|
140 | - $this->pos += $read; |
|
141 | - return $data; |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * @param string $data |
|
146 | - * @return int |
|
147 | - */ |
|
148 | - public function stream_write($data) { |
|
149 | - return false; |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * @param int $option |
|
154 | - * @param int $arg1 |
|
155 | - * @param int $arg2 |
|
156 | - * @return bool |
|
157 | - */ |
|
158 | - public function stream_set_option($option, $arg1, $arg2) { |
|
159 | - return false; |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * @param int $size |
|
164 | - * @return bool |
|
165 | - */ |
|
166 | - public function stream_truncate($size) { |
|
167 | - return false; |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * @return array |
|
172 | - */ |
|
173 | - public function stream_stat() { |
|
174 | - return []; |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @param int $operation |
|
179 | - * @return bool |
|
180 | - */ |
|
181 | - public function stream_lock($operation) { |
|
182 | - return false; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @return bool |
|
187 | - */ |
|
188 | - public function stream_flush() { |
|
189 | - return false; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * @return bool |
|
194 | - */ |
|
195 | - public function stream_eof() { |
|
196 | - return $this->pos >= $this->size; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * @return bool |
|
201 | - */ |
|
202 | - public function stream_close() { |
|
203 | - return true; |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * Load the source from the stream context and return the context options |
|
209 | - * |
|
210 | - * @param string $name |
|
211 | - * @return array |
|
212 | - * @throws \Exception |
|
213 | - */ |
|
214 | - protected function loadContext($name) { |
|
215 | - $context = stream_context_get_options($this->context); |
|
216 | - if (isset($context[$name])) { |
|
217 | - $context = $context[$name]; |
|
218 | - } else { |
|
219 | - throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set'); |
|
220 | - } |
|
221 | - if (isset($context['nodes']) and is_array($context['nodes'])) { |
|
222 | - $this->nodes = $context['nodes']; |
|
223 | - } else { |
|
224 | - throw new \BadMethodCallException('Invalid context, nodes not set'); |
|
225 | - } |
|
226 | - return $context; |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * @param IFile[] $nodes |
|
231 | - * @return resource |
|
232 | - * |
|
233 | - * @throws \BadMethodCallException |
|
234 | - */ |
|
235 | - public static function wrap(array $nodes) { |
|
236 | - $context = stream_context_create([ |
|
237 | - 'assembly' => [ |
|
238 | - 'nodes' => $nodes] |
|
239 | - ]); |
|
240 | - stream_wrapper_register('assembly', '\OCA\DAV\Upload\AssemblyStream'); |
|
241 | - try { |
|
242 | - $wrapped = fopen('assembly://', 'r', null, $context); |
|
243 | - } catch (\BadMethodCallException $e) { |
|
244 | - stream_wrapper_unregister('assembly'); |
|
245 | - throw $e; |
|
246 | - } |
|
247 | - stream_wrapper_unregister('assembly'); |
|
248 | - return $wrapped; |
|
249 | - } |
|
250 | - |
|
251 | - /** |
|
252 | - * @param $pos |
|
253 | - * @return IFile | null |
|
254 | - */ |
|
255 | - private function getNodeForPosition($pos) { |
|
256 | - foreach($this->sortedNodes as $node) { |
|
257 | - if ($pos >= $node['start'] && $pos < $node['end']) { |
|
258 | - return [$node['node'], $pos - $node['start']]; |
|
259 | - } |
|
260 | - } |
|
261 | - return null; |
|
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * @param IFile $node |
|
266 | - * @return resource |
|
267 | - */ |
|
268 | - private function getStream(IFile $node) { |
|
269 | - $data = $node->get(); |
|
270 | - if (is_resource($data)) { |
|
271 | - return $data; |
|
272 | - } |
|
273 | - |
|
274 | - return fopen('data://text/plain,' . $data,'r'); |
|
275 | - } |
|
38 | + /** @var resource */ |
|
39 | + private $context; |
|
40 | + |
|
41 | + /** @var IFile[] */ |
|
42 | + private $nodes; |
|
43 | + |
|
44 | + /** @var int */ |
|
45 | + private $pos = 0; |
|
46 | + |
|
47 | + /** @var array */ |
|
48 | + private $sortedNodes; |
|
49 | + |
|
50 | + /** @var int */ |
|
51 | + private $size; |
|
52 | + |
|
53 | + /** @var resource */ |
|
54 | + private $currentStream = null; |
|
55 | + |
|
56 | + /** |
|
57 | + * @param string $path |
|
58 | + * @param string $mode |
|
59 | + * @param int $options |
|
60 | + * @param string &$opened_path |
|
61 | + * @return bool |
|
62 | + */ |
|
63 | + public function stream_open($path, $mode, $options, &$opened_path) { |
|
64 | + $this->loadContext('assembly'); |
|
65 | + |
|
66 | + // sort the nodes |
|
67 | + $nodes = $this->nodes; |
|
68 | + // http://stackoverflow.com/a/10985500 |
|
69 | + @usort($nodes, function(IFile $a, IFile $b) { |
|
70 | + return strcmp($a->getName(), $b->getName()); |
|
71 | + }); |
|
72 | + $this->nodes = $nodes; |
|
73 | + |
|
74 | + // build additional information |
|
75 | + $this->sortedNodes = []; |
|
76 | + $start = 0; |
|
77 | + foreach($this->nodes as $node) { |
|
78 | + $size = $node->getSize(); |
|
79 | + $name = $node->getName(); |
|
80 | + $this->sortedNodes[$name] = ['node' => $node, 'start' => $start, 'end' => $start + $size]; |
|
81 | + $start += $size; |
|
82 | + $this->size = $start; |
|
83 | + } |
|
84 | + return true; |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * @param string $offset |
|
89 | + * @param int $whence |
|
90 | + * @return bool |
|
91 | + */ |
|
92 | + public function stream_seek($offset, $whence = SEEK_SET) { |
|
93 | + return false; |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * @return int |
|
98 | + */ |
|
99 | + public function stream_tell() { |
|
100 | + return $this->pos; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * @param int $count |
|
105 | + * @return string |
|
106 | + */ |
|
107 | + public function stream_read($count) { |
|
108 | + do { |
|
109 | + if ($this->currentStream === null) { |
|
110 | + list($node, $posInNode) = $this->getNodeForPosition($this->pos); |
|
111 | + if (is_null($node)) { |
|
112 | + // reached last node, no more data |
|
113 | + return ''; |
|
114 | + } |
|
115 | + $this->currentStream = $this->getStream($node); |
|
116 | + fseek($this->currentStream, $posInNode); |
|
117 | + } |
|
118 | + |
|
119 | + $data = fread($this->currentStream, $count); |
|
120 | + // isset is faster than strlen |
|
121 | + if (isset($data[$count - 1])) { |
|
122 | + // we read the full count |
|
123 | + $read = $count; |
|
124 | + } else { |
|
125 | + // reaching end of stream, which happens less often so strlen is ok |
|
126 | + $read = strlen($data); |
|
127 | + } |
|
128 | + |
|
129 | + if (feof($this->currentStream)) { |
|
130 | + fclose($this->currentStream); |
|
131 | + $this->currentNode = null; |
|
132 | + $this->currentStream = null; |
|
133 | + } |
|
134 | + // if no data read, try again with the next node because |
|
135 | + // returning empty data can make the caller think there is no more |
|
136 | + // data left to read |
|
137 | + } while ($read === 0); |
|
138 | + |
|
139 | + // update position |
|
140 | + $this->pos += $read; |
|
141 | + return $data; |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * @param string $data |
|
146 | + * @return int |
|
147 | + */ |
|
148 | + public function stream_write($data) { |
|
149 | + return false; |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * @param int $option |
|
154 | + * @param int $arg1 |
|
155 | + * @param int $arg2 |
|
156 | + * @return bool |
|
157 | + */ |
|
158 | + public function stream_set_option($option, $arg1, $arg2) { |
|
159 | + return false; |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * @param int $size |
|
164 | + * @return bool |
|
165 | + */ |
|
166 | + public function stream_truncate($size) { |
|
167 | + return false; |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * @return array |
|
172 | + */ |
|
173 | + public function stream_stat() { |
|
174 | + return []; |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @param int $operation |
|
179 | + * @return bool |
|
180 | + */ |
|
181 | + public function stream_lock($operation) { |
|
182 | + return false; |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * @return bool |
|
187 | + */ |
|
188 | + public function stream_flush() { |
|
189 | + return false; |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * @return bool |
|
194 | + */ |
|
195 | + public function stream_eof() { |
|
196 | + return $this->pos >= $this->size; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * @return bool |
|
201 | + */ |
|
202 | + public function stream_close() { |
|
203 | + return true; |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * Load the source from the stream context and return the context options |
|
209 | + * |
|
210 | + * @param string $name |
|
211 | + * @return array |
|
212 | + * @throws \Exception |
|
213 | + */ |
|
214 | + protected function loadContext($name) { |
|
215 | + $context = stream_context_get_options($this->context); |
|
216 | + if (isset($context[$name])) { |
|
217 | + $context = $context[$name]; |
|
218 | + } else { |
|
219 | + throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set'); |
|
220 | + } |
|
221 | + if (isset($context['nodes']) and is_array($context['nodes'])) { |
|
222 | + $this->nodes = $context['nodes']; |
|
223 | + } else { |
|
224 | + throw new \BadMethodCallException('Invalid context, nodes not set'); |
|
225 | + } |
|
226 | + return $context; |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * @param IFile[] $nodes |
|
231 | + * @return resource |
|
232 | + * |
|
233 | + * @throws \BadMethodCallException |
|
234 | + */ |
|
235 | + public static function wrap(array $nodes) { |
|
236 | + $context = stream_context_create([ |
|
237 | + 'assembly' => [ |
|
238 | + 'nodes' => $nodes] |
|
239 | + ]); |
|
240 | + stream_wrapper_register('assembly', '\OCA\DAV\Upload\AssemblyStream'); |
|
241 | + try { |
|
242 | + $wrapped = fopen('assembly://', 'r', null, $context); |
|
243 | + } catch (\BadMethodCallException $e) { |
|
244 | + stream_wrapper_unregister('assembly'); |
|
245 | + throw $e; |
|
246 | + } |
|
247 | + stream_wrapper_unregister('assembly'); |
|
248 | + return $wrapped; |
|
249 | + } |
|
250 | + |
|
251 | + /** |
|
252 | + * @param $pos |
|
253 | + * @return IFile | null |
|
254 | + */ |
|
255 | + private function getNodeForPosition($pos) { |
|
256 | + foreach($this->sortedNodes as $node) { |
|
257 | + if ($pos >= $node['start'] && $pos < $node['end']) { |
|
258 | + return [$node['node'], $pos - $node['start']]; |
|
259 | + } |
|
260 | + } |
|
261 | + return null; |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * @param IFile $node |
|
266 | + * @return resource |
|
267 | + */ |
|
268 | + private function getStream(IFile $node) { |
|
269 | + $data = $node->get(); |
|
270 | + if (is_resource($data)) { |
|
271 | + return $data; |
|
272 | + } |
|
273 | + |
|
274 | + return fopen('data://text/plain,' . $data,'r'); |
|
275 | + } |
|
276 | 276 | |
277 | 277 | } |
@@ -31,169 +31,169 @@ |
||
31 | 31 | |
32 | 32 | class Calendar extends Base { |
33 | 33 | |
34 | - const SUBJECT_ADD = 'calendar_add'; |
|
35 | - const SUBJECT_UPDATE = 'calendar_update'; |
|
36 | - const SUBJECT_DELETE = 'calendar_delete'; |
|
37 | - const SUBJECT_SHARE_USER = 'calendar_user_share'; |
|
38 | - const SUBJECT_SHARE_GROUP = 'calendar_group_share'; |
|
39 | - const SUBJECT_UNSHARE_USER = 'calendar_user_unshare'; |
|
40 | - const SUBJECT_UNSHARE_GROUP = 'calendar_group_unshare'; |
|
41 | - |
|
42 | - /** @var IFactory */ |
|
43 | - protected $languageFactory; |
|
44 | - |
|
45 | - /** @var IL10N */ |
|
46 | - protected $l; |
|
47 | - |
|
48 | - /** @var IURLGenerator */ |
|
49 | - protected $url; |
|
50 | - |
|
51 | - /** @var IManager */ |
|
52 | - protected $activityManager; |
|
53 | - |
|
54 | - /** @var IEventMerger */ |
|
55 | - protected $eventMerger; |
|
56 | - |
|
57 | - /** |
|
58 | - * @param IFactory $languageFactory |
|
59 | - * @param IURLGenerator $url |
|
60 | - * @param IManager $activityManager |
|
61 | - * @param IUserManager $userManager |
|
62 | - * @param IEventMerger $eventMerger |
|
63 | - */ |
|
64 | - public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IEventMerger $eventMerger) { |
|
65 | - parent::__construct($userManager); |
|
66 | - $this->languageFactory = $languageFactory; |
|
67 | - $this->url = $url; |
|
68 | - $this->activityManager = $activityManager; |
|
69 | - $this->eventMerger = $eventMerger; |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * @param string $language |
|
74 | - * @param IEvent $event |
|
75 | - * @param IEvent|null $previousEvent |
|
76 | - * @return IEvent |
|
77 | - * @throws \InvalidArgumentException |
|
78 | - * @since 11.0.0 |
|
79 | - */ |
|
80 | - public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
81 | - if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar') { |
|
82 | - throw new \InvalidArgumentException(); |
|
83 | - } |
|
84 | - |
|
85 | - $this->l = $this->languageFactory->get('dav', $language); |
|
86 | - |
|
87 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg'))); |
|
88 | - |
|
89 | - if ($event->getSubject() === self::SUBJECT_ADD) { |
|
90 | - $subject = $this->l->t('{actor} created calendar {calendar}'); |
|
91 | - } else if ($event->getSubject() === self::SUBJECT_ADD . '_self') { |
|
92 | - $subject = $this->l->t('You created calendar {calendar}'); |
|
93 | - } else if ($event->getSubject() === self::SUBJECT_DELETE) { |
|
94 | - $subject = $this->l->t('{actor} deleted calendar {calendar}'); |
|
95 | - } else if ($event->getSubject() === self::SUBJECT_DELETE . '_self') { |
|
96 | - $subject = $this->l->t('You deleted calendar {calendar}'); |
|
97 | - } else if ($event->getSubject() === self::SUBJECT_UPDATE) { |
|
98 | - $subject = $this->l->t('{actor} updated calendar {calendar}'); |
|
99 | - } else if ($event->getSubject() === self::SUBJECT_UPDATE . '_self') { |
|
100 | - $subject = $this->l->t('You updated calendar {calendar}'); |
|
101 | - |
|
102 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_USER) { |
|
103 | - $subject = $this->l->t('{actor} shared calendar {calendar} with you'); |
|
104 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_USER . '_you') { |
|
105 | - $subject = $this->l->t('You shared calendar {calendar} with {user}'); |
|
106 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_USER . '_by') { |
|
107 | - $subject = $this->l->t('{actor} shared calendar {calendar} with {user}'); |
|
108 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER) { |
|
109 | - $subject = $this->l->t('{actor} unshared calendar {calendar} from you'); |
|
110 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_you') { |
|
111 | - $subject = $this->l->t('You unshared calendar {calendar} from {user}'); |
|
112 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_by') { |
|
113 | - $subject = $this->l->t('{actor} unshared calendar {calendar} from {user}'); |
|
114 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_self') { |
|
115 | - $subject = $this->l->t('{actor} unshared calendar {calendar} from themselves'); |
|
116 | - |
|
117 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_you') { |
|
118 | - $subject = $this->l->t('You shared calendar {calendar} with group {group}'); |
|
119 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_by') { |
|
120 | - $subject = $this->l->t('{actor} shared calendar {calendar} with group {group}'); |
|
121 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_you') { |
|
122 | - $subject = $this->l->t('You unshared calendar {calendar} from group {group}'); |
|
123 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_by') { |
|
124 | - $subject = $this->l->t('{actor} unshared calendar {calendar} from group {group}'); |
|
125 | - } else { |
|
126 | - throw new \InvalidArgumentException(); |
|
127 | - } |
|
128 | - |
|
129 | - $parsedParameters = $this->getParameters($event); |
|
130 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
131 | - |
|
132 | - $event = $this->eventMerger->mergeEvents('calendar', $event, $previousEvent); |
|
133 | - |
|
134 | - if ($event->getChildEvent() === null) { |
|
135 | - if (isset($parsedParameters['user'])) { |
|
136 | - // Couldn't group by calendar, maybe we can group by users |
|
137 | - $event = $this->eventMerger->mergeEvents('user', $event, $previousEvent); |
|
138 | - } else if (isset($parsedParameters['group'])) { |
|
139 | - // Couldn't group by calendar, maybe we can group by groups |
|
140 | - $event = $this->eventMerger->mergeEvents('group', $event, $previousEvent); |
|
141 | - } |
|
142 | - } |
|
143 | - |
|
144 | - return $event; |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * @param IEvent $event |
|
149 | - * @return array |
|
150 | - */ |
|
151 | - protected function getParameters(IEvent $event) { |
|
152 | - $subject = $event->getSubject(); |
|
153 | - $parameters = $event->getSubjectParameters(); |
|
154 | - |
|
155 | - switch ($subject) { |
|
156 | - case self::SUBJECT_ADD: |
|
157 | - case self::SUBJECT_ADD . '_self': |
|
158 | - case self::SUBJECT_DELETE: |
|
159 | - case self::SUBJECT_DELETE . '_self': |
|
160 | - case self::SUBJECT_UPDATE: |
|
161 | - case self::SUBJECT_UPDATE . '_self': |
|
162 | - case self::SUBJECT_SHARE_USER: |
|
163 | - case self::SUBJECT_UNSHARE_USER: |
|
164 | - case self::SUBJECT_UNSHARE_USER . '_self': |
|
165 | - return [ |
|
166 | - 'actor' => $this->generateUserParameter($parameters[0]), |
|
167 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
168 | - ]; |
|
169 | - case self::SUBJECT_SHARE_USER . '_you': |
|
170 | - case self::SUBJECT_UNSHARE_USER . '_you': |
|
171 | - return [ |
|
172 | - 'user' => $this->generateUserParameter($parameters[0]), |
|
173 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
174 | - ]; |
|
175 | - case self::SUBJECT_SHARE_USER . '_by': |
|
176 | - case self::SUBJECT_UNSHARE_USER . '_by': |
|
177 | - return [ |
|
178 | - 'user' => $this->generateUserParameter($parameters[0]), |
|
179 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
180 | - 'actor' => $this->generateUserParameter($parameters[2]), |
|
181 | - ]; |
|
182 | - case self::SUBJECT_SHARE_GROUP . '_you': |
|
183 | - case self::SUBJECT_UNSHARE_GROUP . '_you': |
|
184 | - return [ |
|
185 | - 'group' => $this->generateGroupParameter($parameters[0]), |
|
186 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
187 | - ]; |
|
188 | - case self::SUBJECT_SHARE_GROUP . '_by': |
|
189 | - case self::SUBJECT_UNSHARE_GROUP . '_by': |
|
190 | - return [ |
|
191 | - 'group' => $this->generateGroupParameter($parameters[0]), |
|
192 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
193 | - 'actor' => $this->generateUserParameter($parameters[2]), |
|
194 | - ]; |
|
195 | - } |
|
196 | - |
|
197 | - throw new \InvalidArgumentException(); |
|
198 | - } |
|
34 | + const SUBJECT_ADD = 'calendar_add'; |
|
35 | + const SUBJECT_UPDATE = 'calendar_update'; |
|
36 | + const SUBJECT_DELETE = 'calendar_delete'; |
|
37 | + const SUBJECT_SHARE_USER = 'calendar_user_share'; |
|
38 | + const SUBJECT_SHARE_GROUP = 'calendar_group_share'; |
|
39 | + const SUBJECT_UNSHARE_USER = 'calendar_user_unshare'; |
|
40 | + const SUBJECT_UNSHARE_GROUP = 'calendar_group_unshare'; |
|
41 | + |
|
42 | + /** @var IFactory */ |
|
43 | + protected $languageFactory; |
|
44 | + |
|
45 | + /** @var IL10N */ |
|
46 | + protected $l; |
|
47 | + |
|
48 | + /** @var IURLGenerator */ |
|
49 | + protected $url; |
|
50 | + |
|
51 | + /** @var IManager */ |
|
52 | + protected $activityManager; |
|
53 | + |
|
54 | + /** @var IEventMerger */ |
|
55 | + protected $eventMerger; |
|
56 | + |
|
57 | + /** |
|
58 | + * @param IFactory $languageFactory |
|
59 | + * @param IURLGenerator $url |
|
60 | + * @param IManager $activityManager |
|
61 | + * @param IUserManager $userManager |
|
62 | + * @param IEventMerger $eventMerger |
|
63 | + */ |
|
64 | + public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IEventMerger $eventMerger) { |
|
65 | + parent::__construct($userManager); |
|
66 | + $this->languageFactory = $languageFactory; |
|
67 | + $this->url = $url; |
|
68 | + $this->activityManager = $activityManager; |
|
69 | + $this->eventMerger = $eventMerger; |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * @param string $language |
|
74 | + * @param IEvent $event |
|
75 | + * @param IEvent|null $previousEvent |
|
76 | + * @return IEvent |
|
77 | + * @throws \InvalidArgumentException |
|
78 | + * @since 11.0.0 |
|
79 | + */ |
|
80 | + public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
81 | + if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar') { |
|
82 | + throw new \InvalidArgumentException(); |
|
83 | + } |
|
84 | + |
|
85 | + $this->l = $this->languageFactory->get('dav', $language); |
|
86 | + |
|
87 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg'))); |
|
88 | + |
|
89 | + if ($event->getSubject() === self::SUBJECT_ADD) { |
|
90 | + $subject = $this->l->t('{actor} created calendar {calendar}'); |
|
91 | + } else if ($event->getSubject() === self::SUBJECT_ADD . '_self') { |
|
92 | + $subject = $this->l->t('You created calendar {calendar}'); |
|
93 | + } else if ($event->getSubject() === self::SUBJECT_DELETE) { |
|
94 | + $subject = $this->l->t('{actor} deleted calendar {calendar}'); |
|
95 | + } else if ($event->getSubject() === self::SUBJECT_DELETE . '_self') { |
|
96 | + $subject = $this->l->t('You deleted calendar {calendar}'); |
|
97 | + } else if ($event->getSubject() === self::SUBJECT_UPDATE) { |
|
98 | + $subject = $this->l->t('{actor} updated calendar {calendar}'); |
|
99 | + } else if ($event->getSubject() === self::SUBJECT_UPDATE . '_self') { |
|
100 | + $subject = $this->l->t('You updated calendar {calendar}'); |
|
101 | + |
|
102 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_USER) { |
|
103 | + $subject = $this->l->t('{actor} shared calendar {calendar} with you'); |
|
104 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_USER . '_you') { |
|
105 | + $subject = $this->l->t('You shared calendar {calendar} with {user}'); |
|
106 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_USER . '_by') { |
|
107 | + $subject = $this->l->t('{actor} shared calendar {calendar} with {user}'); |
|
108 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER) { |
|
109 | + $subject = $this->l->t('{actor} unshared calendar {calendar} from you'); |
|
110 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_you') { |
|
111 | + $subject = $this->l->t('You unshared calendar {calendar} from {user}'); |
|
112 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_by') { |
|
113 | + $subject = $this->l->t('{actor} unshared calendar {calendar} from {user}'); |
|
114 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_self') { |
|
115 | + $subject = $this->l->t('{actor} unshared calendar {calendar} from themselves'); |
|
116 | + |
|
117 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_you') { |
|
118 | + $subject = $this->l->t('You shared calendar {calendar} with group {group}'); |
|
119 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_by') { |
|
120 | + $subject = $this->l->t('{actor} shared calendar {calendar} with group {group}'); |
|
121 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_you') { |
|
122 | + $subject = $this->l->t('You unshared calendar {calendar} from group {group}'); |
|
123 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_by') { |
|
124 | + $subject = $this->l->t('{actor} unshared calendar {calendar} from group {group}'); |
|
125 | + } else { |
|
126 | + throw new \InvalidArgumentException(); |
|
127 | + } |
|
128 | + |
|
129 | + $parsedParameters = $this->getParameters($event); |
|
130 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
131 | + |
|
132 | + $event = $this->eventMerger->mergeEvents('calendar', $event, $previousEvent); |
|
133 | + |
|
134 | + if ($event->getChildEvent() === null) { |
|
135 | + if (isset($parsedParameters['user'])) { |
|
136 | + // Couldn't group by calendar, maybe we can group by users |
|
137 | + $event = $this->eventMerger->mergeEvents('user', $event, $previousEvent); |
|
138 | + } else if (isset($parsedParameters['group'])) { |
|
139 | + // Couldn't group by calendar, maybe we can group by groups |
|
140 | + $event = $this->eventMerger->mergeEvents('group', $event, $previousEvent); |
|
141 | + } |
|
142 | + } |
|
143 | + |
|
144 | + return $event; |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * @param IEvent $event |
|
149 | + * @return array |
|
150 | + */ |
|
151 | + protected function getParameters(IEvent $event) { |
|
152 | + $subject = $event->getSubject(); |
|
153 | + $parameters = $event->getSubjectParameters(); |
|
154 | + |
|
155 | + switch ($subject) { |
|
156 | + case self::SUBJECT_ADD: |
|
157 | + case self::SUBJECT_ADD . '_self': |
|
158 | + case self::SUBJECT_DELETE: |
|
159 | + case self::SUBJECT_DELETE . '_self': |
|
160 | + case self::SUBJECT_UPDATE: |
|
161 | + case self::SUBJECT_UPDATE . '_self': |
|
162 | + case self::SUBJECT_SHARE_USER: |
|
163 | + case self::SUBJECT_UNSHARE_USER: |
|
164 | + case self::SUBJECT_UNSHARE_USER . '_self': |
|
165 | + return [ |
|
166 | + 'actor' => $this->generateUserParameter($parameters[0]), |
|
167 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
168 | + ]; |
|
169 | + case self::SUBJECT_SHARE_USER . '_you': |
|
170 | + case self::SUBJECT_UNSHARE_USER . '_you': |
|
171 | + return [ |
|
172 | + 'user' => $this->generateUserParameter($parameters[0]), |
|
173 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
174 | + ]; |
|
175 | + case self::SUBJECT_SHARE_USER . '_by': |
|
176 | + case self::SUBJECT_UNSHARE_USER . '_by': |
|
177 | + return [ |
|
178 | + 'user' => $this->generateUserParameter($parameters[0]), |
|
179 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
180 | + 'actor' => $this->generateUserParameter($parameters[2]), |
|
181 | + ]; |
|
182 | + case self::SUBJECT_SHARE_GROUP . '_you': |
|
183 | + case self::SUBJECT_UNSHARE_GROUP . '_you': |
|
184 | + return [ |
|
185 | + 'group' => $this->generateGroupParameter($parameters[0]), |
|
186 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
187 | + ]; |
|
188 | + case self::SUBJECT_SHARE_GROUP . '_by': |
|
189 | + case self::SUBJECT_UNSHARE_GROUP . '_by': |
|
190 | + return [ |
|
191 | + 'group' => $this->generateGroupParameter($parameters[0]), |
|
192 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
193 | + 'actor' => $this->generateUserParameter($parameters[2]), |
|
194 | + ]; |
|
195 | + } |
|
196 | + |
|
197 | + throw new \InvalidArgumentException(); |
|
198 | + } |
|
199 | 199 | } |
@@ -28,102 +28,102 @@ |
||
28 | 28 | |
29 | 29 | abstract class Base implements IProvider { |
30 | 30 | |
31 | - /** @var IUserManager */ |
|
32 | - protected $userManager; |
|
31 | + /** @var IUserManager */ |
|
32 | + protected $userManager; |
|
33 | 33 | |
34 | - /** @var string[] cached displayNames - key is the UID and value the displayname */ |
|
35 | - protected $displayNames = []; |
|
34 | + /** @var string[] cached displayNames - key is the UID and value the displayname */ |
|
35 | + protected $displayNames = []; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @param IUserManager $userManager |
|
39 | - */ |
|
40 | - public function __construct(IUserManager $userManager) { |
|
41 | - $this->userManager = $userManager; |
|
42 | - } |
|
37 | + /** |
|
38 | + * @param IUserManager $userManager |
|
39 | + */ |
|
40 | + public function __construct(IUserManager $userManager) { |
|
41 | + $this->userManager = $userManager; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param IEvent $event |
|
46 | - * @param string $subject |
|
47 | - * @param array $parameters |
|
48 | - */ |
|
49 | - protected function setSubjects(IEvent $event, $subject, array $parameters) { |
|
50 | - $placeholders = $replacements = []; |
|
51 | - foreach ($parameters as $placeholder => $parameter) { |
|
52 | - $placeholders[] = '{' . $placeholder . '}'; |
|
53 | - $replacements[] = $parameter['name']; |
|
54 | - } |
|
44 | + /** |
|
45 | + * @param IEvent $event |
|
46 | + * @param string $subject |
|
47 | + * @param array $parameters |
|
48 | + */ |
|
49 | + protected function setSubjects(IEvent $event, $subject, array $parameters) { |
|
50 | + $placeholders = $replacements = []; |
|
51 | + foreach ($parameters as $placeholder => $parameter) { |
|
52 | + $placeholders[] = '{' . $placeholder . '}'; |
|
53 | + $replacements[] = $parameter['name']; |
|
54 | + } |
|
55 | 55 | |
56 | - $event->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
57 | - ->setRichSubject($subject, $parameters); |
|
58 | - } |
|
56 | + $event->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
57 | + ->setRichSubject($subject, $parameters); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param array $eventData |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - protected function generateObjectParameter($eventData) { |
|
65 | - if (!is_array($eventData) || !isset($eventData['id']) || !isset($eventData['name'])) { |
|
66 | - throw new \InvalidArgumentException(); |
|
67 | - }; |
|
60 | + /** |
|
61 | + * @param array $eventData |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + protected function generateObjectParameter($eventData) { |
|
65 | + if (!is_array($eventData) || !isset($eventData['id']) || !isset($eventData['name'])) { |
|
66 | + throw new \InvalidArgumentException(); |
|
67 | + }; |
|
68 | 68 | |
69 | - return [ |
|
70 | - 'type' => 'calendar-event', |
|
71 | - 'id' => $eventData['id'], |
|
72 | - 'name' => $eventData['name'], |
|
73 | - ]; |
|
74 | - } |
|
69 | + return [ |
|
70 | + 'type' => 'calendar-event', |
|
71 | + 'id' => $eventData['id'], |
|
72 | + 'name' => $eventData['name'], |
|
73 | + ]; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param int $id |
|
78 | - * @param string $name |
|
79 | - * @return array |
|
80 | - */ |
|
81 | - protected function generateCalendarParameter($id, $name) { |
|
82 | - return [ |
|
83 | - 'type' => 'calendar', |
|
84 | - 'id' => $id, |
|
85 | - 'name' => $name, |
|
86 | - ]; |
|
87 | - } |
|
76 | + /** |
|
77 | + * @param int $id |
|
78 | + * @param string $name |
|
79 | + * @return array |
|
80 | + */ |
|
81 | + protected function generateCalendarParameter($id, $name) { |
|
82 | + return [ |
|
83 | + 'type' => 'calendar', |
|
84 | + 'id' => $id, |
|
85 | + 'name' => $name, |
|
86 | + ]; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @param string $id |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - protected function generateGroupParameter($id) { |
|
94 | - return [ |
|
95 | - 'type' => 'group', |
|
96 | - 'id' => $id, |
|
97 | - 'name' => $id, |
|
98 | - ]; |
|
99 | - } |
|
89 | + /** |
|
90 | + * @param string $id |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + protected function generateGroupParameter($id) { |
|
94 | + return [ |
|
95 | + 'type' => 'group', |
|
96 | + 'id' => $id, |
|
97 | + 'name' => $id, |
|
98 | + ]; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @param string $uid |
|
103 | - * @return array |
|
104 | - */ |
|
105 | - protected function generateUserParameter($uid) { |
|
106 | - if (!isset($this->displayNames[$uid])) { |
|
107 | - $this->displayNames[$uid] = $this->getDisplayName($uid); |
|
108 | - } |
|
101 | + /** |
|
102 | + * @param string $uid |
|
103 | + * @return array |
|
104 | + */ |
|
105 | + protected function generateUserParameter($uid) { |
|
106 | + if (!isset($this->displayNames[$uid])) { |
|
107 | + $this->displayNames[$uid] = $this->getDisplayName($uid); |
|
108 | + } |
|
109 | 109 | |
110 | - return [ |
|
111 | - 'type' => 'user', |
|
112 | - 'id' => $uid, |
|
113 | - 'name' => $this->displayNames[$uid], |
|
114 | - ]; |
|
115 | - } |
|
110 | + return [ |
|
111 | + 'type' => 'user', |
|
112 | + 'id' => $uid, |
|
113 | + 'name' => $this->displayNames[$uid], |
|
114 | + ]; |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * @param string $uid |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - protected function getDisplayName($uid) { |
|
122 | - $user = $this->userManager->get($uid); |
|
123 | - if ($user instanceof IUser) { |
|
124 | - return $user->getDisplayName(); |
|
125 | - } else { |
|
126 | - return $uid; |
|
127 | - } |
|
128 | - } |
|
117 | + /** |
|
118 | + * @param string $uid |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + protected function getDisplayName($uid) { |
|
122 | + $user = $this->userManager->get($uid); |
|
123 | + if ($user instanceof IUser) { |
|
124 | + return $user->getDisplayName(); |
|
125 | + } else { |
|
126 | + return $uid; |
|
127 | + } |
|
128 | + } |
|
129 | 129 | } |
@@ -31,107 +31,107 @@ |
||
31 | 31 | |
32 | 32 | class Event extends Base { |
33 | 33 | |
34 | - const SUBJECT_OBJECT_ADD = 'object_add'; |
|
35 | - const SUBJECT_OBJECT_UPDATE = 'object_update'; |
|
36 | - const SUBJECT_OBJECT_DELETE = 'object_delete'; |
|
37 | - |
|
38 | - /** @var IFactory */ |
|
39 | - protected $languageFactory; |
|
40 | - |
|
41 | - /** @var IL10N */ |
|
42 | - protected $l; |
|
43 | - |
|
44 | - /** @var IURLGenerator */ |
|
45 | - protected $url; |
|
46 | - |
|
47 | - /** @var IManager */ |
|
48 | - protected $activityManager; |
|
49 | - |
|
50 | - /** @var IEventMerger */ |
|
51 | - protected $eventMerger; |
|
52 | - |
|
53 | - /** |
|
54 | - * @param IFactory $languageFactory |
|
55 | - * @param IURLGenerator $url |
|
56 | - * @param IManager $activityManager |
|
57 | - * @param IUserManager $userManager |
|
58 | - * @param IEventMerger $eventMerger |
|
59 | - */ |
|
60 | - public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IEventMerger $eventMerger) { |
|
61 | - parent::__construct($userManager); |
|
62 | - $this->languageFactory = $languageFactory; |
|
63 | - $this->url = $url; |
|
64 | - $this->activityManager = $activityManager; |
|
65 | - $this->eventMerger = $eventMerger; |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @param string $language |
|
70 | - * @param IEvent $event |
|
71 | - * @param IEvent|null $previousEvent |
|
72 | - * @return IEvent |
|
73 | - * @throws \InvalidArgumentException |
|
74 | - * @since 11.0.0 |
|
75 | - */ |
|
76 | - public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
77 | - if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_event') { |
|
78 | - throw new \InvalidArgumentException(); |
|
79 | - } |
|
80 | - |
|
81 | - $this->l = $this->languageFactory->get('dav', $language); |
|
82 | - |
|
83 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg'))); |
|
84 | - |
|
85 | - if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_event') { |
|
86 | - $subject = $this->l->t('{actor} created event {event} in calendar {calendar}'); |
|
87 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_event_self') { |
|
88 | - $subject = $this->l->t('You created event {event} in calendar {calendar}'); |
|
89 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_event') { |
|
90 | - $subject = $this->l->t('{actor} deleted event {event} from calendar {calendar}'); |
|
91 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_event_self') { |
|
92 | - $subject = $this->l->t('You deleted event {event} from calendar {calendar}'); |
|
93 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_event') { |
|
94 | - $subject = $this->l->t('{actor} updated event {event} in calendar {calendar}'); |
|
95 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_event_self') { |
|
96 | - $subject = $this->l->t('You updated event {event} in calendar {calendar}'); |
|
97 | - } else { |
|
98 | - throw new \InvalidArgumentException(); |
|
99 | - } |
|
100 | - |
|
101 | - $parsedParameters = $this->getParameters($event); |
|
102 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
103 | - |
|
104 | - $event = $this->eventMerger->mergeEvents('event', $event, $previousEvent); |
|
105 | - |
|
106 | - return $event; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * @param IEvent $event |
|
111 | - * @return array |
|
112 | - */ |
|
113 | - protected function getParameters(IEvent $event) { |
|
114 | - $subject = $event->getSubject(); |
|
115 | - $parameters = $event->getSubjectParameters(); |
|
116 | - |
|
117 | - switch ($subject) { |
|
118 | - case self::SUBJECT_OBJECT_ADD . '_event': |
|
119 | - case self::SUBJECT_OBJECT_DELETE . '_event': |
|
120 | - case self::SUBJECT_OBJECT_UPDATE . '_event': |
|
121 | - return [ |
|
122 | - 'actor' => $this->generateUserParameter($parameters[0]), |
|
123 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
124 | - 'event' => $this->generateObjectParameter($parameters[2]), |
|
125 | - ]; |
|
126 | - case self::SUBJECT_OBJECT_ADD . '_event_self': |
|
127 | - case self::SUBJECT_OBJECT_DELETE . '_event_self': |
|
128 | - case self::SUBJECT_OBJECT_UPDATE . '_event_self': |
|
129 | - return [ |
|
130 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
131 | - 'event' => $this->generateObjectParameter($parameters[2]), |
|
132 | - ]; |
|
133 | - } |
|
134 | - |
|
135 | - throw new \InvalidArgumentException(); |
|
136 | - } |
|
34 | + const SUBJECT_OBJECT_ADD = 'object_add'; |
|
35 | + const SUBJECT_OBJECT_UPDATE = 'object_update'; |
|
36 | + const SUBJECT_OBJECT_DELETE = 'object_delete'; |
|
37 | + |
|
38 | + /** @var IFactory */ |
|
39 | + protected $languageFactory; |
|
40 | + |
|
41 | + /** @var IL10N */ |
|
42 | + protected $l; |
|
43 | + |
|
44 | + /** @var IURLGenerator */ |
|
45 | + protected $url; |
|
46 | + |
|
47 | + /** @var IManager */ |
|
48 | + protected $activityManager; |
|
49 | + |
|
50 | + /** @var IEventMerger */ |
|
51 | + protected $eventMerger; |
|
52 | + |
|
53 | + /** |
|
54 | + * @param IFactory $languageFactory |
|
55 | + * @param IURLGenerator $url |
|
56 | + * @param IManager $activityManager |
|
57 | + * @param IUserManager $userManager |
|
58 | + * @param IEventMerger $eventMerger |
|
59 | + */ |
|
60 | + public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IEventMerger $eventMerger) { |
|
61 | + parent::__construct($userManager); |
|
62 | + $this->languageFactory = $languageFactory; |
|
63 | + $this->url = $url; |
|
64 | + $this->activityManager = $activityManager; |
|
65 | + $this->eventMerger = $eventMerger; |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @param string $language |
|
70 | + * @param IEvent $event |
|
71 | + * @param IEvent|null $previousEvent |
|
72 | + * @return IEvent |
|
73 | + * @throws \InvalidArgumentException |
|
74 | + * @since 11.0.0 |
|
75 | + */ |
|
76 | + public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
77 | + if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_event') { |
|
78 | + throw new \InvalidArgumentException(); |
|
79 | + } |
|
80 | + |
|
81 | + $this->l = $this->languageFactory->get('dav', $language); |
|
82 | + |
|
83 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg'))); |
|
84 | + |
|
85 | + if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_event') { |
|
86 | + $subject = $this->l->t('{actor} created event {event} in calendar {calendar}'); |
|
87 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_event_self') { |
|
88 | + $subject = $this->l->t('You created event {event} in calendar {calendar}'); |
|
89 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_event') { |
|
90 | + $subject = $this->l->t('{actor} deleted event {event} from calendar {calendar}'); |
|
91 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_event_self') { |
|
92 | + $subject = $this->l->t('You deleted event {event} from calendar {calendar}'); |
|
93 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_event') { |
|
94 | + $subject = $this->l->t('{actor} updated event {event} in calendar {calendar}'); |
|
95 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_event_self') { |
|
96 | + $subject = $this->l->t('You updated event {event} in calendar {calendar}'); |
|
97 | + } else { |
|
98 | + throw new \InvalidArgumentException(); |
|
99 | + } |
|
100 | + |
|
101 | + $parsedParameters = $this->getParameters($event); |
|
102 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
103 | + |
|
104 | + $event = $this->eventMerger->mergeEvents('event', $event, $previousEvent); |
|
105 | + |
|
106 | + return $event; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * @param IEvent $event |
|
111 | + * @return array |
|
112 | + */ |
|
113 | + protected function getParameters(IEvent $event) { |
|
114 | + $subject = $event->getSubject(); |
|
115 | + $parameters = $event->getSubjectParameters(); |
|
116 | + |
|
117 | + switch ($subject) { |
|
118 | + case self::SUBJECT_OBJECT_ADD . '_event': |
|
119 | + case self::SUBJECT_OBJECT_DELETE . '_event': |
|
120 | + case self::SUBJECT_OBJECT_UPDATE . '_event': |
|
121 | + return [ |
|
122 | + 'actor' => $this->generateUserParameter($parameters[0]), |
|
123 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
124 | + 'event' => $this->generateObjectParameter($parameters[2]), |
|
125 | + ]; |
|
126 | + case self::SUBJECT_OBJECT_ADD . '_event_self': |
|
127 | + case self::SUBJECT_OBJECT_DELETE . '_event_self': |
|
128 | + case self::SUBJECT_OBJECT_UPDATE . '_event_self': |
|
129 | + return [ |
|
130 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
131 | + 'event' => $this->generateObjectParameter($parameters[2]), |
|
132 | + ]; |
|
133 | + } |
|
134 | + |
|
135 | + throw new \InvalidArgumentException(); |
|
136 | + } |
|
137 | 137 | } |
@@ -25,86 +25,86 @@ |
||
25 | 25 | |
26 | 26 | class Todo extends Event { |
27 | 27 | |
28 | - /** |
|
29 | - * @param string $language |
|
30 | - * @param IEvent $event |
|
31 | - * @param IEvent|null $previousEvent |
|
32 | - * @return IEvent |
|
33 | - * @throws \InvalidArgumentException |
|
34 | - * @since 11.0.0 |
|
35 | - */ |
|
36 | - public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
37 | - if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_todo') { |
|
38 | - throw new \InvalidArgumentException(); |
|
39 | - } |
|
28 | + /** |
|
29 | + * @param string $language |
|
30 | + * @param IEvent $event |
|
31 | + * @param IEvent|null $previousEvent |
|
32 | + * @return IEvent |
|
33 | + * @throws \InvalidArgumentException |
|
34 | + * @since 11.0.0 |
|
35 | + */ |
|
36 | + public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
37 | + if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_todo') { |
|
38 | + throw new \InvalidArgumentException(); |
|
39 | + } |
|
40 | 40 | |
41 | - $this->l = $this->languageFactory->get('dav', $language); |
|
41 | + $this->l = $this->languageFactory->get('dav', $language); |
|
42 | 42 | |
43 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.svg'))); |
|
43 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.svg'))); |
|
44 | 44 | |
45 | - if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_todo') { |
|
46 | - $subject = $this->l->t('{actor} created todo {todo} in list {calendar}'); |
|
47 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_todo_self') { |
|
48 | - $subject = $this->l->t('You created todo {todo} in list {calendar}'); |
|
49 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_todo') { |
|
50 | - $subject = $this->l->t('{actor} deleted todo {todo} from list {calendar}'); |
|
51 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_todo_self') { |
|
52 | - $subject = $this->l->t('You deleted todo {todo} from list {calendar}'); |
|
53 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo') { |
|
54 | - $subject = $this->l->t('{actor} updated todo {todo} in list {calendar}'); |
|
55 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_self') { |
|
56 | - $subject = $this->l->t('You updated todo {todo} in list {calendar}'); |
|
45 | + if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_todo') { |
|
46 | + $subject = $this->l->t('{actor} created todo {todo} in list {calendar}'); |
|
47 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_todo_self') { |
|
48 | + $subject = $this->l->t('You created todo {todo} in list {calendar}'); |
|
49 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_todo') { |
|
50 | + $subject = $this->l->t('{actor} deleted todo {todo} from list {calendar}'); |
|
51 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_todo_self') { |
|
52 | + $subject = $this->l->t('You deleted todo {todo} from list {calendar}'); |
|
53 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo') { |
|
54 | + $subject = $this->l->t('{actor} updated todo {todo} in list {calendar}'); |
|
55 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_self') { |
|
56 | + $subject = $this->l->t('You updated todo {todo} in list {calendar}'); |
|
57 | 57 | |
58 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed') { |
|
59 | - $subject = $this->l->t('{actor} solved todo {todo} in list {calendar}'); |
|
60 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self') { |
|
61 | - $subject = $this->l->t('You solved todo {todo} in list {calendar}'); |
|
62 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action') { |
|
63 | - $subject = $this->l->t('{actor} reopened todo {todo} in list {calendar}'); |
|
64 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self') { |
|
65 | - $subject = $this->l->t('You reopened todo {todo} in list {calendar}'); |
|
66 | - } else { |
|
67 | - throw new \InvalidArgumentException(); |
|
68 | - } |
|
58 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed') { |
|
59 | + $subject = $this->l->t('{actor} solved todo {todo} in list {calendar}'); |
|
60 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self') { |
|
61 | + $subject = $this->l->t('You solved todo {todo} in list {calendar}'); |
|
62 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action') { |
|
63 | + $subject = $this->l->t('{actor} reopened todo {todo} in list {calendar}'); |
|
64 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self') { |
|
65 | + $subject = $this->l->t('You reopened todo {todo} in list {calendar}'); |
|
66 | + } else { |
|
67 | + throw new \InvalidArgumentException(); |
|
68 | + } |
|
69 | 69 | |
70 | - $parsedParameters = $this->getParameters($event); |
|
71 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
70 | + $parsedParameters = $this->getParameters($event); |
|
71 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
72 | 72 | |
73 | - $event = $this->eventMerger->mergeEvents('todo', $event, $previousEvent); |
|
73 | + $event = $this->eventMerger->mergeEvents('todo', $event, $previousEvent); |
|
74 | 74 | |
75 | - return $event; |
|
76 | - } |
|
75 | + return $event; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param IEvent $event |
|
80 | - * @return array |
|
81 | - */ |
|
82 | - protected function getParameters(IEvent $event) { |
|
83 | - $subject = $event->getSubject(); |
|
84 | - $parameters = $event->getSubjectParameters(); |
|
78 | + /** |
|
79 | + * @param IEvent $event |
|
80 | + * @return array |
|
81 | + */ |
|
82 | + protected function getParameters(IEvent $event) { |
|
83 | + $subject = $event->getSubject(); |
|
84 | + $parameters = $event->getSubjectParameters(); |
|
85 | 85 | |
86 | - switch ($subject) { |
|
87 | - case self::SUBJECT_OBJECT_ADD . '_todo': |
|
88 | - case self::SUBJECT_OBJECT_DELETE . '_todo': |
|
89 | - case self::SUBJECT_OBJECT_UPDATE . '_todo': |
|
90 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_completed': |
|
91 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action': |
|
92 | - return [ |
|
93 | - 'actor' => $this->generateUserParameter($parameters[0]), |
|
94 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
95 | - 'todo' => $this->generateObjectParameter($parameters[2]), |
|
96 | - ]; |
|
97 | - case self::SUBJECT_OBJECT_ADD . '_todo_self': |
|
98 | - case self::SUBJECT_OBJECT_DELETE . '_todo_self': |
|
99 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_self': |
|
100 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self': |
|
101 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self': |
|
102 | - return [ |
|
103 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
104 | - 'todo' => $this->generateObjectParameter($parameters[2]), |
|
105 | - ]; |
|
106 | - } |
|
86 | + switch ($subject) { |
|
87 | + case self::SUBJECT_OBJECT_ADD . '_todo': |
|
88 | + case self::SUBJECT_OBJECT_DELETE . '_todo': |
|
89 | + case self::SUBJECT_OBJECT_UPDATE . '_todo': |
|
90 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_completed': |
|
91 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action': |
|
92 | + return [ |
|
93 | + 'actor' => $this->generateUserParameter($parameters[0]), |
|
94 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
95 | + 'todo' => $this->generateObjectParameter($parameters[2]), |
|
96 | + ]; |
|
97 | + case self::SUBJECT_OBJECT_ADD . '_todo_self': |
|
98 | + case self::SUBJECT_OBJECT_DELETE . '_todo_self': |
|
99 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_self': |
|
100 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self': |
|
101 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self': |
|
102 | + return [ |
|
103 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
104 | + 'todo' => $this->generateObjectParameter($parameters[2]), |
|
105 | + ]; |
|
106 | + } |
|
107 | 107 | |
108 | - throw new \InvalidArgumentException(); |
|
109 | - } |
|
108 | + throw new \InvalidArgumentException(); |
|
109 | + } |
|
110 | 110 | } |
@@ -28,65 +28,65 @@ |
||
28 | 28 | |
29 | 29 | class Calendar implements IFilter { |
30 | 30 | |
31 | - /** @var IL10N */ |
|
32 | - protected $l; |
|
31 | + /** @var IL10N */ |
|
32 | + protected $l; |
|
33 | 33 | |
34 | - /** @var IURLGenerator */ |
|
35 | - protected $url; |
|
34 | + /** @var IURLGenerator */ |
|
35 | + protected $url; |
|
36 | 36 | |
37 | - public function __construct(IL10N $l, IURLGenerator $url) { |
|
38 | - $this->l = $l; |
|
39 | - $this->url = $url; |
|
40 | - } |
|
37 | + public function __construct(IL10N $l, IURLGenerator $url) { |
|
38 | + $this->l = $l; |
|
39 | + $this->url = $url; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string Lowercase a-z and underscore only identifier |
|
44 | - * @since 11.0.0 |
|
45 | - */ |
|
46 | - public function getIdentifier() { |
|
47 | - return 'calendar'; |
|
48 | - } |
|
42 | + /** |
|
43 | + * @return string Lowercase a-z and underscore only identifier |
|
44 | + * @since 11.0.0 |
|
45 | + */ |
|
46 | + public function getIdentifier() { |
|
47 | + return 'calendar'; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return string A translated string |
|
52 | - * @since 11.0.0 |
|
53 | - */ |
|
54 | - public function getName() { |
|
55 | - return $this->l->t('Calendar'); |
|
56 | - } |
|
50 | + /** |
|
51 | + * @return string A translated string |
|
52 | + * @since 11.0.0 |
|
53 | + */ |
|
54 | + public function getName() { |
|
55 | + return $this->l->t('Calendar'); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return int whether the filter should be rather on the top or bottom of |
|
60 | - * the admin section. The filters are arranged in ascending order of the |
|
61 | - * priority values. It is required to return a value between 0 and 100. |
|
62 | - * @since 11.0.0 |
|
63 | - */ |
|
64 | - public function getPriority() { |
|
65 | - return 40; |
|
66 | - } |
|
58 | + /** |
|
59 | + * @return int whether the filter should be rather on the top or bottom of |
|
60 | + * the admin section. The filters are arranged in ascending order of the |
|
61 | + * priority values. It is required to return a value between 0 and 100. |
|
62 | + * @since 11.0.0 |
|
63 | + */ |
|
64 | + public function getPriority() { |
|
65 | + return 40; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return string Full URL to an icon, empty string when none is given |
|
70 | - * @since 11.0.0 |
|
71 | - */ |
|
72 | - public function getIcon() { |
|
73 | - return $this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')); |
|
74 | - } |
|
68 | + /** |
|
69 | + * @return string Full URL to an icon, empty string when none is given |
|
70 | + * @since 11.0.0 |
|
71 | + */ |
|
72 | + public function getIcon() { |
|
73 | + return $this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param string[] $types |
|
78 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
79 | - * @since 11.0.0 |
|
80 | - */ |
|
81 | - public function filterTypes(array $types) { |
|
82 | - return array_intersect(['calendar', 'calendar_event'], $types); |
|
83 | - } |
|
76 | + /** |
|
77 | + * @param string[] $types |
|
78 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
79 | + * @since 11.0.0 |
|
80 | + */ |
|
81 | + public function filterTypes(array $types) { |
|
82 | + return array_intersect(['calendar', 'calendar_event'], $types); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
87 | - * @since 11.0.0 |
|
88 | - */ |
|
89 | - public function allowedApps() { |
|
90 | - return []; |
|
91 | - } |
|
85 | + /** |
|
86 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
87 | + * @since 11.0.0 |
|
88 | + */ |
|
89 | + public function allowedApps() { |
|
90 | + return []; |
|
91 | + } |
|
92 | 92 | } |
@@ -28,65 +28,65 @@ |
||
28 | 28 | |
29 | 29 | class Todo implements IFilter { |
30 | 30 | |
31 | - /** @var IL10N */ |
|
32 | - protected $l; |
|
31 | + /** @var IL10N */ |
|
32 | + protected $l; |
|
33 | 33 | |
34 | - /** @var IURLGenerator */ |
|
35 | - protected $url; |
|
34 | + /** @var IURLGenerator */ |
|
35 | + protected $url; |
|
36 | 36 | |
37 | - public function __construct(IL10N $l, IURLGenerator $url) { |
|
38 | - $this->l = $l; |
|
39 | - $this->url = $url; |
|
40 | - } |
|
37 | + public function __construct(IL10N $l, IURLGenerator $url) { |
|
38 | + $this->l = $l; |
|
39 | + $this->url = $url; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string Lowercase a-z and underscore only identifier |
|
44 | - * @since 11.0.0 |
|
45 | - */ |
|
46 | - public function getIdentifier() { |
|
47 | - return 'calendar_todo'; |
|
48 | - } |
|
42 | + /** |
|
43 | + * @return string Lowercase a-z and underscore only identifier |
|
44 | + * @since 11.0.0 |
|
45 | + */ |
|
46 | + public function getIdentifier() { |
|
47 | + return 'calendar_todo'; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return string A translated string |
|
52 | - * @since 11.0.0 |
|
53 | - */ |
|
54 | - public function getName() { |
|
55 | - return $this->l->t('Todos'); |
|
56 | - } |
|
50 | + /** |
|
51 | + * @return string A translated string |
|
52 | + * @since 11.0.0 |
|
53 | + */ |
|
54 | + public function getName() { |
|
55 | + return $this->l->t('Todos'); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return int whether the filter should be rather on the top or bottom of |
|
60 | - * the admin section. The filters are arranged in ascending order of the |
|
61 | - * priority values. It is required to return a value between 0 and 100. |
|
62 | - * @since 11.0.0 |
|
63 | - */ |
|
64 | - public function getPriority() { |
|
65 | - return 40; |
|
66 | - } |
|
58 | + /** |
|
59 | + * @return int whether the filter should be rather on the top or bottom of |
|
60 | + * the admin section. The filters are arranged in ascending order of the |
|
61 | + * priority values. It is required to return a value between 0 and 100. |
|
62 | + * @since 11.0.0 |
|
63 | + */ |
|
64 | + public function getPriority() { |
|
65 | + return 40; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return string Full URL to an icon, empty string when none is given |
|
70 | - * @since 11.0.0 |
|
71 | - */ |
|
72 | - public function getIcon() { |
|
73 | - return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.svg')); |
|
74 | - } |
|
68 | + /** |
|
69 | + * @return string Full URL to an icon, empty string when none is given |
|
70 | + * @since 11.0.0 |
|
71 | + */ |
|
72 | + public function getIcon() { |
|
73 | + return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.svg')); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param string[] $types |
|
78 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
79 | - * @since 11.0.0 |
|
80 | - */ |
|
81 | - public function filterTypes(array $types) { |
|
82 | - return array_intersect(['calendar_todo'], $types); |
|
83 | - } |
|
76 | + /** |
|
77 | + * @param string[] $types |
|
78 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
79 | + * @since 11.0.0 |
|
80 | + */ |
|
81 | + public function filterTypes(array $types) { |
|
82 | + return array_intersect(['calendar_todo'], $types); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
87 | - * @since 11.0.0 |
|
88 | - */ |
|
89 | - public function allowedApps() { |
|
90 | - return []; |
|
91 | - } |
|
85 | + /** |
|
86 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
87 | + * @since 11.0.0 |
|
88 | + */ |
|
89 | + public function allowedApps() { |
|
90 | + return []; |
|
91 | + } |
|
92 | 92 | } |
@@ -27,72 +27,72 @@ |
||
27 | 27 | |
28 | 28 | class Calendar implements ISetting { |
29 | 29 | |
30 | - /** @var IL10N */ |
|
31 | - protected $l; |
|
30 | + /** @var IL10N */ |
|
31 | + protected $l; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param IL10N $l |
|
35 | - */ |
|
36 | - public function __construct(IL10N $l) { |
|
37 | - $this->l = $l; |
|
38 | - } |
|
33 | + /** |
|
34 | + * @param IL10N $l |
|
35 | + */ |
|
36 | + public function __construct(IL10N $l) { |
|
37 | + $this->l = $l; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string Lowercase a-z and underscore only identifier |
|
42 | - * @since 11.0.0 |
|
43 | - */ |
|
44 | - public function getIdentifier() { |
|
45 | - return 'calendar'; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string Lowercase a-z and underscore only identifier |
|
42 | + * @since 11.0.0 |
|
43 | + */ |
|
44 | + public function getIdentifier() { |
|
45 | + return 'calendar'; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return string A translated string |
|
50 | - * @since 11.0.0 |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return $this->l->t('A <strong>calendar</strong> was modified'); |
|
54 | - } |
|
48 | + /** |
|
49 | + * @return string A translated string |
|
50 | + * @since 11.0.0 |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return $this->l->t('A <strong>calendar</strong> was modified'); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return int whether the filter should be rather on the top or bottom of |
|
58 | - * the admin section. The filters are arranged in ascending order of the |
|
59 | - * priority values. It is required to return a value between 0 and 100. |
|
60 | - * @since 11.0.0 |
|
61 | - */ |
|
62 | - public function getPriority() { |
|
63 | - return 50; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @return int whether the filter should be rather on the top or bottom of |
|
58 | + * the admin section. The filters are arranged in ascending order of the |
|
59 | + * priority values. It is required to return a value between 0 and 100. |
|
60 | + * @since 11.0.0 |
|
61 | + */ |
|
62 | + public function getPriority() { |
|
63 | + return 50; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return bool True when the option can be changed for the stream |
|
68 | - * @since 11.0.0 |
|
69 | - */ |
|
70 | - public function canChangeStream() { |
|
71 | - return true; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return bool True when the option can be changed for the stream |
|
68 | + * @since 11.0.0 |
|
69 | + */ |
|
70 | + public function canChangeStream() { |
|
71 | + return true; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return bool True when the option can be changed for the stream |
|
76 | - * @since 11.0.0 |
|
77 | - */ |
|
78 | - public function isDefaultEnabledStream() { |
|
79 | - return true; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @return bool True when the option can be changed for the stream |
|
76 | + * @since 11.0.0 |
|
77 | + */ |
|
78 | + public function isDefaultEnabledStream() { |
|
79 | + return true; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return bool True when the option can be changed for the mail |
|
84 | - * @since 11.0.0 |
|
85 | - */ |
|
86 | - public function canChangeMail() { |
|
87 | - return true; |
|
88 | - } |
|
82 | + /** |
|
83 | + * @return bool True when the option can be changed for the mail |
|
84 | + * @since 11.0.0 |
|
85 | + */ |
|
86 | + public function canChangeMail() { |
|
87 | + return true; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return bool True when the option can be changed for the stream |
|
92 | - * @since 11.0.0 |
|
93 | - */ |
|
94 | - public function isDefaultEnabledMail() { |
|
95 | - return false; |
|
96 | - } |
|
90 | + /** |
|
91 | + * @return bool True when the option can be changed for the stream |
|
92 | + * @since 11.0.0 |
|
93 | + */ |
|
94 | + public function isDefaultEnabledMail() { |
|
95 | + return false; |
|
96 | + } |
|
97 | 97 | } |
98 | 98 |