aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/functions_user.inc.php8
-rw-r--r--install.php2
-rw-r--r--profile.php4
3 files changed, 9 insertions, 5 deletions
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 925eeb2b0..54fab06b5 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -33,12 +33,13 @@
// o check if address is not used by a other user
// If the mail address doesn't correspond, an error message is returned.
//
-function validate_mail_address($mail_address)
+function validate_mail_address($user_id, $mail_address)
{
global $conf;
if (empty($mail_address) and
- !($conf['obligatory_user_mail_address'] and in_array(script_basename(), array('register', 'profile'))))
+ !($conf['obligatory_user_mail_address'] and
+ in_array(script_basename(), array('register', 'profile'))))
{
return '';
}
@@ -55,6 +56,7 @@ function validate_mail_address($mail_address)
select count(*)
from '.USERS_TABLE.'
where upper('.$conf['user_fields']['email'].') = upper(\''.$mail_address.'\')
+'.(is_numeric($user_id) ? 'and '.$conf['user_fields']['id'].' != \''.$user_id.'\'' : '').'
;';
list($count) = mysql_fetch_array(pwg_query($query));
if ($count != 0)
@@ -84,7 +86,7 @@ function register_user($login, $password, $mail_address, $errors = array())
{
array_push($errors, l10n('reg_err_login5'));
}
- $mail_error = validate_mail_address($mail_address);
+ $mail_error = validate_mail_address(null, $mail_address);
if ('' != $mail_error)
{
array_push($errors, $mail_error);
diff --git a/install.php b/install.php
index 33ccec937..cbf4bf12a 100644
--- a/install.php
+++ b/install.php
@@ -268,7 +268,7 @@ if ( isset( $_POST['install'] ))
array_push( $errors, $lang['reg_err_mail_address'] );
else
{
- $error_mail_address = validate_mail_address($admin_mail);
+ $error_mail_address = validate_mail_address(null, $admin_mail);
if (!empty($error_mail_address))
array_push( $errors, $error_mail_address );
}
diff --git a/profile.php b/profile.php
index 5b244edf2..ff19bb3a0 100644
--- a/profile.php
+++ b/profile.php
@@ -115,7 +115,9 @@ function save_profile_from_post(&$userdata, &$errors)
if (isset($_POST['mail_address']))
{
- $mail_error = validate_mail_address($_POST['mail_address']);
+ // if $_POST and $userdata have are same email
+ // validate_mail_address allows, however, to check email
+ $mail_error = validate_mail_address($userdata['id'], $_POST['mail_address']);
if (!empty($mail_error))
{
$errors[] = $mail_error;