Cache.php 1.9 KB

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