@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | $this->tags = $this->mapper->loadTags($this->owners, $this->type); |
| 137 | 137 | |
| 138 | - if(count($defaultTags) > 0 && count($this->tags) === 0) { |
|
| 138 | + if (count($defaultTags) > 0 && count($this->tags) === 0) { |
|
| 139 | 139 | $this->addMultiple($defaultTags, true); |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * @return array |
| 177 | 177 | */ |
| 178 | 178 | public function getTags() { |
| 179 | - if(!count($this->tags)) { |
|
| 179 | + if (!count($this->tags)) { |
|
| 180 | 180 | return array(); |
| 181 | 181 | } |
| 182 | 182 | |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | }); |
| 186 | 186 | $tagMap = array(); |
| 187 | 187 | |
| 188 | - foreach($this->tags as $tag) { |
|
| 189 | - if($tag->getName() !== self::TAG_FAVORITE) { |
|
| 188 | + foreach ($this->tags as $tag) { |
|
| 189 | + if ($tag->getName() !== self::TAG_FAVORITE) { |
|
| 190 | 190 | $tagMap[] = $this->tagMap($tag); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -224,25 +224,25 @@ discard block |
||
| 224 | 224 | $chunks = array_chunk($objIds, 900, false); |
| 225 | 225 | foreach ($chunks as $chunk) { |
| 226 | 226 | $result = $conn->executeQuery( |
| 227 | - 'SELECT `category`, `categoryid`, `objid` ' . |
|
| 228 | - 'FROM `' . self::RELATION_TABLE . '` r, `' . self::TAG_TABLE . '` ' . |
|
| 227 | + 'SELECT `category`, `categoryid`, `objid` '. |
|
| 228 | + 'FROM `'.self::RELATION_TABLE.'` r, `'.self::TAG_TABLE.'` '. |
|
| 229 | 229 | 'WHERE `categoryid` = `id` AND `uid` = ? AND r.`type` = ? AND `objid` IN (?)', |
| 230 | 230 | array($this->user, $this->type, $chunk), |
| 231 | 231 | array(null, null, IQueryBuilder::PARAM_INT_ARRAY) |
| 232 | 232 | ); |
| 233 | 233 | while ($row = $result->fetch()) { |
| 234 | - $objId = (int)$row['objid']; |
|
| 234 | + $objId = (int) $row['objid']; |
|
| 235 | 235 | if (!isset($entries[$objId])) { |
| 236 | 236 | $entries[$objId] = array(); |
| 237 | 237 | } |
| 238 | 238 | $entries[$objId][] = $row['category']; |
| 239 | 239 | } |
| 240 | 240 | if ($result === null) { |
| 241 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
| 241 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
| 242 | 242 | return false; |
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | - } catch(\Exception $e) { |
|
| 245 | + } catch (\Exception $e) { |
|
| 246 | 246 | \OC::$server->getLogger()->logException($e, [ |
| 247 | 247 | 'message' => __METHOD__, |
| 248 | 248 | 'level' => ILogger::ERROR, |
@@ -266,18 +266,18 @@ discard block |
||
| 266 | 266 | public function getIdsForTag($tag) { |
| 267 | 267 | $result = null; |
| 268 | 268 | $tagId = false; |
| 269 | - if(is_numeric($tag)) { |
|
| 269 | + if (is_numeric($tag)) { |
|
| 270 | 270 | $tagId = $tag; |
| 271 | - } elseif(is_string($tag)) { |
|
| 271 | + } elseif (is_string($tag)) { |
|
| 272 | 272 | $tag = trim($tag); |
| 273 | - if($tag === '') { |
|
| 273 | + if ($tag === '') { |
|
| 274 | 274 | \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', ILogger::DEBUG); |
| 275 | 275 | return false; |
| 276 | 276 | } |
| 277 | 277 | $tagId = $this->getTagId($tag); |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if($tagId === false) { |
|
| 280 | + if ($tagId === false) { |
|
| 281 | 281 | $l10n = \OC::$server->getL10N('core'); |
| 282 | 282 | throw new \Exception( |
| 283 | 283 | $l10n->t('Could not find category "%s"', [$tag]) |
@@ -285,17 +285,17 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | $ids = array(); |
| 288 | - $sql = 'SELECT `objid` FROM `' . self::RELATION_TABLE |
|
| 288 | + $sql = 'SELECT `objid` FROM `'.self::RELATION_TABLE |
|
| 289 | 289 | . '` WHERE `categoryid` = ?'; |
| 290 | 290 | |
| 291 | 291 | try { |
| 292 | 292 | $stmt = \OC_DB::prepare($sql); |
| 293 | 293 | $result = $stmt->execute(array($tagId)); |
| 294 | 294 | if ($result === null) { |
| 295 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
| 295 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
| 296 | 296 | return false; |
| 297 | 297 | } |
| 298 | - } catch(\Exception $e) { |
|
| 298 | + } catch (\Exception $e) { |
|
| 299 | 299 | \OC::$server->getLogger()->logException($e, [ |
| 300 | 300 | 'message' => __METHOD__, |
| 301 | 301 | 'level' => ILogger::ERROR, |
@@ -304,9 +304,9 @@ discard block |
||
| 304 | 304 | return false; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - if(!is_null($result)) { |
|
| 308 | - while( $row = $result->fetchRow()) { |
|
| 309 | - $id = (int)$row['objid']; |
|
| 307 | + if (!is_null($result)) { |
|
| 308 | + while ($row = $result->fetchRow()) { |
|
| 309 | + $id = (int) $row['objid']; |
|
| 310 | 310 | |
| 311 | 311 | if ($this->includeShared) { |
| 312 | 312 | // We have to check if we are really allowed to access the |
@@ -360,19 +360,19 @@ discard block |
||
| 360 | 360 | public function add($name) { |
| 361 | 361 | $name = trim($name); |
| 362 | 362 | |
| 363 | - if($name === '') { |
|
| 363 | + if ($name === '') { |
|
| 364 | 364 | \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', ILogger::DEBUG); |
| 365 | 365 | return false; |
| 366 | 366 | } |
| 367 | - if($this->userHasTag($name, $this->user)) { |
|
| 368 | - \OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', ILogger::DEBUG); |
|
| 367 | + if ($this->userHasTag($name, $this->user)) { |
|
| 368 | + \OCP\Util::writeLog('core', __METHOD__.', name: '.$name.' exists already', ILogger::DEBUG); |
|
| 369 | 369 | return false; |
| 370 | 370 | } |
| 371 | 371 | try { |
| 372 | 372 | $tag = new Tag($this->user, $this->type, $name); |
| 373 | 373 | $tag = $this->mapper->insert($tag); |
| 374 | 374 | $this->tags[] = $tag; |
| 375 | - } catch(\Exception $e) { |
|
| 375 | + } catch (\Exception $e) { |
|
| 376 | 376 | \OC::$server->getLogger()->logException($e, [ |
| 377 | 377 | 'message' => __METHOD__, |
| 378 | 378 | 'level' => ILogger::ERROR, |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | ]); |
| 381 | 381 | return false; |
| 382 | 382 | } |
| 383 | - \OCP\Util::writeLog('core', __METHOD__.', id: ' . $tag->getId(), ILogger::DEBUG); |
|
| 383 | + \OCP\Util::writeLog('core', __METHOD__.', id: '.$tag->getId(), ILogger::DEBUG); |
|
| 384 | 384 | return $tag->getId(); |
| 385 | 385 | } |
| 386 | 386 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | $from = trim($from); |
| 396 | 396 | $to = trim($to); |
| 397 | 397 | |
| 398 | - if($to === '' || $from === '') { |
|
| 398 | + if ($to === '' || $from === '') { |
|
| 399 | 399 | \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', ILogger::DEBUG); |
| 400 | 400 | return false; |
| 401 | 401 | } |
@@ -405,21 +405,21 @@ discard block |
||
| 405 | 405 | } else { |
| 406 | 406 | $key = $this->getTagByName($from); |
| 407 | 407 | } |
| 408 | - if($key === false) { |
|
| 409 | - \OCP\Util::writeLog('core', __METHOD__.', tag: ' . $from. ' does not exist', ILogger::DEBUG); |
|
| 408 | + if ($key === false) { |
|
| 409 | + \OCP\Util::writeLog('core', __METHOD__.', tag: '.$from.' does not exist', ILogger::DEBUG); |
|
| 410 | 410 | return false; |
| 411 | 411 | } |
| 412 | 412 | $tag = $this->tags[$key]; |
| 413 | 413 | |
| 414 | - if($this->userHasTag($to, $tag->getOwner())) { |
|
| 415 | - \OCP\Util::writeLog('core', __METHOD__.', A tag named ' . $to. ' already exists for user ' . $tag->getOwner() . '.', ILogger::DEBUG); |
|
| 414 | + if ($this->userHasTag($to, $tag->getOwner())) { |
|
| 415 | + \OCP\Util::writeLog('core', __METHOD__.', A tag named '.$to.' already exists for user '.$tag->getOwner().'.', ILogger::DEBUG); |
|
| 416 | 416 | return false; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | try { |
| 420 | 420 | $tag->setName($to); |
| 421 | 421 | $this->tags[$key] = $this->mapper->update($tag); |
| 422 | - } catch(\Exception $e) { |
|
| 422 | + } catch (\Exception $e) { |
|
| 423 | 423 | \OC::$server->getLogger()->logException($e, [ |
| 424 | 424 | 'message' => __METHOD__, |
| 425 | 425 | 'level' => ILogger::ERROR, |
@@ -439,25 +439,25 @@ discard block |
||
| 439 | 439 | * @param int|null $id int Optional object id to add to this|these tag(s) |
| 440 | 440 | * @return bool Returns false on error. |
| 441 | 441 | */ |
| 442 | - public function addMultiple($names, $sync=false, $id = null) { |
|
| 443 | - if(!is_array($names)) { |
|
| 442 | + public function addMultiple($names, $sync = false, $id = null) { |
|
| 443 | + if (!is_array($names)) { |
|
| 444 | 444 | $names = array($names); |
| 445 | 445 | } |
| 446 | 446 | $names = array_map('trim', $names); |
| 447 | 447 | array_filter($names); |
| 448 | 448 | |
| 449 | 449 | $newones = array(); |
| 450 | - foreach($names as $name) { |
|
| 451 | - if(!$this->hasTag($name) && $name !== '') { |
|
| 450 | + foreach ($names as $name) { |
|
| 451 | + if (!$this->hasTag($name) && $name !== '') { |
|
| 452 | 452 | $newones[] = new Tag($this->user, $this->type, $name); |
| 453 | 453 | } |
| 454 | - if(!is_null($id) ) { |
|
| 454 | + if (!is_null($id)) { |
|
| 455 | 455 | // Insert $objectid, $categoryid pairs if not exist. |
| 456 | 456 | self::$relations[] = array('objid' => $id, 'tag' => $name); |
| 457 | 457 | } |
| 458 | 458 | } |
| 459 | 459 | $this->tags = array_merge($this->tags, $newones); |
| 460 | - if($sync === true) { |
|
| 460 | + if ($sync === true) { |
|
| 461 | 461 | $this->save(); |
| 462 | 462 | } |
| 463 | 463 | |
@@ -468,13 +468,13 @@ discard block |
||
| 468 | 468 | * Save the list of tags and their object relations |
| 469 | 469 | */ |
| 470 | 470 | protected function save() { |
| 471 | - if(is_array($this->tags)) { |
|
| 472 | - foreach($this->tags as $tag) { |
|
| 471 | + if (is_array($this->tags)) { |
|
| 472 | + foreach ($this->tags as $tag) { |
|
| 473 | 473 | try { |
| 474 | 474 | if (!$this->mapper->tagExists($tag)) { |
| 475 | 475 | $this->mapper->insert($tag); |
| 476 | 476 | } |
| 477 | - } catch(\Exception $e) { |
|
| 477 | + } catch (\Exception $e) { |
|
| 478 | 478 | \OC::$server->getLogger()->logException($e, [ |
| 479 | 479 | 'message' => __METHOD__, |
| 480 | 480 | 'level' => ILogger::ERROR, |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | |
| 486 | 486 | // reload tags to get the proper ids. |
| 487 | 487 | $this->tags = $this->mapper->loadTags($this->owners, $this->type); |
| 488 | - \OCP\Util::writeLog('core', __METHOD__.', tags: ' . print_r($this->tags, true), |
|
| 488 | + \OCP\Util::writeLog('core', __METHOD__.', tags: '.print_r($this->tags, true), |
|
| 489 | 489 | ILogger::DEBUG); |
| 490 | 490 | // Loop through temporarily cached objectid/tagname pairs |
| 491 | 491 | // and save relations. |
@@ -493,10 +493,10 @@ discard block |
||
| 493 | 493 | // For some reason this is needed or array_search(i) will return 0..? |
| 494 | 494 | ksort($tags); |
| 495 | 495 | $dbConnection = \OC::$server->getDatabaseConnection(); |
| 496 | - foreach(self::$relations as $relation) { |
|
| 496 | + foreach (self::$relations as $relation) { |
|
| 497 | 497 | $tagId = $this->getTagId($relation['tag']); |
| 498 | - \OCP\Util::writeLog('core', __METHOD__ . 'catid, ' . $relation['tag'] . ' ' . $tagId, ILogger::DEBUG); |
|
| 499 | - if($tagId) { |
|
| 498 | + \OCP\Util::writeLog('core', __METHOD__.'catid, '.$relation['tag'].' '.$tagId, ILogger::DEBUG); |
|
| 499 | + if ($tagId) { |
|
| 500 | 500 | try { |
| 501 | 501 | $dbConnection->insertIfNotExist(self::RELATION_TABLE, |
| 502 | 502 | array( |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | 'categoryid' => $tagId, |
| 505 | 505 | 'type' => $this->type, |
| 506 | 506 | )); |
| 507 | - } catch(\Exception $e) { |
|
| 507 | + } catch (\Exception $e) { |
|
| 508 | 508 | \OC::$server->getLogger()->logException($e, [ |
| 509 | 509 | 'message' => __METHOD__, |
| 510 | 510 | 'level' => ILogger::ERROR, |
@@ -531,13 +531,13 @@ discard block |
||
| 531 | 531 | // Find all objectid/tagId pairs. |
| 532 | 532 | $result = null; |
| 533 | 533 | try { |
| 534 | - $stmt = \OC_DB::prepare('SELECT `id` FROM `' . self::TAG_TABLE . '` ' |
|
| 534 | + $stmt = \OC_DB::prepare('SELECT `id` FROM `'.self::TAG_TABLE.'` ' |
|
| 535 | 535 | . 'WHERE `uid` = ?'); |
| 536 | 536 | $result = $stmt->execute(array($arguments['uid'])); |
| 537 | 537 | if ($result === null) { |
| 538 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
| 538 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
| 539 | 539 | } |
| 540 | - } catch(\Exception $e) { |
|
| 540 | + } catch (\Exception $e) { |
|
| 541 | 541 | \OC::$server->getLogger()->logException($e, [ |
| 542 | 542 | 'message' => __METHOD__, |
| 543 | 543 | 'level' => ILogger::ERROR, |
@@ -545,14 +545,14 @@ discard block |
||
| 545 | 545 | ]); |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - if(!is_null($result)) { |
|
| 548 | + if (!is_null($result)) { |
|
| 549 | 549 | try { |
| 550 | - $stmt = \OC_DB::prepare('DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
| 550 | + $stmt = \OC_DB::prepare('DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
| 551 | 551 | . 'WHERE `categoryid` = ?'); |
| 552 | - while( $row = $result->fetchRow()) { |
|
| 552 | + while ($row = $result->fetchRow()) { |
|
| 553 | 553 | try { |
| 554 | 554 | $stmt->execute(array($row['id'])); |
| 555 | - } catch(\Exception $e) { |
|
| 555 | + } catch (\Exception $e) { |
|
| 556 | 556 | \OC::$server->getLogger()->logException($e, [ |
| 557 | 557 | 'message' => __METHOD__, |
| 558 | 558 | 'level' => ILogger::ERROR, |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | ]); |
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | - } catch(\Exception $e) { |
|
| 563 | + } catch (\Exception $e) { |
|
| 564 | 564 | \OC::$server->getLogger()->logException($e, [ |
| 565 | 565 | 'message' => __METHOD__, |
| 566 | 566 | 'level' => ILogger::ERROR, |
@@ -569,13 +569,13 @@ discard block |
||
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | try { |
| 572 | - $stmt = \OC_DB::prepare('DELETE FROM `' . self::TAG_TABLE . '` ' |
|
| 572 | + $stmt = \OC_DB::prepare('DELETE FROM `'.self::TAG_TABLE.'` ' |
|
| 573 | 573 | . 'WHERE `uid` = ?'); |
| 574 | 574 | $result = $stmt->execute(array($arguments['uid'])); |
| 575 | 575 | if ($result === null) { |
| 576 | - \OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
| 576 | + \OCP\Util::writeLog('core', __METHOD__.', DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
| 577 | 577 | } |
| 578 | - } catch(\Exception $e) { |
|
| 578 | + } catch (\Exception $e) { |
|
| 579 | 579 | \OC::$server->getLogger()->logException($e, [ |
| 580 | 580 | 'message' => __METHOD__, |
| 581 | 581 | 'level' => ILogger::ERROR, |
@@ -591,23 +591,23 @@ discard block |
||
| 591 | 591 | * @return boolean Returns false on error. |
| 592 | 592 | */ |
| 593 | 593 | public function purgeObjects(array $ids) { |
| 594 | - if(count($ids) === 0) { |
|
| 594 | + if (count($ids) === 0) { |
|
| 595 | 595 | // job done ;) |
| 596 | 596 | return true; |
| 597 | 597 | } |
| 598 | 598 | $updates = $ids; |
| 599 | 599 | try { |
| 600 | - $query = 'DELETE FROM `' . self::RELATION_TABLE . '` '; |
|
| 601 | - $query .= 'WHERE `objid` IN (' . str_repeat('?,', count($ids)-1) . '?) '; |
|
| 600 | + $query = 'DELETE FROM `'.self::RELATION_TABLE.'` '; |
|
| 601 | + $query .= 'WHERE `objid` IN ('.str_repeat('?,', count($ids) - 1).'?) '; |
|
| 602 | 602 | $query .= 'AND `type`= ?'; |
| 603 | 603 | $updates[] = $this->type; |
| 604 | 604 | $stmt = \OC_DB::prepare($query); |
| 605 | 605 | $result = $stmt->execute($updates); |
| 606 | 606 | if ($result === null) { |
| 607 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
| 607 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
| 608 | 608 | return false; |
| 609 | 609 | } |
| 610 | - } catch(\Exception $e) { |
|
| 610 | + } catch (\Exception $e) { |
|
| 611 | 611 | \OC::$server->getLogger()->logException($e, [ |
| 612 | 612 | 'message' => __METHOD__, |
| 613 | 613 | 'level' => ILogger::ERROR, |
@@ -624,13 +624,13 @@ discard block |
||
| 624 | 624 | * @return array|false An array of object ids. |
| 625 | 625 | */ |
| 626 | 626 | public function getFavorites() { |
| 627 | - if(!$this->userHasTag(self::TAG_FAVORITE, $this->user)) { |
|
| 627 | + if (!$this->userHasTag(self::TAG_FAVORITE, $this->user)) { |
|
| 628 | 628 | return []; |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | try { |
| 632 | 632 | return $this->getIdsForTag(self::TAG_FAVORITE); |
| 633 | - } catch(\Exception $e) { |
|
| 633 | + } catch (\Exception $e) { |
|
| 634 | 634 | \OC::$server->getLogger()->logException($e, [ |
| 635 | 635 | 'message' => __METHOD__, |
| 636 | 636 | 'level' => ILogger::ERROR, |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | * @return boolean |
| 648 | 648 | */ |
| 649 | 649 | public function addToFavorites($objid) { |
| 650 | - if(!$this->userHasTag(self::TAG_FAVORITE, $this->user)) { |
|
| 650 | + if (!$this->userHasTag(self::TAG_FAVORITE, $this->user)) { |
|
| 651 | 651 | $this->add(self::TAG_FAVORITE); |
| 652 | 652 | } |
| 653 | 653 | return $this->tagAs($objid, self::TAG_FAVORITE); |
@@ -671,16 +671,16 @@ discard block |
||
| 671 | 671 | * @return boolean Returns false on error. |
| 672 | 672 | */ |
| 673 | 673 | public function tagAs($objid, $tag) { |
| 674 | - if(is_string($tag) && !is_numeric($tag)) { |
|
| 674 | + if (is_string($tag) && !is_numeric($tag)) { |
|
| 675 | 675 | $tag = trim($tag); |
| 676 | - if($tag === '') { |
|
| 676 | + if ($tag === '') { |
|
| 677 | 677 | \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', ILogger::DEBUG); |
| 678 | 678 | return false; |
| 679 | 679 | } |
| 680 | - if(!$this->hasTag($tag)) { |
|
| 680 | + if (!$this->hasTag($tag)) { |
|
| 681 | 681 | $this->add($tag); |
| 682 | 682 | } |
| 683 | - $tagId = $this->getTagId($tag); |
|
| 683 | + $tagId = $this->getTagId($tag); |
|
| 684 | 684 | } else { |
| 685 | 685 | $tagId = $tag; |
| 686 | 686 | } |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | 'categoryid' => $tagId, |
| 692 | 692 | 'type' => $this->type, |
| 693 | 693 | )); |
| 694 | - } catch(\Exception $e) { |
|
| 694 | + } catch (\Exception $e) { |
|
| 695 | 695 | \OC::$server->getLogger()->logException($e, [ |
| 696 | 696 | 'message' => __METHOD__, |
| 697 | 697 | 'level' => ILogger::ERROR, |
@@ -710,23 +710,23 @@ discard block |
||
| 710 | 710 | * @return boolean |
| 711 | 711 | */ |
| 712 | 712 | public function unTag($objid, $tag) { |
| 713 | - if(is_string($tag) && !is_numeric($tag)) { |
|
| 713 | + if (is_string($tag) && !is_numeric($tag)) { |
|
| 714 | 714 | $tag = trim($tag); |
| 715 | - if($tag === '') { |
|
| 715 | + if ($tag === '') { |
|
| 716 | 716 | \OCP\Util::writeLog('core', __METHOD__.', Tag name is empty', ILogger::DEBUG); |
| 717 | 717 | return false; |
| 718 | 718 | } |
| 719 | - $tagId = $this->getTagId($tag); |
|
| 719 | + $tagId = $this->getTagId($tag); |
|
| 720 | 720 | } else { |
| 721 | 721 | $tagId = $tag; |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | try { |
| 725 | - $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
| 725 | + $sql = 'DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
| 726 | 726 | . 'WHERE `objid` = ? AND `categoryid` = ? AND `type` = ?'; |
| 727 | 727 | $stmt = \OC_DB::prepare($sql); |
| 728 | 728 | $stmt->execute(array($objid, $tagId, $this->type)); |
| 729 | - } catch(\Exception $e) { |
|
| 729 | + } catch (\Exception $e) { |
|
| 730 | 730 | \OC::$server->getLogger()->logException($e, [ |
| 731 | 731 | 'message' => __METHOD__, |
| 732 | 732 | 'level' => ILogger::ERROR, |
@@ -744,16 +744,16 @@ discard block |
||
| 744 | 744 | * @return bool Returns false on error |
| 745 | 745 | */ |
| 746 | 746 | public function delete($names) { |
| 747 | - if(!is_array($names)) { |
|
| 747 | + if (!is_array($names)) { |
|
| 748 | 748 | $names = array($names); |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | $names = array_map('trim', $names); |
| 752 | 752 | array_filter($names); |
| 753 | 753 | |
| 754 | - \OCP\Util::writeLog('core', __METHOD__ . ', before: ' |
|
| 754 | + \OCP\Util::writeLog('core', __METHOD__.', before: ' |
|
| 755 | 755 | . print_r($this->tags, true), ILogger::DEBUG); |
| 756 | - foreach($names as $name) { |
|
| 756 | + foreach ($names as $name) { |
|
| 757 | 757 | $id = null; |
| 758 | 758 | |
| 759 | 759 | if (is_numeric($name)) { |
@@ -767,22 +767,22 @@ discard block |
||
| 767 | 767 | unset($this->tags[$key]); |
| 768 | 768 | $this->mapper->delete($tag); |
| 769 | 769 | } else { |
| 770 | - \OCP\Util::writeLog('core', __METHOD__ . 'Cannot delete tag ' . $name |
|
| 770 | + \OCP\Util::writeLog('core', __METHOD__.'Cannot delete tag '.$name |
|
| 771 | 771 | . ': not found.', ILogger::ERROR); |
| 772 | 772 | } |
| 773 | - if(!is_null($id) && $id !== false) { |
|
| 773 | + if (!is_null($id) && $id !== false) { |
|
| 774 | 774 | try { |
| 775 | - $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
| 775 | + $sql = 'DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
| 776 | 776 | . 'WHERE `categoryid` = ?'; |
| 777 | 777 | $stmt = \OC_DB::prepare($sql); |
| 778 | 778 | $result = $stmt->execute(array($id)); |
| 779 | 779 | if ($result === null) { |
| 780 | 780 | \OCP\Util::writeLog('core', |
| 781 | - __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), |
|
| 781 | + __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), |
|
| 782 | 782 | ILogger::ERROR); |
| 783 | 783 | return false; |
| 784 | 784 | } |
| 785 | - } catch(\Exception $e) { |
|
| 785 | + } catch (\Exception $e) { |
|
| 786 | 786 | \OC::$server->getLogger()->logException($e, [ |
| 787 | 787 | 'message' => __METHOD__, |
| 788 | 788 | 'level' => ILogger::ERROR, |
@@ -796,8 +796,8 @@ discard block |
||
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | // case-insensitive array_search |
| 799 | - protected function array_searchi($needle, $haystack, $mem='getName') { |
|
| 800 | - if(!is_array($haystack)) { |
|
| 799 | + protected function array_searchi($needle, $haystack, $mem = 'getName') { |
|
| 800 | + if (!is_array($haystack)) { |
|
| 801 | 801 | return false; |
| 802 | 802 | } |
| 803 | 803 | return array_search(strtolower($needle), array_map( |