Ignore:
Timestamp:
Feb 26, 2011, 5:46:35 PM (13 years ago)
Author:
Eric
Message:

-Check if username already exists before modification

  • Final step for localisation files update : FR and EN files are up to date.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/LCAS/trunk/admin/LCAS_admin.php

    r9384 r9388  
    8282       
    8383        if ((isset($_POST['user-'.$lcas_UserToUpdate])) && ($_POST['user-'.$lcas_UserToUpdate] != '')) {
    84           // Vérifier si le nom n'est pas déjà pris
    85          
    86          
    87          
    88           // Mise à jour du nom
     84          // Check if username already exists
    8985          $query = '
    90             UPDATE '.USERS_TABLE.'
    91             SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'"
    92             WHERE id='.$lcas_UserToUpdate.'
    93             LIMIT 1
     86            SELECT username
     87            FROM '.USERS_TABLE.'
     88            WHERE username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'"
    9489            ;';
    9590
    96           pwg_query($query);
     91          $count = pwg_db_num_rows(pwg_query($query));
     92         
     93          if ($count != 0)
     94          {
     95            // Username update
     96            $query = '
     97              UPDATE '.USERS_TABLE.'
     98              SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'"
     99              WHERE id='.$lcas_UserToUpdate.'
     100              LIMIT 1
     101              ;';
    97102
    98         if (isset($conf_LCAS[1]) and $conf_LCAS[1] == 'true')
    99         {
    100           LCAS_SendMail($lcas_UserToUpdate, $_POST['user-'.$lcas_UserToUpdate]);
    101         }
     103            pwg_query($query);
    102104
    103           array_push($page['infos'], l10n('LCAS_Info_userlist_username_renamed'));
     105            if (isset($conf_LCAS[1]) and $conf_LCAS[1] == 'true')
     106            {
     107              LCAS_SendMail($lcas_UserToUpdate, $_POST['user-'.$lcas_UserToUpdate]);
     108            }
     109
     110            array_push($page['infos'], l10n('LCAS_Info_userlist_username_renamed'));
     111          }
     112          else
     113          {
     114            // Username already exists
     115            array_push($page['errors'], l10n('LCAS_Err_Userlist_New_Username_Exists'));
     116          }
    104117        }
    105118        else {
Note: See TracChangeset for help on using the changeset viewer.