@@ -103,6 +103,6 @@ |
||
103 | 103 | $time = new \DateTime('now', $timeZone); |
104 | 104 | $timestampInfo = $time->format($this->config->getSystemValue('logdateformat', \DateTime::ATOM)); |
105 | 105 | |
106 | - return $timestampInfo . ' ' . $this->formatter->format($message); |
|
106 | + return $timestampInfo.' '.$this->formatter->format($message); |
|
107 | 107 | } |
108 | 108 | } |
@@ -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( |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | ->execute(); |
120 | 120 | |
121 | 121 | $groups = []; |
122 | - while($row = $result->fetch()) { |
|
122 | + while ($row = $result->fetch()) { |
|
123 | 123 | $group = $this->groupManager->get($row['gid']); |
124 | - if(!is_null($group)) { |
|
124 | + if (!is_null($group)) { |
|
125 | 125 | $groups[] = $group; |
126 | 126 | } |
127 | 127 | } |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | ->execute(); |
145 | 145 | |
146 | 146 | $users = []; |
147 | - while($row = $result->fetch()) { |
|
147 | + while ($row = $result->fetch()) { |
|
148 | 148 | $user = $this->userManager->get($row['uid']); |
149 | - if(!is_null($user)) { |
|
149 | + if (!is_null($user)) { |
|
150 | 150 | $users[] = $user; |
151 | 151 | } |
152 | 152 | } |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | ->execute(); |
168 | 168 | |
169 | 169 | $subadmins = []; |
170 | - while($row = $result->fetch()) { |
|
170 | + while ($row = $result->fetch()) { |
|
171 | 171 | $user = $this->userManager->get($row['uid']); |
172 | 172 | $group = $this->groupManager->get($row['gid']); |
173 | - if(!is_null($user) && !is_null($group)) { |
|
173 | + if (!is_null($user) && !is_null($group)) { |
|
174 | 174 | $subadmins[] = [ |
175 | 175 | 'user' => $user, |
176 | 176 | 'group' => $group |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID()))) |
201 | 201 | ->execute(); |
202 | 202 | |
203 | - $fetch = $result->fetch(); |
|
203 | + $fetch = $result->fetch(); |
|
204 | 204 | $result->closeCursor(); |
205 | 205 | $result = !empty($fetch) ? true : false; |
206 | 206 | |
@@ -241,15 +241,15 @@ discard block |
||
241 | 241 | * @return bool |
242 | 242 | */ |
243 | 243 | public function isUserAccessible($subadmin, $user) { |
244 | - if(!$this->isSubAdmin($subadmin)) { |
|
244 | + if (!$this->isSubAdmin($subadmin)) { |
|
245 | 245 | return false; |
246 | 246 | } |
247 | - if($this->groupManager->isAdmin($user->getUID())) { |
|
247 | + if ($this->groupManager->isAdmin($user->getUID())) { |
|
248 | 248 | return false; |
249 | 249 | } |
250 | 250 | $accessibleGroups = $this->getSubAdminsGroups($subadmin); |
251 | - foreach($accessibleGroups as $accessibleGroup) { |
|
252 | - if($accessibleGroup->inGroup($user)) { |
|
251 | + foreach ($accessibleGroups as $accessibleGroup) { |
|
252 | + if ($accessibleGroup->inGroup($user)) { |
|
253 | 253 | return true; |
254 | 254 | } |
255 | 255 | } |
@@ -162,7 +162,7 @@ |
||
162 | 162 | */ |
163 | 163 | public function setAuthor($author) { |
164 | 164 | if (!is_string($author) || isset($author[64])) { |
165 | - throw new \InvalidArgumentException('The given author user is invalid'. serialize($author)); |
|
165 | + throw new \InvalidArgumentException('The given author user is invalid'.serialize($author)); |
|
166 | 166 | } |
167 | 167 | $this->author = (string) $author; |
168 | 168 | return $this; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | $this->consumers = []; |
115 | - foreach($this->consumersClosures as $consumer) { |
|
115 | + foreach ($this->consumersClosures as $consumer) { |
|
116 | 116 | $c = $consumer(); |
117 | 117 | if ($c instanceof IConsumer) { |
118 | 118 | $this->consumers[] = $c; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | $this->extensions = []; |
136 | - foreach($this->extensionsClosures as $extension) { |
|
136 | + foreach ($this->extensionsClosures as $extension) { |
|
137 | 137 | $e = $extension(); |
138 | 138 | if ($e instanceof IExtension) { |
139 | 139 | $this->extensions[] = $e; |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | return array(null, null); |
670 | 670 | } |
671 | 671 | |
672 | - return array(' and ((' . implode(') or (', $conditions) . '))', $parameters); |
|
672 | + return array(' and (('.implode(') or (', $conditions).'))', $parameters); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @return string |
53 | 53 | */ |
54 | 54 | public function getNonce() { |
55 | - if($this->nonce === '') { |
|
55 | + if ($this->nonce === '') { |
|
56 | 56 | $this->nonce = base64_encode($this->csrfTokenManager->getToken()->getEncryptedValue()); |
57 | 57 | } |
58 | 58 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | '/^Mozilla\/5\.0 \([^)]+\) Gecko\/[0-9.]+ Firefox\/(4[5-9]|[5-9][0-9])\.[0-9.]+$/', |
72 | 72 | ]; |
73 | 73 | |
74 | - if($this->request->isUserAgent($browserWhitelist)) { |
|
74 | + if ($this->request->isUserAgent($browserWhitelist)) { |
|
75 | 75 | return true; |
76 | 76 | } |
77 | 77 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function getDefaultPolicy() { |
45 | 45 | $defaultPolicy = new \OC\Security\CSP\ContentSecurityPolicy(); |
46 | - foreach($this->policies as $policy) { |
|
46 | + foreach ($this->policies as $policy) { |
|
47 | 47 | $defaultPolicy = $this->mergePolicies($defaultPolicy, $policy); |
48 | 48 | } |
49 | 49 | return $defaultPolicy; |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function mergePolicies(ContentSecurityPolicy $defaultPolicy, |
60 | 60 | EmptyContentSecurityPolicy $originalPolicy) { |
61 | - foreach((object)(array)$originalPolicy as $name => $value) { |
|
61 | + foreach ((object) (array) $originalPolicy as $name => $value) { |
|
62 | 62 | $setter = 'set'.ucfirst($name); |
63 | - if(is_array($value)) { |
|
63 | + if (is_array($value)) { |
|
64 | 64 | $getter = 'get'.ucfirst($name); |
65 | 65 | $currentValues = is_array($defaultPolicy->$getter()) ? $defaultPolicy->$getter() : []; |
66 | 66 | $defaultPolicy->$setter(array_values(array_unique(array_merge($currentValues, $value)))); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | return true; |
82 | 82 | } |
83 | 83 | // Reject misformed domains in any case |
84 | - if (strpos($domain,'-') === 0 || strpos($domain,'..') !== false) { |
|
84 | + if (strpos($domain, '-') === 0 || strpos($domain, '..') !== false) { |
|
85 | 85 | return false; |
86 | 86 | } |
87 | 87 | // Match, allowing for * wildcards |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | if (gettype($trusted) !== 'string') { |
90 | 90 | break; |
91 | 91 | } |
92 | - $regex = '/^' . join('[-\.a-zA-Z0-9]*', array_map(function($v) { return preg_quote($v, '/'); }, explode('*', $trusted))) . '$/'; |
|
92 | + $regex = '/^'.join('[-\.a-zA-Z0-9]*', array_map(function($v) { return preg_quote($v, '/'); }, explode('*', $trusted))).'$/'; |
|
93 | 93 | if (preg_match($regex, $domain) || preg_match($regex, $domainWithPort)) { |
94 | 94 | return true; |
95 | 95 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $this->config = $config; |
63 | 63 | |
64 | 64 | $hashingCost = $this->config->getSystemValue('hashingCost', null); |
65 | - if(!is_null($hashingCost)) { |
|
65 | + if (!is_null($hashingCost)) { |
|
66 | 66 | $this->options['cost'] = $hashingCost; |
67 | 67 | } |
68 | 68 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @return string Hash of the message with appended version parameter |
77 | 77 | */ |
78 | 78 | public function hash($message) { |
79 | - return $this->currentVersion . '|' . password_hash($message, PASSWORD_DEFAULT, $this->options); |
|
79 | + return $this->currentVersion.'|'.password_hash($message, PASSWORD_DEFAULT, $this->options); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | */ |
87 | 87 | protected function splitHash($prefixedHash) { |
88 | 88 | $explodedString = explode('|', $prefixedHash, 2); |
89 | - if(sizeof($explodedString) === 2) { |
|
90 | - if((int)$explodedString[0] > 0) { |
|
91 | - return array('version' => (int)$explodedString[0], 'hash' => $explodedString[1]); |
|
89 | + if (sizeof($explodedString) === 2) { |
|
90 | + if ((int) $explodedString[0] > 0) { |
|
91 | + return array('version' => (int) $explodedString[0], 'hash' => $explodedString[1]); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | * @return bool Whether $hash is a valid hash of $message |
104 | 104 | */ |
105 | 105 | protected function legacyHashVerify($message, $hash, &$newHash = null) { |
106 | - if(empty($this->legacySalt)) { |
|
106 | + if (empty($this->legacySalt)) { |
|
107 | 107 | $this->legacySalt = $this->config->getSystemValue('passwordsalt', ''); |
108 | 108 | } |
109 | 109 | |
110 | 110 | // Verify whether it matches a legacy PHPass or SHA1 string |
111 | 111 | $hashLength = strlen($hash); |
112 | - if($hashLength === 60 && password_verify($message.$this->legacySalt, $hash) || |
|
112 | + if ($hashLength === 60 && password_verify($message.$this->legacySalt, $hash) || |
|
113 | 113 | $hashLength === 40 && hash_equals($hash, sha1($message))) { |
114 | 114 | $newHash = $this->hash($message); |
115 | 115 | return true; |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @return bool Whether $hash is a valid hash of $message |
127 | 127 | */ |
128 | 128 | protected function verifyHashV1($message, $hash, &$newHash = null) { |
129 | - if(password_verify($message, $hash)) { |
|
130 | - if(password_needs_rehash($hash, PASSWORD_DEFAULT, $this->options)) { |
|
129 | + if (password_verify($message, $hash)) { |
|
130 | + if (password_needs_rehash($hash, PASSWORD_DEFAULT, $this->options)) { |
|
131 | 131 | $newHash = $this->hash($message); |
132 | 132 | } |
133 | 133 | return true; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | public function verify($message, $hash, &$newHash = null) { |
146 | 146 | $splittedHash = $this->splitHash($hash); |
147 | 147 | |
148 | - if(isset($splittedHash['version'])) { |
|
148 | + if (isset($splittedHash['version'])) { |
|
149 | 149 | switch ($splittedHash['version']) { |
150 | 150 | case 1: |
151 | 151 | return $this->verifyHashV1($message, $splittedHash['hash'], $newHash); |