From 631152fc3ec731bb173fb139f0ec8769890eb61e Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sat, 20 Aug 2011 12:03:03 -0400 Subject: [PATCH] Implement searching of files shared with you --- apps/files_sharing/sharedstorage.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php index b890d9ac9f..e2147bea49 100644 --- a/apps/files_sharing/sharedstorage.php +++ b/apps/files_sharing/sharedstorage.php @@ -526,9 +526,25 @@ class OC_Filestorage_Shared extends OC_Filestorage { } } - // TODO query all shared files? - public function search($query) { - + public function search($query) { + return $this->searchInDir($query); + } + + private function searchInDir($query, $path = ""){ + $files = array(); + if ($dh = $this->opendir($path)) { + while (($filename = readdir($dh)) !== false) { + if ($filename != "." && $filename != "..") { + if (strstr(strtolower($filename), strtolower($query))) { + $files[] = $path."/".$filename; + } + if ($this->is_dir($path."/".$filename)) { + $files = array_merge($files, $this->searchInDir($query, $path."/".$filename)); + } + } + } + } + return $files; } public function getLocalFile($path) {