diff options
Diffstat (limited to 'lib/private/Files/Node/Folder.php')
-rw-r--r-- | lib/private/Files/Node/Folder.php | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 4a134cdcdbf..56ec39d86a8 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -34,7 +34,7 @@ use OCP\Files\FileInfo; use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; -use OCP\Files\Search\ISearchOperator; +use OCP\Files\Search\ISearchQuery; class Folder extends Node implements \OCP\Files\Folder { /** @@ -191,7 +191,7 @@ class Folder extends Node implements \OCP\Files\Folder { /** * search for files with the name matching $query * - * @param string|ISearchOperator $query + * @param string|ISearchQuery $query * @return \OC\Files\Node\Node[] */ public function search($query) { @@ -229,6 +229,11 @@ class Folder extends Node implements \OCP\Files\Folder { * @return \OC\Files\Node\Node[] */ private function searchCommon($method, $args) { + $limitToHome = ($method === 'searchQuery')? $args[0]->limitToHome(): false; + if ($limitToHome && count(explode('/', $this->path)) !== 3) { + throw new \InvalidArgumentException('searching by owner is only allows on the users home folder'); + } + $files = array(); $rootLength = strlen($this->path); $mount = $this->root->getMount($this->path); @@ -252,19 +257,22 @@ class Folder extends Node implements \OCP\Files\Folder { } } - $mounts = $this->root->getMountsIn($this->path); - foreach ($mounts as $mount) { - $storage = $mount->getStorage(); - if ($storage) { - $cache = $storage->getCache(''); - - $relativeMountPoint = ltrim(substr($mount->getMountPoint(), $rootLength), '/'); - $results = call_user_func_array(array($cache, $method), $args); - foreach ($results as $result) { - $result['internalPath'] = $result['path']; - $result['path'] = $relativeMountPoint . $result['path']; - $result['storage'] = $storage; - $files[] = new \OC\Files\FileInfo($this->path . '/' . $result['path'], $storage, $result['internalPath'], $result, $mount); + if (!$limitToHome) { + $mounts = $this->root->getMountsIn($this->path); + foreach ($mounts as $mount) { + $storage = $mount->getStorage(); + if ($storage) { + $cache = $storage->getCache(''); + + $relativeMountPoint = ltrim(substr($mount->getMountPoint(), $rootLength), '/'); + $results = call_user_func_array([$cache, $method], $args); + foreach ($results as $result) { + $result['internalPath'] = $result['path']; + $result['path'] = $relativeMountPoint . $result['path']; + $result['storage'] = $storage; + $files[] = new \OC\Files\FileInfo($this->path . '/' . $result['path'], $storage, + $result['internalPath'], $result, $mount); + } } } } |