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
|
<?php
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2013, Sam Tuke <samtuke@owncloud.com>
|
* 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
|
<?php
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2013, Sam Tuke <samtuke@owncloud.com>
|
* Copyright (c) 2013, Sam Tuke <samtuke@owncloud.com>
|
||||||
|
@ -13,6 +11,7 @@ use OCA\Encryption;
|
||||||
|
|
||||||
\OCP\JSON::checkLoggedIn();
|
\OCP\JSON::checkLoggedIn();
|
||||||
\OCP\JSON::checkAppEnabled( 'files_encryption' );
|
\OCP\JSON::checkAppEnabled( 'files_encryption' );
|
||||||
|
\OCP\JSON::callCheck();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
isset( $_POST['userEnableRecovery'] )
|
isset( $_POST['userEnableRecovery'] )
|
||||||
|
@ -24,16 +23,13 @@ if (
|
||||||
$util = new \OCA\Encryption\Util( $view, $userId );
|
$util = new \OCA\Encryption\Util( $view, $userId );
|
||||||
|
|
||||||
// Save recovery preference to DB
|
// Save recovery preference to DB
|
||||||
$result = $util->setRecoveryForUser( $_POST['userEnableRecovery'] );
|
$return = $util->setRecoveryForUser( $_POST['userEnableRecovery'] );
|
||||||
|
|
||||||
if ( $result ) {
|
} else {
|
||||||
|
|
||||||
|
$return = false;
|
||||||
|
|
||||||
\OCP\JSON::success();
|
}
|
||||||
|
|
||||||
} else {
|
// Return success or failure
|
||||||
|
( $return ) ? \OCP\JSON::success() : \OCP\JSON::error();
|
||||||
\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(
|
$( 'input:radio[name="userEnableRecovery"]' ).change(
|
||||||
function() {
|
function() {
|
||||||
|
|
||||||
|
// Hide feedback messages in case they're already visible
|
||||||
|
$('#recoveryEnabledSuccess').hide();
|
||||||
|
$('#recoveryEnabledError').hide();
|
||||||
|
|
||||||
var recoveryStatus = $( this ).val();
|
var recoveryStatus = $( this ).val();
|
||||||
|
|
||||||
$.post(
|
$.post(
|
||||||
OC.filePath( 'files_encryption', 'ajax', 'userrecovery.php' )
|
OC.filePath( 'files_encryption', 'ajax', 'userrecovery.php' )
|
||||||
, { userEnableRecovery: recoveryStatus }
|
, { userEnableRecovery: recoveryStatus }
|
||||||
, function( data ) {
|
, 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.
|
* See the COPYING-README file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Add CSS stylesheet
|
||||||
|
\OC_Util::addStyle( 'files_encryption', 'settings-personal' );
|
||||||
|
|
||||||
$tmpl = new OCP\Template( 'files_encryption', 'settings-personal');
|
$tmpl = new OCP\Template( 'files_encryption', 'settings-personal');
|
||||||
|
|
||||||
$blackList = explode( ',', \OCP\Config::getAppValue( 'files_encryption', 'type_blacklist', '' ) );
|
$blackList = explode( ',', \OCP\Config::getAppValue( 'files_encryption', 'type_blacklist', '' ) );
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
<form id="encryption">
|
<form id="encryption">
|
||||||
<fieldset class="personalblock">
|
<fieldset class="personalblock">
|
||||||
<legend>
|
<legend>
|
||||||
<?php p($l->t( 'Encryption' )); ?>
|
<?php p( $l->t( 'Encryption' ) ); ?>
|
||||||
</legend>
|
</legend>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?php p($l->t( 'File encryption is enabled.' )); ?>
|
<!-- <?php p( $l->t( 'File encryption is enabled.' ) ); ?> -->
|
||||||
</p>
|
</p>
|
||||||
<?php if ( ! empty( $_["blacklist"] ) ): ?>
|
<?php if ( ! empty( $_["blacklist"] ) ): ?>
|
||||||
<p>
|
<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>
|
</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -20,17 +22,19 @@
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<br />
|
||||||
<?php if ( $_["recoveryEnabled"] ): ?>
|
<?php if ( $_["recoveryEnabled"] ): ?>
|
||||||
<p>
|
<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 />
|
<br />
|
||||||
<input
|
<input
|
||||||
type='radio'
|
type='radio'
|
||||||
name='userEnableRecovery'
|
name='userEnableRecovery'
|
||||||
value='1'
|
value='1'
|
||||||
<?php echo ( $_["recoveryEnabledForUser"] == 1 ? 'checked="checked"' : '' ); ?> />
|
<?php echo ( $_["recoveryEnabledForUser"] == 1 ? 'checked="checked"' : '' ); ?> />
|
||||||
<?php p($l->t( "Enabled" )); ?>
|
<?php p( $l->t( "Enabled" ) ); ?>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<input
|
<input
|
||||||
|
@ -38,9 +42,23 @@
|
||||||
name='userEnableRecovery'
|
name='userEnableRecovery'
|
||||||
value='0'
|
value='0'
|
||||||
<?php echo ( $_["recoveryEnabledForUser"] == 0 ? 'checked="checked"' : '' ); ?> />
|
<?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>
|
</p>
|
||||||
<?php endif; ?>
|
<?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>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in New Issue