From 8cfef6746ded70637386be8e136b616d5cca3e0a Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 28 Mar 2014 16:56:35 +0000 Subject: [PATCH] added several checks for account editing in addressbook: doublicate account name, passwords match, set email for new accounts according to policy --- addressbook/js/app.js | 50 ++++++++++++++++++-- addressbook/templates/default/edit.xet | 2 +- admin/inc/class.admin_account.inc.php | 29 ++++++++++++ admin/inc/class.admin_cmd_edit_group.inc.php | 11 +++-- admin/inc/class.admin_cmd_edit_user.inc.php | 7 +-- admin/inc/class.admin_ui.inc.php | 2 +- admin/js/app.js | 6 +-- admin/templates/default/account.xet | 6 +-- 8 files changed, 94 insertions(+), 19 deletions(-) diff --git a/addressbook/js/app.js b/addressbook/js/app.js index e2cbc5f9db..0d4883fbbd 100644 --- a/addressbook/js/app.js +++ b/addressbook/js/app.js @@ -113,8 +113,8 @@ app.classes.addressbook = AppJS.extend( var list = etemplate2.getById( $j(this.et2.getInstanceManager().DOMContainer).nextAll('.et2_container').attr('id') ); - var nm = null; - if(list != null && (nm = list.widgetContainer.getWidgetById('nm'))) + var nm = list ? list.widgetContainer.getWidgetById('nm') : null; + if(nm) { // Update the link filter to new contact var filter = {col_filter:{}}; @@ -379,6 +379,12 @@ app.classes.addressbook = AppJS.extend( */ check_value: function(widget, own_id) { + // if we edit an account, call account_change to let it do it's stuff too + if (this.et2.getWidgetById('account_lid')) + { + this.account_change(null, widget); + } + var values = this.et2._inst.getValues(this.et2); if (widget.id.match(/n_/)) @@ -653,6 +659,44 @@ app.classes.addressbook = AppJS.extend( return false; } return this._super.apply(this, arguments); - } + }, + /** + * Field changed, call server validation + * + * @param {jQuery.Event} _ev + * @param {et2_button} _widget + */ + account_change: function(_ev, _widget) + { + switch(_widget.id) + { + case 'account_lid': + case 'n_family': + case 'n_given': + case 'email': + case 'account_passwd_2': + var values = this.et2._inst.getValues(this.et2); + var data = { + account_id: this.et2.getArrayMgr('content').data.account_id, + account_lid: values.account_lid, + account_firstname: values.n_given, + account_lastname: values.n_family, + account_email: values.email, + account_passwd: values.account_passwd, + account_passwd_2: values.account_passwd_2 + }; + + this.egw.message(''); + this.egw.json('admin_account::ajax_check', [data], function(_msg) + { + if (_msg && typeof _msg == 'string') + { + egw(window).message(_msg, 'error'); // context get's lost :( + _widget.getDOMNode().focus(); + } + }, this).sendRequest(); + break; + } + } }); diff --git a/addressbook/templates/default/edit.xet b/addressbook/templates/default/edit.xet index 744b4a2b3a..f2022418cd 100644 --- a/addressbook/templates/default/edit.xet +++ b/addressbook/templates/default/edit.xet @@ -48,7 +48,7 @@ -