mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-27 03:39:57 +03:00
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
This commit is contained in:
parent
af2302c1db
commit
34a70eceec
1 changed files with 30 additions and 22 deletions
52
profile.php
52
profile.php
|
@ -92,7 +92,7 @@ SELECT '.implode(',', $fields).'
|
||||||
//------------------------------------------------------ update & customization
|
//------------------------------------------------------ update & customization
|
||||||
function save_profile_from_post($userdata, &$errors)
|
function save_profile_from_post($userdata, &$errors)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf, $page;
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
||||||
if (!isset($_POST['validate']))
|
if (!isset($_POST['validate']))
|
||||||
|
@ -208,30 +208,38 @@ function save_profile_from_post($userdata, &$errors)
|
||||||
// username is updated only if allowed
|
// username is updated only if allowed
|
||||||
if (!empty($_POST['username']))
|
if (!empty($_POST['username']))
|
||||||
{
|
{
|
||||||
array_push($fields, $conf['user_fields']['username']);
|
if ($_POST['username'] != $userdata['username'] and get_userid($_POST['username']))
|
||||||
$data{$conf['user_fields']['username']} = $_POST['username'];
|
|
||||||
|
|
||||||
// send email to the user
|
|
||||||
if ($_POST['username'] != $userdata['username'])
|
|
||||||
{
|
{
|
||||||
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
array_push($page['errors'], l10n('this login is already used'));
|
||||||
switch_lang_to($userdata['language']);
|
unset($_POST['redirect']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
array_push($fields, $conf['user_fields']['username']);
|
||||||
|
$data{$conf['user_fields']['username']} = $_POST['username'];
|
||||||
|
|
||||||
$keyargs_content = array(
|
// send email to the user
|
||||||
get_l10n_args('Hello', ''),
|
if ($_POST['username'] != $userdata['username'])
|
||||||
get_l10n_args('Your username has been successfully changed to : %s', $_POST['username']),
|
{
|
||||||
);
|
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||||
|
switch_lang_to($userdata['language']);
|
||||||
|
|
||||||
pwg_mail(
|
$keyargs_content = array(
|
||||||
$_POST['mail_address'],
|
get_l10n_args('Hello', ''),
|
||||||
array(
|
get_l10n_args('Your username has been successfully changed to : %s', $_POST['username']),
|
||||||
'subject' => '['.$conf['gallery_title'].'] '.l10n('Username modification'),
|
);
|
||||||
'content' => l10n_args($keyargs_content),
|
|
||||||
'content_format' => 'text/plain',
|
pwg_mail(
|
||||||
)
|
$_POST['mail_address'],
|
||||||
);
|
array(
|
||||||
|
'subject' => '['.$conf['gallery_title'].'] '.l10n('Username modification'),
|
||||||
switch_lang_back();
|
'content' => l10n_args($keyargs_content),
|
||||||
|
'content_format' => 'text/plain',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
switch_lang_back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue