Added facility to manually encrypt all files from personal settings
Added success/fail feedback to personal settings functions Improved look/layout of personal settings page Fixed misplaced plain text in ajax scripts
This commit is contained in:
parent
b535964006
commit
4b53f72d0d
|
@ -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();
|
||||
// Return success or failure
|
||||
( $return ) ? \OCP\JSON::success() : \OCP\JSON::error();
|
|
@ -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();
|
|
@ -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'] );
|
||||
$return = $util->setRecoveryForUser( $_POST['userEnableRecovery'] );
|
||||
|
||||
if ( $result ) {
|
||||
} else {
|
||||
|
||||
$return = false;
|
||||
|
||||
\OCP\JSON::success();
|
||||
|
||||
} else {
|
||||
|
||||
\OCP\JSON::error();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Return success or failure
|
||||
( $return ) ? \OCP\JSON::success() : \OCP\JSON::error();
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
);
|
||||
})
|
|
@ -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', '' ) );
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue