2012-02-22 21:20:46 +00:00
|
|
|
/**
|
2013-09-27 15:02:57 +00:00
|
|
|
* Copyright (c) 2013
|
|
|
|
* Sam Tuke <samtuke@owncloud.com>
|
|
|
|
* Robin Appelman <icewind1991@gmail.com>
|
|
|
|
* Bjoern Schiessle <schiessle@owncloud.com>
|
2012-02-22 21:20:46 +00:00
|
|
|
* This file is licensed under the Affero General Public License version 3 or later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2013-05-15 14:12:20 +00:00
|
|
|
OC.msg={
|
|
|
|
startSaving:function(selector){
|
|
|
|
$(selector)
|
|
|
|
.html( t('settings', 'Saving...') )
|
|
|
|
.removeClass('success')
|
|
|
|
.removeClass('error')
|
|
|
|
.stop(true, true)
|
|
|
|
.show();
|
|
|
|
},
|
|
|
|
finishedSaving:function(selector, data){
|
|
|
|
if( data.status === "success" ){
|
|
|
|
$(selector).html( data.data.message )
|
|
|
|
.addClass('success')
|
|
|
|
.stop(true, true)
|
|
|
|
.delay(3000)
|
|
|
|
.fadeOut(900);
|
|
|
|
}else{
|
|
|
|
$(selector).html( data.data.message ).addClass('error');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2012-02-22 21:20:46 +00:00
|
|
|
|
|
|
|
$(document).ready(function(){
|
2013-03-29 20:11:29 +00:00
|
|
|
// Trigger ajax on recoveryAdmin status change
|
2013-05-15 09:42:22 +00:00
|
|
|
var enabledStatus = $('#adminEnableRecovery').val();
|
|
|
|
|
2013-09-18 14:03:53 +00:00
|
|
|
$('input:password[name="encryptionRecoveryPassword"]').keyup(function(event) {
|
|
|
|
var recoveryPassword = $( '#encryptionRecoveryPassword' ).val();
|
|
|
|
var recoveryPasswordRepeated = $( '#repeatEncryptionRecoveryPassword' ).val();
|
2013-05-15 09:42:22 +00:00
|
|
|
var checkedButton = $('input:radio[name="adminEnableRecovery"]:checked').val();
|
|
|
|
var uncheckedValue = (1+parseInt(checkedButton)) % 2;
|
2013-09-19 08:13:21 +00:00
|
|
|
if (recoveryPassword !== '' && recoveryPassword === recoveryPasswordRepeated) {
|
2013-05-15 09:42:22 +00:00
|
|
|
$('input:radio[name="adminEnableRecovery"][value="'+uncheckedValue.toString()+'"]').removeAttr("disabled");
|
|
|
|
} else {
|
|
|
|
$('input:radio[name="adminEnableRecovery"][value="'+uncheckedValue.toString()+'"]').attr("disabled", "true");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-09-18 14:03:53 +00:00
|
|
|
$( 'input:radio[name="adminEnableRecovery"]' ).change(
|
2013-03-29 20:11:29 +00:00
|
|
|
function() {
|
2013-05-01 17:18:31 +00:00
|
|
|
var recoveryStatus = $( this ).val();
|
2013-05-15 12:02:13 +00:00
|
|
|
var oldStatus = (1+parseInt(recoveryStatus)) % 2;
|
2013-09-18 14:03:53 +00:00
|
|
|
var recoveryPassword = $( '#encryptionRecoveryPassword' ).val();
|
2013-05-15 09:42:22 +00:00
|
|
|
$.post(
|
|
|
|
OC.filePath( 'files_encryption', 'ajax', 'adminrecovery.php' )
|
|
|
|
, { adminEnableRecovery: recoveryStatus, recoveryPassword: recoveryPassword }
|
2013-05-22 16:01:18 +00:00
|
|
|
, function( result ) {
|
|
|
|
if (result.status === "error") {
|
|
|
|
OC.Notification.show(t('admin', result.data.message));
|
2013-05-15 12:02:13 +00:00
|
|
|
$('input:radio[name="adminEnableRecovery"][value="'+oldStatus.toString()+'"]').attr("checked", "true");
|
2013-05-15 14:12:20 +00:00
|
|
|
} else {
|
2013-05-22 16:01:18 +00:00
|
|
|
OC.Notification.hide();
|
|
|
|
if (recoveryStatus === "0") {
|
2013-10-03 10:22:25 +00:00
|
|
|
$('p[name="changeRecoveryPasswordBlock"]').addClass("hidden");
|
2013-05-15 14:12:20 +00:00
|
|
|
} else {
|
2013-09-18 14:03:53 +00:00
|
|
|
$('input:password[name="changeRecoveryPassword"]').val("");
|
2013-10-03 10:22:25 +00:00
|
|
|
$('p[name="changeRecoveryPasswordBlock"]').removeClass("hidden");
|
2013-05-15 14:12:20 +00:00
|
|
|
}
|
2013-05-15 12:02:13 +00:00
|
|
|
}
|
2013-05-15 09:42:22 +00:00
|
|
|
}
|
|
|
|
);
|
2013-03-29 20:11:29 +00:00
|
|
|
}
|
|
|
|
);
|
2013-05-15 14:12:20 +00:00
|
|
|
|
2013-05-16 12:53:04 +00:00
|
|
|
// change recovery password
|
2013-05-15 14:12:20 +00:00
|
|
|
|
|
|
|
$('input:password[name="changeRecoveryPassword"]').keyup(function(event) {
|
2013-09-18 14:03:53 +00:00
|
|
|
var oldRecoveryPassword = $('#oldEncryptionRecoveryPassword').val();
|
|
|
|
var newRecoveryPassword = $('#newEncryptionRecoveryPassword').val();
|
|
|
|
var newRecoveryPasswordRepeated = $('#repeatedNewEncryptionRecoveryPassword').val();
|
2013-09-18 14:08:29 +00:00
|
|
|
|
2013-09-18 14:03:53 +00:00
|
|
|
if (newRecoveryPassword !== '' && oldRecoveryPassword !== '' && newRecoveryPassword === newRecoveryPasswordRepeated) {
|
2013-05-15 14:12:20 +00:00
|
|
|
$('button:button[name="submitChangeRecoveryKey"]').removeAttr("disabled");
|
|
|
|
} else {
|
|
|
|
$('button:button[name="submitChangeRecoveryKey"]').attr("disabled", "true");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$('button:button[name="submitChangeRecoveryKey"]').click(function() {
|
2013-09-18 14:03:53 +00:00
|
|
|
var oldRecoveryPassword = $('#oldEncryptionRecoveryPassword').val();
|
|
|
|
var newRecoveryPassword = $('#newEncryptionRecoveryPassword').val();
|
2013-05-15 14:12:20 +00:00
|
|
|
OC.msg.startSaving('#encryption .msg');
|
|
|
|
$.post(
|
|
|
|
OC.filePath( 'files_encryption', 'ajax', 'changeRecoveryPassword.php' )
|
|
|
|
, { oldPassword: oldRecoveryPassword, newPassword: newRecoveryPassword }
|
|
|
|
, function( data ) {
|
|
|
|
if (data.status == "error") {
|
|
|
|
OC.msg.finishedSaving('#encryption .msg', data);
|
|
|
|
} else {
|
|
|
|
OC.msg.finishedSaving('#encryption .msg', data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2013-09-18 14:03:53 +00:00
|
|
|
|
2013-08-18 09:02:08 +00:00
|
|
|
});
|