Ignore:
Timestamp:
Mar 5, 2010, 1:12:41 PM (14 years ago)
Author:
Eric
Message:

[NBC_UserAdvManager] Pre-2.13.5

  • Bug 1465 fixed : Plugin data are now serialized
  • Code simplification : Variables improved
  • Files renamed : functions.inc.php and UAM_admin.php
  • Update of obsolete.list (There is a bug on obsolete fils deletion)
File:
1 edited

Legend:

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

    r4957 r5056  
    22/*
    33Plugin Name: NBC UserAdvManager
    4 Version: 2.13.4
     4Version: 2.13.5
    55Description: Renforcer la gestion des utilisateurs - Enforce users management
    66Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=216
     
    4242
    4343include_once (NBC_UAM_PATH.'include/constants.php');
    44 include_once (NBC_UAM_PATH.'include/functions_UserAdvManager.inc.php');
     44include_once (NBC_UAM_PATH.'include/functions.inc.php');
    4545
    4646load_language('plugin.lang', NBC_UAM_PATH);
     
    4848
    4949/* Plugin admin */
    50 add_event_handler('get_admin_plugin_menu_links', 'nbc_UserAdvManager_admin_menu');
    51 
    52 function nbc_UserAdvManager_admin_menu($menu)
     50add_event_handler('get_admin_plugin_menu_links', 'UAM_admin_menu');
     51
     52function UAM_admin_menu($menu)
    5353{
    5454  array_push($menu,
    5555    array(
    5656      'NAME' => 'UserAdvManager',
    57       'URL'  => get_admin_plugin_menu_link(NBC_UAM_PATH.'/admin/UserAdvManager_admin.php')
     57      'URL'  => get_admin_plugin_menu_link(NBC_UAM_PATH.'/admin/UAM_admin.php')
    5858    )
    5959  );
     
    6363
    6464/* Lastvisit table feed for Ghost Tracker */
    65 add_event_handler('loc_begin_index', 'UserAdvManager_GhostTracker');
    66 
    67 function UserAdvManager_GhostTracker()
     65add_event_handler('loc_begin_index', 'UAM_GhostTracker');
     66
     67function UAM_GhostTracker()
    6868{
    6969  global $conf, $user;
    70  
    71   $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
    72 
    73   if (isset($conf_nbc_UserAdvManager[17]) and $conf_nbc_UserAdvManager[17] == 'true' and !is_admin() and !is_a_guest())
     70
     71  $conf_UAM = unserialize($conf['nbc_UserAdvManager']);
     72
     73  if (isset($conf_UAM[17]) and $conf_UAM[17] == 'true' and !is_admin() and !is_a_guest())
    7474  {
    7575
     
    110110
    111111/* User creation */
    112 add_event_handler('register_user', 'UserAdvManager_Adduser');
    113 
    114 function UserAdvManager_Adduser($register_user)
     112add_event_handler('register_user', 'UAM_Adduser');
     113
     114function UAM_Adduser($register_user)
    115115{
    116116  global $conf;
    117  
    118   $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
     117
     118  $conf_UAM = unserialize($conf['nbc_UserAdvManager']);
    119119 
    120120  /* Sending registration confirmation by email */
    121   if ((isset($conf_nbc_UserAdvManager[0]) and $conf_nbc_UserAdvManager[0] == 'true' and !is_admin()) or (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true' and !is_admin()))
     121  if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true' and !is_admin()) or (isset($conf_UAM[2]) and $conf_UAM[2] == 'true' and !is_admin()))
    122122  {
    123123    $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';
     
    129129
    130130/* User deletion */
    131 add_event_handler('delete_user', 'UserAdvManager_Deluser');
    132 
    133 function UserAdvManager_Deluser($user_id)
     131add_event_handler('delete_user', 'UAM_Deluser');
     132
     133function UAM_Deluser($user_id)
    134134{
    135135  /* Cleanup for ConfirmMail table */
     
    141141
    142142/* Check users registration */
    143 add_event_handler('register_user_check', 'UserAdvManager_RegistrationCheck', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    144 
    145 function UserAdvManager_RegistrationCheck($err, $user)
     143add_event_handler('register_user_check', 'UAM_RegistrationCheck', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
     144
     145function UAM_RegistrationCheck($err, $user)
    146146{
    147147  global $errors, $conf;
     
    227227/* ****************************************** */
    228228  $PasswordCheck = 0;
    229  
    230   $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
     229
     230  $conf_UAM = unserialize($conf['nbc_UserAdvManager']);
    231231
    232232  /* Password enforcement control */
    233   if (isset($conf_nbc_UserAdvManager[14]) and $conf_nbc_UserAdvManager[14] == 'true' and !empty($conf_nbc_UserAdvManager[15]))
     233  if (isset($conf_UAM[14]) and $conf_UAM[14] == 'true' and !empty($conf_UAM[15]))
    234234  {
    235235    if (!empty($user['password']) and !is_admin())
     
    237237      $PasswordCheck = testpassword($user['password']);
    238238 
    239       if ($PasswordCheck < $conf_nbc_UserAdvManager[15])
     239      if ($PasswordCheck < $conf_UAM[15])
    240240      {
    241241        $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck);
    242         return($lang['reg_err_pass'] = l10n_args($message).$conf_nbc_UserAdvManager[15]);
    243       }
    244     }
    245     else if (!empty($user['password']) and is_admin() and isset($conf_nbc_UserAdvManager[16]) and $conf_nbc_UserAdvManager[16] == 'true')
     242        return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[15]);
     243      }
     244    }
     245    else if (!empty($user['password']) and is_admin() and isset($conf_UAM[16]) and $conf_UAM[16] == 'true')
    246246    {
    247247      $PasswordCheck = testpassword($user['password']);
    248248 
    249       if ($PasswordCheck < $conf_nbc_UserAdvManager[15])
     249      if ($PasswordCheck < $conf_UAM[15])
    250250      {
    251251        $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck);
    252         return($lang['reg_err_pass'] = l10n_args($message).$conf_nbc_UserAdvManager[15]);
     252        return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[15]);
    253253      }
    254254    }
     
    256256
    257257  /* Username non case sensitive */
    258   if (isset($conf_nbc_UserAdvManager[1]) and $conf_nbc_UserAdvManager[1] == 'true' and NotSensibleSearchUsername($_POST['login']))
     258  if (isset($conf_UAM[1]) and $conf_UAM[1] == 'true' and NotSensibleSearchUsername($_POST['login']))
    259259  {
    260260    return($lang['reg_err_login5'] = l10n('reg_err_login5'));
     
    262262
    263263  /* Username without forbidden keys */
    264   if (isset($conf_nbc_UserAdvManager[7]) and $conf_nbc_UserAdvManager[7] == 'true' and !empty($_POST['login']) and ValidateUsername($_POST['login']) and !is_admin())
     264  if (isset($conf_UAM[7]) and $conf_UAM[7] == 'true' and !empty($_POST['login']) and ValidateUsername($_POST['login']) and !is_admin())
    265265  {
    266266    $_POST['login'] = '';
    267     return($lang['reg_err_login1'] = l10n('reg_err_login6')."'".$conf_nbc_UserAdvManager[8]."'");
     267    return($lang['reg_err_login1'] = l10n('reg_err_login6')."'".$conf_UAM[8]."'");
    268268  }
    269269
    270270  /* Email without forbidden domains */
    271   if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['mail_address']) and ValidateEmailProvider($_POST['mail_address']) and !is_admin())
     271  if (isset($conf_UAM[12]) and $conf_UAM[12] == 'true' and !empty($_POST['mail_address']) and ValidateEmailProvider($_POST['mail_address']) and !is_admin())
    272272  {
    273273    $_POST['mail_address'] = '';
    274     return($lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'");
     274    return($lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_UAM[13]."'");
    275275  }
    276276}
     
    279279if (script_basename() == 'profile')
    280280{
    281   add_event_handler('loc_begin_profile', 'UserAdvManager_Profile_Init');
    282 
    283   function UserAdvManager_Profile_Init()
     281  add_event_handler('loc_begin_profile', 'UAM_Profile_Init');
     282
     283  function UAM_Profile_Init()
    284284  {
    285285    global $conf, $user, $template;
    286286
    287     $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
     287    $conf_UAM = unserialize($conf['nbc_UserAdvManager']);
    288288
    289289    if (isset($_POST['validate']) and !is_admin())
    290290    {
    291291      /* Email without forbidden domains */
    292       if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['mail_address']))
     292      if (isset($conf_UAM[12]) and $conf_UAM[12] == 'true' and !empty($_POST['mail_address']))
    293293      {
    294294        if (ValidateEmailProvider($_POST['mail_address']))
    295295        {
    296           $template->append('errors', l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'");
     296          $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[13]."'");
    297297          unset($_POST['validate']);
    298298        }
     
    306306       
    307307        /* Password enforcement control */
    308         if (isset($conf_nbc_UserAdvManager[14]) and $conf_nbc_UserAdvManager[14] == 'true' and !empty($conf_nbc_UserAdvManager[15]))
     308        if (isset($conf_UAM[14]) and $conf_UAM[14] == 'true' and !empty($conf_UAM[15]))
    309309        {
    310310          $PasswordCheck = testpassword($_POST['use_new_pwd']);
    311311         
    312           if ($PasswordCheck < $conf_nbc_UserAdvManager[15])
     312          if ($PasswordCheck < $conf_UAM[15])
    313313          {
    314314            $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck);
    315             $template->append('errors', l10n_args($message).$conf_nbc_UserAdvManager[15]);
     315            $template->append('errors', l10n_args($message).$conf_UAM[15]);
    316316            unset($_POST['use_new_pwd']);
    317317            unset($_POST['validate']);
     
    321321     
    322322      /* Sending registration confirmation by email */
    323       if ((isset($conf_nbc_UserAdvManager[0]) and $conf_nbc_UserAdvManager[0] == 'true') or (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true'))
     323      if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or (isset($conf_UAM[2]) and $conf_UAM[2] == 'true'))
    324324      {
    325325        $confirm_mail_need = false;
     
    335335          list($current_email) = mysql_fetch_row(pwg_query($query));
    336336     
    337           if ($_POST['mail_address'] != $current_email and ( isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true'))
     337          if ($_POST['mail_address'] != $current_email and ( isset($conf_UAM[2]) and $conf_UAM[2] == 'true'))
    338338       
    339339            $confirm_mail_need = true;
    340340        }
    341341       
    342         if ((!empty($_POST['use_new_pwd']) and (isset($conf_nbc_UserAdvManager[0]) and $conf_nbc_UserAdvManager[0] == 'true') or $confirm_mail_need))
     342        if ((!empty($_POST['use_new_pwd']) and (isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or $confirm_mail_need))
    343343        {
    344344          $query = '
     
    358358
    359359
    360 add_event_handler('init', 'UserAdvManager_InitPage');
     360add_event_handler('init', 'UAM_InitPage');
    361361/* *** Important ! This is necessary to make email exclusion work in admin's users management panel *** */
    362 function UserAdvManager_InitPage()
     362function UAM_InitPage()
    363363{
    364364  load_language('plugin.lang', NBC_UAM_PATH);
    365365  global $conf, $template, $page, $lang, $errors;
    366366
    367   $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
     367  $conf_UAM = unserialize($conf['nbc_UserAdvManager']);
    368368
    369369/* Admin user management */
     
    373373    {
    374374      /* Email without forbidden domains */
    375       if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['email']) and ValidateEmailProvider($_POST['email']))
    376       {
    377         $template->append('errors', l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'");
     375      if (isset($conf_UAM[12]) and $conf_UAM[12] == 'true' and !empty($_POST['email']) and ValidateEmailProvider($_POST['email']))
     376      {
     377        $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[13]."'");
    378378        unset($_POST['submit_add']);
    379379      }
     
    383383
    384384
    385 add_event_handler('user_comment_check', 'UserAdvManager_CheckEmptyCommentAuthor', 50, 2);
    386 
    387 function UserAdvManager_CheckEmptyCommentAuthor($comment_action, $comm)
     385add_event_handler('user_comment_check', 'UAM_CheckEmptyCommentAuthor', 50, 2);
     386
     387function UAM_CheckEmptyCommentAuthor($comment_action, $comm)
    388388{
    389389  load_language('plugin.lang', NBC_UAM_PATH);
    390390  global $infos, $conf, $template;
    391391
    392   $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
     392  $conf_UAM = unserialize($conf['nbc_UserAdvManager']);
    393393
    394394/* User creation OR update */
    395   if (isset($conf_nbc_UserAdvManager[6]) and $conf_nbc_UserAdvManager[6] == 'true' and $conf['comments_forall'] == 'true' and $comm['author'] == 'guest')
     395  if (isset($conf_UAM[6]) and $conf_UAM[6] == 'true' and $conf['comments_forall'] == 'true' and $comm['author'] == 'guest')
    396396  {
    397397    $comment_action = 'reject';
    398398
    399     array_push($infos, l10n('UserAdvManager_Empty Author'));
     399    array_push($infos, l10n('UAM_Empty Author'));
    400400  }
    401401
Note: See TracChangeset for help on using the changeset viewer.