Ignore:
Timestamp:
Nov 9, 2009, 8:58:14 PM (14 years ago)
Author:
Eric
Message:

[NBC_UserAdvManager]

  • Bug 1233 fixed : "duplicate key error" when a user wants to register with an existing username. In fact, all standard Piwigo's register controls didn't work when plugin was activated. That fixes this too.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/NBC_UserAdvManager/trunk/main.inc.php

    r4226 r4234  
    22/*
    33Plugin Name: NBC UserAdvManager
    4 Version: 2.12.4
     4Version: 2.12.5
    55Description: Renforcer les possibilités de gestion des utilisateurs - Enforce users management
    66Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=216
     
    9292-- 2.12.4 : Adding a password field control for SendMail2User - Neighborhood plugin compatibility improvement
    9393            Bug 1229 fixed - Email was no longer mandatory when plugin was active, even if Piwigo's email madatory option was set.
     94
     95-- 2.12.5 : Bug 1233 fixed -  "duplicate key error" when a user wants to register with an existing username. In fact, all standard Piwigo's register controls didn't work when plugin was activated. That fixes this too.
     96            Adding DE, ES and IT languages. All translations are not finalized and could be improved.
     97            Adding of description.txt file in language directories.
    9498*/
    9599
     
    235239  global $errors, $conf;
    236240
     241/* *********************************************************** */
     242/* We need to reset the standard Piwigo's register controls    */
     243/* because the call of register_user_check trigger resets them */
     244/* *********************************************************** */
     245  /* ********************************** */
     246  /* Standard Piwigo's username control */
     247  /* ********************************** */
     248  if ($_POST['login'] == '')
     249  {
     250    return l10n('reg_err_login1');
     251  }
     252  if (preg_match('/^.* $/', $_POST['login']))
     253  {
     254    return l10n('reg_err_login2');
     255  }
     256  if (preg_match('/^ .*$/', $_POST['login']))
     257  {
     258    return l10n('reg_err_login3');
     259  }
     260  if (get_userid($_POST['login']))
     261  {
     262    return l10n('reg_err_login5');
     263  }
     264 
     265  /* ***************************** */
     266  /* Standard Piwigo's email check */
     267  /* ***************************** */
     268  $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase
     269  $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name
     270  $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';
     271
     272  if (!preg_match($regex, $_POST['mail_address']))
     273  {
     274    return l10n('reg_err_mail_address');
     275  }
     276
     277  if (!empty($_POST['mail_address']))
     278  {
     279    $query = '
     280select count(*)
     281from '.USERS_TABLE.'
     282where upper('.$conf['user_fields']['email'].') = upper(\''.$_POST['mail_address'].'\');';
     283    list($count) = mysql_fetch_array(pwg_query($query));
     284    if ($count != 0)
     285    {
     286      return l10n('reg_err_mail_address_dbl');
     287    }
     288  }
     289/* ****************************************** */
     290/* End of Piwigo's standard register controls */
     291/* ****************************************** */
     292
     293
     294/* ****************************************** */
     295/* Here begins the advanced register controls */
     296/* ****************************************** */
    237297  $PasswordCheck = 0;
    238298 
     
    276336    $_POST['login'] = '';
    277337    return($lang['reg_err_login1'] = l10n('reg_err_login6')."'".$conf_nbc_UserAdvManager[8]."'");
    278   }
    279 
    280   /* Email mandatory - Needed to be add here to avoid jump of standard Piwigo email control */
    281   if (empty($_POST['mail_address']) and $conf['obligatory_user_mail_address'])
    282   {
    283     //$_POST['mail_address'] = '';
    284     return l10n('reg_err_mail_address');
    285338  }
    286339
Note: See TracChangeset for help on using the changeset viewer.