@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | )) { |
221 | 221 | // note: pre-fetching only supported for depth <= 1 |
222 | 222 | $folderContent = $node->getChildren(); |
223 | - $fileIds[] = (int)$node->getId(); |
|
223 | + $fileIds[] = (int) $node->getId(); |
|
224 | 224 | foreach ($folderContent as $info) { |
225 | - $fileIds[] = (int)$info->getId(); |
|
225 | + $fileIds[] = (int) $info->getId(); |
|
226 | 226 | } |
227 | 227 | $tags = $this->getTagger()->getTagsForObjects($fileIds); |
228 | 228 | if ($tags === false) { |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | }); |
279 | 279 | |
280 | 280 | $propPatch->handle(self::FAVORITE_PROPERTYNAME, function($favState) use ($node) { |
281 | - if ((int)$favState === 1 || $favState === 'true') { |
|
281 | + if ((int) $favState === 1 || $favState === 'true') { |
|
282 | 282 | $this->getTagger()->tagAs($node->getId(), self::TAG_FAVORITE); |
283 | 283 | } else { |
284 | 284 | $this->getTagger()->unTag($node->getId(), self::TAG_FAVORITE); |
@@ -51,246 +51,246 @@ |
||
51 | 51 | class TagsPlugin extends \Sabre\DAV\ServerPlugin |
52 | 52 | { |
53 | 53 | |
54 | - // namespace |
|
55 | - const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
56 | - const TAGS_PROPERTYNAME = '{http://owncloud.org/ns}tags'; |
|
57 | - const FAVORITE_PROPERTYNAME = '{http://owncloud.org/ns}favorite'; |
|
58 | - const TAG_FAVORITE = '_$!<Favorite>!$_'; |
|
54 | + // namespace |
|
55 | + const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
56 | + const TAGS_PROPERTYNAME = '{http://owncloud.org/ns}tags'; |
|
57 | + const FAVORITE_PROPERTYNAME = '{http://owncloud.org/ns}favorite'; |
|
58 | + const TAG_FAVORITE = '_$!<Favorite>!$_'; |
|
59 | 59 | |
60 | - /** |
|
61 | - * Reference to main server object |
|
62 | - * |
|
63 | - * @var \Sabre\DAV\Server |
|
64 | - */ |
|
65 | - private $server; |
|
60 | + /** |
|
61 | + * Reference to main server object |
|
62 | + * |
|
63 | + * @var \Sabre\DAV\Server |
|
64 | + */ |
|
65 | + private $server; |
|
66 | 66 | |
67 | - /** |
|
68 | - * @var \OCP\ITagManager |
|
69 | - */ |
|
70 | - private $tagManager; |
|
67 | + /** |
|
68 | + * @var \OCP\ITagManager |
|
69 | + */ |
|
70 | + private $tagManager; |
|
71 | 71 | |
72 | - /** |
|
73 | - * @var \OCP\ITags |
|
74 | - */ |
|
75 | - private $tagger; |
|
72 | + /** |
|
73 | + * @var \OCP\ITags |
|
74 | + */ |
|
75 | + private $tagger; |
|
76 | 76 | |
77 | - /** |
|
78 | - * Array of file id to tags array |
|
79 | - * The null value means the cache wasn't initialized. |
|
80 | - * |
|
81 | - * @var array |
|
82 | - */ |
|
83 | - private $cachedTags; |
|
77 | + /** |
|
78 | + * Array of file id to tags array |
|
79 | + * The null value means the cache wasn't initialized. |
|
80 | + * |
|
81 | + * @var array |
|
82 | + */ |
|
83 | + private $cachedTags; |
|
84 | 84 | |
85 | - /** |
|
86 | - * @var \Sabre\DAV\Tree |
|
87 | - */ |
|
88 | - private $tree; |
|
85 | + /** |
|
86 | + * @var \Sabre\DAV\Tree |
|
87 | + */ |
|
88 | + private $tree; |
|
89 | 89 | |
90 | - /** |
|
91 | - * @param \Sabre\DAV\Tree $tree tree |
|
92 | - * @param \OCP\ITagManager $tagManager tag manager |
|
93 | - */ |
|
94 | - public function __construct(\Sabre\DAV\Tree $tree, \OCP\ITagManager $tagManager) { |
|
95 | - $this->tree = $tree; |
|
96 | - $this->tagManager = $tagManager; |
|
97 | - $this->tagger = null; |
|
98 | - $this->cachedTags = array(); |
|
99 | - } |
|
90 | + /** |
|
91 | + * @param \Sabre\DAV\Tree $tree tree |
|
92 | + * @param \OCP\ITagManager $tagManager tag manager |
|
93 | + */ |
|
94 | + public function __construct(\Sabre\DAV\Tree $tree, \OCP\ITagManager $tagManager) { |
|
95 | + $this->tree = $tree; |
|
96 | + $this->tagManager = $tagManager; |
|
97 | + $this->tagger = null; |
|
98 | + $this->cachedTags = array(); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * This initializes the plugin. |
|
103 | - * |
|
104 | - * This function is called by \Sabre\DAV\Server, after |
|
105 | - * addPlugin is called. |
|
106 | - * |
|
107 | - * This method should set up the required event subscriptions. |
|
108 | - * |
|
109 | - * @param \Sabre\DAV\Server $server |
|
110 | - * @return void |
|
111 | - */ |
|
112 | - public function initialize(\Sabre\DAV\Server $server) { |
|
101 | + /** |
|
102 | + * This initializes the plugin. |
|
103 | + * |
|
104 | + * This function is called by \Sabre\DAV\Server, after |
|
105 | + * addPlugin is called. |
|
106 | + * |
|
107 | + * This method should set up the required event subscriptions. |
|
108 | + * |
|
109 | + * @param \Sabre\DAV\Server $server |
|
110 | + * @return void |
|
111 | + */ |
|
112 | + public function initialize(\Sabre\DAV\Server $server) { |
|
113 | 113 | |
114 | - $server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc'; |
|
115 | - $server->xml->elementMap[self::TAGS_PROPERTYNAME] = TagList::class; |
|
114 | + $server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc'; |
|
115 | + $server->xml->elementMap[self::TAGS_PROPERTYNAME] = TagList::class; |
|
116 | 116 | |
117 | - $this->server = $server; |
|
118 | - $this->server->on('propFind', array($this, 'handleGetProperties')); |
|
119 | - $this->server->on('propPatch', array($this, 'handleUpdateProperties')); |
|
120 | - } |
|
117 | + $this->server = $server; |
|
118 | + $this->server->on('propFind', array($this, 'handleGetProperties')); |
|
119 | + $this->server->on('propPatch', array($this, 'handleUpdateProperties')); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Returns the tagger |
|
124 | - * |
|
125 | - * @return \OCP\ITags tagger |
|
126 | - */ |
|
127 | - private function getTagger() { |
|
128 | - if (!$this->tagger) { |
|
129 | - $this->tagger = $this->tagManager->load('files'); |
|
130 | - } |
|
131 | - return $this->tagger; |
|
132 | - } |
|
122 | + /** |
|
123 | + * Returns the tagger |
|
124 | + * |
|
125 | + * @return \OCP\ITags tagger |
|
126 | + */ |
|
127 | + private function getTagger() { |
|
128 | + if (!$this->tagger) { |
|
129 | + $this->tagger = $this->tagManager->load('files'); |
|
130 | + } |
|
131 | + return $this->tagger; |
|
132 | + } |
|
133 | 133 | |
134 | - /** |
|
135 | - * Returns tags and favorites. |
|
136 | - * |
|
137 | - * @param integer $fileId file id |
|
138 | - * @return array list($tags, $favorite) with $tags as tag array |
|
139 | - * and $favorite is a boolean whether the file was favorited |
|
140 | - */ |
|
141 | - private function getTagsAndFav($fileId) { |
|
142 | - $isFav = false; |
|
143 | - $tags = $this->getTags($fileId); |
|
144 | - if ($tags) { |
|
145 | - $favPos = array_search(self::TAG_FAVORITE, $tags); |
|
146 | - if ($favPos !== false) { |
|
147 | - $isFav = true; |
|
148 | - unset($tags[$favPos]); |
|
149 | - } |
|
150 | - } |
|
151 | - return array($tags, $isFav); |
|
152 | - } |
|
134 | + /** |
|
135 | + * Returns tags and favorites. |
|
136 | + * |
|
137 | + * @param integer $fileId file id |
|
138 | + * @return array list($tags, $favorite) with $tags as tag array |
|
139 | + * and $favorite is a boolean whether the file was favorited |
|
140 | + */ |
|
141 | + private function getTagsAndFav($fileId) { |
|
142 | + $isFav = false; |
|
143 | + $tags = $this->getTags($fileId); |
|
144 | + if ($tags) { |
|
145 | + $favPos = array_search(self::TAG_FAVORITE, $tags); |
|
146 | + if ($favPos !== false) { |
|
147 | + $isFav = true; |
|
148 | + unset($tags[$favPos]); |
|
149 | + } |
|
150 | + } |
|
151 | + return array($tags, $isFav); |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
155 | - * Returns tags for the given file id |
|
156 | - * |
|
157 | - * @param integer $fileId file id |
|
158 | - * @return array list of tags for that file |
|
159 | - */ |
|
160 | - private function getTags($fileId) { |
|
161 | - if (isset($this->cachedTags[$fileId])) { |
|
162 | - return $this->cachedTags[$fileId]; |
|
163 | - } else { |
|
164 | - $tags = $this->getTagger()->getTagsForObjects(array($fileId)); |
|
165 | - if ($tags !== false) { |
|
166 | - if (empty($tags)) { |
|
167 | - return array(); |
|
168 | - } |
|
169 | - return current($tags); |
|
170 | - } |
|
171 | - } |
|
172 | - return null; |
|
173 | - } |
|
154 | + /** |
|
155 | + * Returns tags for the given file id |
|
156 | + * |
|
157 | + * @param integer $fileId file id |
|
158 | + * @return array list of tags for that file |
|
159 | + */ |
|
160 | + private function getTags($fileId) { |
|
161 | + if (isset($this->cachedTags[$fileId])) { |
|
162 | + return $this->cachedTags[$fileId]; |
|
163 | + } else { |
|
164 | + $tags = $this->getTagger()->getTagsForObjects(array($fileId)); |
|
165 | + if ($tags !== false) { |
|
166 | + if (empty($tags)) { |
|
167 | + return array(); |
|
168 | + } |
|
169 | + return current($tags); |
|
170 | + } |
|
171 | + } |
|
172 | + return null; |
|
173 | + } |
|
174 | 174 | |
175 | - /** |
|
176 | - * Updates the tags of the given file id |
|
177 | - * |
|
178 | - * @param int $fileId |
|
179 | - * @param array $tags array of tag strings |
|
180 | - */ |
|
181 | - private function updateTags($fileId, $tags) { |
|
182 | - $tagger = $this->getTagger(); |
|
183 | - $currentTags = $this->getTags($fileId); |
|
175 | + /** |
|
176 | + * Updates the tags of the given file id |
|
177 | + * |
|
178 | + * @param int $fileId |
|
179 | + * @param array $tags array of tag strings |
|
180 | + */ |
|
181 | + private function updateTags($fileId, $tags) { |
|
182 | + $tagger = $this->getTagger(); |
|
183 | + $currentTags = $this->getTags($fileId); |
|
184 | 184 | |
185 | - $newTags = array_diff($tags, $currentTags); |
|
186 | - foreach ($newTags as $tag) { |
|
187 | - if ($tag === self::TAG_FAVORITE) { |
|
188 | - continue; |
|
189 | - } |
|
190 | - $tagger->tagAs($fileId, $tag); |
|
191 | - } |
|
192 | - $deletedTags = array_diff($currentTags, $tags); |
|
193 | - foreach ($deletedTags as $tag) { |
|
194 | - if ($tag === self::TAG_FAVORITE) { |
|
195 | - continue; |
|
196 | - } |
|
197 | - $tagger->unTag($fileId, $tag); |
|
198 | - } |
|
199 | - } |
|
185 | + $newTags = array_diff($tags, $currentTags); |
|
186 | + foreach ($newTags as $tag) { |
|
187 | + if ($tag === self::TAG_FAVORITE) { |
|
188 | + continue; |
|
189 | + } |
|
190 | + $tagger->tagAs($fileId, $tag); |
|
191 | + } |
|
192 | + $deletedTags = array_diff($currentTags, $tags); |
|
193 | + foreach ($deletedTags as $tag) { |
|
194 | + if ($tag === self::TAG_FAVORITE) { |
|
195 | + continue; |
|
196 | + } |
|
197 | + $tagger->unTag($fileId, $tag); |
|
198 | + } |
|
199 | + } |
|
200 | 200 | |
201 | - /** |
|
202 | - * Adds tags and favorites properties to the response, |
|
203 | - * if requested. |
|
204 | - * |
|
205 | - * @param PropFind $propFind |
|
206 | - * @param \Sabre\DAV\INode $node |
|
207 | - * @return void |
|
208 | - */ |
|
209 | - public function handleGetProperties( |
|
210 | - PropFind $propFind, |
|
211 | - \Sabre\DAV\INode $node |
|
212 | - ) { |
|
213 | - if (!($node instanceof \OCA\DAV\Connector\Sabre\Node)) { |
|
214 | - return; |
|
215 | - } |
|
201 | + /** |
|
202 | + * Adds tags and favorites properties to the response, |
|
203 | + * if requested. |
|
204 | + * |
|
205 | + * @param PropFind $propFind |
|
206 | + * @param \Sabre\DAV\INode $node |
|
207 | + * @return void |
|
208 | + */ |
|
209 | + public function handleGetProperties( |
|
210 | + PropFind $propFind, |
|
211 | + \Sabre\DAV\INode $node |
|
212 | + ) { |
|
213 | + if (!($node instanceof \OCA\DAV\Connector\Sabre\Node)) { |
|
214 | + return; |
|
215 | + } |
|
216 | 216 | |
217 | - // need prefetch ? |
|
218 | - if ($node instanceof \OCA\DAV\Connector\Sabre\Directory |
|
219 | - && $propFind->getDepth() !== 0 |
|
220 | - && (!is_null($propFind->getStatus(self::TAGS_PROPERTYNAME)) |
|
221 | - || !is_null($propFind->getStatus(self::FAVORITE_PROPERTYNAME)) |
|
222 | - )) { |
|
223 | - // note: pre-fetching only supported for depth <= 1 |
|
224 | - $folderContent = $node->getChildren(); |
|
225 | - $fileIds[] = (int)$node->getId(); |
|
226 | - foreach ($folderContent as $info) { |
|
227 | - $fileIds[] = (int)$info->getId(); |
|
228 | - } |
|
229 | - $tags = $this->getTagger()->getTagsForObjects($fileIds); |
|
230 | - if ($tags === false) { |
|
231 | - // the tags API returns false on error... |
|
232 | - $tags = array(); |
|
233 | - } |
|
217 | + // need prefetch ? |
|
218 | + if ($node instanceof \OCA\DAV\Connector\Sabre\Directory |
|
219 | + && $propFind->getDepth() !== 0 |
|
220 | + && (!is_null($propFind->getStatus(self::TAGS_PROPERTYNAME)) |
|
221 | + || !is_null($propFind->getStatus(self::FAVORITE_PROPERTYNAME)) |
|
222 | + )) { |
|
223 | + // note: pre-fetching only supported for depth <= 1 |
|
224 | + $folderContent = $node->getChildren(); |
|
225 | + $fileIds[] = (int)$node->getId(); |
|
226 | + foreach ($folderContent as $info) { |
|
227 | + $fileIds[] = (int)$info->getId(); |
|
228 | + } |
|
229 | + $tags = $this->getTagger()->getTagsForObjects($fileIds); |
|
230 | + if ($tags === false) { |
|
231 | + // the tags API returns false on error... |
|
232 | + $tags = array(); |
|
233 | + } |
|
234 | 234 | |
235 | - $this->cachedTags = $this->cachedTags + $tags; |
|
236 | - $emptyFileIds = array_diff($fileIds, array_keys($tags)); |
|
237 | - // also cache the ones that were not found |
|
238 | - foreach ($emptyFileIds as $fileId) { |
|
239 | - $this->cachedTags[$fileId] = []; |
|
240 | - } |
|
241 | - } |
|
235 | + $this->cachedTags = $this->cachedTags + $tags; |
|
236 | + $emptyFileIds = array_diff($fileIds, array_keys($tags)); |
|
237 | + // also cache the ones that were not found |
|
238 | + foreach ($emptyFileIds as $fileId) { |
|
239 | + $this->cachedTags[$fileId] = []; |
|
240 | + } |
|
241 | + } |
|
242 | 242 | |
243 | - $isFav = null; |
|
243 | + $isFav = null; |
|
244 | 244 | |
245 | - $propFind->handle(self::TAGS_PROPERTYNAME, function() use (&$isFav, $node) { |
|
246 | - list($tags, $isFav) = $this->getTagsAndFav($node->getId()); |
|
247 | - return new TagList($tags); |
|
248 | - }); |
|
245 | + $propFind->handle(self::TAGS_PROPERTYNAME, function() use (&$isFav, $node) { |
|
246 | + list($tags, $isFav) = $this->getTagsAndFav($node->getId()); |
|
247 | + return new TagList($tags); |
|
248 | + }); |
|
249 | 249 | |
250 | - $propFind->handle(self::FAVORITE_PROPERTYNAME, function() use ($isFav, $node) { |
|
251 | - if (is_null($isFav)) { |
|
252 | - list(, $isFav) = $this->getTagsAndFav($node->getId()); |
|
253 | - } |
|
254 | - if ($isFav) { |
|
255 | - return 1; |
|
256 | - } else { |
|
257 | - return 0; |
|
258 | - } |
|
259 | - }); |
|
260 | - } |
|
250 | + $propFind->handle(self::FAVORITE_PROPERTYNAME, function() use ($isFav, $node) { |
|
251 | + if (is_null($isFav)) { |
|
252 | + list(, $isFav) = $this->getTagsAndFav($node->getId()); |
|
253 | + } |
|
254 | + if ($isFav) { |
|
255 | + return 1; |
|
256 | + } else { |
|
257 | + return 0; |
|
258 | + } |
|
259 | + }); |
|
260 | + } |
|
261 | 261 | |
262 | - /** |
|
263 | - * Updates tags and favorites properties, if applicable. |
|
264 | - * |
|
265 | - * @param string $path |
|
266 | - * @param PropPatch $propPatch |
|
267 | - * |
|
268 | - * @return void |
|
269 | - */ |
|
270 | - public function handleUpdateProperties($path, PropPatch $propPatch) { |
|
271 | - $node = $this->tree->getNodeForPath($path); |
|
272 | - if (!($node instanceof \OCA\DAV\Connector\Sabre\Node)) { |
|
273 | - return; |
|
274 | - } |
|
262 | + /** |
|
263 | + * Updates tags and favorites properties, if applicable. |
|
264 | + * |
|
265 | + * @param string $path |
|
266 | + * @param PropPatch $propPatch |
|
267 | + * |
|
268 | + * @return void |
|
269 | + */ |
|
270 | + public function handleUpdateProperties($path, PropPatch $propPatch) { |
|
271 | + $node = $this->tree->getNodeForPath($path); |
|
272 | + if (!($node instanceof \OCA\DAV\Connector\Sabre\Node)) { |
|
273 | + return; |
|
274 | + } |
|
275 | 275 | |
276 | - $propPatch->handle(self::TAGS_PROPERTYNAME, function($tagList) use ($node) { |
|
277 | - $this->updateTags($node->getId(), $tagList->getTags()); |
|
278 | - return true; |
|
279 | - }); |
|
276 | + $propPatch->handle(self::TAGS_PROPERTYNAME, function($tagList) use ($node) { |
|
277 | + $this->updateTags($node->getId(), $tagList->getTags()); |
|
278 | + return true; |
|
279 | + }); |
|
280 | 280 | |
281 | - $propPatch->handle(self::FAVORITE_PROPERTYNAME, function($favState) use ($node) { |
|
282 | - if ((int)$favState === 1 || $favState === 'true') { |
|
283 | - $this->getTagger()->tagAs($node->getId(), self::TAG_FAVORITE); |
|
284 | - } else { |
|
285 | - $this->getTagger()->unTag($node->getId(), self::TAG_FAVORITE); |
|
286 | - } |
|
281 | + $propPatch->handle(self::FAVORITE_PROPERTYNAME, function($favState) use ($node) { |
|
282 | + if ((int)$favState === 1 || $favState === 'true') { |
|
283 | + $this->getTagger()->tagAs($node->getId(), self::TAG_FAVORITE); |
|
284 | + } else { |
|
285 | + $this->getTagger()->unTag($node->getId(), self::TAG_FAVORITE); |
|
286 | + } |
|
287 | 287 | |
288 | - if (is_null($favState)) { |
|
289 | - // confirm deletion |
|
290 | - return 204; |
|
291 | - } |
|
288 | + if (is_null($favState)) { |
|
289 | + // confirm deletion |
|
290 | + return 204; |
|
291 | + } |
|
292 | 292 | |
293 | - return 200; |
|
294 | - }); |
|
295 | - } |
|
293 | + return 200; |
|
294 | + }); |
|
295 | + } |
|
296 | 296 | } |
@@ -68,8 +68,8 @@ |
||
68 | 68 | $this->getBundles(), |
69 | 69 | $this->getDefaultInstallationBundle() |
70 | 70 | ); |
71 | - foreach($bundles as $bundle) { |
|
72 | - if($bundle->getIdentifier() === $identifier) { |
|
71 | + foreach ($bundles as $bundle) { |
|
72 | + if ($bundle->getIdentifier() === $identifier) { |
|
73 | 73 | return $bundle; |
74 | 74 | } |
75 | 75 | } |
@@ -24,58 +24,58 @@ |
||
24 | 24 | use OCP\IL10N; |
25 | 25 | |
26 | 26 | class BundleFetcher { |
27 | - /** @var IL10N */ |
|
28 | - private $l10n; |
|
27 | + /** @var IL10N */ |
|
28 | + private $l10n; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param IL10N $l10n |
|
32 | - */ |
|
33 | - public function __construct(IL10N $l10n) { |
|
34 | - $this->l10n = $l10n; |
|
35 | - } |
|
30 | + /** |
|
31 | + * @param IL10N $l10n |
|
32 | + */ |
|
33 | + public function __construct(IL10N $l10n) { |
|
34 | + $this->l10n = $l10n; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @return Bundle[] |
|
39 | - */ |
|
40 | - public function getBundles() { |
|
41 | - return [ |
|
42 | - new EnterpriseBundle($this->l10n), |
|
43 | - new GroupwareBundle($this->l10n), |
|
44 | - new SocialSharingBundle($this->l10n), |
|
45 | - new EducationBundle($this->l10n), |
|
46 | - ]; |
|
47 | - } |
|
37 | + /** |
|
38 | + * @return Bundle[] |
|
39 | + */ |
|
40 | + public function getBundles() { |
|
41 | + return [ |
|
42 | + new EnterpriseBundle($this->l10n), |
|
43 | + new GroupwareBundle($this->l10n), |
|
44 | + new SocialSharingBundle($this->l10n), |
|
45 | + new EducationBundle($this->l10n), |
|
46 | + ]; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Bundles that should be installed by default after installation |
|
51 | - * |
|
52 | - * @return Bundle[] |
|
53 | - */ |
|
54 | - public function getDefaultInstallationBundle() { |
|
55 | - return [ |
|
56 | - new CoreBundle($this->l10n), |
|
57 | - ]; |
|
58 | - } |
|
49 | + /** |
|
50 | + * Bundles that should be installed by default after installation |
|
51 | + * |
|
52 | + * @return Bundle[] |
|
53 | + */ |
|
54 | + public function getDefaultInstallationBundle() { |
|
55 | + return [ |
|
56 | + new CoreBundle($this->l10n), |
|
57 | + ]; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Get the bundle with the specified identifier |
|
62 | - * |
|
63 | - * @param string $identifier |
|
64 | - * @return Bundle |
|
65 | - * @throws \BadMethodCallException If the bundle does not exist |
|
66 | - */ |
|
67 | - public function getBundleByIdentifier($identifier) { |
|
68 | - /** @var Bundle[] $bundles */ |
|
69 | - $bundles = array_merge( |
|
70 | - $this->getBundles(), |
|
71 | - $this->getDefaultInstallationBundle() |
|
72 | - ); |
|
73 | - foreach($bundles as $bundle) { |
|
74 | - if($bundle->getIdentifier() === $identifier) { |
|
75 | - return $bundle; |
|
76 | - } |
|
77 | - } |
|
60 | + /** |
|
61 | + * Get the bundle with the specified identifier |
|
62 | + * |
|
63 | + * @param string $identifier |
|
64 | + * @return Bundle |
|
65 | + * @throws \BadMethodCallException If the bundle does not exist |
|
66 | + */ |
|
67 | + public function getBundleByIdentifier($identifier) { |
|
68 | + /** @var Bundle[] $bundles */ |
|
69 | + $bundles = array_merge( |
|
70 | + $this->getBundles(), |
|
71 | + $this->getDefaultInstallationBundle() |
|
72 | + ); |
|
73 | + foreach($bundles as $bundle) { |
|
74 | + if($bundle->getIdentifier() === $identifier) { |
|
75 | + return $bundle; |
|
76 | + } |
|
77 | + } |
|
78 | 78 | |
79 | - throw new \BadMethodCallException('Bundle with specified identifier does not exist'); |
|
80 | - } |
|
79 | + throw new \BadMethodCallException('Bundle with specified identifier does not exist'); |
|
80 | + } |
|
81 | 81 | } |
@@ -55,17 +55,17 @@ |
||
55 | 55 | |
56 | 56 | try { |
57 | 57 | $jobStartTime = time(); |
58 | - $logger->debug('Run ' . get_class($this) . ' job with ID ' . $this->getId(), ['app' => 'cron']); |
|
58 | + $logger->debug('Run '.get_class($this).' job with ID '.$this->getId(), ['app' => 'cron']); |
|
59 | 59 | $this->run($this->argument); |
60 | 60 | $timeTaken = time() - $jobStartTime; |
61 | 61 | |
62 | - $logger->debug('Finished ' . get_class($this) . ' job with ID ' . $this->getId() . ' in ' . $timeTaken . ' seconds', ['app' => 'cron']); |
|
62 | + $logger->debug('Finished '.get_class($this).' job with ID '.$this->getId().' in '.$timeTaken.' seconds', ['app' => 'cron']); |
|
63 | 63 | $jobList->setExecutionTime($this, $timeTaken); |
64 | 64 | } catch (\Exception $e) { |
65 | 65 | if ($logger) { |
66 | 66 | $logger->logException($e, [ |
67 | 67 | 'app' => 'core', |
68 | - 'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')' |
|
68 | + 'message' => 'Error while running background job (class: '.get_class($this).', arguments: '.print_r($this->argument, true).')' |
|
69 | 69 | ]); |
70 | 70 | } |
71 | 71 | } |
@@ -28,72 +28,72 @@ |
||
28 | 28 | use OCP\ILogger; |
29 | 29 | |
30 | 30 | abstract class Job implements IJob { |
31 | - /** |
|
32 | - * @var int $id |
|
33 | - */ |
|
34 | - protected $id; |
|
31 | + /** |
|
32 | + * @var int $id |
|
33 | + */ |
|
34 | + protected $id; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var int $lastRun |
|
38 | - */ |
|
39 | - protected $lastRun; |
|
36 | + /** |
|
37 | + * @var int $lastRun |
|
38 | + */ |
|
39 | + protected $lastRun; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var mixed $argument |
|
43 | - */ |
|
44 | - protected $argument; |
|
41 | + /** |
|
42 | + * @var mixed $argument |
|
43 | + */ |
|
44 | + protected $argument; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param JobList $jobList |
|
48 | - * @param ILogger|null $logger |
|
49 | - */ |
|
50 | - public function execute($jobList, ILogger $logger = null) { |
|
51 | - $jobList->setLastRun($this); |
|
52 | - if ($logger === null) { |
|
53 | - $logger = \OC::$server->getLogger(); |
|
54 | - } |
|
46 | + /** |
|
47 | + * @param JobList $jobList |
|
48 | + * @param ILogger|null $logger |
|
49 | + */ |
|
50 | + public function execute($jobList, ILogger $logger = null) { |
|
51 | + $jobList->setLastRun($this); |
|
52 | + if ($logger === null) { |
|
53 | + $logger = \OC::$server->getLogger(); |
|
54 | + } |
|
55 | 55 | |
56 | - try { |
|
57 | - $jobStartTime = time(); |
|
58 | - $logger->debug('Run ' . get_class($this) . ' job with ID ' . $this->getId(), ['app' => 'cron']); |
|
59 | - $this->run($this->argument); |
|
60 | - $timeTaken = time() - $jobStartTime; |
|
56 | + try { |
|
57 | + $jobStartTime = time(); |
|
58 | + $logger->debug('Run ' . get_class($this) . ' job with ID ' . $this->getId(), ['app' => 'cron']); |
|
59 | + $this->run($this->argument); |
|
60 | + $timeTaken = time() - $jobStartTime; |
|
61 | 61 | |
62 | - $logger->debug('Finished ' . get_class($this) . ' job with ID ' . $this->getId() . ' in ' . $timeTaken . ' seconds', ['app' => 'cron']); |
|
63 | - $jobList->setExecutionTime($this, $timeTaken); |
|
64 | - } catch (\Exception $e) { |
|
65 | - if ($logger) { |
|
66 | - $logger->logException($e, [ |
|
67 | - 'app' => 'core', |
|
68 | - 'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')' |
|
69 | - ]); |
|
70 | - } |
|
71 | - } |
|
72 | - } |
|
62 | + $logger->debug('Finished ' . get_class($this) . ' job with ID ' . $this->getId() . ' in ' . $timeTaken . ' seconds', ['app' => 'cron']); |
|
63 | + $jobList->setExecutionTime($this, $timeTaken); |
|
64 | + } catch (\Exception $e) { |
|
65 | + if ($logger) { |
|
66 | + $logger->logException($e, [ |
|
67 | + 'app' => 'core', |
|
68 | + 'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')' |
|
69 | + ]); |
|
70 | + } |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | - abstract protected function run($argument); |
|
74 | + abstract protected function run($argument); |
|
75 | 75 | |
76 | - public function setId($id) { |
|
77 | - $this->id = $id; |
|
78 | - } |
|
76 | + public function setId($id) { |
|
77 | + $this->id = $id; |
|
78 | + } |
|
79 | 79 | |
80 | - public function setLastRun($lastRun) { |
|
81 | - $this->lastRun = $lastRun; |
|
82 | - } |
|
80 | + public function setLastRun($lastRun) { |
|
81 | + $this->lastRun = $lastRun; |
|
82 | + } |
|
83 | 83 | |
84 | - public function setArgument($argument) { |
|
85 | - $this->argument = $argument; |
|
86 | - } |
|
84 | + public function setArgument($argument) { |
|
85 | + $this->argument = $argument; |
|
86 | + } |
|
87 | 87 | |
88 | - public function getId() { |
|
89 | - return $this->id; |
|
90 | - } |
|
88 | + public function getId() { |
|
89 | + return $this->id; |
|
90 | + } |
|
91 | 91 | |
92 | - public function getLastRun() { |
|
93 | - return $this->lastRun; |
|
94 | - } |
|
92 | + public function getLastRun() { |
|
93 | + return $this->lastRun; |
|
94 | + } |
|
95 | 95 | |
96 | - public function getArgument() { |
|
97 | - return $this->argument; |
|
98 | - } |
|
96 | + public function getArgument() { |
|
97 | + return $this->argument; |
|
98 | + } |
|
99 | 99 | } |
@@ -32,100 +32,100 @@ |
||
32 | 32 | * @since 7.0.0 |
33 | 33 | */ |
34 | 34 | interface IJobList { |
35 | - /** |
|
36 | - * Add a job to the list |
|
37 | - * |
|
38 | - * @param \OCP\BackgroundJob\IJob|string $job |
|
39 | - * @param mixed $argument The argument to be passed to $job->run() when the job is exectured |
|
40 | - * @since 7.0.0 |
|
41 | - */ |
|
42 | - public function add($job, $argument = null); |
|
35 | + /** |
|
36 | + * Add a job to the list |
|
37 | + * |
|
38 | + * @param \OCP\BackgroundJob\IJob|string $job |
|
39 | + * @param mixed $argument The argument to be passed to $job->run() when the job is exectured |
|
40 | + * @since 7.0.0 |
|
41 | + */ |
|
42 | + public function add($job, $argument = null); |
|
43 | 43 | |
44 | - /** |
|
45 | - * Remove a job from the list |
|
46 | - * |
|
47 | - * @param \OCP\BackgroundJob\IJob|string $job |
|
48 | - * @param mixed $argument |
|
49 | - * @since 7.0.0 |
|
50 | - */ |
|
51 | - public function remove($job, $argument = null); |
|
44 | + /** |
|
45 | + * Remove a job from the list |
|
46 | + * |
|
47 | + * @param \OCP\BackgroundJob\IJob|string $job |
|
48 | + * @param mixed $argument |
|
49 | + * @since 7.0.0 |
|
50 | + */ |
|
51 | + public function remove($job, $argument = null); |
|
52 | 52 | |
53 | - /** |
|
54 | - * check if a job is in the list |
|
55 | - * |
|
56 | - * @param \OCP\BackgroundJob\IJob|string $job |
|
57 | - * @param mixed $argument |
|
58 | - * @return bool |
|
59 | - * @since 7.0.0 |
|
60 | - */ |
|
61 | - public function has($job, $argument); |
|
53 | + /** |
|
54 | + * check if a job is in the list |
|
55 | + * |
|
56 | + * @param \OCP\BackgroundJob\IJob|string $job |
|
57 | + * @param mixed $argument |
|
58 | + * @return bool |
|
59 | + * @since 7.0.0 |
|
60 | + */ |
|
61 | + public function has($job, $argument); |
|
62 | 62 | |
63 | - /** |
|
64 | - * get all jobs in the list |
|
65 | - * |
|
66 | - * @return \OCP\BackgroundJob\IJob[] |
|
67 | - * @since 7.0.0 |
|
68 | - * @deprecated 9.0.0 - This method is dangerous since it can cause load and |
|
69 | - * memory problems when creating too many instances. |
|
70 | - */ |
|
71 | - public function getAll(); |
|
63 | + /** |
|
64 | + * get all jobs in the list |
|
65 | + * |
|
66 | + * @return \OCP\BackgroundJob\IJob[] |
|
67 | + * @since 7.0.0 |
|
68 | + * @deprecated 9.0.0 - This method is dangerous since it can cause load and |
|
69 | + * memory problems when creating too many instances. |
|
70 | + */ |
|
71 | + public function getAll(); |
|
72 | 72 | |
73 | - /** |
|
74 | - * get the next job in the list |
|
75 | - * |
|
76 | - * @return \OCP\BackgroundJob\IJob|null |
|
77 | - * @since 7.0.0 |
|
78 | - */ |
|
79 | - public function getNext(); |
|
73 | + /** |
|
74 | + * get the next job in the list |
|
75 | + * |
|
76 | + * @return \OCP\BackgroundJob\IJob|null |
|
77 | + * @since 7.0.0 |
|
78 | + */ |
|
79 | + public function getNext(); |
|
80 | 80 | |
81 | - /** |
|
82 | - * @param int $id |
|
83 | - * @return \OCP\BackgroundJob\IJob|null |
|
84 | - * @since 7.0.0 |
|
85 | - */ |
|
86 | - public function getById($id); |
|
81 | + /** |
|
82 | + * @param int $id |
|
83 | + * @return \OCP\BackgroundJob\IJob|null |
|
84 | + * @since 7.0.0 |
|
85 | + */ |
|
86 | + public function getById($id); |
|
87 | 87 | |
88 | - /** |
|
89 | - * set the job that was last ran to the current time |
|
90 | - * |
|
91 | - * @param \OCP\BackgroundJob\IJob $job |
|
92 | - * @since 7.0.0 |
|
93 | - */ |
|
94 | - public function setLastJob(IJob $job); |
|
88 | + /** |
|
89 | + * set the job that was last ran to the current time |
|
90 | + * |
|
91 | + * @param \OCP\BackgroundJob\IJob $job |
|
92 | + * @since 7.0.0 |
|
93 | + */ |
|
94 | + public function setLastJob(IJob $job); |
|
95 | 95 | |
96 | - /** |
|
97 | - * Remove the reservation for a job |
|
98 | - * |
|
99 | - * @param IJob $job |
|
100 | - * @since 9.1.0 |
|
101 | - */ |
|
102 | - public function unlockJob(IJob $job); |
|
96 | + /** |
|
97 | + * Remove the reservation for a job |
|
98 | + * |
|
99 | + * @param IJob $job |
|
100 | + * @since 9.1.0 |
|
101 | + */ |
|
102 | + public function unlockJob(IJob $job); |
|
103 | 103 | |
104 | - /** |
|
105 | - * get the id of the last ran job |
|
106 | - * |
|
107 | - * @return int |
|
108 | - * @since 7.0.0 |
|
109 | - * @deprecated 9.1.0 - The functionality behind the value is deprecated, it |
|
110 | - * only tells you which job finished last, but since we now allow multiple |
|
111 | - * executors to run in parallel, it's not used to calculate the next job. |
|
112 | - */ |
|
113 | - public function getLastJob(); |
|
104 | + /** |
|
105 | + * get the id of the last ran job |
|
106 | + * |
|
107 | + * @return int |
|
108 | + * @since 7.0.0 |
|
109 | + * @deprecated 9.1.0 - The functionality behind the value is deprecated, it |
|
110 | + * only tells you which job finished last, but since we now allow multiple |
|
111 | + * executors to run in parallel, it's not used to calculate the next job. |
|
112 | + */ |
|
113 | + public function getLastJob(); |
|
114 | 114 | |
115 | - /** |
|
116 | - * set the lastRun of $job to now |
|
117 | - * |
|
118 | - * @param IJob $job |
|
119 | - * @since 7.0.0 |
|
120 | - */ |
|
121 | - public function setLastRun(IJob $job); |
|
115 | + /** |
|
116 | + * set the lastRun of $job to now |
|
117 | + * |
|
118 | + * @param IJob $job |
|
119 | + * @since 7.0.0 |
|
120 | + */ |
|
121 | + public function setLastRun(IJob $job); |
|
122 | 122 | |
123 | - /** |
|
124 | - * set the run duration of $job |
|
125 | - * |
|
126 | - * @param IJob $job |
|
127 | - * @param $timeTaken |
|
128 | - * @since 12.0.0 |
|
129 | - */ |
|
130 | - public function setExecutionTime(IJob $job, $timeTaken); |
|
123 | + /** |
|
124 | + * set the run duration of $job |
|
125 | + * |
|
126 | + * @param IJob $job |
|
127 | + * @param $timeTaken |
|
128 | + * @since 12.0.0 |
|
129 | + */ |
|
130 | + public function setExecutionTime(IJob $job, $timeTaken); |
|
131 | 131 | } |
@@ -35,133 +35,133 @@ |
||
35 | 35 | */ |
36 | 36 | class CalendarSearchReport implements XmlDeserializable { |
37 | 37 | |
38 | - /** |
|
39 | - * An array with requested properties. |
|
40 | - * |
|
41 | - * @var array |
|
42 | - */ |
|
43 | - public $properties; |
|
44 | - |
|
45 | - /** |
|
46 | - * List of property/component filters. |
|
47 | - * |
|
48 | - * @var array |
|
49 | - */ |
|
50 | - public $filters; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var int |
|
54 | - */ |
|
55 | - public $limit; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var int |
|
59 | - */ |
|
60 | - public $offset; |
|
61 | - |
|
62 | - /** |
|
63 | - * The deserialize method is called during xml parsing. |
|
64 | - * |
|
65 | - * This method is called statically, this is because in theory this method |
|
66 | - * may be used as a type of constructor, or factory method. |
|
67 | - * |
|
68 | - * Often you want to return an instance of the current class, but you are |
|
69 | - * free to return other data as well. |
|
70 | - * |
|
71 | - * You are responsible for advancing the reader to the next element. Not |
|
72 | - * doing anything will result in a never-ending loop. |
|
73 | - * |
|
74 | - * If you just want to skip parsing for this element altogether, you can |
|
75 | - * just call $reader->next(); |
|
76 | - * |
|
77 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
78 | - * the next element. |
|
79 | - * |
|
80 | - * @param Reader $reader |
|
81 | - * @return mixed |
|
82 | - */ |
|
83 | - static function xmlDeserialize(Reader $reader) { |
|
84 | - $elems = $reader->parseInnerTree([ |
|
85 | - '{http://nextcloud.com/ns}comp-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter', |
|
86 | - '{http://nextcloud.com/ns}prop-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter', |
|
87 | - '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter', |
|
88 | - '{http://nextcloud.com/ns}search-term' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter', |
|
89 | - '{http://nextcloud.com/ns}limit' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter', |
|
90 | - '{http://nextcloud.com/ns}offset' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter', |
|
91 | - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
92 | - ]); |
|
93 | - |
|
94 | - $newProps = [ |
|
95 | - 'filters' => [], |
|
96 | - 'properties' => [], |
|
97 | - 'limit' => null, |
|
98 | - 'offset' => null |
|
99 | - ]; |
|
100 | - |
|
101 | - if (!is_array($elems)) { |
|
102 | - $elems = []; |
|
103 | - } |
|
104 | - |
|
105 | - foreach ($elems as $elem) { |
|
106 | - switch ($elem['name']) { |
|
107 | - case '{DAV:}prop': |
|
108 | - $newProps['properties'] = array_keys($elem['value']); |
|
109 | - break; |
|
110 | - case '{' . SearchPlugin::NS_Nextcloud . '}filter': |
|
111 | - foreach ($elem['value'] as $subElem) { |
|
112 | - if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') { |
|
113 | - if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) { |
|
114 | - $newProps['filters']['comps'] = []; |
|
115 | - } |
|
116 | - $newProps['filters']['comps'][] = $subElem['value']; |
|
117 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') { |
|
118 | - if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) { |
|
119 | - $newProps['filters']['props'] = []; |
|
120 | - } |
|
121 | - $newProps['filters']['props'][] = $subElem['value']; |
|
122 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') { |
|
123 | - if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) { |
|
124 | - $newProps['filters']['params'] = []; |
|
125 | - } |
|
126 | - $newProps['filters']['params'][] = $subElem['value']; |
|
127 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') { |
|
128 | - $newProps['filters']['search-term'] = $subElem['value']; |
|
129 | - } |
|
130 | - } |
|
131 | - break; |
|
132 | - case '{' . SearchPlugin::NS_Nextcloud . '}limit': |
|
133 | - $newProps['limit'] = $elem['value']; |
|
134 | - break; |
|
135 | - case '{' . SearchPlugin::NS_Nextcloud . '}offset': |
|
136 | - $newProps['offset'] = $elem['value']; |
|
137 | - break; |
|
138 | - |
|
139 | - } |
|
140 | - } |
|
141 | - |
|
142 | - if (empty($newProps['filters'])) { |
|
143 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request'); |
|
144 | - } |
|
145 | - |
|
146 | - $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params'])); |
|
147 | - $noCompsDefined = empty($newProps['filters']['comps']); |
|
148 | - if ($propsOrParamsDefined && $noCompsDefined) { |
|
149 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter'); |
|
150 | - } |
|
151 | - |
|
152 | - if (!isset($newProps['filters']['search-term'])) { |
|
153 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request'); |
|
154 | - } |
|
155 | - |
|
156 | - if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) { |
|
157 | - throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request'); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - $obj = new self(); |
|
162 | - foreach ($newProps as $key => $value) { |
|
163 | - $obj->$key = $value; |
|
164 | - } |
|
165 | - return $obj; |
|
166 | - } |
|
38 | + /** |
|
39 | + * An array with requested properties. |
|
40 | + * |
|
41 | + * @var array |
|
42 | + */ |
|
43 | + public $properties; |
|
44 | + |
|
45 | + /** |
|
46 | + * List of property/component filters. |
|
47 | + * |
|
48 | + * @var array |
|
49 | + */ |
|
50 | + public $filters; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var int |
|
54 | + */ |
|
55 | + public $limit; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var int |
|
59 | + */ |
|
60 | + public $offset; |
|
61 | + |
|
62 | + /** |
|
63 | + * The deserialize method is called during xml parsing. |
|
64 | + * |
|
65 | + * This method is called statically, this is because in theory this method |
|
66 | + * may be used as a type of constructor, or factory method. |
|
67 | + * |
|
68 | + * Often you want to return an instance of the current class, but you are |
|
69 | + * free to return other data as well. |
|
70 | + * |
|
71 | + * You are responsible for advancing the reader to the next element. Not |
|
72 | + * doing anything will result in a never-ending loop. |
|
73 | + * |
|
74 | + * If you just want to skip parsing for this element altogether, you can |
|
75 | + * just call $reader->next(); |
|
76 | + * |
|
77 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
78 | + * the next element. |
|
79 | + * |
|
80 | + * @param Reader $reader |
|
81 | + * @return mixed |
|
82 | + */ |
|
83 | + static function xmlDeserialize(Reader $reader) { |
|
84 | + $elems = $reader->parseInnerTree([ |
|
85 | + '{http://nextcloud.com/ns}comp-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter', |
|
86 | + '{http://nextcloud.com/ns}prop-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter', |
|
87 | + '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter', |
|
88 | + '{http://nextcloud.com/ns}search-term' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter', |
|
89 | + '{http://nextcloud.com/ns}limit' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter', |
|
90 | + '{http://nextcloud.com/ns}offset' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter', |
|
91 | + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
92 | + ]); |
|
93 | + |
|
94 | + $newProps = [ |
|
95 | + 'filters' => [], |
|
96 | + 'properties' => [], |
|
97 | + 'limit' => null, |
|
98 | + 'offset' => null |
|
99 | + ]; |
|
100 | + |
|
101 | + if (!is_array($elems)) { |
|
102 | + $elems = []; |
|
103 | + } |
|
104 | + |
|
105 | + foreach ($elems as $elem) { |
|
106 | + switch ($elem['name']) { |
|
107 | + case '{DAV:}prop': |
|
108 | + $newProps['properties'] = array_keys($elem['value']); |
|
109 | + break; |
|
110 | + case '{' . SearchPlugin::NS_Nextcloud . '}filter': |
|
111 | + foreach ($elem['value'] as $subElem) { |
|
112 | + if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') { |
|
113 | + if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) { |
|
114 | + $newProps['filters']['comps'] = []; |
|
115 | + } |
|
116 | + $newProps['filters']['comps'][] = $subElem['value']; |
|
117 | + } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') { |
|
118 | + if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) { |
|
119 | + $newProps['filters']['props'] = []; |
|
120 | + } |
|
121 | + $newProps['filters']['props'][] = $subElem['value']; |
|
122 | + } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') { |
|
123 | + if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) { |
|
124 | + $newProps['filters']['params'] = []; |
|
125 | + } |
|
126 | + $newProps['filters']['params'][] = $subElem['value']; |
|
127 | + } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') { |
|
128 | + $newProps['filters']['search-term'] = $subElem['value']; |
|
129 | + } |
|
130 | + } |
|
131 | + break; |
|
132 | + case '{' . SearchPlugin::NS_Nextcloud . '}limit': |
|
133 | + $newProps['limit'] = $elem['value']; |
|
134 | + break; |
|
135 | + case '{' . SearchPlugin::NS_Nextcloud . '}offset': |
|
136 | + $newProps['offset'] = $elem['value']; |
|
137 | + break; |
|
138 | + |
|
139 | + } |
|
140 | + } |
|
141 | + |
|
142 | + if (empty($newProps['filters'])) { |
|
143 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request'); |
|
144 | + } |
|
145 | + |
|
146 | + $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params'])); |
|
147 | + $noCompsDefined = empty($newProps['filters']['comps']); |
|
148 | + if ($propsOrParamsDefined && $noCompsDefined) { |
|
149 | + throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter'); |
|
150 | + } |
|
151 | + |
|
152 | + if (!isset($newProps['filters']['search-term'])) { |
|
153 | + throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request'); |
|
154 | + } |
|
155 | + |
|
156 | + if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) { |
|
157 | + throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request'); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + $obj = new self(); |
|
162 | + foreach ($newProps as $key => $value) { |
|
163 | + $obj->$key = $value; |
|
164 | + } |
|
165 | + return $obj; |
|
166 | + } |
|
167 | 167 | } |
@@ -107,32 +107,32 @@ discard block |
||
107 | 107 | case '{DAV:}prop': |
108 | 108 | $newProps['properties'] = array_keys($elem['value']); |
109 | 109 | break; |
110 | - case '{' . SearchPlugin::NS_Nextcloud . '}filter': |
|
110 | + case '{'.SearchPlugin::NS_Nextcloud.'}filter': |
|
111 | 111 | foreach ($elem['value'] as $subElem) { |
112 | - if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') { |
|
112 | + if ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}comp-filter') { |
|
113 | 113 | if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) { |
114 | 114 | $newProps['filters']['comps'] = []; |
115 | 115 | } |
116 | 116 | $newProps['filters']['comps'][] = $subElem['value']; |
117 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') { |
|
117 | + } elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}prop-filter') { |
|
118 | 118 | if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) { |
119 | 119 | $newProps['filters']['props'] = []; |
120 | 120 | } |
121 | 121 | $newProps['filters']['props'][] = $subElem['value']; |
122 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') { |
|
122 | + } elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}param-filter') { |
|
123 | 123 | if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) { |
124 | 124 | $newProps['filters']['params'] = []; |
125 | 125 | } |
126 | 126 | $newProps['filters']['params'][] = $subElem['value']; |
127 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') { |
|
127 | + } elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}search-term') { |
|
128 | 128 | $newProps['filters']['search-term'] = $subElem['value']; |
129 | 129 | } |
130 | 130 | } |
131 | 131 | break; |
132 | - case '{' . SearchPlugin::NS_Nextcloud . '}limit': |
|
132 | + case '{'.SearchPlugin::NS_Nextcloud.'}limit': |
|
133 | 133 | $newProps['limit'] = $elem['value']; |
134 | 134 | break; |
135 | - case '{' . SearchPlugin::NS_Nextcloud . '}offset': |
|
135 | + case '{'.SearchPlugin::NS_Nextcloud.'}offset': |
|
136 | 136 | $newProps['offset'] = $elem['value']; |
137 | 137 | break; |
138 | 138 | |
@@ -140,21 +140,21 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | if (empty($newProps['filters'])) { |
143 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request'); |
|
143 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}filter element is required for this request'); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params'])); |
147 | 147 | $noCompsDefined = empty($newProps['filters']['comps']); |
148 | 148 | if ($propsOrParamsDefined && $noCompsDefined) { |
149 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter'); |
|
149 | + throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter given without any {'.SearchPlugin::NS_Nextcloud.'}comp-filter'); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | if (!isset($newProps['filters']['search-term'])) { |
153 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request'); |
|
153 | + throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}search-term is required for this request'); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) { |
157 | - throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request'); |
|
157 | + throw new BadRequest('At least one{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter is required for this request'); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 |
@@ -23,20 +23,20 @@ |
||
23 | 23 | |
24 | 24 | class CoreBundle extends Bundle { |
25 | 25 | |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getName() { |
|
30 | - return 'Core bundle'; |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getName() { |
|
30 | + return 'Core bundle'; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * {@inheritDoc} |
|
35 | - */ |
|
36 | - public function getAppIdentifiers() { |
|
37 | - return [ |
|
38 | - 'bruteforcesettings', |
|
39 | - ]; |
|
40 | - } |
|
33 | + /** |
|
34 | + * {@inheritDoc} |
|
35 | + */ |
|
36 | + public function getAppIdentifiers() { |
|
37 | + return [ |
|
38 | + 'bruteforcesettings', |
|
39 | + ]; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * {@inheritDoc} |
28 | 28 | */ |
29 | 29 | public function getName() { |
30 | - return (string)$this->l10n->t('Groupware bundle'); |
|
30 | + return (string) $this->l10n->t('Groupware bundle'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -25,23 +25,23 @@ |
||
25 | 25 | |
26 | 26 | class GroupwareBundle extends Bundle { |
27 | 27 | |
28 | - /** |
|
29 | - * {@inheritDoc} |
|
30 | - */ |
|
31 | - public function getName() { |
|
32 | - return (string)$this->l10n->t('Groupware bundle'); |
|
33 | - } |
|
28 | + /** |
|
29 | + * {@inheritDoc} |
|
30 | + */ |
|
31 | + public function getName() { |
|
32 | + return (string)$this->l10n->t('Groupware bundle'); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * {@inheritDoc} |
|
37 | - */ |
|
38 | - public function getAppIdentifiers() { |
|
39 | - return [ |
|
40 | - 'calendar', |
|
41 | - 'contacts', |
|
42 | - 'deck', |
|
43 | - 'mail' |
|
44 | - ]; |
|
45 | - } |
|
35 | + /** |
|
36 | + * {@inheritDoc} |
|
37 | + */ |
|
38 | + public function getAppIdentifiers() { |
|
39 | + return [ |
|
40 | + 'calendar', |
|
41 | + 'contacts', |
|
42 | + 'deck', |
|
43 | + 'mail' |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | } |
@@ -24,36 +24,36 @@ |
||
24 | 24 | use OCP\IL10N; |
25 | 25 | |
26 | 26 | abstract class Bundle { |
27 | - /** @var IL10N */ |
|
28 | - protected $l10n; |
|
27 | + /** @var IL10N */ |
|
28 | + protected $l10n; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param IL10N $l10n |
|
32 | - */ |
|
33 | - public function __construct(IL10N $l10n) { |
|
34 | - $this->l10n = $l10n; |
|
35 | - } |
|
30 | + /** |
|
31 | + * @param IL10N $l10n |
|
32 | + */ |
|
33 | + public function __construct(IL10N $l10n) { |
|
34 | + $this->l10n = $l10n; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Get the identifier of the bundle |
|
39 | - * |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public final function getIdentifier() { |
|
43 | - return substr(strrchr(get_class($this), '\\'), 1); |
|
44 | - } |
|
37 | + /** |
|
38 | + * Get the identifier of the bundle |
|
39 | + * |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public final function getIdentifier() { |
|
43 | + return substr(strrchr(get_class($this), '\\'), 1); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Get the name of the bundle |
|
48 | - * |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public abstract function getName(); |
|
46 | + /** |
|
47 | + * Get the name of the bundle |
|
48 | + * |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public abstract function getName(); |
|
52 | 52 | |
53 | - /** |
|
54 | - * Get the list of app identifiers in the bundle |
|
55 | - * |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public abstract function getAppIdentifiers(); |
|
53 | + /** |
|
54 | + * Get the list of app identifiers in the bundle |
|
55 | + * |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public abstract function getAppIdentifiers(); |
|
59 | 59 | } |
@@ -34,59 +34,59 @@ |
||
34 | 34 | use Symfony\Component\Console\Output\OutputInterface; |
35 | 35 | |
36 | 36 | class ConvertMysqlToMB4 extends Command { |
37 | - /** @var IConfig */ |
|
38 | - private $config; |
|
37 | + /** @var IConfig */ |
|
38 | + private $config; |
|
39 | 39 | |
40 | - /** @var IDBConnection */ |
|
41 | - private $connection; |
|
40 | + /** @var IDBConnection */ |
|
41 | + private $connection; |
|
42 | 42 | |
43 | - /** @var IURLGenerator */ |
|
44 | - private $urlGenerator; |
|
43 | + /** @var IURLGenerator */ |
|
44 | + private $urlGenerator; |
|
45 | 45 | |
46 | - /** @var ILogger */ |
|
47 | - private $logger; |
|
46 | + /** @var ILogger */ |
|
47 | + private $logger; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param IConfig $config |
|
51 | - * @param IDBConnection $connection |
|
52 | - * @param IURLGenerator $urlGenerator |
|
53 | - * @param ILogger $logger |
|
54 | - */ |
|
55 | - public function __construct(IConfig $config, IDBConnection $connection, IURLGenerator $urlGenerator, ILogger $logger) { |
|
56 | - $this->config = $config; |
|
57 | - $this->connection = $connection; |
|
58 | - $this->urlGenerator = $urlGenerator; |
|
59 | - $this->logger = $logger; |
|
60 | - parent::__construct(); |
|
61 | - } |
|
49 | + /** |
|
50 | + * @param IConfig $config |
|
51 | + * @param IDBConnection $connection |
|
52 | + * @param IURLGenerator $urlGenerator |
|
53 | + * @param ILogger $logger |
|
54 | + */ |
|
55 | + public function __construct(IConfig $config, IDBConnection $connection, IURLGenerator $urlGenerator, ILogger $logger) { |
|
56 | + $this->config = $config; |
|
57 | + $this->connection = $connection; |
|
58 | + $this->urlGenerator = $urlGenerator; |
|
59 | + $this->logger = $logger; |
|
60 | + parent::__construct(); |
|
61 | + } |
|
62 | 62 | |
63 | - protected function configure() { |
|
64 | - $this |
|
65 | - ->setName('db:convert-mysql-charset') |
|
66 | - ->setDescription('Convert charset of MySQL/MariaDB to use utf8mb4'); |
|
67 | - } |
|
63 | + protected function configure() { |
|
64 | + $this |
|
65 | + ->setName('db:convert-mysql-charset') |
|
66 | + ->setDescription('Convert charset of MySQL/MariaDB to use utf8mb4'); |
|
67 | + } |
|
68 | 68 | |
69 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
70 | - if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) { |
|
71 | - $output->writeln("This command is only valid for MySQL/MariaDB databases."); |
|
72 | - return 1; |
|
73 | - } |
|
69 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
70 | + if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) { |
|
71 | + $output->writeln("This command is only valid for MySQL/MariaDB databases."); |
|
72 | + return 1; |
|
73 | + } |
|
74 | 74 | |
75 | - $tools = new MySqlTools(); |
|
76 | - if (!$tools->supports4ByteCharset($this->connection)) { |
|
77 | - $url = $this->urlGenerator->linkToDocs('admin-mysql-utf8mb4'); |
|
78 | - $output->writeln("The database is not properly setup to use the charset utf8mb4."); |
|
79 | - $output->writeln("For more information please read the documentation at $url"); |
|
80 | - return 1; |
|
81 | - } |
|
75 | + $tools = new MySqlTools(); |
|
76 | + if (!$tools->supports4ByteCharset($this->connection)) { |
|
77 | + $url = $this->urlGenerator->linkToDocs('admin-mysql-utf8mb4'); |
|
78 | + $output->writeln("The database is not properly setup to use the charset utf8mb4."); |
|
79 | + $output->writeln("For more information please read the documentation at $url"); |
|
80 | + return 1; |
|
81 | + } |
|
82 | 82 | |
83 | - // enable charset |
|
84 | - $this->config->setSystemValue('mysql.utf8mb4', true); |
|
83 | + // enable charset |
|
84 | + $this->config->setSystemValue('mysql.utf8mb4', true); |
|
85 | 85 | |
86 | - // run conversion |
|
87 | - $coll = new Collation($this->config, $this->logger, $this->connection, false); |
|
88 | - $coll->run(new ConsoleOutput($output)); |
|
86 | + // run conversion |
|
87 | + $coll = new Collation($this->config, $this->logger, $this->connection, false); |
|
88 | + $coll->run(new ConsoleOutput($output)); |
|
89 | 89 | |
90 | - return 0; |
|
91 | - } |
|
90 | + return 0; |
|
91 | + } |
|
92 | 92 | } |