HomeObjectStoreStorage.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Björn Schießle <bjoern@schiessle.org>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OC\Files\ObjectStore;
  27. use OC\User\User;
  28. class HomeObjectStoreStorage extends ObjectStoreStorage implements \OCP\Files\IHomeStorage {
  29. /**
  30. * The home user storage requires a user object to create a unique storage id
  31. * @param array $params
  32. */
  33. public function __construct($params) {
  34. if (! isset($params['user']) || ! $params['user'] instanceof User) {
  35. throw new \Exception('missing user object in parameters');
  36. }
  37. $this->user = $params['user'];
  38. parent::__construct($params);
  39. }
  40. public function getId() {
  41. return 'object::user:' . $this->user->getUID();
  42. }
  43. /**
  44. * get the owner of a path
  45. *
  46. * @param string $path The path to get the owner
  47. * @return false|string uid
  48. */
  49. public function getOwner($path) {
  50. if (is_object($this->user)) {
  51. return $this->user->getUID();
  52. }
  53. return false;
  54. }
  55. /**
  56. * @param string $path, optional
  57. * @return \OC\User\User
  58. */
  59. public function getUser($path = null) {
  60. return $this->user;
  61. }
  62. }