@@ -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, |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | public function getFavorites() { |
627 | 627 | try { |
628 | 628 | return $this->getIdsForTag(self::TAG_FAVORITE); |
629 | - } catch(\Exception $e) { |
|
629 | + } catch (\Exception $e) { |
|
630 | 630 | \OC::$server->getLogger()->logException($e, [ |
631 | 631 | 'message' => __METHOD__, |
632 | 632 | 'level' => ILogger::ERROR, |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | * @return boolean |
644 | 644 | */ |
645 | 645 | public function addToFavorites($objid) { |
646 | - if(!$this->userHasTag(self::TAG_FAVORITE, $this->user)) { |
|
646 | + if (!$this->userHasTag(self::TAG_FAVORITE, $this->user)) { |
|
647 | 647 | $this->add(self::TAG_FAVORITE); |
648 | 648 | } |
649 | 649 | return $this->tagAs($objid, self::TAG_FAVORITE); |
@@ -667,16 +667,16 @@ discard block |
||
667 | 667 | * @return boolean Returns false on error. |
668 | 668 | */ |
669 | 669 | public function tagAs($objid, $tag) { |
670 | - if(is_string($tag) && !is_numeric($tag)) { |
|
670 | + if (is_string($tag) && !is_numeric($tag)) { |
|
671 | 671 | $tag = trim($tag); |
672 | - if($tag === '') { |
|
672 | + if ($tag === '') { |
|
673 | 673 | \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', ILogger::DEBUG); |
674 | 674 | return false; |
675 | 675 | } |
676 | - if(!$this->hasTag($tag)) { |
|
676 | + if (!$this->hasTag($tag)) { |
|
677 | 677 | $this->add($tag); |
678 | 678 | } |
679 | - $tagId = $this->getTagId($tag); |
|
679 | + $tagId = $this->getTagId($tag); |
|
680 | 680 | } else { |
681 | 681 | $tagId = $tag; |
682 | 682 | } |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | 'categoryid' => $tagId, |
688 | 688 | 'type' => $this->type, |
689 | 689 | )); |
690 | - } catch(\Exception $e) { |
|
690 | + } catch (\Exception $e) { |
|
691 | 691 | \OC::$server->getLogger()->logException($e, [ |
692 | 692 | 'message' => __METHOD__, |
693 | 693 | 'level' => ILogger::ERROR, |
@@ -706,23 +706,23 @@ discard block |
||
706 | 706 | * @return boolean |
707 | 707 | */ |
708 | 708 | public function unTag($objid, $tag) { |
709 | - if(is_string($tag) && !is_numeric($tag)) { |
|
709 | + if (is_string($tag) && !is_numeric($tag)) { |
|
710 | 710 | $tag = trim($tag); |
711 | - if($tag === '') { |
|
711 | + if ($tag === '') { |
|
712 | 712 | \OCP\Util::writeLog('core', __METHOD__.', Tag name is empty', ILogger::DEBUG); |
713 | 713 | return false; |
714 | 714 | } |
715 | - $tagId = $this->getTagId($tag); |
|
715 | + $tagId = $this->getTagId($tag); |
|
716 | 716 | } else { |
717 | 717 | $tagId = $tag; |
718 | 718 | } |
719 | 719 | |
720 | 720 | try { |
721 | - $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
721 | + $sql = 'DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
722 | 722 | . 'WHERE `objid` = ? AND `categoryid` = ? AND `type` = ?'; |
723 | 723 | $stmt = \OC_DB::prepare($sql); |
724 | 724 | $stmt->execute(array($objid, $tagId, $this->type)); |
725 | - } catch(\Exception $e) { |
|
725 | + } catch (\Exception $e) { |
|
726 | 726 | \OC::$server->getLogger()->logException($e, [ |
727 | 727 | 'message' => __METHOD__, |
728 | 728 | 'level' => ILogger::ERROR, |
@@ -740,16 +740,16 @@ discard block |
||
740 | 740 | * @return bool Returns false on error |
741 | 741 | */ |
742 | 742 | public function delete($names) { |
743 | - if(!is_array($names)) { |
|
743 | + if (!is_array($names)) { |
|
744 | 744 | $names = array($names); |
745 | 745 | } |
746 | 746 | |
747 | 747 | $names = array_map('trim', $names); |
748 | 748 | array_filter($names); |
749 | 749 | |
750 | - \OCP\Util::writeLog('core', __METHOD__ . ', before: ' |
|
750 | + \OCP\Util::writeLog('core', __METHOD__.', before: ' |
|
751 | 751 | . print_r($this->tags, true), ILogger::DEBUG); |
752 | - foreach($names as $name) { |
|
752 | + foreach ($names as $name) { |
|
753 | 753 | $id = null; |
754 | 754 | |
755 | 755 | if (is_numeric($name)) { |
@@ -763,22 +763,22 @@ discard block |
||
763 | 763 | unset($this->tags[$key]); |
764 | 764 | $this->mapper->delete($tag); |
765 | 765 | } else { |
766 | - \OCP\Util::writeLog('core', __METHOD__ . 'Cannot delete tag ' . $name |
|
766 | + \OCP\Util::writeLog('core', __METHOD__.'Cannot delete tag '.$name |
|
767 | 767 | . ': not found.', ILogger::ERROR); |
768 | 768 | } |
769 | - if(!is_null($id) && $id !== false) { |
|
769 | + if (!is_null($id) && $id !== false) { |
|
770 | 770 | try { |
771 | - $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
771 | + $sql = 'DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
772 | 772 | . 'WHERE `categoryid` = ?'; |
773 | 773 | $stmt = \OC_DB::prepare($sql); |
774 | 774 | $result = $stmt->execute(array($id)); |
775 | 775 | if ($result === null) { |
776 | 776 | \OCP\Util::writeLog('core', |
777 | - __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), |
|
777 | + __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), |
|
778 | 778 | ILogger::ERROR); |
779 | 779 | return false; |
780 | 780 | } |
781 | - } catch(\Exception $e) { |
|
781 | + } catch (\Exception $e) { |
|
782 | 782 | \OC::$server->getLogger()->logException($e, [ |
783 | 783 | 'message' => __METHOD__, |
784 | 784 | 'level' => ILogger::ERROR, |
@@ -792,8 +792,8 @@ discard block |
||
792 | 792 | } |
793 | 793 | |
794 | 794 | // case-insensitive array_search |
795 | - protected function array_searchi($needle, $haystack, $mem='getName') { |
|
796 | - if(!is_array($haystack)) { |
|
795 | + protected function array_searchi($needle, $haystack, $mem = 'getName') { |
|
796 | + if (!is_array($haystack)) { |
|
797 | 797 | return false; |
798 | 798 | } |
799 | 799 | return array_search(strtolower($needle), array_map( |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this->createDatabase($connection); |
54 | 54 | |
55 | 55 | //fill the database if needed |
56 | - $query='select count(*) from information_schema.tables where table_schema=? AND table_name = ?'; |
|
56 | + $query = 'select count(*) from information_schema.tables where table_schema=? AND table_name = ?'; |
|
57 | 57 | $connection->executeQuery($query, [$this->dbName, $this->tablePrefix.'users']); |
58 | 58 | } |
59 | 59 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param \OC\DB\Connection $connection |
62 | 62 | */ |
63 | 63 | private function createDatabase($connection) { |
64 | - try{ |
|
64 | + try { |
|
65 | 65 | $name = $this->dbName; |
66 | 66 | $user = $this->dbUser; |
67 | 67 | //we can't use OC_DB functions here because we need to connect as the administrative user. |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | try { |
81 | 81 | //this query will fail if there aren't the right permissions, ignore the error |
82 | - $query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'"; |
|
82 | + $query = "GRANT ALL PRIVILEGES ON `$name` . * TO '$user'"; |
|
83 | 83 | $connection->executeUpdate($query); |
84 | 84 | } catch (\Exception $ex) { |
85 | 85 | $this->logger->logException($ex, [ |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @throws \OC\DatabaseSetupException |
96 | 96 | */ |
97 | 97 | private function createDBUser($connection) { |
98 | - try{ |
|
98 | + try { |
|
99 | 99 | $name = $this->dbUser; |
100 | 100 | $password = $this->dbPassword; |
101 | 101 | // we need to create 2 accounts, one for global use and one for local user. if we don't specify the local one, |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'"; |
106 | 106 | $connection->executeUpdate($query); |
107 | 107 | } |
108 | - catch (\Exception $ex){ |
|
108 | + catch (\Exception $ex) { |
|
109 | 109 | $this->logger->logException($ex, [ |
110 | 110 | 'message' => 'Database user creation failed.', |
111 | 111 | 'level' => ILogger::ERROR, |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | //we don't have a dbuser specified in config |
128 | 128 | if ($this->dbUser !== $oldUser) { |
129 | 129 | //add prefix to the admin username to prevent collisions |
130 | - $adminUser = substr('oc_' . $username, 0, 16); |
|
130 | + $adminUser = substr('oc_'.$username, 0, 16); |
|
131 | 131 | |
132 | 132 | $i = 1; |
133 | 133 | while (true) { |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | $this->dbUser = $adminUser; |
145 | 145 | |
146 | 146 | //create a random password so we don't need to store the admin password in the config file |
147 | - $this->dbPassword = $this->random->generate(30); |
|
147 | + $this->dbPassword = $this->random->generate(30); |
|
148 | 148 | |
149 | 149 | $this->createDBUser($connection); |
150 | 150 | |
151 | 151 | break; |
152 | 152 | } else { |
153 | 153 | //repeat with different username |
154 | - $length = strlen((string)$i); |
|
155 | - $adminUser = substr('oc_' . $username, 0, 16 - $length) . $i; |
|
154 | + $length = strlen((string) $i); |
|
155 | + $adminUser = substr('oc_'.$username, 0, 16 - $length).$i; |
|
156 | 156 | $i++; |
157 | 157 | } |
158 | 158 | } else { |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | $apps = self::getEnabledApps(); |
113 | 113 | |
114 | 114 | // Add each apps' folder as allowed class path |
115 | - foreach($apps as $app) { |
|
115 | + foreach ($apps as $app) { |
|
116 | 116 | $path = self::getAppPath($app); |
117 | - if($path !== false) { |
|
117 | + if ($path !== false) { |
|
118 | 118 | self::registerAutoloading($app, $path); |
119 | 119 | } |
120 | 120 | } |
@@ -140,15 +140,15 @@ discard block |
||
140 | 140 | public static function loadApp(string $app) { |
141 | 141 | self::$loadedApps[] = $app; |
142 | 142 | $appPath = self::getAppPath($app); |
143 | - if($appPath === false) { |
|
143 | + if ($appPath === false) { |
|
144 | 144 | return; |
145 | 145 | } |
146 | 146 | |
147 | 147 | // in case someone calls loadApp() directly |
148 | 148 | self::registerAutoloading($app, $appPath); |
149 | 149 | |
150 | - if (is_file($appPath . '/appinfo/app.php')) { |
|
151 | - \OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app); |
|
150 | + if (is_file($appPath.'/appinfo/app.php')) { |
|
151 | + \OC::$server->getEventLogger()->start('load_app_'.$app, 'Load app: '.$app); |
|
152 | 152 | try { |
153 | 153 | self::requireAppFile($app); |
154 | 154 | } catch (Error $ex) { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | \OC::$server->getAppManager()->disableApp($app); |
159 | 159 | } |
160 | 160 | } |
161 | - \OC::$server->getEventLogger()->end('load_app_' . $app); |
|
161 | + \OC::$server->getEventLogger()->end('load_app_'.$app); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | $info = self::getAppInfo($app); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $plugins = isset($info['collaboration']['plugins']['plugin']['@value']) ? |
205 | 205 | [$info['collaboration']['plugins']['plugin']] : $info['collaboration']['plugins']['plugin']; |
206 | 206 | foreach ($plugins as $plugin) { |
207 | - if($plugin['@attributes']['type'] === 'collaborator-search') { |
|
207 | + if ($plugin['@attributes']['type'] === 'collaborator-search') { |
|
208 | 208 | $pluginInfo = [ |
209 | 209 | 'shareType' => $plugin['@attributes']['share-type'], |
210 | 210 | 'class' => $plugin['@value'], |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * @param string $path |
224 | 224 | */ |
225 | 225 | public static function registerAutoloading(string $app, string $path) { |
226 | - $key = $app . '-' . $path; |
|
227 | - if(isset(self::$alreadyRegistered[$key])) { |
|
226 | + $key = $app.'-'.$path; |
|
227 | + if (isset(self::$alreadyRegistered[$key])) { |
|
228 | 228 | return; |
229 | 229 | } |
230 | 230 | |
@@ -234,17 +234,17 @@ discard block |
||
234 | 234 | $appNamespace = \OC\AppFramework\App::buildAppNamespace($app); |
235 | 235 | \OC::$server->registerNamespace($app, $appNamespace); |
236 | 236 | |
237 | - if (file_exists($path . '/composer/autoload.php')) { |
|
238 | - require_once $path . '/composer/autoload.php'; |
|
237 | + if (file_exists($path.'/composer/autoload.php')) { |
|
238 | + require_once $path.'/composer/autoload.php'; |
|
239 | 239 | } else { |
240 | - \OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true); |
|
240 | + \OC::$composerAutoloader->addPsr4($appNamespace.'\\', $path.'/lib/', true); |
|
241 | 241 | // Register on legacy autoloader |
242 | 242 | \OC::$loader->addValidRoot($path); |
243 | 243 | } |
244 | 244 | |
245 | 245 | // Register Test namespace only when testing |
246 | 246 | if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) { |
247 | - \OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true); |
|
247 | + \OC::$composerAutoloader->addPsr4($appNamespace.'\\Tests\\', $path.'/tests/', true); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | */ |
257 | 257 | private static function requireAppFile(string $app) { |
258 | 258 | // encapsulated here to avoid variable scope conflicts |
259 | - require_once $app . '/appinfo/app.php'; |
|
259 | + require_once $app.'/appinfo/app.php'; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | public static function setAppTypes(string $app) { |
302 | 302 | $appManager = \OC::$server->getAppManager(); |
303 | 303 | $appData = $appManager->getAppInfo($app); |
304 | - if(!is_array($appData)) { |
|
304 | + if (!is_array($appData)) { |
|
305 | 305 | return; |
306 | 306 | } |
307 | 307 | |
@@ -349,8 +349,8 @@ discard block |
||
349 | 349 | } else { |
350 | 350 | $apps = $appManager->getEnabledAppsForUser($user); |
351 | 351 | } |
352 | - $apps = array_filter($apps, function ($app) { |
|
353 | - return $app !== 'files';//we add this manually |
|
352 | + $apps = array_filter($apps, function($app) { |
|
353 | + return $app !== 'files'; //we add this manually |
|
354 | 354 | }); |
355 | 355 | sort($apps); |
356 | 356 | array_unshift($apps, 'files'); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $installer = \OC::$server->query(Installer::class); |
389 | 389 | $isDownloaded = $installer->isDownloaded($appId); |
390 | 390 | |
391 | - if(!$isDownloaded) { |
|
391 | + if (!$isDownloaded) { |
|
392 | 392 | $installer->downloadApp($appId); |
393 | 393 | } |
394 | 394 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | */ |
440 | 440 | public static function findAppInDirectories(string $appId) { |
441 | 441 | $sanitizedAppId = self::cleanAppId($appId); |
442 | - if($sanitizedAppId !== $appId) { |
|
442 | + if ($sanitizedAppId !== $appId) { |
|
443 | 443 | return false; |
444 | 444 | } |
445 | 445 | static $app_dir = []; |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | |
451 | 451 | $possibleApps = []; |
452 | 452 | foreach (OC::$APPSROOTS as $dir) { |
453 | - if (file_exists($dir['path'] . '/' . $appId)) { |
|
453 | + if (file_exists($dir['path'].'/'.$appId)) { |
|
454 | 454 | $possibleApps[] = $dir; |
455 | 455 | } |
456 | 456 | } |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | } |
492 | 492 | |
493 | 493 | if (($dir = self::findAppInDirectories($appId)) != false) { |
494 | - return $dir['path'] . '/' . $appId; |
|
494 | + return $dir['path'].'/'.$appId; |
|
495 | 495 | } |
496 | 496 | return false; |
497 | 497 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | */ |
506 | 506 | public static function getAppWebPath(string $appId) { |
507 | 507 | if (($dir = self::findAppInDirectories($appId)) != false) { |
508 | - return OC::$WEBROOT . $dir['url'] . '/' . $appId; |
|
508 | + return OC::$WEBROOT.$dir['url'].'/'.$appId; |
|
509 | 509 | } |
510 | 510 | return false; |
511 | 511 | } |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | * @return string |
530 | 530 | */ |
531 | 531 | public static function getAppVersionByPath(string $path): string { |
532 | - $infoFile = $path . '/appinfo/info.xml'; |
|
532 | + $infoFile = $path.'/appinfo/info.xml'; |
|
533 | 533 | $appData = \OC::$server->getAppManager()->getAppInfo($infoFile, true); |
534 | 534 | return isset($appData['version']) ? $appData['version'] : ''; |
535 | 535 | } |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | * @param string $page |
630 | 630 | */ |
631 | 631 | public static function registerAdmin(string $app, string $page) { |
632 | - self::$adminForms[] = $app . '/' . $page . '.php'; |
|
632 | + self::$adminForms[] = $app.'/'.$page.'.php'; |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | /** |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | * @param string $page |
639 | 639 | */ |
640 | 640 | public static function registerPersonal(string $app, string $page) { |
641 | - self::$personalForms[] = $app . '/' . $page . '.php'; |
|
641 | + self::$personalForms[] = $app.'/'.$page.'.php'; |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | |
668 | 668 | foreach (OC::$APPSROOTS as $apps_dir) { |
669 | 669 | if (!is_readable($apps_dir['path'])) { |
670 | - \OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], ILogger::WARN); |
|
670 | + \OCP\Util::writeLog('core', 'unable to read app folder : '.$apps_dir['path'], ILogger::WARN); |
|
671 | 671 | continue; |
672 | 672 | } |
673 | 673 | $dh = opendir($apps_dir['path']); |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | if (is_resource($dh)) { |
676 | 676 | while (($file = readdir($dh)) !== false) { |
677 | 677 | |
678 | - if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) { |
|
678 | + if ($file[0] != '.' and is_dir($apps_dir['path'].'/'.$file) and is_file($apps_dir['path'].'/'.$file.'/appinfo/info.xml')) { |
|
679 | 679 | |
680 | 680 | $apps[] = $file; |
681 | 681 | } |
@@ -708,12 +708,12 @@ discard block |
||
708 | 708 | |
709 | 709 | $info = OC_App::getAppInfo($app, false, $langCode); |
710 | 710 | if (!is_array($info)) { |
711 | - \OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', ILogger::ERROR); |
|
711 | + \OCP\Util::writeLog('core', 'Could not read app info file for app "'.$app.'"', ILogger::ERROR); |
|
712 | 712 | continue; |
713 | 713 | } |
714 | 714 | |
715 | 715 | if (!isset($info['name'])) { |
716 | - \OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', ILogger::ERROR); |
|
716 | + \OCP\Util::writeLog('core', 'App id "'.$app.'" has no name in appinfo', ILogger::ERROR); |
|
717 | 717 | continue; |
718 | 718 | } |
719 | 719 | |
@@ -740,13 +740,13 @@ discard block |
||
740 | 740 | } |
741 | 741 | |
742 | 742 | $appPath = self::getAppPath($app); |
743 | - if($appPath !== false) { |
|
744 | - $appIcon = $appPath . '/img/' . $app . '.svg'; |
|
743 | + if ($appPath !== false) { |
|
744 | + $appIcon = $appPath.'/img/'.$app.'.svg'; |
|
745 | 745 | if (file_exists($appIcon)) { |
746 | - $info['preview'] = $urlGenerator->imagePath($app, $app . '.svg'); |
|
746 | + $info['preview'] = $urlGenerator->imagePath($app, $app.'.svg'); |
|
747 | 747 | $info['previewAsIcon'] = true; |
748 | 748 | } else { |
749 | - $appIcon = $appPath . '/img/app.svg'; |
|
749 | + $appIcon = $appPath.'/img/app.svg'; |
|
750 | 750 | if (file_exists($appIcon)) { |
751 | 751 | $info['preview'] = $urlGenerator->imagePath($app, 'app.svg'); |
752 | 752 | $info['previewAsIcon'] = true; |
@@ -867,7 +867,7 @@ discard block |
||
867 | 867 | public static function getAppVersions() { |
868 | 868 | static $versions; |
869 | 869 | |
870 | - if(!$versions) { |
|
870 | + if (!$versions) { |
|
871 | 871 | $appConfig = \OC::$server->getAppConfig(); |
872 | 872 | $versions = $appConfig->getValues(false, 'installed_version'); |
873 | 873 | } |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | */ |
883 | 883 | public static function updateApp(string $appId): bool { |
884 | 884 | $appPath = self::getAppPath($appId); |
885 | - if($appPath === false) { |
|
885 | + if ($appPath === false) { |
|
886 | 886 | return false; |
887 | 887 | } |
888 | 888 | self::registerAutoloading($appId, $appPath); |
@@ -890,8 +890,8 @@ discard block |
||
890 | 890 | $appData = self::getAppInfo($appId); |
891 | 891 | self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']); |
892 | 892 | |
893 | - if (file_exists($appPath . '/appinfo/database.xml')) { |
|
894 | - OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml'); |
|
893 | + if (file_exists($appPath.'/appinfo/database.xml')) { |
|
894 | + OC_DB::updateDbFromStructure($appPath.'/appinfo/database.xml'); |
|
895 | 895 | } else { |
896 | 896 | $ms = new MigrationService($appId, \OC::$server->getDatabaseConnection()); |
897 | 897 | $ms->migrate(); |
@@ -903,23 +903,23 @@ discard block |
||
903 | 903 | \OC::$server->getAppManager()->getAppVersion($appId, false); |
904 | 904 | |
905 | 905 | // run upgrade code |
906 | - if (file_exists($appPath . '/appinfo/update.php')) { |
|
906 | + if (file_exists($appPath.'/appinfo/update.php')) { |
|
907 | 907 | self::loadApp($appId); |
908 | - include $appPath . '/appinfo/update.php'; |
|
908 | + include $appPath.'/appinfo/update.php'; |
|
909 | 909 | } |
910 | 910 | self::setupBackgroundJobs($appData['background-jobs']); |
911 | 911 | |
912 | 912 | //set remote/public handlers |
913 | 913 | if (array_key_exists('ocsid', $appData)) { |
914 | 914 | \OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']); |
915 | - } elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) { |
|
915 | + } elseif (\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) { |
|
916 | 916 | \OC::$server->getConfig()->deleteAppValue($appId, 'ocsid'); |
917 | 917 | } |
918 | 918 | foreach ($appData['remote'] as $name => $path) { |
919 | - \OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path); |
|
919 | + \OC::$server->getConfig()->setAppValue('core', 'remote_'.$name, $appId.'/'.$path); |
|
920 | 920 | } |
921 | 921 | foreach ($appData['public'] as $name => $path) { |
922 | - \OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path); |
|
922 | + \OC::$server->getConfig()->setAppValue('core', 'public_'.$name, $appId.'/'.$path); |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | self::setAppTypes($appId); |
@@ -989,17 +989,17 @@ discard block |
||
989 | 989 | public static function getStorage(string $appId) { |
990 | 990 | if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check |
991 | 991 | if (\OC::$server->getUserSession()->isLoggedIn()) { |
992 | - $view = new \OC\Files\View('/' . OC_User::getUser()); |
|
992 | + $view = new \OC\Files\View('/'.OC_User::getUser()); |
|
993 | 993 | if (!$view->file_exists($appId)) { |
994 | 994 | $view->mkdir($appId); |
995 | 995 | } |
996 | - return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId); |
|
996 | + return new \OC\Files\View('/'.OC_User::getUser().'/'.$appId); |
|
997 | 997 | } else { |
998 | - \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', ILogger::ERROR); |
|
998 | + \OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.', user not logged in', ILogger::ERROR); |
|
999 | 999 | return false; |
1000 | 1000 | } |
1001 | 1001 | } else { |
1002 | - \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', ILogger::ERROR); |
|
1002 | + \OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.' not enabled', ILogger::ERROR); |
|
1003 | 1003 | return false; |
1004 | 1004 | } |
1005 | 1005 | } |
@@ -1036,9 +1036,9 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | if ($attributeLang === $similarLang) { |
1038 | 1038 | $similarLangFallback = $option['@value']; |
1039 | - } else if (strpos($attributeLang, $similarLang . '_') === 0) { |
|
1039 | + } else if (strpos($attributeLang, $similarLang.'_') === 0) { |
|
1040 | 1040 | if ($similarLangFallback === false) { |
1041 | - $similarLangFallback = $option['@value']; |
|
1041 | + $similarLangFallback = $option['@value']; |
|
1042 | 1042 | } |
1043 | 1043 | } |
1044 | 1044 | } else { |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | $data['description'] = trim(self::findBestL10NOption($data['description'], $lang)); |
1074 | 1074 | } else if (isset($data['description']) && is_string($data['description'])) { |
1075 | 1075 | $data['description'] = trim($data['description']); |
1076 | - } else { |
|
1076 | + } else { |
|
1077 | 1077 | $data['description'] = ''; |
1078 | 1078 | } |
1079 | 1079 |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | case 'database': |
92 | 92 | case 'mysql': |
93 | 93 | case 'sqlite': |
94 | - \OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', ILogger::DEBUG); |
|
94 | + \OCP\Util::writeLog('core', 'Adding user backend '.$backend.'.', ILogger::DEBUG); |
|
95 | 95 | self::$_usedBackends[$backend] = new \OC\User\Database(); |
96 | 96 | \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); |
97 | 97 | break; |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); |
101 | 101 | break; |
102 | 102 | default: |
103 | - \OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', ILogger::DEBUG); |
|
104 | - $className = 'OC_USER_' . strtoupper($backend); |
|
103 | + \OCP\Util::writeLog('core', 'Adding default user backend '.$backend.'.', ILogger::DEBUG); |
|
104 | + $className = 'OC_USER_'.strtoupper($backend); |
|
105 | 105 | self::$_usedBackends[$backend] = new $className(); |
106 | 106 | \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); |
107 | 107 | break; |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | self::useBackend($backend); |
146 | 146 | self::$_setupedBackends[] = $i; |
147 | 147 | } else { |
148 | - \OCP\Util::writeLog('core', 'User backend ' . $class . ' already initialized.', ILogger::DEBUG); |
|
148 | + \OCP\Util::writeLog('core', 'User backend '.$class.' already initialized.', ILogger::DEBUG); |
|
149 | 149 | } |
150 | 150 | } else { |
151 | - \OCP\Util::writeLog('core', 'User backend ' . $class . ' not found.', ILogger::ERROR); |
|
151 | + \OCP\Util::writeLog('core', 'User backend '.$class.' not found.', ILogger::ERROR); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | if ($user) { |
367 | 367 | return $user->getHome(); |
368 | 368 | } else { |
369 | - return \OC::$server->getSystemConfig()->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid; |
|
369 | + return \OC::$server->getSystemConfig()->getValue('datadirectory', OC::$SERVERROOT.'/data').'/'.$uid; |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | private static function sendHeaders($filename, $name, array $rangeArray) { |
77 | 77 | OC_Response::setContentDispositionHeader($name, 'attachment'); |
78 | 78 | header('Content-Transfer-Encoding: binary', true); |
79 | - header('Pragma: public');// enable caching in IE |
|
79 | + header('Pragma: public'); // enable caching in IE |
|
80 | 80 | header('Expires: 0'); |
81 | 81 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
82 | 82 | $fileSize = \OC\Files\Filesystem::filesize($filename); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | if (!is_array($files)) { |
123 | - $filename = $dir . '/' . $files; |
|
123 | + $filename = $dir.'/'.$files; |
|
124 | 124 | if (!$view->is_dir($filename)) { |
125 | 125 | self::getSingleFile($view, $dir, $files, is_null($params) ? array() : $params); |
126 | 126 | return; |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | $name = $basename; |
136 | 136 | } |
137 | 137 | |
138 | - $filename = $dir . '/' . $name; |
|
138 | + $filename = $dir.'/'.$name; |
|
139 | 139 | } else { |
140 | - $filename = $dir . '/' . $files; |
|
140 | + $filename = $dir.'/'.$files; |
|
141 | 141 | $getType = self::ZIP_DIR; |
142 | 142 | // downloading root ? |
143 | 143 | if ($files !== '') { |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | $fileInfos = array(); |
153 | 153 | $fileSize = 0; |
154 | 154 | foreach ($files as $file) { |
155 | - $fileInfo = \OC\Files\Filesystem::getFileInfo($dir . '/' . $file); |
|
155 | + $fileInfo = \OC\Files\Filesystem::getFileInfo($dir.'/'.$file); |
|
156 | 156 | $fileSize += $fileInfo->getSize(); |
157 | 157 | $fileInfos[] = $fileInfo; |
158 | 158 | } |
159 | 159 | $numberOfFiles = self::getNumberOfFiles($fileInfos); |
160 | 160 | } elseif ($getType === self::ZIP_DIR) { |
161 | - $fileInfo = \OC\Files\Filesystem::getFileInfo($dir . '/' . $files); |
|
161 | + $fileInfo = \OC\Files\Filesystem::getFileInfo($dir.'/'.$files); |
|
162 | 162 | $fileSize = $fileInfo->getSize(); |
163 | 163 | $numberOfFiles = self::getNumberOfFiles(array($fileInfo)); |
164 | 164 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | OC_Util::obEnd(); |
168 | 168 | |
169 | 169 | $streamer->sendHeaders($name); |
170 | - $executionTime = (int)OC::$server->getIniWrapper()->getNumeric('max_execution_time'); |
|
170 | + $executionTime = (int) OC::$server->getIniWrapper()->getNumeric('max_execution_time'); |
|
171 | 171 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
172 | 172 | @set_time_limit(0); |
173 | 173 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | if ($getType === self::ZIP_FILES) { |
177 | 177 | foreach ($files as $file) { |
178 | - $file = $dir . '/' . $file; |
|
178 | + $file = $dir.'/'.$file; |
|
179 | 179 | if (\OC\Files\Filesystem::is_file($file)) { |
180 | 180 | $fileSize = \OC\Files\Filesystem::filesize($file); |
181 | 181 | $fileTime = \OC\Files\Filesystem::filemtime($file); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | } |
189 | 189 | } elseif ($getType === self::ZIP_DIR) { |
190 | - $file = $dir . '/' . $files; |
|
190 | + $file = $dir.'/'.$files; |
|
191 | 191 | $streamer->addDirRecursive($file); |
192 | 192 | } |
193 | 193 | $streamer->finalize(); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @return array $rangeArray ('from'=>int,'to'=>int), ... |
220 | 220 | */ |
221 | 221 | private static function parseHttpRangeHeader($rangeHeaderPos, $fileSize) { |
222 | - $rArray=explode(',', $rangeHeaderPos); |
|
222 | + $rArray = explode(',', $rangeHeaderPos); |
|
223 | 223 | $minOffset = 0; |
224 | 224 | $ind = 0; |
225 | 225 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | if ($ranges[0] < $minOffset) { // case: bytes=500-700,601-999 |
232 | 232 | $ranges[0] = $minOffset; |
233 | 233 | } |
234 | - if ($ind > 0 && $rangeArray[$ind-1]['to']+1 == $ranges[0]) { // case: bytes=500-600,601-999 |
|
234 | + if ($ind > 0 && $rangeArray[$ind - 1]['to'] + 1 == $ranges[0]) { // case: bytes=500-600,601-999 |
|
235 | 235 | $ind--; |
236 | 236 | $ranges[0] = $rangeArray[$ind]['from']; |
237 | 237 | } |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | if (is_numeric($ranges[0]) && is_numeric($ranges[1]) && $ranges[0] < $fileSize && $ranges[0] <= $ranges[1]) { |
241 | 241 | // case: x-x |
242 | 242 | if ($ranges[1] >= $fileSize) { |
243 | - $ranges[1] = $fileSize-1; |
|
243 | + $ranges[1] = $fileSize - 1; |
|
244 | 244 | } |
245 | - $rangeArray[$ind++] = array( 'from' => $ranges[0], 'to' => $ranges[1], 'size' => $fileSize ); |
|
245 | + $rangeArray[$ind++] = array('from' => $ranges[0], 'to' => $ranges[1], 'size' => $fileSize); |
|
246 | 246 | $minOffset = $ranges[1] + 1; |
247 | 247 | if ($minOffset >= $fileSize) { |
248 | 248 | break; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | elseif (is_numeric($ranges[0]) && $ranges[0] < $fileSize) { |
252 | 252 | // case: x- |
253 | - $rangeArray[$ind++] = array( 'from' => $ranges[0], 'to' => $fileSize-1, 'size' => $fileSize ); |
|
253 | + $rangeArray[$ind++] = array('from' => $ranges[0], 'to' => $fileSize - 1, 'size' => $fileSize); |
|
254 | 254 | break; |
255 | 255 | } |
256 | 256 | elseif (is_numeric($ranges[1])) { |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | if ($ranges[1] > $fileSize) { |
259 | 259 | $ranges[1] = $fileSize; |
260 | 260 | } |
261 | - $rangeArray[$ind++] = array( 'from' => $fileSize-$ranges[1], 'to' => $fileSize-1, 'size' => $fileSize ); |
|
261 | + $rangeArray[$ind++] = array('from' => $fileSize - $ranges[1], 'to' => $fileSize - 1, 'size' => $fileSize); |
|
262 | 262 | break; |
263 | 263 | } |
264 | 264 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param array $params ; 'head' boolean to only send header of the request ; 'range' http range header |
273 | 273 | */ |
274 | 274 | private static function getSingleFile($view, $dir, $name, $params) { |
275 | - $filename = $dir . '/' . $name; |
|
275 | + $filename = $dir.'/'.$name; |
|
276 | 276 | OC_Util::obEnd(); |
277 | 277 | $view->lockFile($filename, ILockingProvider::LOCK_SHARED); |
278 | 278 | |
@@ -361,17 +361,17 @@ discard block |
||
361 | 361 | */ |
362 | 362 | public static function lockFiles($view, $dir, $files) { |
363 | 363 | if (!is_array($files)) { |
364 | - $file = $dir . '/' . $files; |
|
364 | + $file = $dir.'/'.$files; |
|
365 | 365 | $files = [$file]; |
366 | 366 | } |
367 | 367 | foreach ($files as $file) { |
368 | - $file = $dir . '/' . $file; |
|
368 | + $file = $dir.'/'.$file; |
|
369 | 369 | $view->lockFile($file, ILockingProvider::LOCK_SHARED); |
370 | 370 | if ($view->is_dir($file)) { |
371 | 371 | $contents = $view->getDirectoryContent($file); |
372 | 372 | $contents = array_map(function($fileInfo) use ($file) { |
373 | 373 | /** @var \OCP\Files\FileInfo $fileInfo */ |
374 | - return $file . '/' . $fileInfo->getName(); |
|
374 | + return $file.'/'.$fileInfo->getName(); |
|
375 | 375 | }, $contents); |
376 | 376 | self::lockFiles($view, $dir, $contents); |
377 | 377 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | */ |
388 | 388 | public static function setUploadLimit($size, $files = []) { |
389 | 389 | //don't allow user to break his config |
390 | - $size = (int)$size; |
|
390 | + $size = (int) $size; |
|
391 | 391 | if ($size < self::UPLOAD_MIN_LIMIT_BYTES) { |
392 | 392 | return false; |
393 | 393 | } |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | |
401 | 401 | // default locations if not overridden by $files |
402 | 402 | $files = array_merge([ |
403 | - '.htaccess' => OC::$SERVERROOT . '/.htaccess', |
|
404 | - '.user.ini' => OC::$SERVERROOT . '/.user.ini' |
|
403 | + '.htaccess' => OC::$SERVERROOT.'/.htaccess', |
|
404 | + '.user.ini' => OC::$SERVERROOT.'/.user.ini' |
|
405 | 405 | ], $files); |
406 | 406 | |
407 | 407 | $updateFiles = [ |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $handle = @fopen($filename, 'r+'); |
423 | 423 | if (!$handle) { |
424 | 424 | \OCP\Util::writeLog('files', |
425 | - 'Can\'t write upload limit to ' . $filename . '. Please check the file permissions', |
|
425 | + 'Can\'t write upload limit to '.$filename.'. Please check the file permissions', |
|
426 | 426 | ILogger::WARN); |
427 | 427 | $success = false; |
428 | 428 | continue; // try to update as many files as possible |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | $content = $newContent; |
443 | 443 | } |
444 | 444 | if ($hasReplaced === 0) { |
445 | - $content .= "\n" . $setting; |
|
445 | + $content .= "\n".$setting; |
|
446 | 446 | } |
447 | 447 | } |
448 | 448 | |
@@ -473,12 +473,12 @@ discard block |
||
473 | 473 | } |
474 | 474 | if ($getType === self::ZIP_FILES) { |
475 | 475 | foreach ($files as $file) { |
476 | - $file = $dir . '/' . $file; |
|
476 | + $file = $dir.'/'.$file; |
|
477 | 477 | $view->unlockFile($file, ILockingProvider::LOCK_SHARED); |
478 | 478 | } |
479 | 479 | } |
480 | 480 | if ($getType === self::ZIP_DIR) { |
481 | - $file = $dir . '/' . $files; |
|
481 | + $file = $dir.'/'.$files; |
|
482 | 482 | $view->unlockFile($file, ILockingProvider::LOCK_SHARED); |
483 | 483 | } |
484 | 484 | } |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | throw new \Exception("Access Key, Secret and Bucket have to be configured."); |
53 | 53 | } |
54 | 54 | |
55 | - $this->id = 'amazon::' . $params['bucket']; |
|
55 | + $this->id = 'amazon::'.$params['bucket']; |
|
56 | 56 | |
57 | 57 | $this->test = isset($params['test']); |
58 | 58 | $this->bucket = $params['bucket']; |
59 | 59 | $this->timeout = !isset($params['timeout']) ? 15 : $params['timeout']; |
60 | 60 | $params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region']; |
61 | - $params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname']; |
|
61 | + $params['hostname'] = empty($params['hostname']) ? 's3.'.$params['region'].'.amazonaws.com' : $params['hostname']; |
|
62 | 62 | if (!isset($params['port']) || $params['port'] === '') { |
63 | 63 | $params['port'] = (isset($params['use_ssl']) && $params['use_ssl'] === false) ? 80 : 443; |
64 | 64 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | $scheme = (isset($this->params['use_ssl']) && $this->params['use_ssl'] === false) ? 'http' : 'https'; |
81 | - $base_url = $scheme . '://' . $this->params['hostname'] . ':' . $this->params['port'] . '/'; |
|
81 | + $base_url = $scheme.'://'.$this->params['hostname'].':'.$this->params['port'].'/'; |
|
82 | 82 | |
83 | 83 | $options = [ |
84 | 84 | 'version' => isset($this->params['version']) ? $this->params['version'] : 'latest', |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | $this->connection = new S3Client($options); |
101 | 101 | |
102 | 102 | if (!$this->connection->isBucketDnsCompatible($this->bucket)) { |
103 | - throw new \Exception("The configured bucket name is invalid: " . $this->bucket); |
|
103 | + throw new \Exception("The configured bucket name is invalid: ".$this->bucket); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | if (!$this->connection->doesBucketExist($this->bucket)) { |
107 | 107 | $logger = \OC::$server->getLogger(); |
108 | 108 | try { |
109 | - $logger->info('Bucket "' . $this->bucket . '" does not exist - creating it.', ['app' => 'objectstore']); |
|
109 | + $logger->info('Bucket "'.$this->bucket.'" does not exist - creating it.', ['app' => 'objectstore']); |
|
110 | 110 | $this->connection->createBucket(array( |
111 | 111 | 'Bucket' => $this->bucket |
112 | 112 | )); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | 'level' => ILogger::DEBUG, |
118 | 118 | 'app' => 'objectstore', |
119 | 119 | ]); |
120 | - throw new \Exception('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage()); |
|
120 | + throw new \Exception('Creation of bucket "'.$this->bucket.'" failed. '.$e->getMessage()); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 |
@@ -409,17 +409,17 @@ discard block |
||
409 | 409 | $userObject = $userManager->get($user); |
410 | 410 | |
411 | 411 | if (is_null($userObject)) { |
412 | - \OCP\Util::writeLog('files', ' Backends provided no user object for ' . $user, ILogger::ERROR); |
|
412 | + \OCP\Util::writeLog('files', ' Backends provided no user object for '.$user, ILogger::ERROR); |
|
413 | 413 | // reset flag, this will make it possible to rethrow the exception if called again |
414 | 414 | unset(self::$usersSetup[$user]); |
415 | - throw new \OC\User\NoUserException('Backends provided no user object for ' . $user); |
|
415 | + throw new \OC\User\NoUserException('Backends provided no user object for '.$user); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | $realUid = $userObject->getUID(); |
419 | 419 | // workaround in case of different casings |
420 | 420 | if ($user !== $realUid) { |
421 | 421 | $stack = json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 50)); |
422 | - \OCP\Util::writeLog('files', 'initMountPoints() called with wrong user casing. This could be a bug. Expected: "' . $realUid . '" got "' . $user . '". Stack: ' . $stack, ILogger::WARN); |
|
422 | + \OCP\Util::writeLog('files', 'initMountPoints() called with wrong user casing. This could be a bug. Expected: "'.$realUid.'" got "'.$user.'". Stack: '.$stack, ILogger::WARN); |
|
423 | 423 | $user = $realUid; |
424 | 424 | |
425 | 425 | // again with the correct casing |
@@ -452,11 +452,11 @@ discard block |
||
452 | 452 | } else { |
453 | 453 | self::getMountManager()->addMount(new MountPoint( |
454 | 454 | new NullStorage([]), |
455 | - '/' . $user |
|
455 | + '/'.$user |
|
456 | 456 | )); |
457 | 457 | self::getMountManager()->addMount(new MountPoint( |
458 | 458 | new NullStorage([]), |
459 | - '/' . $user . '/files' |
|
459 | + '/'.$user.'/files' |
|
460 | 460 | )); |
461 | 461 | } |
462 | 462 | \OC_Hook::emit('OC_Filesystem', 'post_initMountPoints', array('user' => $user)); |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | private static function listenForNewMountProviders(MountProviderCollection $mountConfigManager, IUserManager $userManager) { |
472 | 472 | if (!self::$listeningForProviders) { |
473 | 473 | self::$listeningForProviders = true; |
474 | - $mountConfigManager->listen('\OC\Files\Config', 'registerMountProvider', function (IMountProvider $provider) use ($userManager) { |
|
474 | + $mountConfigManager->listen('\OC\Files\Config', 'registerMountProvider', function(IMountProvider $provider) use ($userManager) { |
|
475 | 475 | foreach (Filesystem::$usersSetup as $user => $setup) { |
476 | 476 | $userObject = $userManager->get($user); |
477 | 477 | if ($userObject) { |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | * @return string |
567 | 567 | */ |
568 | 568 | static public function getLocalPath($path) { |
569 | - $datadir = \OC_User::getHome(\OC_User::getUser()) . '/files'; |
|
569 | + $datadir = \OC_User::getHome(\OC_User::getUser()).'/files'; |
|
570 | 570 | $newpath = $path; |
571 | 571 | if (strncmp($newpath, $datadir, strlen($datadir)) == 0) { |
572 | 572 | $newpath = substr($path, strlen($datadir)); |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | static public function isValidPath($path) { |
584 | 584 | $path = self::normalizePath($path); |
585 | 585 | if (!$path || $path[0] !== '/') { |
586 | - $path = '/' . $path; |
|
586 | + $path = '/'.$path; |
|
587 | 587 | } |
588 | 588 | if (strpos($path, '/../') !== false || strrchr($path, '/') === '/..') { |
589 | 589 | return false; |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | * conversion should get removed as soon as all existing |
805 | 805 | * function calls have been fixed. |
806 | 806 | */ |
807 | - $path = (string)$path; |
|
807 | + $path = (string) $path; |
|
808 | 808 | |
809 | 809 | $cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath, $keepUnicode]); |
810 | 810 | |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | |
827 | 827 | //add leading slash |
828 | 828 | if ($path[0] !== '/') { |
829 | - $path = '/' . $path; |
|
829 | + $path = '/'.$path; |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | // remove '/./' |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | $path = '/'; |
128 | 128 | } |
129 | 129 | if ($path[0] !== '/') { |
130 | - $path = '/' . $path; |
|
130 | + $path = '/'.$path; |
|
131 | 131 | } |
132 | - return $this->fakeRoot . $path; |
|
132 | + return $this->fakeRoot.$path; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | public function chroot($fakeRoot) { |
142 | 142 | if (!$fakeRoot == '') { |
143 | 143 | if ($fakeRoot[0] !== '/') { |
144 | - $fakeRoot = '/' . $fakeRoot; |
|
144 | + $fakeRoot = '/'.$fakeRoot; |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | $this->fakeRoot = $fakeRoot; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | // missing slashes can cause wrong matches! |
176 | - $root = rtrim($this->fakeRoot, '/') . '/'; |
|
176 | + $root = rtrim($this->fakeRoot, '/').'/'; |
|
177 | 177 | |
178 | 178 | if (strpos($path, $root) !== 0) { |
179 | 179 | return null; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | if ($mount instanceof MoveableMount) { |
280 | 280 | // cut of /user/files to get the relative path to data/user/files |
281 | 281 | $pathParts = explode('/', $path, 4); |
282 | - $relPath = '/' . $pathParts[3]; |
|
282 | + $relPath = '/'.$pathParts[3]; |
|
283 | 283 | $this->lockFile($relPath, ILockingProvider::LOCK_SHARED, true); |
284 | 284 | \OC_Hook::emit( |
285 | 285 | Filesystem::CLASSNAME, "umount", |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | } |
700 | 700 | $postFix = (substr($path, -1) === '/') ? '/' : ''; |
701 | 701 | $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); |
702 | - $mount = Filesystem::getMountManager()->find($absolutePath . $postFix); |
|
702 | + $mount = Filesystem::getMountManager()->find($absolutePath.$postFix); |
|
703 | 703 | if ($mount and $mount->getInternalPath($absolutePath) === '') { |
704 | 704 | return $this->removeMount($mount, $absolutePath); |
705 | 705 | } |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | $this->renameUpdate($storage1, $storage2, $internalPath1, $internalPath2); |
820 | 820 | } |
821 | 821 | } |
822 | - } catch(\Exception $e) { |
|
822 | + } catch (\Exception $e) { |
|
823 | 823 | throw $e; |
824 | 824 | } finally { |
825 | 825 | $this->changeLock($path1, ILockingProvider::LOCK_SHARED, true); |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | } |
844 | 844 | } |
845 | 845 | } |
846 | - } catch(\Exception $e) { |
|
846 | + } catch (\Exception $e) { |
|
847 | 847 | throw $e; |
848 | 848 | } finally { |
849 | 849 | $this->unlockFile($path1, ILockingProvider::LOCK_SHARED, true); |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | $hooks[] = 'write'; |
977 | 977 | break; |
978 | 978 | default: |
979 | - \OCP\Util::writeLog('core', 'invalid mode (' . $mode . ') for ' . $path, ILogger::ERROR); |
|
979 | + \OCP\Util::writeLog('core', 'invalid mode ('.$mode.') for '.$path, ILogger::ERROR); |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | if ($mode !== 'r' && $mode !== 'w') { |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | array(Filesystem::signal_param_path => $this->getHookPath($path)) |
1081 | 1081 | ); |
1082 | 1082 | } |
1083 | - list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix); |
|
1083 | + list($storage, $internalPath) = Filesystem::resolvePath($absolutePath.$postFix); |
|
1084 | 1084 | if ($storage) { |
1085 | 1085 | return $storage->hash($type, $internalPath, $raw); |
1086 | 1086 | } |
@@ -1134,7 +1134,7 @@ discard block |
||
1134 | 1134 | |
1135 | 1135 | $run = $this->runHooks($hooks, $path); |
1136 | 1136 | /** @var \OC\Files\Storage\Storage $storage */ |
1137 | - list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix); |
|
1137 | + list($storage, $internalPath) = Filesystem::resolvePath($absolutePath.$postFix); |
|
1138 | 1138 | if ($run and $storage) { |
1139 | 1139 | if (in_array('write', $hooks) || in_array('delete', $hooks)) { |
1140 | 1140 | $this->changeLock($path, ILockingProvider::LOCK_EXCLUSIVE); |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | $unlockLater = true; |
1174 | 1174 | // make sure our unlocking callback will still be called if connection is aborted |
1175 | 1175 | ignore_user_abort(true); |
1176 | - $result = CallbackWrapper::wrap($result, null, null, function () use ($hooks, $path) { |
|
1176 | + $result = CallbackWrapper::wrap($result, null, null, function() use ($hooks, $path) { |
|
1177 | 1177 | if (in_array('write', $hooks)) { |
1178 | 1178 | $this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE); |
1179 | 1179 | } else if (in_array('read', $hooks)) { |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | return true; |
1235 | 1235 | } |
1236 | 1236 | |
1237 | - return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/'); |
|
1237 | + return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot.'/'); |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | /** |
@@ -1253,7 +1253,7 @@ discard block |
||
1253 | 1253 | if ($hook != 'read') { |
1254 | 1254 | \OC_Hook::emit( |
1255 | 1255 | Filesystem::CLASSNAME, |
1256 | - $prefix . $hook, |
|
1256 | + $prefix.$hook, |
|
1257 | 1257 | array( |
1258 | 1258 | Filesystem::signal_param_run => &$run, |
1259 | 1259 | Filesystem::signal_param_path => $path |
@@ -1262,7 +1262,7 @@ discard block |
||
1262 | 1262 | } elseif (!$post) { |
1263 | 1263 | \OC_Hook::emit( |
1264 | 1264 | Filesystem::CLASSNAME, |
1265 | - $prefix . $hook, |
|
1265 | + $prefix.$hook, |
|
1266 | 1266 | array( |
1267 | 1267 | Filesystem::signal_param_path => $path |
1268 | 1268 | ) |
@@ -1357,7 +1357,7 @@ discard block |
||
1357 | 1357 | return $this->getPartFileInfo($path); |
1358 | 1358 | } |
1359 | 1359 | $relativePath = $path; |
1360 | - $path = Filesystem::normalizePath($this->fakeRoot . '/' . $path); |
|
1360 | + $path = Filesystem::normalizePath($this->fakeRoot.'/'.$path); |
|
1361 | 1361 | |
1362 | 1362 | $mount = Filesystem::getMountManager()->find($path); |
1363 | 1363 | if (!$mount) { |
@@ -1384,7 +1384,7 @@ discard block |
||
1384 | 1384 | //add the sizes of other mount points to the folder |
1385 | 1385 | $extOnly = ($includeMountPoints === 'ext'); |
1386 | 1386 | $mounts = Filesystem::getMountManager()->findIn($path); |
1387 | - $info->setSubMounts(array_filter($mounts, function (IMountPoint $mount) use ($extOnly) { |
|
1387 | + $info->setSubMounts(array_filter($mounts, function(IMountPoint $mount) use ($extOnly) { |
|
1388 | 1388 | $subStorage = $mount->getStorage(); |
1389 | 1389 | return !($extOnly && $subStorage instanceof \OCA\Files_Sharing\SharedStorage); |
1390 | 1390 | })); |
@@ -1434,12 +1434,12 @@ discard block |
||
1434 | 1434 | /** |
1435 | 1435 | * @var \OC\Files\FileInfo[] $files |
1436 | 1436 | */ |
1437 | - $files = array_map(function (ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) { |
|
1437 | + $files = array_map(function(ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) { |
|
1438 | 1438 | if ($sharingDisabled) { |
1439 | 1439 | $content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE; |
1440 | 1440 | } |
1441 | 1441 | $owner = $this->getUserObjectForOwner($storage->getOwner($content['path'])); |
1442 | - return new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content, $mount, $owner); |
|
1442 | + return new FileInfo($path.'/'.$content['name'], $storage, $content['path'], $content, $mount, $owner); |
|
1443 | 1443 | }, $contents); |
1444 | 1444 | |
1445 | 1445 | //add a folder for any mountpoint in this directory and add the sizes of other mountpoints to the folders |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | } catch (\Exception $e) { |
1464 | 1464 | // sometimes when the storage is not available it can be any exception |
1465 | 1465 | \OC::$server->getLogger()->logException($e, [ |
1466 | - 'message' => 'Exception while scanning storage "' . $subStorage->getId() . '"', |
|
1466 | + 'message' => 'Exception while scanning storage "'.$subStorage->getId().'"', |
|
1467 | 1467 | 'level' => ILogger::ERROR, |
1468 | 1468 | 'app' => 'lib', |
1469 | 1469 | ]); |
@@ -1501,7 +1501,7 @@ discard block |
||
1501 | 1501 | break; |
1502 | 1502 | } |
1503 | 1503 | } |
1504 | - $rootEntry['path'] = substr(Filesystem::normalizePath($path . '/' . $rootEntry['name']), strlen($user) + 2); // full path without /$user/ |
|
1504 | + $rootEntry['path'] = substr(Filesystem::normalizePath($path.'/'.$rootEntry['name']), strlen($user) + 2); // full path without /$user/ |
|
1505 | 1505 | |
1506 | 1506 | // if sharing was disabled for the user we remove the share permissions |
1507 | 1507 | if (\OCP\Util::isSharingDisabledForUser()) { |
@@ -1509,14 +1509,14 @@ discard block |
||
1509 | 1509 | } |
1510 | 1510 | |
1511 | 1511 | $owner = $this->getUserObjectForOwner($subStorage->getOwner('')); |
1512 | - $files[] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner); |
|
1512 | + $files[] = new FileInfo($path.'/'.$rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner); |
|
1513 | 1513 | } |
1514 | 1514 | } |
1515 | 1515 | } |
1516 | 1516 | } |
1517 | 1517 | |
1518 | 1518 | if ($mimetype_filter) { |
1519 | - $files = array_filter($files, function (FileInfo $file) use ($mimetype_filter) { |
|
1519 | + $files = array_filter($files, function(FileInfo $file) use ($mimetype_filter) { |
|
1520 | 1520 | if (strpos($mimetype_filter, '/')) { |
1521 | 1521 | return $file->getMimetype() === $mimetype_filter; |
1522 | 1522 | } else { |
@@ -1545,7 +1545,7 @@ discard block |
||
1545 | 1545 | if ($data instanceof FileInfo) { |
1546 | 1546 | $data = $data->getData(); |
1547 | 1547 | } |
1548 | - $path = Filesystem::normalizePath($this->fakeRoot . '/' . $path); |
|
1548 | + $path = Filesystem::normalizePath($this->fakeRoot.'/'.$path); |
|
1549 | 1549 | /** |
1550 | 1550 | * @var \OC\Files\Storage\Storage $storage |
1551 | 1551 | * @var string $internalPath |
@@ -1572,7 +1572,7 @@ discard block |
||
1572 | 1572 | * @return FileInfo[] |
1573 | 1573 | */ |
1574 | 1574 | public function search($query) { |
1575 | - return $this->searchCommon('search', array('%' . $query . '%')); |
|
1575 | + return $this->searchCommon('search', array('%'.$query.'%')); |
|
1576 | 1576 | } |
1577 | 1577 | |
1578 | 1578 | /** |
@@ -1623,10 +1623,10 @@ discard block |
||
1623 | 1623 | |
1624 | 1624 | $results = call_user_func_array(array($cache, $method), $args); |
1625 | 1625 | foreach ($results as $result) { |
1626 | - if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') { |
|
1626 | + if (substr($mountPoint.$result['path'], 0, $rootLength + 1) === $this->fakeRoot.'/') { |
|
1627 | 1627 | $internalPath = $result['path']; |
1628 | - $path = $mountPoint . $result['path']; |
|
1629 | - $result['path'] = substr($mountPoint . $result['path'], $rootLength); |
|
1628 | + $path = $mountPoint.$result['path']; |
|
1629 | + $result['path'] = substr($mountPoint.$result['path'], $rootLength); |
|
1630 | 1630 | $owner = \OC::$server->getUserManager()->get($storage->getOwner($internalPath)); |
1631 | 1631 | $files[] = new FileInfo($path, $storage, $internalPath, $result, $mount, $owner); |
1632 | 1632 | } |
@@ -1644,8 +1644,8 @@ discard block |
||
1644 | 1644 | if ($results) { |
1645 | 1645 | foreach ($results as $result) { |
1646 | 1646 | $internalPath = $result['path']; |
1647 | - $result['path'] = rtrim($relativeMountPoint . $result['path'], '/'); |
|
1648 | - $path = rtrim($mountPoint . $internalPath, '/'); |
|
1647 | + $result['path'] = rtrim($relativeMountPoint.$result['path'], '/'); |
|
1648 | + $path = rtrim($mountPoint.$internalPath, '/'); |
|
1649 | 1649 | $owner = \OC::$server->getUserManager()->get($storage->getOwner($internalPath)); |
1650 | 1650 | $files[] = new FileInfo($path, $storage, $internalPath, $result, $mount, $owner); |
1651 | 1651 | } |
@@ -1666,7 +1666,7 @@ discard block |
||
1666 | 1666 | public function getOwner($path) { |
1667 | 1667 | $info = $this->getFileInfo($path); |
1668 | 1668 | if (!$info) { |
1669 | - throw new NotFoundException($path . ' not found while trying to get owner'); |
|
1669 | + throw new NotFoundException($path.' not found while trying to get owner'); |
|
1670 | 1670 | } |
1671 | 1671 | return $info->getOwner()->getUID(); |
1672 | 1672 | } |
@@ -1700,7 +1700,7 @@ discard block |
||
1700 | 1700 | * @return string |
1701 | 1701 | */ |
1702 | 1702 | public function getPath($id) { |
1703 | - $id = (int)$id; |
|
1703 | + $id = (int) $id; |
|
1704 | 1704 | $manager = Filesystem::getMountManager(); |
1705 | 1705 | $mounts = $manager->findIn($this->fakeRoot); |
1706 | 1706 | $mounts[] = $manager->find($this->fakeRoot); |
@@ -1715,7 +1715,7 @@ discard block |
||
1715 | 1715 | $cache = $mount->getStorage()->getCache(); |
1716 | 1716 | $internalPath = $cache->getPathById($id); |
1717 | 1717 | if (is_string($internalPath)) { |
1718 | - $fullPath = $mount->getMountPoint() . $internalPath; |
|
1718 | + $fullPath = $mount->getMountPoint().$internalPath; |
|
1719 | 1719 | if (!is_null($path = $this->getRelativePath($fullPath))) { |
1720 | 1720 | return $path; |
1721 | 1721 | } |
@@ -1758,10 +1758,10 @@ discard block |
||
1758 | 1758 | } |
1759 | 1759 | |
1760 | 1760 | // note: cannot use the view because the target is already locked |
1761 | - $fileId = (int)$targetStorage->getCache()->getId($targetInternalPath); |
|
1761 | + $fileId = (int) $targetStorage->getCache()->getId($targetInternalPath); |
|
1762 | 1762 | if ($fileId === -1) { |
1763 | 1763 | // target might not exist, need to check parent instead |
1764 | - $fileId = (int)$targetStorage->getCache()->getId(dirname($targetInternalPath)); |
|
1764 | + $fileId = (int) $targetStorage->getCache()->getId(dirname($targetInternalPath)); |
|
1765 | 1765 | } |
1766 | 1766 | |
1767 | 1767 | // check if any of the parents were shared by the current owner (include collections) |
@@ -1861,7 +1861,7 @@ discard block |
||
1861 | 1861 | $resultPath = ''; |
1862 | 1862 | foreach ($parts as $part) { |
1863 | 1863 | if ($part) { |
1864 | - $resultPath .= '/' . $part; |
|
1864 | + $resultPath .= '/'.$part; |
|
1865 | 1865 | $result[] = $resultPath; |
1866 | 1866 | } |
1867 | 1867 | } |
@@ -2124,16 +2124,16 @@ discard block |
||
2124 | 2124 | public function getUidAndFilename($filename) { |
2125 | 2125 | $info = $this->getFileInfo($filename); |
2126 | 2126 | if (!$info instanceof \OCP\Files\FileInfo) { |
2127 | - throw new NotFoundException($this->getAbsolutePath($filename) . ' not found'); |
|
2127 | + throw new NotFoundException($this->getAbsolutePath($filename).' not found'); |
|
2128 | 2128 | } |
2129 | 2129 | $uid = $info->getOwner()->getUID(); |
2130 | 2130 | if ($uid != \OCP\User::getUser()) { |
2131 | 2131 | Filesystem::initMountPoints($uid); |
2132 | - $ownerView = new View('/' . $uid . '/files'); |
|
2132 | + $ownerView = new View('/'.$uid.'/files'); |
|
2133 | 2133 | try { |
2134 | 2134 | $filename = $ownerView->getPath($info['fileid']); |
2135 | 2135 | } catch (NotFoundException $e) { |
2136 | - throw new NotFoundException('File with id ' . $info['fileid'] . ' not found for user ' . $uid); |
|
2136 | + throw new NotFoundException('File with id '.$info['fileid'].' not found for user '.$uid); |
|
2137 | 2137 | } |
2138 | 2138 | } |
2139 | 2139 | return [$uid, $filename]; |
@@ -2150,7 +2150,7 @@ discard block |
||
2150 | 2150 | $directoryParts = array_filter($directoryParts); |
2151 | 2151 | foreach ($directoryParts as $key => $part) { |
2152 | 2152 | $currentPathElements = array_slice($directoryParts, 0, $key); |
2153 | - $currentPath = '/' . implode('/', $currentPathElements); |
|
2153 | + $currentPath = '/'.implode('/', $currentPathElements); |
|
2154 | 2154 | if ($this->is_file($currentPath)) { |
2155 | 2155 | return false; |
2156 | 2156 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } else { |
107 | 107 | // Update old classes to new namespace |
108 | 108 | if (strpos($storage, 'OC_Filestorage_') !== false) { |
109 | - $storage = '\OC\Files\Storage\\' . substr($storage, 15); |
|
109 | + $storage = '\OC\Files\Storage\\'.substr($storage, 15); |
|
110 | 110 | } |
111 | 111 | $this->class = $storage; |
112 | 112 | $this->arguments = $arguments; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | return; |
159 | 159 | } |
160 | 160 | } else { |
161 | - \OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', ILogger::ERROR); |
|
161 | + \OCP\Util::writeLog('core', 'storage backend '.$this->class.' not found', ILogger::ERROR); |
|
162 | 162 | $this->invalidStorage = true; |
163 | 163 | return; |
164 | 164 | } |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function getInternalPath($path) { |
210 | 210 | $path = Filesystem::normalizePath($path, true, false, true); |
211 | - if ($this->mountPoint === $path or $this->mountPoint . '/' === $path) { |
|
211 | + if ($this->mountPoint === $path or $this->mountPoint.'/' === $path) { |
|
212 | 212 | $internalPath = ''; |
213 | 213 | } else { |
214 | 214 | $internalPath = substr($path, strlen($this->mountPoint)); |
215 | 215 | } |
216 | 216 | // substr returns false instead of an empty string, we always want a string |
217 | - return (string)$internalPath; |
|
217 | + return (string) $internalPath; |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | */ |
268 | 268 | public function getStorageRootId() { |
269 | 269 | if (is_null($this->rootId)) { |
270 | - $this->rootId = (int)$this->getStorage()->getCache()->getId(''); |
|
270 | + $this->rootId = (int) $this->getStorage()->getCache()->getId(''); |
|
271 | 271 | } |
272 | 272 | return $this->rootId; |
273 | 273 | } |