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