diff options
author | rub <rub@piwigo.org> | 2007-10-06 06:41:18 +0000 |
---|---|---|
committer | rub <rub@piwigo.org> | 2007-10-06 06:41:18 +0000 |
commit | 5132cc1f87025bd17d6bd90e5ac8ad73288bf482 (patch) | |
tree | 9c871884505b17b689546d00ae7bfb34df4de0b9 | |
parent | 924733b9f0678a8071abda29af74b88d27f06000 (diff) |
Resolved 0000759: email unique for each user
Fix bug of last commit 2115
git-svn-id: http://piwigo.org/svn/trunk@2124 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r-- | include/functions_user.inc.php | 8 | ||||
-rw-r--r-- | install.php | 2 | ||||
-rw-r--r-- | profile.php | 4 |
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; |