From d10ad0d603d0755f0e57e92ecbce447a8944dc3a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= <schiessle@owncloud.com>
Date: Fri, 21 Jun 2013 10:37:51 +0200
Subject: [PATCH] Squashed commit of the following:
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

commit 1345201c9da99a82f198e41fba24da6b0d7ae59a
Author: Björn Schießle <schiessle@owncloud.com>
Date:   Thu Jun 20 16:27:46 2013 +0200

    add l10n support

commit bf2c79c8de8710e839a4a55642a91874c374fa1c
Author: Björn Schießle <schiessle@owncloud.com>
Date:   Thu Jun 20 16:19:10 2013 +0200

    only init session if openssl extension is loaded

commit cbd52af6afbaa310bb1a534db64ff5e476dfd5d7
Author: Björn Schießle <schiessle@owncloud.com>
Date:   Thu Jun 20 12:25:40 2013 +0200

    first disable app and than show error page

commit 55baf593179c433642de59552592e6b0f1932880
Author: Björn Schießle <schiessle@owncloud.com>
Date:   Thu Jun 20 12:17:34 2013 +0200

    typo fixed

commit 1d9bef0b058e7cc3d511b81ae12d5a07660c75b2
Author: Björn Schießle <schiessle@owncloud.com>
Date:   Thu Jun 20 12:15:40 2013 +0200

    move dependency check to the encryption app

commit c186e95da526f0470e20f014f1bd9513db5518ff
Author: Björn Schießle <schiessle@owncloud.com>
Date:   Thu Jun 20 11:13:11 2013 +0200

    make sure that openssl is installed and loaded
---
 apps/files_encryption/appinfo/app.php | 13 +++++++++----
 apps/files_encryption/hooks/hooks.php | 14 +++++++++-----
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php
index 419bef1edef..d97811bb791 100644
--- a/apps/files_encryption/appinfo/app.php
+++ b/apps/files_encryption/appinfo/app.php
@@ -33,13 +33,18 @@ if (!OC_Config::getValue('maintenance', false)) {
 		}
 
 		$view = new OC_FilesystemView('/');
-		$session = new \OCA\Encryption\Session($view);
+
+		$sessionReady = false;
+		if(extension_loaded("openssl")) {
+			$session = new \OCA\Encryption\Session($view);
+			$sessionReady = true;
+		}
 
 		$user = \OCP\USER::getUser();
 		// check if user has a private key
-		if (
-			!$view->file_exists('/' . $user . '/files_encryption/' . $user . '.private.key')
-			&& OCA\Encryption\Crypt::mode() === 'server'
+		if ($sessionReady === false
+			|| (!$view->file_exists('/' . $user . '/files_encryption/' . $user . '.private.key')
+				&& OCA\Encryption\Crypt::mode() === 'server')
 		) {
 
 			// Force the user to log-in again if the encryption key isn't unlocked
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index 7698b95cfd3..e39e068cc5d 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -38,11 +38,15 @@ class Hooks {
 	 * @note This method should never be called for users using client side encryption
 	 */
 	public static function login($params) {
-
-		// Manually initialise Filesystem{} singleton with correct 
-		// fake root path, in order to avoid fatal webdav errors
-		// NOTE: disabled because this give errors on webdav!
-		//\OC\Files\Filesystem::init( $params['uid'], '/' . 'files' . '/' );
+		$l = new \OC_L10N('files_encryption');
+		//check if openssl is available
+		if(!extension_loaded("openssl") ) {
+			$error_msg = $l->t("PHP module OpenSSL is not installed.");
+			$hint = $l->t('Please ask your server administrator to install the module. For now the encryption app was disabled.');
+			\OC_App::disable('files_encryption');
+			\OCP\Util::writeLog('Encryption library', $error_msg . ' ' . $hint, \OCP\Util::ERROR);
+			\OCP\Template::printErrorPage($error_msg, $hint);
+		}
 
 		$view = new \OC_FilesystemView('/');
 
-- 
GitLab