Cache.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Morris Jobke <hey@morrisjobke.de>
  6. * @author Robin Appelman <robin@icewind.nl>
  7. * @author Vincent Petry <pvince81@owncloud.com>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OCA\Files_Sharing\External;
  25. use OCP\Federation\ICloudId;
  26. class Cache extends \OC\Files\Cache\Cache {
  27. /** @var ICloudId */
  28. private $cloudId;
  29. private $remote;
  30. private $remoteUser;
  31. private $storage;
  32. /**
  33. * @param \OCA\Files_Sharing\External\Storage $storage
  34. * @param ICloudId $cloudId
  35. */
  36. public function __construct($storage, ICloudId $cloudId) {
  37. $this->cloudId = $cloudId;
  38. $this->storage = $storage;
  39. list(, $remote) = explode('://', $cloudId->getRemote(), 2);
  40. $this->remote = $remote;
  41. $this->remoteUser = $cloudId->getUser();
  42. parent::__construct($storage);
  43. }
  44. public function get($file) {
  45. $result = parent::get($file);
  46. if (!$result) {
  47. return false;
  48. }
  49. $result['displayname_owner'] = $this->cloudId->getDisplayId();
  50. if (!$file || $file === '') {
  51. $result['is_share_mount_point'] = true;
  52. $mountPoint = rtrim($this->storage->getMountPoint());
  53. $result['name'] = basename($mountPoint);
  54. }
  55. return $result;
  56. }
  57. public function getFolderContentsById($id) {
  58. $results = parent::getFolderContentsById($id);
  59. foreach ($results as &$file) {
  60. $file['displayname_owner'] = $this->cloudId->getDisplayId();
  61. }
  62. return $results;
  63. }
  64. }