summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-05-15 17:56:45 +0200
committerBjörn Schießle <schiessle@owncloud.com>2013-05-15 17:56:45 +0200
commit57c0a7ed693fec6ef487b71a514202b24dd70df2 (patch)
tree749accb9c34d30fb7510183cff1c0fea23455702
parent1a31dc036ac3ca30b266ce2715e0adee3d112299 (diff)
downloadnextcloud-server-57c0a7ed693fec6ef487b71a514202b24dd70df2.tar.gz
nextcloud-server-57c0a7ed693fec6ef487b71a514202b24dd70df2.zip
add recovery key to all files if the user enabled the feature and removes them again on disable
-rw-r--r--apps/files_encryption/ajax/userrecovery.php6
-rw-r--r--apps/files_encryption/lib/util.php34
-rw-r--r--apps/files_encryption/templates/settings-personal.php3
3 files changed, 42 insertions, 1 deletions
diff --git a/apps/files_encryption/ajax/userrecovery.php b/apps/files_encryption/ajax/userrecovery.php
index 85a799011d7..1f42b376e42 100644
--- a/apps/files_encryption/ajax/userrecovery.php
+++ b/apps/files_encryption/ajax/userrecovery.php
@@ -24,6 +24,12 @@ if (
// Save recovery preference to DB
$return = $util->setRecoveryForUser( $_POST['userEnableRecovery'] );
+
+ if ($_POST['userEnableRecovery'] == "1") {
+ $util->addRecoveryKeys();
+ } else {
+ $util->removeRecoveryKeys();
+ }
} else {
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 6cb4ccb8085..6eee1ada8a8 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -1310,4 +1310,38 @@ class Util {
return $this->recoveryKeyId;
}
+ /**
+ * @brief add recovery key to all encrypted files
+ */
+ public function addRecoveryKeys($path = '/') {
+ $dirContent = $this->view->getDirectoryContent($this->keyfilesPath.$path);
+ foreach ($dirContent as $item) {
+ $filePath = substr($item['path'], 25);
+ if ($item['type'] == 'dir') {
+ $this->addRecoveryKey($filePath.'/');
+ } else {
+ $session = new Session(new \OC_FilesystemView('/'));
+ $sharingEnabled = \OCP\Share::isEnabled();
+ $file = substr($filePath, 0, -4);
+ $usersSharing = $this->getSharingUsersArray($sharingEnabled, $file);
+ $this->setSharedFileKeyfiles( $session, $usersSharing, $file );
+ }
+ }
+ }
+
+ /**
+ * @brief remove recovery key to all encrypted files
+ */
+ public function removeRecoveryKeys($path = '/') {
+ $dirContent = $this->view->getDirectoryContent($this->keyfilesPath.$path);
+ foreach ($dirContent as $item) {
+ $filePath = substr($item['path'], 25);
+ if ($item['type'] == 'dir') {
+ $this->removeRecoveryKeys($filePath.'/');
+ } else {
+ $file = substr($filePath, 0, -4);
+ $this->view->unlink($this->shareKeysPath.'/'.$file.'.'.$this->recoveryKeyId.'.shareKey');
+ }
+ }
+ }
}
diff --git a/apps/files_encryption/templates/settings-personal.php b/apps/files_encryption/templates/settings-personal.php
index 00f567ecb26..33989416d33 100644
--- a/apps/files_encryption/templates/settings-personal.php
+++ b/apps/files_encryption/templates/settings-personal.php
@@ -48,6 +48,7 @@
</p>
<?php endif; ?>
<br />
+<!--
<p>
<label for="encryptAll"><?php p( $l->t( "Scan for unencrypted files and encrypt them" ) ); ?></label>
<br />
@@ -59,6 +60,6 @@
<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>