]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added cURL dependency check to Google Drive and WebDAV backend
authorPhilipp Kapfer <philipp.kapfer@gmx.at>
Sat, 25 May 2013 15:10:20 +0000 (17:10 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Thu, 3 Apr 2014 14:30:48 +0000 (16:30 +0200)
Added check for backend's checkDependencies method to OC_Mount_Config::getBackends() when backend is configured to have some instead of blindly calling it and crashing

Conflicts:
apps/files_external/lib/config.php
apps/files_external/lib/google.php

apps/files_external/appinfo/app.php
apps/files_external/lib/config.php
apps/files_external/lib/google.php
apps/files_external/lib/webdav.php

index d6238932cdb04774e41703522cfaa88133098717..39881b8455bf3d970cdfc844be49a0360b7042b1 100644 (file)
@@ -69,7 +69,8 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\Google', array(
                'configured' => '#configured',
                'token' => '#token',
                'token_secret' => '#token secret'),
-       'custom' => 'google'));
+       'custom' => 'google',
+       'has_dependencies' => true));
 
 OC_Mount_Config::registerBackend('\OC\Files\Storage\SWIFT', array(
        'backend' => 'OpenStack Swift',
@@ -97,7 +98,8 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\DAV', array(
                'user' => 'Username',
                'password' => '*Password',
                'root' => '&Root',
-               'secure' => '!Secure https://')));
+               'secure' => '!Secure https://'),
+       'has_dependencies' => true));
 
 OC_Mount_Config::registerBackend('\OC\Files\Storage\SFTP', array(
        'backend' => 'SFTP',
index 00f77ea686b6d6f084a3746dbf608944b28d5e89..ebc83c7af842f671cb25e116fed08542970da30e 100755 (executable)
@@ -66,7 +66,10 @@ class OC_Mount_Config {
 
                foreach (OC_Mount_Config::$backends as $class => $backend) {
                        if (isset($backend['has_dependencies']) and $backend['has_dependencies'] === true) {
-                               if ($class::checkDependencies() !== true) {
+                               if (!method_exists($class, 'checkDependencies')) {
+                                       \OCP\Util::writeLog('files_external', "Backend class $class has dependencies but doesn't provide method checkDependencies()", \OCP\Util::DEBUG);
+                                       continue;
+                               } elseif ($class::checkDependencies() !== true) {
                                        continue;
                                }
                        }
@@ -75,7 +78,7 @@ class OC_Mount_Config {
 
                uasort($backends, $sortFunc);
 
-               return($backends);
+               return $backends;
        }
 
        /**
index 35457f6852841dec9e55621c245d0526e4b6f49d..936153b35a5b737f172ac7aa0a9c9f9afbda4893 100644 (file)
@@ -41,6 +41,18 @@ class Google extends \OC\Files\Storage\Common {
        const DRAWING = 'application/vnd.google-apps.drawing';
        const PRESENTATION = 'application/vnd.google-apps.presentation';
 
+       /**
+        * check if curl is installed
+        */
+       public static function checkDependencies() {
+               if (function_exists('curl_init')) {
+                       return true;
+               } else {
+                       $l = new \OC_L10N('files_external');
+                       return $l->t('<b>Warning:</b> The cURL support in PHP is not enabled or installed. Mounting of Google Drive is not possible. Please ask your system administrator to install it.');
+               }
+       }
+
        public function __construct($params) {
                if (isset($params['configured']) && $params['configured'] === 'true'
                        && isset($params['client_id']) && isset($params['client_secret'])
index 279ae716935994411e889bbadef270ecf362ef97..ac6663133d015f081556cdbe37ba13ffd6bd92e3 100644 (file)
@@ -23,6 +23,18 @@ class DAV extends \OC\Files\Storage\Common {
 
        private static $tempFiles = array();
 
+       /**
+        * check if curl is installed
+        */
+       public static function checkDependencies() {
+               if (function_exists('curl_init')) {
+                       return true;
+               } else {
+                       $l = new \OC_L10N('files_external');
+                       return $l->t('<b>Warning:</b> The cURL support in PHP is not enabled or installed. Mounting of ownCloud / WebDAV is not possible. Please ask your system administrator to install it.');
+               }
+       }
+
        public function __construct($params) {
                if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
                        $host = $params['host'];