Index: /trunk/admin/themes/default/template/profile_content.tpl
===================================================================
--- /trunk/admin/themes/default/template/profile_content.tpl	(revision 12881)
+++ /trunk/admin/themes/default/template/profile_content.tpl	(revision 12882)
@@ -6,8 +6,14 @@
     <ul>
       <li>
-        <span class="property">{'Username'|@translate}</span>
+        <span class="property">
+          <label for="username">{'Username'|@translate}</label>
+        </span>
+      {if not $SPECIAL_USER}
+        <input type="text" name="username" id="username" value="{$USERNAME}">
+      {else}
         {$USERNAME}
+      {/if}
       </li>
-{if not $SPECIAL_USER} {* can modify password + email*}
+    {if not $SPECIAL_USER} {* can modify password + email*}
       <li>
         <span class="property">
@@ -16,12 +22,4 @@
         <input type="text" name="mail_address" id="mail_address" value="{$EMAIL}">
       </li>
-{if not $IN_ADMIN} {* admins do not need old password*}
-      <li>
-        <span class="property">
-          <label for="password">{'Password'|@translate}</label>
-        </span>
-        <input type="password" name="password" id="password" value="">
-      </li>
-{/if}
       <li>
         <span class="property">
@@ -36,5 +34,5 @@
         <input type="password" name="passwordConf" id="passwordConf" value="">
       </li>
-{/if}
+    {/if}
     </ul>
   </fieldset>
Index: /trunk/language/en_UK/common.lang.php
===================================================================
--- /trunk/language/en_UK/common.lang.php	(revision 12881)
+++ /trunk/language/en_UK/common.lang.php	(revision 12882)
@@ -348,4 +348,5 @@
 $lang['Username or email'] = 'Username or email';
 $lang['Username'] = "Username";
+$lang['Username modification'] = 'Username modification';
 $lang['View'] = "View";
 $lang['Visits'] = "Visits";
@@ -362,4 +363,5 @@
 $lang['Your favorites'] = "Your favorites";
 $lang['Your Gallery Customization'] = "Your gallery customization";
+$lang['Your username has been successfully changed to : %s'] = 'Your username has been successfully changed to : %s';
 $lang['Your password has been reset'] = 'Your password has been reset';
 $lang['square'] = "Square";
Index: /trunk/language/fr_CA/common.lang.php
===================================================================
--- /trunk/language/fr_CA/common.lang.php	(revision 12881)
+++ /trunk/language/fr_CA/common.lang.php	(revision 12882)
@@ -366,4 +366,6 @@
 $lang['EXIF Metadata'] = 'Données EXIF';
 $lang['IPTC Metadata'] = 'Données IPTC';
+$lang['Your username has been successfully changed to : %s'] = 'Votre nom d\'utilisateur a bien été changé par : %s';
+$lang['Username modification'] = 'Modification du nom d\'utilisateur';
 
 ?>
Index: /trunk/language/fr_FR/common.lang.php
===================================================================
--- /trunk/language/fr_FR/common.lang.php	(revision 12881)
+++ /trunk/language/fr_FR/common.lang.php	(revision 12882)
@@ -348,4 +348,5 @@
 $lang['Username or email'] = 'Nom d\'utilisateur ou adresse email';
 $lang['Username'] = 'Nom d\'utilisateur';
+$lang['Username modification'] = 'Modification du nom d\'utilisateur';
 $lang['View'] = 'Vue';
 $lang['Visits'] = 'Visites';
@@ -362,4 +363,5 @@
 $lang['Your favorites'] = 'Mes favorites';
 $lang['Your Gallery Customization'] = 'Personnalisation de votre affichage ';
+$lang['Your username has been successfully changed to : %s'] = 'Votre nom d\'utilisateur a bien été changé par : %s';
 $lang['Your password has been reset'] = 'Votre mot de passe a été réinitialisé';
 
Index: /trunk/profile.php
===================================================================
--- /trunk/profile.php	(revision 12881)
+++ /trunk/profile.php	(revision 12882)
@@ -105,4 +105,5 @@
   {
     unset(
+      $_POST['username'],
       $_POST['mail_address'],
       $_POST['password'],
@@ -115,4 +116,9 @@
     $_POST['language'] = get_default_language();
   }
+  
+  if (!defined('IN_ADMIN'))
+  {
+    unset($_POST['username']);
+  }
 
   if ($conf['allow_user_customization'] or defined('IN_ADMIN'))
@@ -197,10 +203,42 @@
         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));
     }
Index: /trunk/themes/default/template/profile_content.tpl
===================================================================
--- /trunk/themes/default/template/profile_content.tpl	(revision 12881)
+++ /trunk/themes/default/template/profile_content.tpl	(revision 12882)
@@ -9,5 +9,5 @@
         {$USERNAME}
       </li>
-{if not $SPECIAL_USER} {* can modify password + email*}
+    {if not $SPECIAL_USER} {* can modify password + email*}
       <li>
         <span class="property">
@@ -16,5 +16,4 @@
         <input type="text" name="mail_address" id="mail_address" value="{$EMAIL}">
       </li>
-{if not $IN_ADMIN} {* admins do not need old password*}
       <li>
         <span class="property">
@@ -23,5 +22,4 @@
         <input type="password" name="password" id="password" value="">
       </li>
-{/if}
       <li>
         <span class="property">
@@ -36,6 +34,6 @@
         <input type="password" name="passwordConf" id="passwordConf" value="">
       </li>
+    {/if}
     </ul>
-{/if}
   </fieldset>
 
