2013-05-01 21:18:31 +04:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2013-06-05 16:51:51 +04:00
|
|
|
function updatePrivateKeyPasswd() {
|
|
|
|
var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
|
|
|
|
var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
|
|
|
|
OC.msg.startSaving('#encryption .msg');
|
|
|
|
$.post(
|
|
|
|
OC.filePath( 'files_encryption', 'ajax', 'updatePrivateKeyPassword.php' )
|
|
|
|
, { oldPassword: oldPrivateKeyPassword, newPassword: newPrivateKeyPassword }
|
|
|
|
, function( data ) {
|
|
|
|
if (data.status === "error") {
|
|
|
|
OC.msg.finishedSaving('#encryption .msg', data);
|
|
|
|
} else {
|
|
|
|
OC.msg.finishedSaving('#encryption .msg', data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-05-01 21:18:31 +04:00
|
|
|
$(document).ready(function(){
|
2013-06-05 16:51:51 +04:00
|
|
|
|
2013-05-01 21:18:31 +04:00
|
|
|
// Trigger ajax on recoveryAdmin status change
|
|
|
|
$( 'input:radio[name="userEnableRecovery"]' ).change(
|
|
|
|
function() {
|
|
|
|
|
2013-05-07 18:17:38 +04:00
|
|
|
// Hide feedback messages in case they're already visible
|
|
|
|
$('#recoveryEnabledSuccess').hide();
|
|
|
|
$('#recoveryEnabledError').hide();
|
|
|
|
|
2013-05-01 21:18:31 +04:00
|
|
|
var recoveryStatus = $( this ).val();
|
|
|
|
|
|
|
|
$.post(
|
|
|
|
OC.filePath( 'files_encryption', 'ajax', 'userrecovery.php' )
|
|
|
|
, { userEnableRecovery: recoveryStatus }
|
|
|
|
, function( data ) {
|
2013-05-07 18:17:38 +04:00
|
|
|
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();
|
|
|
|
}
|
2013-05-01 21:18:31 +04:00
|
|
|
}
|
|
|
|
);
|
2013-05-07 18:17:38 +04:00
|
|
|
// Ensure page is not reloaded on form submit
|
|
|
|
return false;
|
2013-05-01 21:18:31 +04:00
|
|
|
}
|
2013-05-07 18:17:38 +04:00
|
|
|
|
2013-05-01 21:18:31 +04:00
|
|
|
);
|
2013-06-03 17:27:31 +04:00
|
|
|
|
|
|
|
// update private key password
|
|
|
|
|
|
|
|
$('input:password[name="changePrivateKeyPassword"]').keyup(function(event) {
|
|
|
|
var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
|
|
|
|
var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
|
2013-06-05 16:51:51 +04:00
|
|
|
if (newPrivateKeyPassword !== '' && oldPrivateKeyPassword !== '' ) {
|
2013-06-03 17:27:31 +04:00
|
|
|
$('button:button[name="submitChangePrivateKeyPassword"]').removeAttr("disabled");
|
2013-06-05 16:51:51 +04:00
|
|
|
if(event.which === 13) {
|
|
|
|
updatePrivateKeyPasswd();
|
|
|
|
}
|
2013-06-03 17:27:31 +04:00
|
|
|
} else {
|
|
|
|
$('button:button[name="submitChangePrivateKeyPassword"]').attr("disabled", "true");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('button:button[name="submitChangePrivateKeyPassword"]').click(function() {
|
2013-06-05 16:51:51 +04:00
|
|
|
updatePrivateKeyPasswd();
|
2013-06-03 17:27:31 +04:00
|
|
|
});
|
|
|
|
|
2013-08-18 13:02:08 +04:00
|
|
|
});
|