aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2012-01-14 12:08:34 +0000
committermistic100 <mistic@piwigo.org>2012-01-14 12:08:34 +0000
commit34a70eceec0cdfed0203e4bee816256faa8c0294 (patch)
tree0e8f0bc0c22cb56797a1315ff53197d675a082e6
parentaf2302c1dbefa94968bd1dc067b9488790fd6f9c (diff)
feature:2517 ability to change username, add test to avoid existing usernames
git-svn-id: http://piwigo.org/svn/trunk@12884 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--profile.php52
1 files changed, 30 insertions, 22 deletions
diff --git a/profile.php b/profile.php
index 9e1820cef..01e5c8308 100644
--- a/profile.php
+++ b/profile.php
@@ -92,7 +92,7 @@ SELECT '.implode(',', $fields).'
//------------------------------------------------------ update & customization
function save_profile_from_post($userdata, &$errors)
{
- global $conf;
+ global $conf, $page;
$errors = array();
if (!isset($_POST['validate']))
@@ -208,30 +208,38 @@ function save_profile_from_post($userdata, &$errors)
// username is updated only if allowed
if (!empty($_POST['username']))
{
- array_push($fields, $conf['user_fields']['username']);
- $data{$conf['user_fields']['username']} = $_POST['username'];
-
- // send email to the user
- if ($_POST['username'] != $userdata['username'])
+ if ($_POST['username'] != $userdata['username'] and get_userid($_POST['username']))
{
- include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
- switch_lang_to($userdata['language']);
+ array_push($page['errors'], l10n('this login is already used'));
+ unset($_POST['redirect']);
+ }
+ else
+ {
+ array_push($fields, $conf['user_fields']['username']);
+ $data{$conf['user_fields']['username']} = $_POST['username'];
- $keyargs_content = array(
- get_l10n_args('Hello', ''),
- get_l10n_args('Your username has been successfully changed to : %s', $_POST['username']),
- );
-
- pwg_mail(
- $_POST['mail_address'],
- array(
- 'subject' => '['.$conf['gallery_title'].'] '.l10n('Username modification'),
- 'content' => l10n_args($keyargs_content),
- 'content_format' => 'text/plain',
- )
- );
+ // send email to the user
+ if ($_POST['username'] != $userdata['username'])
+ {
+ include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
+ switch_lang_to($userdata['language']);
- switch_lang_back();
+ $keyargs_content = array(
+ get_l10n_args('Hello', ''),
+ get_l10n_args('Your username has been successfully changed to : %s', $_POST['username']),
+ );
+
+ pwg_mail(
+ $_POST['mail_address'],
+ array(
+ 'subject' => '['.$conf['gallery_title'].'] '.l10n('Username modification'),
+ 'content' => l10n_args($keyargs_content),
+ 'content_format' => 'text/plain',
+ )
+ );
+
+ switch_lang_back();
+ }
}
}