cache.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace OCA\Files_Sharing\External;
  9. class Cache extends \OC\Files\Cache\Cache {
  10. private $remote;
  11. private $remoteUser;
  12. private $storage;
  13. /**
  14. * @param \OCA\Files_Sharing\External\Storage $storage
  15. * @param string $remote
  16. * @param string $remoteUser
  17. */
  18. public function __construct($storage, $remote, $remoteUser) {
  19. $this->storage = $storage;
  20. list(, $remote) = explode('://', $remote, 2);
  21. $this->remote = $remote;
  22. $this->remoteUser = $remoteUser;
  23. parent::__construct($storage);
  24. }
  25. public function get($file) {
  26. $result = parent::get($file);
  27. $result['displayname_owner'] = $this->remoteUser . '@' . $this->remote;
  28. if (!$file || $file === '') {
  29. $result['is_share_mount_point'] = true;
  30. $mountPoint = rtrim($this->storage->getMountPoint());
  31. $result['name'] = basename($mountPoint);
  32. }
  33. return $result;
  34. }
  35. public function getFolderContentsById($id) {
  36. $results = parent::getFolderContentsById($id);
  37. foreach ($results as &$file) {
  38. $file['displayname_owner'] = $this->remoteUser . '@' . $this->remote;
  39. }
  40. return $results;
  41. }
  42. }