--- /dev/null
+/*
+Copyright (c) Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Alexandre Lefevre, Marc Salvat 2014-2016
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Marc Salvat, Marc Suarez, Harifetra Ramamonjy 2017
+For licensing, see README.txt or http://www.pentilanero.com (Cecill-C or AGPL or LGPL)
+*/
+Ext.ns("EntSavoie.Preference");
+EntSavoie.Preference.WebdavPanel = function (config) {
+ Ext.apply(this, config);
+
+ // Ajoute le texte des erreurs
+ Ext.QuickTips.init();
+
+ // Panel de gestion du mot de passe Webdav
+
+ // Status printed for manually created users
+ this.webdavManuallyCreatedUser = this.webdavManuallyCreatedUser || new Ext.form.DisplayField({
+ value: this.i18n.Preference.WebdavPanel.status.manuallycreateduser,
+ style: 'font-size: 12px;',
+ hidden: !this.isManualUser
+ });
+
+ // Status printed for users with WebDAV activated
+ this.webdavActivatedStatus = this.webdavActivatedStatus || new Ext.form.DisplayField({
+ value: this.i18n.Preference.WebdavPanel.status.activated,
+ style: 'font-size: 12px;',
+ hidden: !this.isWebdavActivated || this.isManualUser
+ });
+
+ // Status printed for users with WebDAV not yet activated
+ this.webdavNotActivatedStatus = this.webdavNotActivatedStatus || new Ext.form.DisplayField({
+ value: this.i18n.Preference.WebdavPanel.status.notactivated,
+ style: 'font-size: 12px;',
+ hidden: this.isWebdavActivated || this.isManualUser
+ });
+
+ // The WebDAV activation button
+ this.activateWebdavBtn = this.activateWebdavBtn || new Ext.Button({
+ style: "margin-top: 10px",
+ text: this.i18n.Preference.WebdavPanel.activateBtn.text,
+ tooltip: this.i18n.Preference.WebdavPanel.activateBtn.tooltip,
+ handler: this.onActivateWebdav,
+ scope: this,
+ hidden: this.isWebdavActivated || this.isManualUser
+ });
+
+ // The old password
+ this.passwordField = this.passwordField || new Ext.form.TextField ({
+ fieldLabel: this.i18n.Preference.WebdavPanel.passwordField.fieldLabel,
+ height: 29,
+ inputType: 'password',
+ width: 200,
+ style: 'margin-top:5px;',
+ value: '',
+ allowBlank:false,
+ hidden: !this.isWebdavActivated || this.isManualUser
+ });
+
+ // The new password
+ this.newPasswordField = this.newPasswordField || new Ext.form.TextField ({
+ fieldLabel: this.i18n.Preference.WebdavPanel.newPasswordField.fieldLabel,
+ height: 29,
+ inputType: 'password',
+ width: 200,
+ style: 'margin-top:5px;',
+ value: '',
+ allowBlank:false,
+ hidden: !this.isWebdavActivated || this.isManualUser
+ });
+
+ // The new password confirmation
+ this.confirmNewPasswordField = this.confirmNewPasswordField || new Ext.form.TextField ({
+ fieldLabel: this.i18n.Preference.WebdavPanel.confirmNewPasswordField.fieldLabel,
+ height: 29,
+ inputType: 'password',
+ width: 200,
+ style: 'margin-top:5px;',
+ value: '',
+ allowBlank:false,
+ hidden: !this.isWebdavActivated || this.isManualUser
+ });
+
+ // The change password button
+ this.changePasswordBtn = this.changePasswordBtn || new Ext.Button({
+ style: "margin-top: 10px",
+ text: this.i18n.Preference.WebdavPanel.changePasswordBtn.text,
+ tooltip: this.i18n.Preference.WebdavPanel.changePasswordBtn.tooltip,
+ handler: this.onChangePassword,
+ scope: this,
+ hidden: !this.isWebdavActivated || this.isManualUser
+ });
+
+ // Lost password
+ this.lostPassword = this.lostPassword || new Ext.form.DisplayField({
+ value: this.i18n.Preference.WebdavPanel.lostpassword,
+ style: 'font-size: 12px;',
+ hidden: !this.isWebdavActivated || this.isManualUser
+ });
+
+
+
+ EntSavoie.Preference.WebdavPanel.superclass.constructor.call(this, {
+ title: this.title || this.i18n.Preference.WebdavPanel.title,
+ border: this.border || true,
+ height: this.height || 555,
+ width: this.width || 420,
+ padding: this.padding || 10,
+ items: [
+ this.webdavManuallyCreatedUser,
+ this.webdavActivatedStatus,
+ this.webdavNotActivatedStatus,
+ {
+ layout: 'form',
+ labelWidth: 175,
+ border: false,
+ items: [
+ this.passwordField,
+ this.newPasswordField,
+ this.confirmNewPasswordField
+ ]
+ },
+ this.lostPassword,
+ this.activateWebdavBtn,
+ this.changePasswordBtn
+ ]
+ });
+
+
+
+};
+
+Ext.extend(EntSavoie.Preference.WebdavPanel, Ext.Panel, {
+ initComponent: function () {
+ EntSavoie.Preference.WebdavPanel.superclass.initComponent.call(this);
+ this.load();
+ },
+
+ load: function() {
+ if (this.isManualUser) {
+ this.webdavManuallyCreatedUser.show();
+ } else {
+ if (this.isWebdavActivated) {
+ this.webdavActivatedStatus.show();
+ this.passwordField.show();
+ this.newPasswordField.show();
+ this.confirmNewPasswordField.show();
+ this.lostPassword.show();
+ this.changePasswordBtn.show();
+
+ this.webdavNotActivatedStatus.hide();
+ this.activateWebdavBtn.hide();
+
+ } else {
+ this.webdavActivatedStatus.hide();
+ this.passwordField.hide();
+ this.newPasswordField.hide();
+ this.confirmNewPasswordField.hide();
+ this.lostPassword.hide();
+ this.changePasswordBtn.hide();
+
+ this.webdavNotActivatedStatus.show();
+ this.activateWebdavBtn.show();
+ }
+ }
+ },
+
+ onActivateWebdav: function() {
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "activateWebdav"
+ },
+ scope: this,
+ success: this.onSuccessActivateWebdav,
+ failure: this.onFailureActivateWebdav
+ });
+ },
+
+ onSuccessActivateWebdav: function(response, options) {
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ console.log("activateWebdav is not a success");
+ } else {
+ console.log("activateWebdav is success");
+ // Open window with generated password
+ Ext.Msg.show({
+ title:this.i18n.Preference.WebdavPanel.activation.done,
+ msg: this.i18n.Preference.WebdavPanel.activation.keepPassword + '<br/>'
+ + this.i18n.Preference.WebdavPanel.activation.screenname + backObj.screenname + '<br/>'
+ + this.i18n.Preference.WebdavPanel.activation.password + backObj.password,
+ buttons: Ext.Msg.OK,
+ icon: Ext.MessageBox.OK
+ });
+ this.isWebdavActivated = true;
+ this.load();
+ }
+ },
+
+ onFailureActivateWebdav: function(response, options) {
+ },
+
+
+ onChangePassword: function(){
+ Ext.Ajax.request({
+ url:this.actionURLAjax,
+ params:{
+ cmd: "editPassword",
+ password1: this.passwordField.getValue(),
+ password2: this.newPasswordField.getValue(),
+ password3: this.confirmNewPasswordField.getValue(),
+ },
+ success: this.onSuccessChangePassword,
+ failure: this.onFailureChangePassword,
+ scope: this
+ });
+ },
+
+ onSuccessChangePassword: function(response, options){
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ if (backObj.portal_message){
+ Ext.MessageBox.alert( this.i18n.Preference.WebdavPanel.editPasswordResult.titleErr , backObj.portal_message, function(btn){});
+ } else {
+ Ext.MessageBox.alert( this.i18n.Preference.WebdavPanel.editPasswordResult.titleErr , this.i18n.Preference.WebdavPanel.editPasswordResult.msgErr , function(btn){});
+ }
+ } else {
+ Ext.slideMsg.msg( this.i18n.Preference.WebdavPanel.editPasswordResult.titleSucc , this.i18n.Preference.WebdavPanel.editPasswordResult.msgSucc );
+ }
+ },
+
+ onFailureChangePassword: function(response, options){
+ Ext.MessageBox.alert( this.i18n.Preference.WebdavPanel.editPasswordResult.titleErr , this.i18n.Preference.WebdavPanel.editPasswordResult.msgErr , function(btn){});
+ },
+
+
+ savePanel: function(reload) {
+ if (reload == true) {
+ document.location.reload();
+ }
+ }
+
+});