diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-12-12 11:18:35 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-12-12 11:18:35 +0100 |
commit | 15ecb28d50e5b8ce4100075caa52d96d4f00ae13 (patch) | |
tree | 02ca5b15c2a09afaa6a44a71fcf14d3c53184200 /lib/private/files | |
parent | 25dde7e93bc648ec8cd14b8f2711d50f77d8d1bf (diff) | |
download | nextcloud-server-15ecb28d50e5b8ce4100075caa52d96d4f00ae13.tar.gz nextcloud-server-15ecb28d50e5b8ce4100075caa52d96d4f00ae13.zip |
Make $userId mandatory for searchByTags
$userId is now a mandatory parameter for searchByTags.
Also fixed some places in the code where the argument was missing (Node
API and View)
Diffstat (limited to 'lib/private/files')
-rw-r--r-- | lib/private/files/cache/cache.php | 5 | ||||
-rw-r--r-- | lib/private/files/cache/wrapper/cachewrapper.php | 2 | ||||
-rw-r--r-- | lib/private/files/filesystem.php | 5 | ||||
-rw-r--r-- | lib/private/files/node/folder.php | 21 | ||||
-rw-r--r-- | lib/private/files/node/nonexistingfolder.php | 2 | ||||
-rw-r--r-- | lib/private/files/view.php | 21 |
6 files changed, 28 insertions, 28 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index a4ae3a069fe..9df64db7f07 100644 --- a/lib/private/files/cache/cache.php +++ b/lib/private/files/cache/cache.php @@ -512,10 +512,7 @@ class Cache { * @param string $userId owner of the tags * @return array file data */ - public function searchByTag($tag, $userId = null) { - if (is_null($userId)) { - $userId = \OC::$server->getUserSession()->getUser()->getUID(); - } + public function searchByTag($tag, $userId) { $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, ' . '`mimetype`, `mimepart`, `size`, `mtime`, ' . '`encrypted`, `unencrypted_size`, `etag`, `permissions` ' . diff --git a/lib/private/files/cache/wrapper/cachewrapper.php b/lib/private/files/cache/wrapper/cachewrapper.php index 4da7c7ecf6f..83811520e4b 100644 --- a/lib/private/files/cache/wrapper/cachewrapper.php +++ b/lib/private/files/cache/wrapper/cachewrapper.php @@ -187,7 +187,7 @@ class CacheWrapper extends Cache { * @param string $userId owner of the tags * @return array file data */ - public function searchByTag($tag, $userId = null) { + public function searchByTag($tag, $userId) { $results = $this->cache->searchByTag($tag, $userId); return array_map(array($this, 'formatCacheEntry'), $results); } diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php index 3d55564f0c6..ed2be59c092 100644 --- a/lib/private/files/filesystem.php +++ b/lib/private/files/filesystem.php @@ -688,10 +688,11 @@ class Filesystem { /** * @param string|int $tag name or tag id + * @param string $userId owner of the tags * @return FileInfo[] array or file info */ - static public function searchByTag($tag) { - return self::$defaultInstance->searchByTag($tag); + static public function searchByTag($tag, $userId) { + return self::$defaultInstance->searchByTag($tag, $userId); } /** diff --git a/lib/private/files/node/folder.php b/lib/private/files/node/folder.php index a65e641388d..bdfb2346716 100644 --- a/lib/private/files/node/folder.php +++ b/lib/private/files/node/folder.php @@ -223,7 +223,7 @@ class Folder extends Node implements \OCP\Files\Folder { * @return \OC\Files\Node\Node[] */ public function search($query) { - return $this->searchCommon('%' . $query . '%', 'search'); + return $this->searchCommon('search', array('%' . $query . '%')); } /** @@ -233,25 +233,26 @@ class Folder extends Node implements \OCP\Files\Folder { * @return Node[] */ public function searchByMime($mimetype) { - return $this->searchCommon($mimetype, 'searchByMime'); + return $this->searchCommon('searchByMime', array($mimetype)); } /** * search for files by tag * - * @param string $tag + * @param string|int $tag name or tag id + * @param string $userId owner of the tags * @return Node[] */ - public function searchByTag($tag) { - return $this->searchCommon($tag, 'searchByTag'); + public function searchByTag($tag, $userId) { + return $this->searchCommon('searchByTag', array($tag, $userId)); } /** - * @param string $query - * @param string $method + * @param string $method cache method + * @param array $args call args * @return \OC\Files\Node\Node[] */ - private function searchCommon($query, $method) { + private function searchCommon($method, $args) { $files = array(); $rootLength = strlen($this->path); /** @@ -262,7 +263,7 @@ class Folder extends Node implements \OCP\Files\Folder { $cache = $storage->getCache(''); - $results = $cache->$method($query); + $results = call_user_func_array(array($cache, $method), $args); foreach ($results as $result) { if ($internalRootLength === 0 or substr($result['path'], 0, $internalRootLength) === $internalPath) { $result['internalPath'] = $result['path']; @@ -279,7 +280,7 @@ class Folder extends Node implements \OCP\Files\Folder { $cache = $storage->getCache(''); $relativeMountPoint = substr($mount->getMountPoint(), $rootLength); - $results = $cache->$method($query); + $results = call_user_func_array(array($cache, $method), $args); foreach ($results as $result) { $result['internalPath'] = $result['path']; $result['path'] = $relativeMountPoint . $result['path']; diff --git a/lib/private/files/node/nonexistingfolder.php b/lib/private/files/node/nonexistingfolder.php index 9d452a94b9c..04f741e8a46 100644 --- a/lib/private/files/node/nonexistingfolder.php +++ b/lib/private/files/node/nonexistingfolder.php @@ -99,7 +99,7 @@ class NonExistingFolder extends Folder { throw new NotFoundException(); } - public function searchByTag($mime) { + public function searchByTag($tag, $userId) { throw new NotFoundException(); } diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 7090e03d40c..73faf261c14 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,25 +1131,26 @@ class View { * @return FileInfo[] */ public function searchByMime($mimetype) { - return $this->searchCommon($mimetype, 'searchByMime'); + return $this->searchCommon('searchByMime', array($mimetype)); } /** * 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) { - return $this->searchCommon($tag, 'searchByTag'); + public function searchByTag($tag, $userId) { + return $this->searchCommon('searchByTag', array($tag, $userId)); } /** - * @param string $query - * @param string $method + * @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); @@ -1158,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']; @@ -1175,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']; |