From af16a4cd2770d63f8948ea4deca8664f41cefc26 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Tue, 14 Jun 2016 21:37:22 +0530 Subject: [PATCH] Make me work with owncloud9 Due to API change (searchByMime), app was completely broken when installed with owncloud9. This change should make it work with owncloud9, while still keeping older owncloud version (upto 8.2) in working state. Lets use functions on object returned by searchByMime instead of directly accessing its data members. --- appinfo/info.xml.in | 2 +- lib/storage.php | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/appinfo/info.xml.in b/appinfo/info.xml.in index 2468d315..29113683 100644 --- a/appinfo/info.xml.in +++ b/appinfo/info.xml.in @@ -10,7 +10,7 @@ https://github.com/owncloud/richdocuments.git productivity - + public.php diff --git a/lib/storage.php b/lib/storage.php index 51cf6b66..c7fa35b0 100644 --- a/lib/storage.php +++ b/lib/storage.php @@ -139,11 +139,29 @@ class Storage { Db\Session::cleanUp($session->getEsId()); } + private static function processDocuments($rawDocuments){ + $documents = array(); + foreach($rawDocuments as $rawDocument){ + $document = array( + 'fileid' => $rawDocument->getId(), + 'path' => $rawDocument->getInternalPath(), + 'name' => $rawDocument->getName(), + 'mimetype' => $rawDocument->getMimetype() + ); + + array_push($documents, $document); + } + + return $documents; + } + protected static function searchDocuments(){ $documents = array(); foreach (self::getSupportedMimetypes() as $mime){ - $documents = array_merge($documents, \OCP\Files::searchByMime($mime)); + $rawDocuments = \OCP\Files::searchByMime($mime); + $documents = array_merge($documents, self::processDocuments($rawDocuments)); } + return $documents; }