Changeset 12884 for trunk


Ignore:
Timestamp:
Jan 14, 2012, 1:08:34 PM (12 years ago)
Author:
mistic100
Message:

feature:2517 ability to change username, add test to avoid existing usernames

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/profile.php

    r12882 r12884  
    9393function save_profile_from_post($userdata, &$errors)
    9494{
    95   global $conf;
     95  global $conf, $page;
    9696  $errors = array();
    9797
     
    209209      if (!empty($_POST['username']))
    210210      {
    211         array_push($fields, $conf['user_fields']['username']);
    212         $data{$conf['user_fields']['username']} = $_POST['username'];
    213        
    214         // send email to the user
    215         if ($_POST['username'] != $userdata['username'])
     211        if ($_POST['username'] != $userdata['username'] and get_userid($_POST['username']))
    216212        {
    217           include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    218           switch_lang_to($userdata['language']);
     213          array_push($page['errors'], l10n('this login is already used'));
     214          unset($_POST['redirect']);
     215        }
     216        else
     217        {
     218          array_push($fields, $conf['user_fields']['username']);
     219          $data{$conf['user_fields']['username']} = $_POST['username'];
    219220         
    220           $keyargs_content = array(
    221             get_l10n_args('Hello', ''),
    222             get_l10n_args('Your username has been successfully changed to : %s', $_POST['username']),
    223             );
     221          // send email to the user
     222          if ($_POST['username'] != $userdata['username'])
     223          {
     224            include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
     225            switch_lang_to($userdata['language']);
    224226           
    225           pwg_mail(
    226             $_POST['mail_address'],
    227             array(
    228               'subject' => '['.$conf['gallery_title'].'] '.l10n('Username modification'),
    229               'content' => l10n_args($keyargs_content),
    230               'content_format' => 'text/plain',
    231               )
    232             );
    233            
    234           switch_lang_back();
     227            $keyargs_content = array(
     228              get_l10n_args('Hello', ''),
     229              get_l10n_args('Your username has been successfully changed to : %s', $_POST['username']),
     230              );
     231             
     232            pwg_mail(
     233              $_POST['mail_address'],
     234              array(
     235                'subject' => '['.$conf['gallery_title'].'] '.l10n('Username modification'),
     236                'content' => l10n_args($keyargs_content),
     237                'content_format' => 'text/plain',
     238                )
     239              );
     240             
     241            switch_lang_back();
     242          }
    235243        }
    236244      }
Note: See TracChangeset for help on using the changeset viewer.