diff options
author | Philipp Kapfer <philipp.kapfer@gmx.at> | 2013-05-25 17:10:20 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-04-03 16:30:48 +0200 |
commit | 8ca897df76d2a93f66dbe097984eb1e8752410ce (patch) | |
tree | 10a02fd2737909ff6742434f1c0c857fea0ce4bc /apps | |
parent | f7da4280ca1512a4a8224d28e3f6fd954c3b7205 (diff) | |
download | nextcloud-server-8ca897df76d2a93f66dbe097984eb1e8752410ce.tar.gz nextcloud-server-8ca897df76d2a93f66dbe097984eb1e8752410ce.zip |
Added cURL dependency check to Google Drive and WebDAV backend
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
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/appinfo/app.php | 6 | ||||
-rwxr-xr-x | apps/files_external/lib/config.php | 7 | ||||
-rw-r--r-- | apps/files_external/lib/google.php | 12 | ||||
-rw-r--r-- | apps/files_external/lib/webdav.php | 12 |
4 files changed, 33 insertions, 4 deletions
diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php index d6238932cdb..39881b8455b 100644 --- a/apps/files_external/appinfo/app.php +++ b/apps/files_external/appinfo/app.php @@ -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', diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 00f77ea686b..ebc83c7af84 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -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; } /** diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php index 35457f68528..936153b35a5 100644 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -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']) diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 279ae716935..ac6663133d0 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -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']; |