diff --git a/appinfo/application.php b/appinfo/application.php index 7d2dc9da..a36f7855 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -66,14 +66,16 @@ class Application extends App { $container->registerService('Logger', function($c) { return $c->query('ServerContainer')->getLogger(); }); - $container->registerService('CoreConfig', function($c) { - return $c->query('ServerContainer')->getConfig(); - }); - $container->registerService('L10N', function($c) { - return $c->query('ServerContainer')->getL10N($c->query('AppName')); - }); - $container->registerService('UserId', function($c) { - return $c->query('ServerContainer')->getUserSession()->getUser()->getUID(); - }); + $container->registerService('CoreConfig', function($c) { + return $c->query('ServerContainer')->getConfig(); + }); + $container->registerService('L10N', function($c) { + return $c->query('ServerContainer')->getL10N($c->query('AppName')); + }); + $container->registerService('UserId', function($c) { + $user = $c->query('ServerContainer')->getUserSession()->getUser(); + $uid = is_null($user) ? '' : $user->getUID(); + return $uid; + }); } } diff --git a/controller/documentcontroller.php b/controller/documentcontroller.php index c1137b7d..c68a843d 100644 --- a/controller/documentcontroller.php +++ b/controller/documentcontroller.php @@ -168,7 +168,8 @@ class DocumentController extends Controller{ } else { $documents[$key] = $document; } - $documents[$key]['icon'] = preg_replace('/\.png$/', '.svg', \OC_Helper::mimetypeIcon($document['mimetype'])); + $documents[$key]['icon'] = preg_replace('/\.png$/', '.svg', \OCP\Template::mimetype_icon($document['mimetype'])); + $documents[$key]['hasPreview'] = \OC::$server->getPreviewManager()->isMimeSupported($document['mimetype']); $fileIds[] = $document['fileid']; } diff --git a/js/documents.js b/js/documents.js index 2eabb8d7..0bcf1943 100644 --- a/js/documents.js +++ b/js/documents.js @@ -61,7 +61,7 @@ $.widget('oc.documentGrid', { previewURL = OC.generateUrl('/core/preview.png?') + $.param(urlSpec); previewURL = previewURL.replace('(', '%28').replace(')', '%29'); - if ( $('#previews_enabled').length ) { + if ( $('#previews_enabled').length && document.hasPreview) { var img = new Image(); img.onload = function(){ var ready = function (node){ diff --git a/lib/db.php b/lib/db.php index 918ec7b8..53935830 100644 --- a/lib/db.php +++ b/lib/db.php @@ -57,7 +57,7 @@ abstract class Db { } $result = $this->execute($this->loadStatement, $value); - $data = $result->fetchRow(); + $data = $result->fetch(); if (!is_array($data)){ $data = array(); } @@ -194,7 +194,7 @@ abstract class Db { * @return mixed (array/false) */ protected function execute($statement, $args = null){ - $query = \OCP\DB::prepare($statement); + $query = \OC::$server->getDatabaseConnection()->prepare($statement); if (!is_null($args)){ $result = $query->execute($args); @@ -204,7 +204,7 @@ abstract class Db { $result = $query->execute(); } - return $result; + return $result ? $query : false; } public function __call($name, $arguments){ diff --git a/lib/db/op.php b/lib/db/op.php index 50449398..b8a8ff03 100644 --- a/lib/db/op.php +++ b/lib/db/op.php @@ -41,18 +41,14 @@ class Op extends \OCA\Documents\Db { * @returns "" when there are no Ops, or the seq of the last Op */ public function getHeadSeq($esId){ - $query = \OCP\DB::prepare(' + $query = \OC::$server->getDatabaseConnection()->prepare(' SELECT `seq` FROM ' . $this->tableName . ' WHERE `es_id`=? ORDER BY `seq` DESC ', 1); - $result = $query->execute(array( - $esId - )) - ->fetchOne() - ; - return !$result ? "" : $result; + $result = $query->execute([$esId]); + return !$result ? "" : $query->fetchColumn(); } public function getOpsAfterJson($esId, $seq){ @@ -75,7 +71,7 @@ class Op extends \OCA\Documents\Db { if ($seq == ""){ $seq = -1; } - $query = \OCP\DB::prepare(' + $query = \OC::$server->getDatabaseConnection()->prepare(' SELECT `opspec` FROM ' . self::DB_TABLE . ' WHERE `es_id`=? @@ -83,7 +79,7 @@ class Op extends \OCA\Documents\Db { ORDER BY `seq` ASC '); $result = $query->execute(array($esId, $seq)); - return $result->fetchAll(); + return $query->fetchAll(); } public function addMember($esId, $memberId, $fullName, $userId, $color, $imageUrl){ diff --git a/lib/db/session.php b/lib/db/session.php index b8de3c1c..cbfe0cb8 100644 --- a/lib/db/session.php +++ b/lib/db/session.php @@ -93,7 +93,7 @@ class Session extends \OCA\Documents\Db { $sessionData['member_id'] = (string) $member->getLastInsertId(); // Do we have OC_Avatar in out disposal? - if (\OC_Config::getValue('enable_avatars', true) !== true){ + if (\OC::$server->getConfig()->getSystemValue('enable_avatars', true) !== true){ $imageUrl = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw=='; } else { $imageUrl = $uid; @@ -198,7 +198,7 @@ class Session extends \OCA\Documents\Db { ] ); - $info = $result->fetchRow(); + $info = $result->fetch(); if (!is_array($info)){ $info = array(); } diff --git a/public.php b/public.php index bb3c9971..b3b84eee 100644 --- a/public.php +++ b/public.php @@ -15,7 +15,7 @@ namespace OCA\Documents; \OCP\JSON::checkAppEnabled('documents'); -if (\OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { +if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { header('HTTP/1.0 404 Not Found'); $tmpl = new OCP\Template('', '404', 'guest'); $tmpl->printPage(); diff --git a/templates/documents.php b/templates/documents.php index 20e0bef4..df5faf24 100644 --- a/templates/documents.php +++ b/templates/documents.php @@ -16,7 +16,7 @@ script('files', 'jquery.fileupload');