aboutsummaryrefslogtreecommitdiffstats
path: root/profile.php
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2012-01-14 10:50:47 +0000
committermistic100 <mistic@piwigo.org>2012-01-14 10:50:47 +0000
commit25481da931ae564320d2d2cc0f4735c8b058a161 (patch)
tree6dc301eba6fc7e93ac2f32890aa5483c43062869 /profile.php
parent56452f8711d231d43f930e3a2cecbde6e900198f (diff)
feature:2517 ability to change username. admins can change usernames, users are notified by mail
git-svn-id: http://piwigo.org/svn/trunk@12882 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'profile.php')
-rw-r--r--profile.php46
1 files changed, 42 insertions, 4 deletions
diff --git a/profile.php b/profile.php
index acdf9822b..9e1820cef 100644
--- a/profile.php
+++ b/profile.php
@@ -104,6 +104,7 @@ function save_profile_from_post($userdata, &$errors)
if ($special_user)
{
unset(
+ $_POST['username'],
$_POST['mail_address'],
$_POST['password'],
$_POST['use_new_pwd'],
@@ -114,6 +115,11 @@ function save_profile_from_post($userdata, &$errors)
$_POST['theme'] = get_default_theme();
$_POST['language'] = get_default_language();
}
+
+ if (!defined('IN_ADMIN'))
+ {
+ unset($_POST['username']);
+ }
if ($conf['allow_user_customization'] or defined('IN_ADMIN'))
{
@@ -196,12 +202,44 @@ function save_profile_from_post($userdata, &$errors)
{
array_push($fields, $conf['user_fields']['password']);
// password is encrpyted with function $conf['pass_convert']
- $data{$conf['user_fields']['password']} =
- $conf['pass_convert']($_POST['use_new_pwd']);
+ $data{$conf['user_fields']['password']} = $conf['pass_convert']($_POST['use_new_pwd']);
+ }
+
+ // 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'])
+ {
+ include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
+ switch_lang_to($userdata['language']);
+
+ $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();
+ }
}
+
mass_updates(USERS_TABLE,
- array('primary' => array($conf['user_fields']['id']),
- 'update' => $fields),
+ array(
+ 'primary' => array($conf['user_fields']['id']),
+ 'update' => $fields
+ ),
array($data));
}