diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-07-26 14:11:59 +0200 |
---|---|---|
committer | Victor Dubiniuk <victor.dubiniuk@gmail.com> | 2013-09-19 21:08:32 +0300 |
commit | e8bf576184fdafbe74f3394dc253a56c07be6507 (patch) | |
tree | 1b50113237eac15a3c30ce3574466965c80beeef /apps/files_sharing | |
parent | ae4775a68315c2aaab3f15c8baf8dbd6ee8ccf7a (diff) | |
download | nextcloud-server-e8bf576184fdafbe74f3394dc253a56c07be6507.tar.gz nextcloud-server-e8bf576184fdafbe74f3394dc253a56c07be6507.zip |
add initial search in shared files
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/lib/cache.php | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php index 33cd1428899..28e3cbdb2e1 100644 --- a/apps/files_sharing/lib/cache.php +++ b/apps/files_sharing/lib/cache.php @@ -226,7 +226,31 @@ class Shared_Cache extends Cache { * @return array of file data */ public function search($pattern) { - // TODO + + // normalize pattern + $pattern = $this->normalize($pattern); + + $ids = \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_GET_ALL); + foreach ($ids as $file) { + $folderBackend = \OCP\Share::getBackend('folder'); + $children = $folderBackend->getChildren($file); + foreach ($children as $child) { + $ids[] = (int)$child['source']; + } + + } + $placeholders = join(',', array_fill(0, count($ids), '?')); + + $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `unencrypted_size`, `etag` + FROM `*PREFIX*filecache` WHERE `name` LIKE ? AND `fileid` IN (' . $placeholders . ')'; + $result = \OC_DB::executeAudited($sql, array_merge(array($pattern), $ids)); + $files = array(); + while ($row = $result->fetchRow()) { + $row['mimetype'] = $this->getMimetype($row['mimetype']); + $row['mimepart'] = $this->getMimetype($row['mimepart']); + $files[] = $row; + } + return $files; } /** |