From 6dc3682cc2fde9a508747f4af1e017a77d01faae Mon Sep 17 00:00:00 2001
From: Bjoern Schiessle <schiessle@owncloud.com>
Date: Mon, 4 May 2015 13:00:17 +0200
Subject: [PATCH 1/4] don't let the the user disable encryption once it was
 activated

---
 settings/css/settings.css    | 4 ++++
 settings/js/admin.js         | 1 +
 settings/templates/admin.php | 6 +++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/settings/css/settings.css b/settings/css/settings.css
index 583e8804951..4e398c64c4e 100644
--- a/settings/css/settings.css
+++ b/settings/css/settings.css
@@ -494,3 +494,7 @@ doesnotexist:-o-prefocus, .strengthify-wrapper {
 #encryptionModules {
 	padding: 10px;
 }
+
+#warning {
+	color: red;
+}
diff --git a/settings/js/admin.js b/settings/js/admin.js
index 9cdb7f5b0f1..e10e1f915cb 100644
--- a/settings/js/admin.js
+++ b/settings/js/admin.js
@@ -55,6 +55,7 @@ $(document).ready(function(){
 	});
 
 	$('#encryptionEnabled').change(function() {
+		$('#encryptionAPI div#EncryptionWarning').toggleClass('hidden');
 		$('#encryptionAPI div#EncryptionSettingsArea').toggleClass('hidden');
 	});
 
diff --git a/settings/templates/admin.php b/settings/templates/admin.php
index 5edf4e2a9c7..9938b6d01f0 100644
--- a/settings/templates/admin.php
+++ b/settings/templates/admin.php
@@ -321,11 +321,15 @@ if ($_['cronErrors']) {
 	<p id="enable">
 		<input type="checkbox" name="encryption_enabled"
 			   id="encryptionEnabled"
-			   value="1" <?php if ($_['encryptionEnabled']) print_unescaped('checked="checked"'); ?> />
+			   value="1" <?php if ($_['encryptionEnabled']) print_unescaped('checked="checked" disabled="disabled"'); ?> />
 		<label
 			for="encryptionEnabled"><?php p($l->t('Enable server-side encryption')); ?> <span id="startmigration_msg" class="msg"></span> </label><br/>
 	</p>
 
+	<div id="EncryptionWarning" class="warning hidden">
+		<?php p($l->t('Once encryption is enabled there is no way to disable it again. This is your last chance to disable it again.')) ?>
+	</div>
+
 	<div id="EncryptionSettingsArea" class="<?php if (!$_['encryptionEnabled']) p('hidden'); ?>">
 		<div id='selectEncryptionModules' class="<?php if (!$_['encryptionReady']) p('hidden'); ?>">
 			<?php

From 8f1e504d7974080381fed378f5335c9dd323e3bf Mon Sep 17 00:00:00 2001
From: Bjoern Schiessle <schiessle@owncloud.com>
Date: Tue, 5 May 2015 10:38:09 +0200
Subject: [PATCH 2/4] adjust wording and add button to confirm encryption

---
 settings/js/admin.js         | 18 ++++++------------
 settings/templates/admin.php | 12 +++++++++---
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/settings/js/admin.js b/settings/js/admin.js
index e10e1f915cb..8f705b9048d 100644
--- a/settings/js/admin.js
+++ b/settings/js/admin.js
@@ -54,21 +54,15 @@ $(document).ready(function(){
 		$('#shareAPI p:not(#enable)').toggleClass('hidden', !this.checked);
 	});
 
-	$('#encryptionEnabled').change(function() {
+	$('#enableEncryption').change(function() {
 		$('#encryptionAPI div#EncryptionWarning').toggleClass('hidden');
-		$('#encryptionAPI div#EncryptionSettingsArea').toggleClass('hidden');
 	});
 
-	$('#encryptionAPI input').change(function() {
-		var value = $(this).val();
-		if ($(this).attr('type') === 'checkbox') {
-			if (this.checked) {
-				value = 'yes';
-			} else {
-				value = 'no';
-			}
-		}
-		OC.AppConfig.setValue('core', $(this).attr('name'), value);
+	$('#reallyEnableEncryption').click(function() {
+		$('#encryptionAPI div#EncryptionWarning').toggleClass('hidden');
+		$('#encryptionAPI div#EncryptionSettingsArea').toggleClass('hidden');
+		OC.AppConfig.setValue('core', 'encryption_enabled', 'yes');
+		$('#enableEncryption').attr('disabled', 'disabled');
 	});
 
 	$('#startmigration').click(function(event){
diff --git a/settings/templates/admin.php b/settings/templates/admin.php
index 9938b6d01f0..7904c1de41b 100644
--- a/settings/templates/admin.php
+++ b/settings/templates/admin.php
@@ -319,15 +319,21 @@ if ($_['cronErrors']) {
 		href="<?php p(link_to_docs('admin-encryption')); ?>"></a>
 
 	<p id="enable">
-		<input type="checkbox" name="encryption_enabled"
-			   id="encryptionEnabled"
+		<input type="checkbox"
+			   id="enableEncryption"
 			   value="1" <?php if ($_['encryptionEnabled']) print_unescaped('checked="checked" disabled="disabled"'); ?> />
 		<label
 			for="encryptionEnabled"><?php p($l->t('Enable server-side encryption')); ?> <span id="startmigration_msg" class="msg"></span> </label><br/>
 	</p>
 
 	<div id="EncryptionWarning" class="warning hidden">
-		<?php p($l->t('Once encryption is enabled there is no way to disable it again. This is your last chance to disable it again.')) ?>
+		<?php p($l->t('Encryption is a one way process. Once encryption is enabled,
+		all files from that point forward will be encrypted on the server and it
+		will not be possible to disable encryption at a later date. This is the final warning:
+		Do you really want to enable encryption?')) ?>
+		<input type="button"
+			   id="reallyEnableEncryption"
+			   value="<?php p($l->t("Enable encryption")); ?>" />
 	</div>
 
 	<div id="EncryptionSettingsArea" class="<?php if (!$_['encryptionEnabled']) p('hidden'); ?>">

From 624c25313e24f78cc8bf90a3c8be4c3bc4a9202d Mon Sep 17 00:00:00 2001
From: Morris Jobke <hey@morrisjobke.de>
Date: Tue, 5 May 2015 11:12:56 +0200
Subject: [PATCH 3/4] fix label reference

---
 settings/templates/admin.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/settings/templates/admin.php b/settings/templates/admin.php
index 7904c1de41b..638c3d7bff5 100644
--- a/settings/templates/admin.php
+++ b/settings/templates/admin.php
@@ -323,7 +323,7 @@ if ($_['cronErrors']) {
 			   id="enableEncryption"
 			   value="1" <?php if ($_['encryptionEnabled']) print_unescaped('checked="checked" disabled="disabled"'); ?> />
 		<label
-			for="encryptionEnabled"><?php p($l->t('Enable server-side encryption')); ?> <span id="startmigration_msg" class="msg"></span> </label><br/>
+			for="enableEncryption"><?php p($l->t('Enable server-side encryption')); ?> <span id="startmigration_msg" class="msg"></span> </label><br/>
 	</p>
 
 	<div id="EncryptionWarning" class="warning hidden">

From a1b944464370da51a9fc952250c3eb597bab30ad Mon Sep 17 00:00:00 2001
From: Morris Jobke <hey@morrisjobke.de>
Date: Tue, 5 May 2015 11:17:48 +0200
Subject: [PATCH 4/4] Don't highlight disabled labels on hover

---
 core/css/styles.css | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/core/css/styles.css b/core/css/styles.css
index 4cf5e4e18ca..c8704066cf1 100644
--- a/core/css/styles.css
+++ b/core/css/styles.css
@@ -224,6 +224,10 @@ textarea:disabled {
 	color: #999;
 	cursor: default;
 }
+input:disabled+label, input:disabled:hover+label, input:disabled:focus+label {
+	color: #999 !important;
+	cursor: default;
+}
 
 /* Primary action button, use sparingly */
 .primary, input[type="submit"].primary, input[type="button"].primary, button.primary, .button.primary {