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 | |
parent | ae4775a68315c2aaab3f15c8baf8dbd6ee8ccf7a (diff) | |
download | nextcloud-server-e8bf576184fdafbe74f3394dc253a56c07be6507.tar.gz nextcloud-server-e8bf576184fdafbe74f3394dc253a56c07be6507.zip |
add initial search in shared files
-rw-r--r-- | apps/files_sharing/lib/cache.php | 26 | ||||
-rw-r--r-- | lib/public/share.php | 2 |
2 files changed, 26 insertions, 2 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; } /** diff --git a/lib/public/share.php b/lib/public/share.php index 9ab956d84b9..10922965ea8 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -748,7 +748,7 @@ class Share { * @param string Item type * @return Sharing backend object */ - private static function getBackend($itemType) { + public static function getBackend($itemType) { if (isset(self::$backends[$itemType])) { return self::$backends[$itemType]; } else if (isset(self::$backendTypes[$itemType]['class'])) { |