Ignore:
Timestamp:
Jan 13, 2011, 2:58:32 AM (13 years ago)
Author:
LucMorizur
Message:

Properely hook (normally :-/ ...) all cases between LCAS options and $confinsensitive_case_logon , at login as well as at register (normally :-/ ...)

File:
1 edited

Legend:

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

    r8271 r8638  
    2323$error = array();
    2424
     25$t = pwg_db_fetch_row(pwg_query('
     26  SELECT `value`
     27  FROM `'.CONFIG_TABLE.'`
     28  WHERE `param` = "LoginCaseAccentsSensitivity"
     29  LIMIT 1;
     30'));
     31
     32$conf['LoginCaseAccentsSensitivity'] = $t[0];
     33
    2534// +-----------------------------------------------------------------------+
    2635// |                      Getting plugin version                           |
     
    2938$version = $plugin['version'];
    3039
    31         if (isset($_POST['submit']) and !is_adviser() and isset($_POST['LCAS_Case_Sensitive']) and isset($_POST['LCAS_Accent_Sensitive']) and isset($_POST['LCAS_Mail']))
     40        if (isset($_POST['submit']) and !is_adviser() and isset($_POST['LCAS_Option']) and isset($_POST['LCAS_Mail']))
    3241  {
    3342
    3443/* General configuration settings */
    3544                $_POST['LCAS_MailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['LCAS_MailText'])));
    36 
    37                 $newconf_LCAS= array(
    38       $_POST['LCAS_Case_Sensitive'],
    39       $_POST['LCAS_Accent_Sensitive'],
     45   
     46                // LCAS configuration is now hereby defined :
     47    // $conf_LCAS[0] : "final case", describe how LCAS should behave;
     48    // $conf_LCAS[1] : LCAS option, describe the choice of the webmaster;
     49    // $conf_LCAS[2] : LCAS_Mail;
     50    // $conf_LCAS[3] : LCAS_MailText.
     51    $newconf_LCAS= array(
     52      LCAS_final_case($_POST['LCAS_Option']),
     53      $_POST['LCAS_Option'],
     54      // $_POST['LCAS__spare'] : quite lazy, but convenient to not have to
     55      // decrease index of each option below everywhere :-/ ...
    4056      $_POST['LCAS_Mail'],
    4157      $_POST['LCAS_MailText']);
     
    5268                pwg_query($query);
    5369
    54     // $conf['insensitive_case_logon'] have to be True for a full LCAS use
    55     if ($conf['insensitive_case_logon'])
     70    array_push($page['infos'], l10n('LCAS_save_config'));
     71  }
     72
     73        $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
     74  $conf_LCAS[0] = LCAS_final_case($conf_LCAS[1]);
     75 
     76  if (isset($conf_LCAS[0]))
     77  {
     78    // $conf['insensitive_case_logon'] must be true or false when needed
     79    if ($conf_LCAS[0]=='4' or $conf_LCAS[0]=='5')
     80     array_push($page['errors'], l10n('LCAS_warning'));
     81    elseif ($conf_LCAS[0]=='6' or $conf_LCAS[0]=='7')
     82     array_push($page['errors'], l10n('LCAS_warning2'));
     83
     84    $case_ins = (in_array($conf_LCAS[0], array('1', '3','6','7')));
     85    $acc_ins = (in_array($conf_LCAS[0], array('2', '5', '3','6','7')));
     86
     87    if ($case_ins or $acc_ins)
    5688    {
    57                   array_push($page['infos'], l10n('LCAS_save_config'));
     89// +-----------------------------------------------------------------------+
     90// |                           initialization                              |
     91// +-----------------------------------------------------------------------+
     92
     93      $lcas_UserToUpdate = -1;
     94      if ((isset($_POST['UserToUpdate'])) && ($_POST['UserToUpdate'] != -1)) {
     95        $lcas_UserToUpdate = $_POST['UserToUpdate'];
     96       
     97        if ((isset($_POST['user-'.$lcas_UserToUpdate])) && ($_POST['user-'.$lcas_UserToUpdate] != '')) {
     98          // Vérifier si le nom n'est pas déjà pris
     99         
     100         
     101         
     102          // Mise à jour du nom
     103          $query = '
     104            UPDATE '.USERS_TABLE.'
     105            SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'"
     106            WHERE id='.$lcas_UserToUpdate.'
     107            LIMIT 1
     108            ;';
     109
     110          pwg_query($query);
     111
     112        if (isset($conf_LCAS[2]) and $conf_LCAS[2] = 'true')
     113        {
     114          LCAS_SendMail($lcas_UserToUpdate, $_POST['user-'.$lcas_UserToUpdate]);
     115        }
     116
     117          array_push($page['infos'], l10n('LCAS_Info_userlist_username_renamed'));
     118        }
     119        else {
     120          // User is empty
     121          array_push($page['errors'], l10n('LCAS_Err_Userlist_Empty_New_Username'));
     122        }
     123      }
     124
     125
     126// +-----------------------------------------------------------------------+
     127// |                               user list                               |
     128// +-----------------------------------------------------------------------+
     129
     130      $page['all_users'] = LCAS_get_user_list($conf_LCAS[0]);
     131
     132// +-----------------------------------------------------------------------+
     133// |                               user list                               |
     134// +-----------------------------------------------------------------------+
     135
     136      $lcas_previous_compare_user = '';
     137      $visible_user_list          = array();
     138      foreach ($page['all_users'] as $local_user)
     139      {
     140        if ($lcas_previous_compare_user != $local_user['transformed']) {
     141          $display = 'orange';
     142          $lcas_previous_compare_user = $local_user['transformed'];
     143        }
     144        else {
     145          $display = '';
     146        }
     147
     148        $template->append(
     149          'users',
     150          array(
     151            'ID'          => $local_user['id'],
     152            'USERNAME'    => stripslashes($local_user['username']),
     153            'COMPARE'     => stripslashes($local_user['transformed']),
     154            'EMAIL'       => get_email_address_as_display_text($local_user['email']),
     155            'DISPLAY'     => $display,
     156          )
     157        );
     158      }
     159      /* Plugin version insert */
     160      $template->assign(
     161        array(
     162          'LCAS_VERSION'  => $version,
     163          'LCAS_PATH'     => LCAS_PATH,
     164        )
     165      );   
     166
     167     
     168// +-----------------------------------------------------------------------+
     169// |                             errors display                            |
     170// +-----------------------------------------------------------------------+
     171      if ( isset ($errors) and count($errors) != 0)
     172      {
     173        $template->assign('errors',array());
     174        foreach ($errors as $error)
     175        {
     176          array_push($page['errors'], $error);
     177        }
     178      } 
     179
    58180    }
    59     else
    60     {
    61       array_push($page['infos'], l10n('LCAS_save_config'));
    62       array_push($page['errors'], l10n('LCAS_warning'));
    63     }
    64   }
    65 
    66         $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
    67 
    68   if ((isset($conf_LCAS[0]) and $conf_LCAS[0]=='true') || (isset($conf_LCAS[1]) and $conf_LCAS[1]=='true'))
    69   {
    70 // +-----------------------------------------------------------------------+
    71 // |                           initialization                              |
    72 // +-----------------------------------------------------------------------+
    73 
    74     $lcas_UserToUpdate = -1;
    75     if ((isset($_POST['UserToUpdate'])) && ($_POST['UserToUpdate'] != -1)) {
    76         $lcas_UserToUpdate = $_POST['UserToUpdate'];
    77        
    78         if ((isset($_POST['user-'.$lcas_UserToUpdate])) && ($_POST['user-'.$lcas_UserToUpdate] != '')) {
    79                 // Vérifier si le nom n'est pas déjà pris
    80                
    81                
    82                
    83                 // Mise à jour du nom
    84                                 $query = '
    85                                 UPDATE '.USERS_TABLE.'
    86                                 SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'"
    87                                 WHERE id='.$lcas_UserToUpdate.'
    88                                 LIMIT 1
    89                                 ;';
    90 
    91                                 pwg_query($query);
    92 
    93       if (isset($conf_LCAS[2]) and $conf_LCAS[2] = 'true')
    94       {
    95         LCAS_SendMail($lcas_UserToUpdate, $_POST['user-'.$lcas_UserToUpdate]);
    96       }
    97 
    98                                 array_push($page['infos'], l10n('LCAS_Info_userlist_username_renamed'));
    99         }
    100         else {
    101                 // User is empty
    102                                 array_push($page['errors'], l10n('LCAS_Err_Userlist_Empty_New_Username'));
    103         }
    104     }
    105 
    106 
    107 // +-----------------------------------------------------------------------+
    108 // |                               user list                               |
    109 // +-----------------------------------------------------------------------+
    110 
    111                 if ($conf_LCAS[0]=='true' && $conf_LCAS[1]=='true')
    112                         $lcas_rule = 3;
    113                 else if ($conf_LCAS[0]=='true')
    114                         $lcas_rule = 1;
    115                 else if ($conf_LCAS[1]=='true')
    116                         $lcas_rule = 2;
    117                 else
    118                         $lcas_rule = 0;
    119                
    120                 $page['all_users'] = LCAS_get_user_list($lcas_rule);
    121 
    122 // +-----------------------------------------------------------------------+
    123 // |                               user list                               |
    124 // +-----------------------------------------------------------------------+
    125 
    126                 $lcas_previous_compare_user = '';
    127     $visible_user_list          = array();
    128     foreach ($page['all_users'] as $local_user)
    129     {
    130       if ($lcas_previous_compare_user != $local_user['transformed']) {
    131         $display = 'orange';
    132         $lcas_previous_compare_user = $local_user['transformed'];
    133       }
    134       else {
    135         $display = '';
    136       }
    137 
    138                 $template->append(
    139                 'users',
    140         array(
    141                 'ID'          => $local_user['id'],
    142                 'USERNAME'    => stripslashes($local_user['username']),
    143                 'COMPARE'     => stripslashes($local_user['transformed']),
    144                                         'EMAIL'       => get_email_address_as_display_text($local_user['email']),
    145           'DISPLAY'     => $display,
    146                                 )
    147                         );
    148                 }
    149     /* Plugin version insert */
    150     $template->assign(
    151       array(
    152         'LCAS_VERSION'  => $version,
    153         'LCAS_PATH'     => LCAS_PATH,
    154       )
    155     );   
    156 
    157    
    158 // +-----------------------------------------------------------------------+
    159 // |                             errors display                            |
    160 // +-----------------------------------------------------------------------+
    161                 if ( isset ($errors) and count($errors) != 0)
    162                 {
    163                 $template->assign('errors',array());
    164                         foreach ($errors as $error)
    165                 {
    166                                 array_push($page['errors'], $error);
    167                 }
    168                 } 
    169 
    170181  }
    171182
     
    178189    'LCAS_VERSION'                  => $version,
    179190    'LCAS_PATH'                     => LCAS_PATH,
    180     'PWG_insensitive_case_logon'    => $conf['insensitive_case_logon']? 'true'              : 'false',
    181                 'LCAS_Case_Sensitive_TRUE'      => $conf_LCAS[0]=='true'          ? 'checked="checked"' : '' ,
    182                 'LCAS_Case_Sensitive_FALSE'     => $conf_LCAS[0]=='false'         ? 'checked="checked"' : '' ,
    183                 'LCAS_Accent_Sensitive_TRUE'    => $conf_LCAS[1]=='true'          ? 'checked="checked"' : '' ,
    184                 'LCAS_Accent_Sensitive_FALSE'   => $conf_LCAS[1]=='false'         ? 'checked="checked"' : '' ,
     191    'PWG_insensitive_case_logon'    => ($conf['insensitive_case_logon']),
     192    'Personalized_not_allowed'      => (!isset($conf['LCAS_replacement_set'][0])),
     193                'LCAS_final_case'               => $conf_LCAS[0],
     194                'LCAS_Option'                   => $conf_LCAS[1],
    185195                'LCAS_MAIL_TRUE'                => $conf_LCAS[2]=='true'          ? 'checked="checked"' : '' ,
    186196                'LCAS_MAIL_FALSE'               => $conf_LCAS[2]=='false'         ? 'checked="checked"' : '' ,
Note: See TracChangeset for help on using the changeset viewer.