forked from extern/egroupware
fix validation of email in account creation to allow to manually enter an email and never automatic add an invalid one
This commit is contained in:
parent
6f98614b15
commit
9e4a03c59c
@ -688,7 +688,7 @@ app.classes.addressbook = AppJS.extend(
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.egw.message('');
|
this.egw.message('');
|
||||||
this.egw.json('admin_account::ajax_check', [data], function(_msg)
|
this.egw.json('admin_account::ajax_check', [data, _widget.id], function(_msg)
|
||||||
{
|
{
|
||||||
if (_msg && typeof _msg == 'string')
|
if (_msg && typeof _msg == 'string')
|
||||||
{
|
{
|
||||||
|
@ -236,14 +236,18 @@ class admin_account
|
|||||||
* Check entered data and return error-msg via json data or null
|
* Check entered data and return error-msg via json data or null
|
||||||
*
|
*
|
||||||
* @param array $data values for account_id and account_lid
|
* @param array $data values for account_id and account_lid
|
||||||
|
* @param string $changed name of addressbook widget triggering change eg. "email", "n_given" or "n_family"
|
||||||
*/
|
*/
|
||||||
public static function ajax_check(array $data)
|
public static function ajax_check(array $data, $changed)
|
||||||
{
|
{
|
||||||
// generate default email address
|
// generate default email address
|
||||||
if (empty($data['account_email']) || !$data['account_id'])
|
if (empty($data['account_email']) || !$data['account_id'] && in_array($changed, array('n_given', 'n_family')))
|
||||||
{
|
{
|
||||||
$email = common::email_address($data['account_firstname'], $data['account_lastname'], $data['account_lid']);
|
$email = common::email_address($data['account_firstname'], $data['account_lastname'], $data['account_lid']);
|
||||||
if ($email) egw_json_response::get()->assign('addressbook-edit_email', 'value', $email);
|
if ($email && $email[0] != '@' && strpos($email, '@')) // only add valid email addresses
|
||||||
|
{
|
||||||
|
egw_json_response::get()->assign('addressbook-edit_email', 'value', $email);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$data['account_lid'] && !$data['account_id']) return; // makes no sense to check before
|
if (!$data['account_lid'] && !$data['account_id']) return; // makes no sense to check before
|
||||||
|
Loading…
Reference in New Issue
Block a user