summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_encryption/ajax/adminrecovery.php5
-rw-r--r--apps/files_encryption/ajax/encryptall.php40
-rw-r--r--apps/files_encryption/ajax/userrecovery.php22
-rw-r--r--apps/files_encryption/css/settings-personal.css10
-rw-r--r--apps/files_encryption/js/settings-personal.js39
-rw-r--r--apps/files_encryption/settings-personal.php3
-rw-r--r--apps/files_encryption/templates/settings-personal.php32
7 files changed, 127 insertions, 24 deletions
diff --git a/apps/files_encryption/ajax/adminrecovery.php b/apps/files_encryption/ajax/adminrecovery.php
index eeeaf4c6ed7..c3c19943c0d 100644
--- a/apps/files_encryption/ajax/adminrecovery.php
+++ b/apps/files_encryption/ajax/adminrecovery.php
@@ -1,5 +1,3 @@
-setValue( $app, $key, $value )
-
<?php
/**
* Copyright (c) 2013, Sam Tuke <samtuke@owncloud.com>
@@ -91,4 +89,5 @@ if (
}
-($return) ? OC_JSON::success() : OC_JSON::error(); \ No newline at end of file
+// Return success or failure
+( $return ) ? \OCP\JSON::success() : \OCP\JSON::error(); \ No newline at end of file
diff --git a/apps/files_encryption/ajax/encryptall.php b/apps/files_encryption/ajax/encryptall.php
new file mode 100644
index 00000000000..ce613ca4435
--- /dev/null
+++ b/apps/files_encryption/ajax/encryptall.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Copyright (c) 2013, Sam Tuke <samtuke@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or later.
+ * See the COPYING-README file.
+ *
+ * @brief Script to handle manual trigger of \OCA\Encryption\Util{}->encryptAll()
+ */
+
+use OCA\Encryption;
+
+\OCP\JSON::checkAppEnabled( 'files_encryption' );
+\OCP\JSON::callCheck();
+
+$return = false;
+
+if (
+ isset( $_POST['encryptAll'] )
+ && ! empty( $_POST['userPassword'] )
+) {
+
+ $view = new \OC_FilesystemView( '' );
+ $userId = \OCP\User::getUser();
+ $util = new \OCA\Encryption\Util( $view, $userId );
+ $session = new \OCA\Encryption\Session( $view );
+ $publicKey = \OCA\Encryption\Keymanager::getPublicKey( $view, $userId );
+ $path = '/' . $userId . '/' . 'files';
+
+ $util->encryptAll( $publicKey, $path, $session->getLegacyKey(), $_POST['userPassword'] );
+
+ $return = true;
+
+} else {
+
+ $return = false;
+
+}
+
+// Return success or failure
+( $return ) ? \OCP\JSON::success() : \OCP\JSON::error(); \ No newline at end of file
diff --git a/apps/files_encryption/ajax/userrecovery.php b/apps/files_encryption/ajax/userrecovery.php
index f72be3181ef..85a799011d7 100644
--- a/apps/files_encryption/ajax/userrecovery.php
+++ b/apps/files_encryption/ajax/userrecovery.php
@@ -1,5 +1,3 @@
-setValue( $app, $key, $value )
-
<?php
/**
* Copyright (c) 2013, Sam Tuke <samtuke@owncloud.com>
@@ -13,6 +11,7 @@ use OCA\Encryption;
\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled( 'files_encryption' );
+\OCP\JSON::callCheck();
if (
isset( $_POST['userEnableRecovery'] )
@@ -24,16 +23,13 @@ if (
$util = new \OCA\Encryption\Util( $view, $userId );
// Save recovery preference to DB
- $result = $util->setRecoveryForUser( $_POST['userEnableRecovery'] );
-
- if ( $result ) {
-
- \OCP\JSON::success();
-
- } else {
+ $return = $util->setRecoveryForUser( $_POST['userEnableRecovery'] );
- \OCP\JSON::error();
-
- }
+} else {
+
+ $return = false;
-} \ No newline at end of file
+}
+
+// Return success or failure
+( $return ) ? \OCP\JSON::success() : \OCP\JSON::error(); \ No newline at end of file
diff --git a/apps/files_encryption/css/settings-personal.css b/apps/files_encryption/css/settings-personal.css
new file mode 100644
index 00000000000..4ee0acc9768
--- /dev/null
+++ b/apps/files_encryption/css/settings-personal.css
@@ -0,0 +1,10 @@
+/* Copyright (c) 2013, Sam Tuke, <samtuke@owncloud.com>
+ This file is licensed under the Affero General Public License version 3 or later.
+ See the COPYING-README file. */
+
+#encryptAllError
+, #encryptAllSuccess
+, #recoveryEnabledError
+, #recoveryEnabledSuccess {
+ display: none;
+} \ No newline at end of file
diff --git a/apps/files_encryption/js/settings-personal.js b/apps/files_encryption/js/settings-personal.js
index e4a1b7448f4..3b9b00dc797 100644
--- a/apps/files_encryption/js/settings-personal.js
+++ b/apps/files_encryption/js/settings-personal.js
@@ -9,15 +9,52 @@ $(document).ready(function(){
$( 'input:radio[name="userEnableRecovery"]' ).change(
function() {
+ // Hide feedback messages in case they're already visible
+ $('#recoveryEnabledSuccess').hide();
+ $('#recoveryEnabledError').hide();
+
var recoveryStatus = $( this ).val();
$.post(
OC.filePath( 'files_encryption', 'ajax', 'userrecovery.php' )
, { userEnableRecovery: recoveryStatus }
, function( data ) {
- alert( data );
+ if ( data.status == "success" ) {
+ $('#recoveryEnabledSuccess').show();
+ } else {
+ $('#recoveryEnabledError').show();
+ }
+ }
+ );
+ // Ensure page is not reloaded on form submit
+ return false;
+ }
+ );
+
+ $("#encryptAll").click(
+ function(){
+
+ // Hide feedback messages in case they're already visible
+ $('#encryptAllSuccess').hide();
+ $('#encryptAllError').hide();
+
+ var userPassword = $( '#userPassword' ).val();
+ var encryptAll = $( '#encryptAll' ).val();
+
+ $.post(
+ OC.filePath( 'files_encryption', 'ajax', 'encryptall.php' )
+ , { encryptAll: encryptAll, userPassword: userPassword }
+ , function( data ) {
+ if ( data.status == "success" ) {
+ $('#encryptAllSuccess').show();
+ } else {
+ $('#encryptAllError').show();
+ }
}
);
+ // Ensure page is not reloaded on form submit
+ return false;
}
+
);
}) \ No newline at end of file
diff --git a/apps/files_encryption/settings-personal.php b/apps/files_encryption/settings-personal.php
index c6d9d80f0b9..46efb61b029 100644
--- a/apps/files_encryption/settings-personal.php
+++ b/apps/files_encryption/settings-personal.php
@@ -6,6 +6,9 @@
* See the COPYING-README file.
*/
+// Add CSS stylesheet
+\OC_Util::addStyle( 'files_encryption', 'settings-personal' );
+
$tmpl = new OCP\Template( 'files_encryption', 'settings-personal');
$blackList = explode( ',', \OCP\Config::getAppValue( 'files_encryption', 'type_blacklist', '' ) );
diff --git a/apps/files_encryption/templates/settings-personal.php b/apps/files_encryption/templates/settings-personal.php
index c81f361ced9..00f567ecb26 100644
--- a/apps/files_encryption/templates/settings-personal.php
+++ b/apps/files_encryption/templates/settings-personal.php
@@ -1,15 +1,17 @@
<form id="encryption">
<fieldset class="personalblock">
<legend>
- <?php p($l->t( 'Encryption' )); ?>
+ <?php p( $l->t( 'Encryption' ) ); ?>
</legend>
<p>
- <?php p($l->t( 'File encryption is enabled.' )); ?>
+<!-- <?php p( $l->t( 'File encryption is enabled.' ) ); ?> -->
</p>
<?php if ( ! empty( $_["blacklist"] ) ): ?>
<p>
- <?php p($l->t( 'The following file types will not be encrypted:' )); ?>
+ <strong>File types</strong>
+ <br />
+ <?php p( $l->t( 'The following file types will not be encrypted:' ) ); ?>
</p>
<ul>
@@ -20,17 +22,19 @@
<?php endforeach; ?>
</ul>
<?php endif; ?>
-
+ <br />
<?php if ( $_["recoveryEnabled"] ): ?>
<p>
- <?php p($l->t( "Enable password recovery by sharing all files with administrator:" )); ?>
+ <label for="userEnableRecovery"><?php p( $l->t( "Enable password recovery by sharing all files with administrator:" ) ); ?></label>
+ <br />
+ <em><?php p( $l->t( "Enabling this option will allow you to reobtain access to your encrypted files if your password is lost" ) ); ?></em>
<br />
<input
type='radio'
name='userEnableRecovery'
value='1'
<?php echo ( $_["recoveryEnabledForUser"] == 1 ? 'checked="checked"' : '' ); ?> />
- <?php p($l->t( "Enabled" )); ?>
+ <?php p( $l->t( "Enabled" ) ); ?>
<br />
<input
@@ -38,9 +42,23 @@
name='userEnableRecovery'
value='0'
<?php echo ( $_["recoveryEnabledForUser"] == 0 ? 'checked="checked"' : '' ); ?> />
- <?php p($l->t( "Disabled" )); ?>
+ <?php p( $l->t( "Disabled" ) ); ?>
+ <div id="recoveryEnabledSuccess"><?php p( $l->t( 'File recovery settings updated' ) ); ?></div>
+ <div id="recoveryEnabledError"><?php p( $l->t( 'Could not update file recovery' ) ); ?></div>
</p>
<?php endif; ?>
+ <br />
+ <p>
+ <label for="encryptAll"><?php p( $l->t( "Scan for unencrypted files and encrypt them" ) ); ?></label>
+ <br />
+ <em><?php p( $l->t( "Use this if you suspect that you still have files which are unencrypted, or encrypted using ownCloud 4 or older." ) ); ?></em>
+ <br />
+ <input type="submit" id="encryptAll" name="encryptAll" value="<?php p( $l->t( 'Scan and encrypt files' ) ); ?>" />
+ <input type="password" name="userPassword" id="userPassword" />
+ <label for="encryptAll"><?php p( $l->t( "Account password" ) ); ?></label>
+ <div id="encryptAllSuccess"><?php p( $l->t( 'Scan complete' ) );?></div>
+ <div id="encryptAllError"><?php p( $l->t( 'Unable to scan and encrypt files' ) );?></div>
+ </p>
</fieldset>
</form>