@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function getGroups($search = '', $limit = null, $offset = null) { |
81 | 81 | if ($limit !== null) { |
82 | - $limit = (int)$limit; |
|
82 | + $limit = (int) $limit; |
|
83 | 83 | } |
84 | 84 | if ($offset !== null) { |
85 | - $offset = (int)$offset; |
|
85 | + $offset = (int) $offset; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $groups = $this->groupManager->search($search, $limit, $offset); |
@@ -107,21 +107,21 @@ discard block |
||
107 | 107 | $user = $this->userSession->getUser(); |
108 | 108 | |
109 | 109 | // Check the group exists |
110 | - if(!$this->groupManager->groupExists($groupId)) { |
|
110 | + if (!$this->groupManager->groupExists($groupId)) { |
|
111 | 111 | throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND); |
112 | 112 | } |
113 | 113 | |
114 | 114 | $isSubadminOfGroup = false; |
115 | 115 | $group = $this->groupManager->get($groupId); |
116 | 116 | if ($group !== null) { |
117 | - $isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminofGroup($user, $group); |
|
117 | + $isSubadminOfGroup = $this->groupManager->getSubAdmin()->isSubAdminofGroup($user, $group); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // Check subadmin has access to this group |
121 | - if($this->groupManager->isAdmin($user->getUID()) |
|
121 | + if ($this->groupManager->isAdmin($user->getUID()) |
|
122 | 122 | || $isSubadminOfGroup) { |
123 | 123 | $users = $this->groupManager->get($groupId)->getUsers(); |
124 | - $users = array_map(function($user) { |
|
124 | + $users = array_map(function($user) { |
|
125 | 125 | /** @var IUser $user */ |
126 | 126 | return $user->getUID(); |
127 | 127 | }, $users); |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function addGroup($groupid) { |
145 | 145 | // Validate name |
146 | - if(empty($groupid)) { |
|
146 | + if (empty($groupid)) { |
|
147 | 147 | $this->logger->error('Group name not supplied', ['app' => 'provisioning_api']); |
148 | 148 | throw new OCSException('Invalid group name', 101); |
149 | 149 | } |
150 | 150 | // Check if it exists |
151 | - if($this->groupManager->groupExists($groupid)){ |
|
151 | + if ($this->groupManager->groupExists($groupid)) { |
|
152 | 152 | throw new OCSException('', 102); |
153 | 153 | } |
154 | 154 | $this->groupManager->createGroup($groupid); |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function deleteGroup($groupId) { |
166 | 166 | // Check it exists |
167 | - if(!$this->groupManager->groupExists($groupId)){ |
|
167 | + if (!$this->groupManager->groupExists($groupId)) { |
|
168 | 168 | throw new OCSException('', 101); |
169 | - } else if($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()){ |
|
169 | + } else if ($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()) { |
|
170 | 170 | // Cannot delete admin group |
171 | 171 | throw new OCSException('', 102); |
172 | 172 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | public function getSubAdminsOfGroup($groupId) { |
183 | 183 | // Check group exists |
184 | 184 | $targetGroup = $this->groupManager->get($groupId); |
185 | - if($targetGroup === null) { |
|
185 | + if ($targetGroup === null) { |
|
186 | 186 | throw new OCSException('Group does not exist', 101); |
187 | 187 | } |
188 | 188 |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @throws ShareNotFound |
93 | 93 | */ |
94 | 94 | public function beforeController($controller, $methodName) { |
95 | - if(!$this->isSharingEnabled()) { |
|
95 | + if (!$this->isSharingEnabled()) { |
|
96 | 96 | throw new NotFoundException('Sharing is disabled.'); |
97 | 97 | } |
98 | 98 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @throws \Exception |
120 | 120 | */ |
121 | 121 | public function afterException($controller, $methodName, \Exception $exception) { |
122 | - if(is_a($exception, '\OCP\Files\NotFoundException')) { |
|
122 | + if (is_a($exception, '\OCP\Files\NotFoundException')) { |
|
123 | 123 | return new NotFoundResponse(); |
124 | 124 | } |
125 | 125 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | private function isSharingEnabled() { |
157 | 157 | // FIXME: This check is done here since the route is globally defined and not inside the files_sharing app |
158 | 158 | // Check whether the sharing application is enabled |
159 | - if(!$this->appManager->isEnabledForUser($this->appName)) { |
|
159 | + if (!$this->appManager->isEnabledForUser($this->appName)) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | // Check whether public sharing is enabled |
177 | - if($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { |
|
177 | + if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { |
|
178 | 178 | return false; |
179 | 179 | } |
180 | 180 |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | |
61 | 61 | $remoteStorages = $this->getRemoteStorages(); |
62 | 62 | |
63 | - $output->writeln(count($remoteStorages) . ' remote storage(s) need(s) to be checked'); |
|
63 | + $output->writeln(count($remoteStorages).' remote storage(s) need(s) to be checked'); |
|
64 | 64 | |
65 | 65 | $remoteShareIds = $this->getRemoteShareIds(); |
66 | 66 | |
67 | - $output->writeln(count($remoteShareIds) . ' remote share(s) exist'); |
|
67 | + $output->writeln(count($remoteShareIds).' remote share(s) exist'); |
|
68 | 68 | |
69 | 69 | foreach ($remoteShareIds as $id => $remoteShareId) { |
70 | 70 | if (isset($remoteStorages[$remoteShareId])) { |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | ->where($queryBuilder->expr()->like( |
143 | 143 | 'id', |
144 | 144 | // match all 'shared::' + 32 characters storages |
145 | - $queryBuilder->createNamedParameter($this->connection->escapeLikeParameter('shared::') . str_repeat('_', 32)), |
|
145 | + $queryBuilder->createNamedParameter($this->connection->escapeLikeParameter('shared::').str_repeat('_', 32)), |
|
146 | 146 | IQueryBuilder::PARAM_STR) |
147 | 147 | ) |
148 | 148 | ->andWhere($queryBuilder->expr()->notLike( |
149 | 149 | 'id', |
150 | 150 | // but not the ones starting with a '/', they are for normal shares |
151 | - $queryBuilder->createNamedParameter($this->connection->escapeLikeParameter('shared::/') . '%'), |
|
151 | + $queryBuilder->createNamedParameter($this->connection->escapeLikeParameter('shared::/').'%'), |
|
152 | 152 | IQueryBuilder::PARAM_STR) |
153 | 153 | )->orderBy('numeric_id'); |
154 | 154 | $query = $queryBuilder->execute(); |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $remoteShareIds = []; |
173 | 173 | |
174 | 174 | while ($row = $query->fetch()) { |
175 | - $remoteShareIds[$row['id']] = 'shared::' . md5($row['share_token'] . '@' . $row['remote']); |
|
175 | + $remoteShareIds[$row['id']] = 'shared::'.md5($row['share_token'].'@'.$row['remote']); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | return $remoteShareIds; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | } |
133 | 133 | $this->tags = $this->mapper->loadTags($this->owners, $this->type); |
134 | 134 | |
135 | - if(count($defaultTags) > 0 && count($this->tags) === 0) { |
|
135 | + if (count($defaultTags) > 0 && count($this->tags) === 0) { |
|
136 | 136 | $this->addMultiple($defaultTags, true); |
137 | 137 | } |
138 | 138 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return array |
174 | 174 | */ |
175 | 175 | public function getTags() { |
176 | - if(!count($this->tags)) { |
|
176 | + if (!count($this->tags)) { |
|
177 | 177 | return array(); |
178 | 178 | } |
179 | 179 | |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | }); |
183 | 183 | $tagMap = array(); |
184 | 184 | |
185 | - foreach($this->tags as $tag) { |
|
186 | - if($tag->getName() !== self::TAG_FAVORITE) { |
|
185 | + foreach ($this->tags as $tag) { |
|
186 | + if ($tag->getName() !== self::TAG_FAVORITE) { |
|
187 | 187 | $tagMap[] = $this->tagMap($tag); |
188 | 188 | } |
189 | 189 | } |
@@ -221,25 +221,25 @@ discard block |
||
221 | 221 | $chunks = array_chunk($objIds, 900, false); |
222 | 222 | foreach ($chunks as $chunk) { |
223 | 223 | $result = $conn->executeQuery( |
224 | - 'SELECT `category`, `categoryid`, `objid` ' . |
|
225 | - 'FROM `' . self::RELATION_TABLE . '` r, `' . self::TAG_TABLE . '` ' . |
|
224 | + 'SELECT `category`, `categoryid`, `objid` '. |
|
225 | + 'FROM `'.self::RELATION_TABLE.'` r, `'.self::TAG_TABLE.'` '. |
|
226 | 226 | 'WHERE `categoryid` = `id` AND `uid` = ? AND r.`type` = ? AND `objid` IN (?)', |
227 | 227 | array($this->user, $this->type, $chunk), |
228 | 228 | array(null, null, IQueryBuilder::PARAM_INT_ARRAY) |
229 | 229 | ); |
230 | 230 | while ($row = $result->fetch()) { |
231 | - $objId = (int)$row['objid']; |
|
231 | + $objId = (int) $row['objid']; |
|
232 | 232 | if (!isset($entries[$objId])) { |
233 | 233 | $entries[$objId] = array(); |
234 | 234 | } |
235 | 235 | $entries[$objId][] = $row['category']; |
236 | 236 | } |
237 | 237 | if (\OCP\DB::isError($result)) { |
238 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR); |
|
238 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OCP\DB::getErrorMessage(), \OCP\Util::ERROR); |
|
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | } |
242 | - } catch(\Exception $e) { |
|
242 | + } catch (\Exception $e) { |
|
243 | 243 | \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
244 | 244 | \OCP\Util::ERROR); |
245 | 245 | return false; |
@@ -260,18 +260,18 @@ discard block |
||
260 | 260 | public function getIdsForTag($tag) { |
261 | 261 | $result = null; |
262 | 262 | $tagId = false; |
263 | - if(is_numeric($tag)) { |
|
263 | + if (is_numeric($tag)) { |
|
264 | 264 | $tagId = $tag; |
265 | - } elseif(is_string($tag)) { |
|
265 | + } elseif (is_string($tag)) { |
|
266 | 266 | $tag = trim($tag); |
267 | - if($tag === '') { |
|
267 | + if ($tag === '') { |
|
268 | 268 | \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', \OCP\Util::DEBUG); |
269 | 269 | return false; |
270 | 270 | } |
271 | 271 | $tagId = $this->getTagId($tag); |
272 | 272 | } |
273 | 273 | |
274 | - if($tagId === false) { |
|
274 | + if ($tagId === false) { |
|
275 | 275 | $l10n = \OC::$server->getL10N('core'); |
276 | 276 | throw new \Exception( |
277 | 277 | $l10n->t('Could not find category "%s"', [$tag]) |
@@ -279,25 +279,25 @@ discard block |
||
279 | 279 | } |
280 | 280 | |
281 | 281 | $ids = array(); |
282 | - $sql = 'SELECT `objid` FROM `' . self::RELATION_TABLE |
|
282 | + $sql = 'SELECT `objid` FROM `'.self::RELATION_TABLE |
|
283 | 283 | . '` WHERE `categoryid` = ?'; |
284 | 284 | |
285 | 285 | try { |
286 | 286 | $stmt = \OCP\DB::prepare($sql); |
287 | 287 | $result = $stmt->execute(array($tagId)); |
288 | 288 | if (\OCP\DB::isError($result)) { |
289 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR); |
|
289 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OCP\DB::getErrorMessage(), \OCP\Util::ERROR); |
|
290 | 290 | return false; |
291 | 291 | } |
292 | - } catch(\Exception $e) { |
|
292 | + } catch (\Exception $e) { |
|
293 | 293 | \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
294 | 294 | \OCP\Util::ERROR); |
295 | 295 | return false; |
296 | 296 | } |
297 | 297 | |
298 | - if(!is_null($result)) { |
|
299 | - while( $row = $result->fetchRow()) { |
|
300 | - $id = (int)$row['objid']; |
|
298 | + if (!is_null($result)) { |
|
299 | + while ($row = $result->fetchRow()) { |
|
300 | + $id = (int) $row['objid']; |
|
301 | 301 | |
302 | 302 | if ($this->includeShared) { |
303 | 303 | // We have to check if we are really allowed to access the |
@@ -351,24 +351,24 @@ discard block |
||
351 | 351 | public function add($name) { |
352 | 352 | $name = trim($name); |
353 | 353 | |
354 | - if($name === '') { |
|
354 | + if ($name === '') { |
|
355 | 355 | \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', \OCP\Util::DEBUG); |
356 | 356 | return false; |
357 | 357 | } |
358 | - if($this->userHasTag($name, $this->user)) { |
|
359 | - \OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', \OCP\Util::DEBUG); |
|
358 | + if ($this->userHasTag($name, $this->user)) { |
|
359 | + \OCP\Util::writeLog('core', __METHOD__.', name: '.$name.' exists already', \OCP\Util::DEBUG); |
|
360 | 360 | return false; |
361 | 361 | } |
362 | 362 | try { |
363 | 363 | $tag = new Tag($this->user, $this->type, $name); |
364 | 364 | $tag = $this->mapper->insert($tag); |
365 | 365 | $this->tags[] = $tag; |
366 | - } catch(\Exception $e) { |
|
366 | + } catch (\Exception $e) { |
|
367 | 367 | \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
368 | 368 | \OCP\Util::ERROR); |
369 | 369 | return false; |
370 | 370 | } |
371 | - \OCP\Util::writeLog('core', __METHOD__.', id: ' . $tag->getId(), \OCP\Util::DEBUG); |
|
371 | + \OCP\Util::writeLog('core', __METHOD__.', id: '.$tag->getId(), \OCP\Util::DEBUG); |
|
372 | 372 | return $tag->getId(); |
373 | 373 | } |
374 | 374 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | $from = trim($from); |
384 | 384 | $to = trim($to); |
385 | 385 | |
386 | - if($to === '' || $from === '') { |
|
386 | + if ($to === '' || $from === '') { |
|
387 | 387 | \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', \OCP\Util::DEBUG); |
388 | 388 | return false; |
389 | 389 | } |
@@ -393,21 +393,21 @@ discard block |
||
393 | 393 | } else { |
394 | 394 | $key = $this->getTagByName($from); |
395 | 395 | } |
396 | - if($key === false) { |
|
397 | - \OCP\Util::writeLog('core', __METHOD__.', tag: ' . $from. ' does not exist', \OCP\Util::DEBUG); |
|
396 | + if ($key === false) { |
|
397 | + \OCP\Util::writeLog('core', __METHOD__.', tag: '.$from.' does not exist', \OCP\Util::DEBUG); |
|
398 | 398 | return false; |
399 | 399 | } |
400 | 400 | $tag = $this->tags[$key]; |
401 | 401 | |
402 | - if($this->userHasTag($to, $tag->getOwner())) { |
|
403 | - \OCP\Util::writeLog('core', __METHOD__.', A tag named ' . $to. ' already exists for user ' . $tag->getOwner() . '.', \OCP\Util::DEBUG); |
|
402 | + if ($this->userHasTag($to, $tag->getOwner())) { |
|
403 | + \OCP\Util::writeLog('core', __METHOD__.', A tag named '.$to.' already exists for user '.$tag->getOwner().'.', \OCP\Util::DEBUG); |
|
404 | 404 | return false; |
405 | 405 | } |
406 | 406 | |
407 | 407 | try { |
408 | 408 | $tag->setName($to); |
409 | 409 | $this->tags[$key] = $this->mapper->update($tag); |
410 | - } catch(\Exception $e) { |
|
410 | + } catch (\Exception $e) { |
|
411 | 411 | \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
412 | 412 | \OCP\Util::ERROR); |
413 | 413 | return false; |
@@ -424,25 +424,25 @@ discard block |
||
424 | 424 | * @param int|null $id int Optional object id to add to this|these tag(s) |
425 | 425 | * @return bool Returns false on error. |
426 | 426 | */ |
427 | - public function addMultiple($names, $sync=false, $id = null) { |
|
428 | - if(!is_array($names)) { |
|
427 | + public function addMultiple($names, $sync = false, $id = null) { |
|
428 | + if (!is_array($names)) { |
|
429 | 429 | $names = array($names); |
430 | 430 | } |
431 | 431 | $names = array_map('trim', $names); |
432 | 432 | array_filter($names); |
433 | 433 | |
434 | 434 | $newones = array(); |
435 | - foreach($names as $name) { |
|
436 | - if(!$this->hasTag($name) && $name !== '') { |
|
435 | + foreach ($names as $name) { |
|
436 | + if (!$this->hasTag($name) && $name !== '') { |
|
437 | 437 | $newones[] = new Tag($this->user, $this->type, $name); |
438 | 438 | } |
439 | - if(!is_null($id) ) { |
|
439 | + if (!is_null($id)) { |
|
440 | 440 | // Insert $objectid, $categoryid pairs if not exist. |
441 | 441 | self::$relations[] = array('objid' => $id, 'tag' => $name); |
442 | 442 | } |
443 | 443 | } |
444 | 444 | $this->tags = array_merge($this->tags, $newones); |
445 | - if($sync === true) { |
|
445 | + if ($sync === true) { |
|
446 | 446 | $this->save(); |
447 | 447 | } |
448 | 448 | |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | * Save the list of tags and their object relations |
454 | 454 | */ |
455 | 455 | protected function save() { |
456 | - if(is_array($this->tags)) { |
|
457 | - foreach($this->tags as $tag) { |
|
456 | + if (is_array($this->tags)) { |
|
457 | + foreach ($this->tags as $tag) { |
|
458 | 458 | try { |
459 | 459 | if (!$this->mapper->tagExists($tag)) { |
460 | 460 | $this->mapper->insert($tag); |
461 | 461 | } |
462 | - } catch(\Exception $e) { |
|
462 | + } catch (\Exception $e) { |
|
463 | 463 | \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
464 | 464 | \OCP\Util::ERROR); |
465 | 465 | } |
@@ -467,17 +467,17 @@ discard block |
||
467 | 467 | |
468 | 468 | // reload tags to get the proper ids. |
469 | 469 | $this->tags = $this->mapper->loadTags($this->owners, $this->type); |
470 | - \OCP\Util::writeLog('core', __METHOD__.', tags: ' . print_r($this->tags, true), |
|
470 | + \OCP\Util::writeLog('core', __METHOD__.', tags: '.print_r($this->tags, true), |
|
471 | 471 | \OCP\Util::DEBUG); |
472 | 472 | // Loop through temporarily cached objectid/tagname pairs |
473 | 473 | // and save relations. |
474 | 474 | $tags = $this->tags; |
475 | 475 | // For some reason this is needed or array_search(i) will return 0..? |
476 | 476 | ksort($tags); |
477 | - foreach(self::$relations as $relation) { |
|
477 | + foreach (self::$relations as $relation) { |
|
478 | 478 | $tagId = $this->getTagId($relation['tag']); |
479 | - \OCP\Util::writeLog('core', __METHOD__ . 'catid, ' . $relation['tag'] . ' ' . $tagId, \OCP\Util::DEBUG); |
|
480 | - if($tagId) { |
|
479 | + \OCP\Util::writeLog('core', __METHOD__.'catid, '.$relation['tag'].' '.$tagId, \OCP\Util::DEBUG); |
|
480 | + if ($tagId) { |
|
481 | 481 | try { |
482 | 482 | \OCP\DB::insertIfNotExist(self::RELATION_TABLE, |
483 | 483 | array( |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | 'categoryid' => $tagId, |
486 | 486 | 'type' => $this->type, |
487 | 487 | )); |
488 | - } catch(\Exception $e) { |
|
488 | + } catch (\Exception $e) { |
|
489 | 489 | \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
490 | 490 | \OCP\Util::ERROR); |
491 | 491 | } |
@@ -509,43 +509,43 @@ discard block |
||
509 | 509 | // Find all objectid/tagId pairs. |
510 | 510 | $result = null; |
511 | 511 | try { |
512 | - $stmt = \OCP\DB::prepare('SELECT `id` FROM `' . self::TAG_TABLE . '` ' |
|
512 | + $stmt = \OCP\DB::prepare('SELECT `id` FROM `'.self::TAG_TABLE.'` ' |
|
513 | 513 | . 'WHERE `uid` = ?'); |
514 | 514 | $result = $stmt->execute(array($arguments['uid'])); |
515 | 515 | if (\OCP\DB::isError($result)) { |
516 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR); |
|
516 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OCP\DB::getErrorMessage(), \OCP\Util::ERROR); |
|
517 | 517 | } |
518 | - } catch(\Exception $e) { |
|
518 | + } catch (\Exception $e) { |
|
519 | 519 | \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
520 | 520 | \OCP\Util::ERROR); |
521 | 521 | } |
522 | 522 | |
523 | - if(!is_null($result)) { |
|
523 | + if (!is_null($result)) { |
|
524 | 524 | try { |
525 | - $stmt = \OCP\DB::prepare('DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
525 | + $stmt = \OCP\DB::prepare('DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
526 | 526 | . 'WHERE `categoryid` = ?'); |
527 | - while( $row = $result->fetchRow()) { |
|
527 | + while ($row = $result->fetchRow()) { |
|
528 | 528 | try { |
529 | 529 | $stmt->execute(array($row['id'])); |
530 | - } catch(\Exception $e) { |
|
530 | + } catch (\Exception $e) { |
|
531 | 531 | \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
532 | 532 | \OCP\Util::ERROR); |
533 | 533 | } |
534 | 534 | } |
535 | - } catch(\Exception $e) { |
|
535 | + } catch (\Exception $e) { |
|
536 | 536 | \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
537 | 537 | \OCP\Util::ERROR); |
538 | 538 | } |
539 | 539 | } |
540 | 540 | try { |
541 | - $stmt = \OCP\DB::prepare('DELETE FROM `' . self::TAG_TABLE . '` ' |
|
541 | + $stmt = \OCP\DB::prepare('DELETE FROM `'.self::TAG_TABLE.'` ' |
|
542 | 542 | . 'WHERE `uid` = ?'); |
543 | 543 | $result = $stmt->execute(array($arguments['uid'])); |
544 | 544 | if (\OCP\DB::isError($result)) { |
545 | - \OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR); |
|
545 | + \OCP\Util::writeLog('core', __METHOD__.', DB error: '.\OCP\DB::getErrorMessage(), \OCP\Util::ERROR); |
|
546 | 546 | } |
547 | - } catch(\Exception $e) { |
|
548 | - \OCP\Util::writeLog('core', __METHOD__ . ', exception: ' |
|
547 | + } catch (\Exception $e) { |
|
548 | + \OCP\Util::writeLog('core', __METHOD__.', exception: ' |
|
549 | 549 | . $e->getMessage(), \OCP\Util::ERROR); |
550 | 550 | } |
551 | 551 | } |
@@ -557,24 +557,24 @@ discard block |
||
557 | 557 | * @return boolean Returns false on error. |
558 | 558 | */ |
559 | 559 | public function purgeObjects(array $ids) { |
560 | - if(count($ids) === 0) { |
|
560 | + if (count($ids) === 0) { |
|
561 | 561 | // job done ;) |
562 | 562 | return true; |
563 | 563 | } |
564 | 564 | $updates = $ids; |
565 | 565 | try { |
566 | - $query = 'DELETE FROM `' . self::RELATION_TABLE . '` '; |
|
567 | - $query .= 'WHERE `objid` IN (' . str_repeat('?,', count($ids)-1) . '?) '; |
|
566 | + $query = 'DELETE FROM `'.self::RELATION_TABLE.'` '; |
|
567 | + $query .= 'WHERE `objid` IN ('.str_repeat('?,', count($ids) - 1).'?) '; |
|
568 | 568 | $query .= 'AND `type`= ?'; |
569 | 569 | $updates[] = $this->type; |
570 | 570 | $stmt = \OCP\DB::prepare($query); |
571 | 571 | $result = $stmt->execute($updates); |
572 | 572 | if (\OCP\DB::isError($result)) { |
573 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR); |
|
573 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OCP\DB::getErrorMessage(), \OCP\Util::ERROR); |
|
574 | 574 | return false; |
575 | 575 | } |
576 | - } catch(\Exception $e) { |
|
577 | - \OCP\Util::writeLog('core', __METHOD__.', exception: ' . $e->getMessage(), |
|
576 | + } catch (\Exception $e) { |
|
577 | + \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
|
578 | 578 | \OCP\Util::ERROR); |
579 | 579 | return false; |
580 | 580 | } |
@@ -589,8 +589,8 @@ discard block |
||
589 | 589 | public function getFavorites() { |
590 | 590 | try { |
591 | 591 | return $this->getIdsForTag(self::TAG_FAVORITE); |
592 | - } catch(\Exception $e) { |
|
593 | - \OCP\Util::writeLog('core', __METHOD__.', exception: ' . $e->getMessage(), |
|
592 | + } catch (\Exception $e) { |
|
593 | + \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
|
594 | 594 | \OCP\Util::DEBUG); |
595 | 595 | return array(); |
596 | 596 | } |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | * @return boolean |
604 | 604 | */ |
605 | 605 | public function addToFavorites($objid) { |
606 | - if(!$this->userHasTag(self::TAG_FAVORITE, $this->user)) { |
|
606 | + if (!$this->userHasTag(self::TAG_FAVORITE, $this->user)) { |
|
607 | 607 | $this->add(self::TAG_FAVORITE); |
608 | 608 | } |
609 | 609 | return $this->tagAs($objid, self::TAG_FAVORITE); |
@@ -627,16 +627,16 @@ discard block |
||
627 | 627 | * @return boolean Returns false on error. |
628 | 628 | */ |
629 | 629 | public function tagAs($objid, $tag) { |
630 | - if(is_string($tag) && !is_numeric($tag)) { |
|
630 | + if (is_string($tag) && !is_numeric($tag)) { |
|
631 | 631 | $tag = trim($tag); |
632 | - if($tag === '') { |
|
632 | + if ($tag === '') { |
|
633 | 633 | \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', \OCP\Util::DEBUG); |
634 | 634 | return false; |
635 | 635 | } |
636 | - if(!$this->hasTag($tag)) { |
|
636 | + if (!$this->hasTag($tag)) { |
|
637 | 637 | $this->add($tag); |
638 | 638 | } |
639 | - $tagId = $this->getTagId($tag); |
|
639 | + $tagId = $this->getTagId($tag); |
|
640 | 640 | } else { |
641 | 641 | $tagId = $tag; |
642 | 642 | } |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | 'categoryid' => $tagId, |
648 | 648 | 'type' => $this->type, |
649 | 649 | )); |
650 | - } catch(\Exception $e) { |
|
650 | + } catch (\Exception $e) { |
|
651 | 651 | \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
652 | 652 | \OCP\Util::ERROR); |
653 | 653 | return false; |
@@ -663,23 +663,23 @@ discard block |
||
663 | 663 | * @return boolean |
664 | 664 | */ |
665 | 665 | public function unTag($objid, $tag) { |
666 | - if(is_string($tag) && !is_numeric($tag)) { |
|
666 | + if (is_string($tag) && !is_numeric($tag)) { |
|
667 | 667 | $tag = trim($tag); |
668 | - if($tag === '') { |
|
668 | + if ($tag === '') { |
|
669 | 669 | \OCP\Util::writeLog('core', __METHOD__.', Tag name is empty', \OCP\Util::DEBUG); |
670 | 670 | return false; |
671 | 671 | } |
672 | - $tagId = $this->getTagId($tag); |
|
672 | + $tagId = $this->getTagId($tag); |
|
673 | 673 | } else { |
674 | 674 | $tagId = $tag; |
675 | 675 | } |
676 | 676 | |
677 | 677 | try { |
678 | - $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
678 | + $sql = 'DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
679 | 679 | . 'WHERE `objid` = ? AND `categoryid` = ? AND `type` = ?'; |
680 | 680 | $stmt = \OCP\DB::prepare($sql); |
681 | 681 | $stmt->execute(array($objid, $tagId, $this->type)); |
682 | - } catch(\Exception $e) { |
|
682 | + } catch (\Exception $e) { |
|
683 | 683 | \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
684 | 684 | \OCP\Util::ERROR); |
685 | 685 | return false; |
@@ -694,16 +694,16 @@ discard block |
||
694 | 694 | * @return bool Returns false on error |
695 | 695 | */ |
696 | 696 | public function delete($names) { |
697 | - if(!is_array($names)) { |
|
697 | + if (!is_array($names)) { |
|
698 | 698 | $names = array($names); |
699 | 699 | } |
700 | 700 | |
701 | 701 | $names = array_map('trim', $names); |
702 | 702 | array_filter($names); |
703 | 703 | |
704 | - \OCP\Util::writeLog('core', __METHOD__ . ', before: ' |
|
704 | + \OCP\Util::writeLog('core', __METHOD__.', before: ' |
|
705 | 705 | . print_r($this->tags, true), \OCP\Util::DEBUG); |
706 | - foreach($names as $name) { |
|
706 | + foreach ($names as $name) { |
|
707 | 707 | $id = null; |
708 | 708 | |
709 | 709 | if (is_numeric($name)) { |
@@ -717,22 +717,22 @@ discard block |
||
717 | 717 | unset($this->tags[$key]); |
718 | 718 | $this->mapper->delete($tag); |
719 | 719 | } else { |
720 | - \OCP\Util::writeLog('core', __METHOD__ . 'Cannot delete tag ' . $name |
|
720 | + \OCP\Util::writeLog('core', __METHOD__.'Cannot delete tag '.$name |
|
721 | 721 | . ': not found.', \OCP\Util::ERROR); |
722 | 722 | } |
723 | - if(!is_null($id) && $id !== false) { |
|
723 | + if (!is_null($id) && $id !== false) { |
|
724 | 724 | try { |
725 | - $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
725 | + $sql = 'DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
726 | 726 | . 'WHERE `categoryid` = ?'; |
727 | 727 | $stmt = \OCP\DB::prepare($sql); |
728 | 728 | $result = $stmt->execute(array($id)); |
729 | 729 | if (\OCP\DB::isError($result)) { |
730 | 730 | \OCP\Util::writeLog('core', |
731 | - __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), |
|
731 | + __METHOD__.'DB error: '.\OCP\DB::getErrorMessage(), |
|
732 | 732 | \OCP\Util::ERROR); |
733 | 733 | return false; |
734 | 734 | } |
735 | - } catch(\Exception $e) { |
|
735 | + } catch (\Exception $e) { |
|
736 | 736 | \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), |
737 | 737 | \OCP\Util::ERROR); |
738 | 738 | return false; |
@@ -743,8 +743,8 @@ discard block |
||
743 | 743 | } |
744 | 744 | |
745 | 745 | // case-insensitive array_search |
746 | - protected function array_searchi($needle, $haystack, $mem='getName') { |
|
747 | - if(!is_array($haystack)) { |
|
746 | + protected function array_searchi($needle, $haystack, $mem = 'getName') { |
|
747 | + if (!is_array($haystack)) { |
|
748 | 748 | return false; |
749 | 749 | } |
750 | 750 | return array_search(strtolower($needle), array_map( |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * pass all other function directly to the \Doctrine\DBAL\Driver\Statement |
56 | 56 | */ |
57 | - public function __call($name,$arguments) { |
|
58 | - return call_user_func_array(array($this->statement,$name), $arguments); |
|
57 | + public function __call($name, $arguments) { |
|
58 | + return call_user_func_array(array($this->statement, $name), $arguments); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @param array $input |
65 | 65 | * @return \OC_DB_StatementWrapper|int|bool |
66 | 66 | */ |
67 | - public function execute($input= []) { |
|
67 | + public function execute($input = []) { |
|
68 | 68 | $this->lastArguments = $input; |
69 | 69 | if (count($input) > 0) { |
70 | 70 | $result = $this->statement->execute($input); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param integer|null $length max length when using an OUT bind |
114 | 114 | * @return boolean |
115 | 115 | */ |
116 | - public function bindParam($column, &$variable, $type = null, $length = null){ |
|
116 | + public function bindParam($column, &$variable, $type = null, $length = null) { |
|
117 | 117 | return $this->statement->bindParam($column, $variable, $type, $length); |
118 | 118 | } |
119 | 119 | } |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | $this->logger = $logger; |
94 | 94 | $cachedGroups = & $this->cachedGroups; |
95 | 95 | $cachedUserGroups = & $this->cachedUserGroups; |
96 | - $this->listen('\OC\Group', 'postDelete', function ($group) use (&$cachedGroups, &$cachedUserGroups) { |
|
96 | + $this->listen('\OC\Group', 'postDelete', function($group) use (&$cachedGroups, &$cachedUserGroups) { |
|
97 | 97 | /** |
98 | 98 | * @var \OC\Group\Group $group |
99 | 99 | */ |
100 | 100 | unset($cachedGroups[$group->getGID()]); |
101 | 101 | $cachedUserGroups = array(); |
102 | 102 | }); |
103 | - $this->listen('\OC\Group', 'postAddUser', function ($group) use (&$cachedUserGroups) { |
|
103 | + $this->listen('\OC\Group', 'postAddUser', function($group) use (&$cachedUserGroups) { |
|
104 | 104 | /** |
105 | 105 | * @var \OC\Group\Group $group |
106 | 106 | */ |
107 | 107 | $cachedUserGroups = array(); |
108 | 108 | }); |
109 | - $this->listen('\OC\Group', 'postRemoveUser', function ($group) use (&$cachedUserGroups) { |
|
109 | + $this->listen('\OC\Group', 'postRemoveUser', function($group) use (&$cachedUserGroups) { |
|
110 | 110 | /** |
111 | 111 | * @var \OC\Group\Group $group |
112 | 112 | */ |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | if ($aGroup instanceof IGroup) { |
236 | 236 | $groups[$groupId] = $aGroup; |
237 | 237 | } else { |
238 | - $this->logger->debug('Group "' . $groupId . '" was returned by search but not found through direct access', ['app' => 'core']); |
|
238 | + $this->logger->debug('Group "'.$groupId.'" was returned by search but not found through direct access', ['app' => 'core']); |
|
239 | 239 | } |
240 | 240 | } |
241 | 241 | if (!is_null($limit) and $limit <= 0) { |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param IUser|null $user |
250 | 250 | * @return \OC\Group\Group[] |
251 | 251 | */ |
252 | - public function getUserGroups(IUser $user= null) { |
|
252 | + public function getUserGroups(IUser $user = null) { |
|
253 | 253 | if (!$user instanceof IUser) { |
254 | 254 | return []; |
255 | 255 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | if ($aGroup instanceof IGroup) { |
274 | 274 | $groups[$groupId] = $aGroup; |
275 | 275 | } else { |
276 | - $this->logger->debug('User "' . $uid . '" belongs to deleted group: "' . $groupId . '"', ['app' => 'core']); |
|
276 | + $this->logger->debug('User "'.$uid.'" belongs to deleted group: "'.$groupId.'"', ['app' => 'core']); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
@@ -322,32 +322,32 @@ discard block |
||
322 | 322 | */ |
323 | 323 | public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) { |
324 | 324 | $group = $this->get($gid); |
325 | - if(is_null($group)) { |
|
325 | + if (is_null($group)) { |
|
326 | 326 | return array(); |
327 | 327 | } |
328 | 328 | |
329 | 329 | $search = trim($search); |
330 | 330 | $groupUsers = array(); |
331 | 331 | |
332 | - if(!empty($search)) { |
|
332 | + if (!empty($search)) { |
|
333 | 333 | // only user backends have the capability to do a complex search for users |
334 | 334 | $searchOffset = 0; |
335 | 335 | $searchLimit = $limit * 100; |
336 | - if($limit === -1) { |
|
336 | + if ($limit === -1) { |
|
337 | 337 | $searchLimit = 500; |
338 | 338 | } |
339 | 339 | |
340 | 340 | do { |
341 | 341 | $filteredUsers = $this->userManager->searchDisplayName($search, $searchLimit, $searchOffset); |
342 | - foreach($filteredUsers as $filteredUser) { |
|
343 | - if($group->inGroup($filteredUser)) { |
|
344 | - $groupUsers[]= $filteredUser; |
|
342 | + foreach ($filteredUsers as $filteredUser) { |
|
343 | + if ($group->inGroup($filteredUser)) { |
|
344 | + $groupUsers[] = $filteredUser; |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | $searchOffset += $searchLimit; |
348 | - } while(count($groupUsers) < $searchLimit+$offset && count($filteredUsers) >= $searchLimit); |
|
348 | + } while (count($groupUsers) < $searchLimit + $offset && count($filteredUsers) >= $searchLimit); |
|
349 | 349 | |
350 | - if($limit === -1) { |
|
350 | + if ($limit === -1) { |
|
351 | 351 | $groupUsers = array_slice($groupUsers, $offset); |
352 | 352 | } else { |
353 | 353 | $groupUsers = array_slice($groupUsers, $offset, $limit); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | } |
358 | 358 | |
359 | 359 | $matchingUsers = array(); |
360 | - foreach($groupUsers as $groupUser) { |
|
360 | + foreach ($groupUsers as $groupUser) { |
|
361 | 361 | $matchingUsers[$groupUser->getUID()] = $groupUser->getDisplayName(); |
362 | 362 | } |
363 | 363 | return $matchingUsers; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @deprecated 8.0.0 Use \OCP\Template::html_select_options() instead |
140 | 140 | * @suppress PhanDeprecatedFunction |
141 | 141 | */ |
142 | -function html_select_options($options, $selected, $params=array()) { |
|
142 | +function html_select_options($options, $selected, $params = array()) { |
|
143 | 143 | return \html_select_options($options, $selected, $params); |
144 | 144 | } |
145 | 145 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @since 8.0.0 |
243 | 243 | * @suppress PhanDeprecatedFunction |
244 | 244 | */ |
245 | - public static function html_select_options($options, $selected, $params=array()) { |
|
245 | + public static function html_select_options($options, $selected, $params = array()) { |
|
246 | 246 | return \html_select_options($options, $selected, $params); |
247 | 247 | } |
248 | 248 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @deprecated 8.1.0 use prepare() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() |
57 | 57 | * @since 4.5.0 |
58 | 58 | */ |
59 | - static public function prepare( $query, $limit=null, $offset=null ) { |
|
59 | + static public function prepare($query, $limit = null, $offset = null) { |
|
60 | 60 | return \OC_DB::prepare($query, $limit, $offset); |
61 | 61 | } |
62 | 62 | |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * @deprecated 8.1.0 use lastInsertId() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() |
90 | 90 | * @since 4.5.0 |
91 | 91 | */ |
92 | - public static function insertid($table=null) { |
|
93 | - return (string)\OC::$server->getDatabaseConnection()->lastInsertId($table); |
|
92 | + public static function insertid($table = null) { |
|
93 | + return (string) \OC::$server->getDatabaseConnection()->lastInsertId($table); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @suppress PhanDeprecatedFunction |
50 | 50 | */ |
51 | - public static function encodedPrint( $data, $setContentType=true ) { |
|
51 | + public static function encodedPrint($data, $setContentType = true) { |
|
52 | 52 | \OC_JSON::encodedPrint($data, $setContentType); |
53 | 53 | } |
54 | 54 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
108 | 108 | * @suppress PhanDeprecatedFunction |
109 | 109 | */ |
110 | - public static function success( $data = array() ) { |
|
110 | + public static function success($data = array()) { |
|
111 | 111 | \OC_JSON::success($data); |
112 | 112 | } |
113 | 113 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
131 | 131 | * @suppress PhanDeprecatedFunction |
132 | 132 | */ |
133 | - public static function error( $data = array() ) { |
|
133 | + public static function error($data = array()) { |
|
134 | 134 | \OC_JSON::error($data); |
135 | 135 | } |
136 | 136 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
141 | 141 | * @suppress PhanDeprecatedFunction |
142 | 142 | */ |
143 | - public static function setContentTypeHeader( $type='application/json' ) { |
|
143 | + public static function setContentTypeHeader($type = 'application/json') { |
|
144 | 144 | \OC_JSON::setContentTypeHeader($type); |
145 | 145 | } |
146 | 146 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @deprecated 8.1.0 Use the AppFramework instead. It will automatically check if the app is enabled. |
162 | 162 | * @suppress PhanDeprecatedFunction |
163 | 163 | */ |
164 | - public static function checkAppEnabled( $app ) { |
|
164 | + public static function checkAppEnabled($app) { |
|
165 | 165 | \OC_JSON::checkAppEnabled($app); |
166 | 166 | } |
167 | 167 |