diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-12-12 14:27:19 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-12-12 14:27:19 +0100 |
commit | 4b57892c4eeeb7bd3c8b1b0465acf032dc84fd19 (patch) | |
tree | fbad2095651334fc34b3729ae5102ad5e1cd866f /lib/private/files/view.php | |
parent | 6b4502adebf1d756707e8fb5b8ab697c1c746e6b (diff) | |
parent | 3878c3782ff37dc56a4e463acea351a61ed7b4c2 (diff) | |
download | nextcloud-server-4b57892c4eeeb7bd3c8b1b0465acf032dc84fd19.tar.gz nextcloud-server-4b57892c4eeeb7bd3c8b1b0465acf032dc84fd19.zip |
Merge pull request #12778 from owncloud/searchbytags2
Added searchByTags to view, storage and cache
Diffstat (limited to 'lib/private/files/view.php')
-rw-r--r-- | lib/private/files/view.php | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 93edbede607..c01763cdad3 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -1111,7 +1111,7 @@ class View { * @return FileInfo[] */ public function search($query) { - return $this->searchCommon('%' . $query . '%', 'search'); + return $this->searchCommon('search', array('%' . $query . '%')); } /** @@ -1121,7 +1121,7 @@ class View { * @return FileInfo[] */ public function searchRaw($query) { - return $this->searchCommon($query, 'search'); + return $this->searchCommon('search', array($query)); } /** @@ -1131,15 +1131,26 @@ class View { * @return FileInfo[] */ public function searchByMime($mimetype) { - return $this->searchCommon($mimetype, 'searchByMime'); + return $this->searchCommon('searchByMime', array($mimetype)); } /** - * @param string $query - * @param string $method + * search for files by tag + * + * @param string|int $tag name or tag id + * @param string $userId owner of the tags + * @return FileInfo[] + */ + public function searchByTag($tag, $userId) { + return $this->searchCommon('searchByTag', array($tag, $userId)); + } + + /** + * @param string $method cache method + * @param array $args * @return FileInfo[] */ - private function searchCommon($query, $method) { + private function searchCommon($method, $args) { $files = array(); $rootLength = strlen($this->fakeRoot); @@ -1148,7 +1159,7 @@ class View { if ($storage) { $cache = $storage->getCache(''); - $results = $cache->$method($query); + $results = call_user_func_array(array($cache, $method), $args); foreach ($results as $result) { if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') { $internalPath = $result['path']; @@ -1165,7 +1176,7 @@ class View { $cache = $storage->getCache(''); $relativeMountPoint = substr($mountPoint, $rootLength); - $results = $cache->$method($query); + $results = call_user_func_array(array($cache, $method), $args); if ($results) { foreach ($results as $result) { $internalPath = $result['path']; |