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 :-/ ...)

Location:
extensions/LCAS/trunk/admin
Files:
2 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"' : '' ,
  • extensions/LCAS/trunk/admin/template/global.tpl

    r8565 r8638  
    77
    88<script type="text/javascript">
    9 jQuery().ready(function()
    10 {ldelim}
     9var LCAS_final_case = '{$LCAS_final_case}';
     10var PWG_insensitive_case_logon = {if $PWG_insensitive_case_logon}true{else}false{/if};
     11var Personalized_not_allowed = {if $Personalized_not_allowed}true{else}false{/if};
     12{literal}
     13jQuery().ready(function(){
    1114  jQuery('.cluetip').cluetip(
    12   {ldelim}
     15  {
    1316    width: 550,
    1417    splitTitle: '|'
    15   {rdelim});
    16 {rdelim});
     18  });
     19});
     20
     21jQuery().ready(function(){
     22  if (PWG_insensitive_case_logon) {
     23    jQuery('#LCAS_id_Option0, #LCAS_id_Option2').attr('disabled', 'disabled');
     24    jQuery('#LCAS_id_Opt0, #LCAS_id_Opt2').attr("title", "{/literal}{'conf[insensitive_case_logon] is true'|@translate}{literal}");
     25  }
     26  else {
     27    jQuery('#LCAS_id_Option1, #LCAS_id_Option3').attr('disabled', 'disabled');
     28    jQuery('#LCAS_id_Opt1, #LCAS_id_Opt3').attr("title", "{/literal}{'conf[insensitive_case_logon] is false'|@translate}{literal}");
     29  }
     30  if (Personalized_not_allowed) {
     31    jQuery('#LCAS_id_Option0').attr('disabled', 'disabled');
     32    jQuery('#LCAS_id_Opt0').attr("title", "{/literal}{'Personalized not allowed tooltip'|@translate}{literal}");
     33  }
     34});
    1735
    1836function LCAS_blockToggleDisplay( headerId, contentId )
    19 {ldelim}
     37{
    2038  if (typeof(headerId)=='string')
    21   {ldelim}
     39  {
    2240   if ( headerId.length>  1)
    2341       blockToggleDisplay(headerId, contentId) ;
    2442      document.getElementById("nb_para").value =headerId ;
    2543      document.getElementById("nb_para2").value =contentId;
    26   {rdelim}
    27 {rdelim}
     44  }
     45}
    2846jQuery(document).ready(function()
    29     {ldelim}
     47    {
    3048      jQuery("#sorting")
    31       .tablesorter({ldelim}sortList:[[3,0]], headers: {ldelim} 1: {ldelim} sorter: false {rdelim}, 4: {ldelim} sorter: false {rdelim}, 5: {ldelim} sorter: false {rdelim} {rdelim} {rdelim})
    32       .tablesorterPager({ldelim}container: jQuery("#pager"), positionFixed: false, size: 20, totalPages: 0{rdelim});
    33     {rdelim}
     49      .tablesorter({sortList:[[3,0]], headers: { 1: { sorter: false }, 4: { sorter: false }, 5: { sorter: false } } })
     50      .tablesorterPager({container: jQuery("#pager"), positionFixed: false, size: 20, totalPages: 0});
     51    }
    3452);
    35 function UpdateAUser(UserId) {ldelim}
     53function UpdateAUser(UserId) {
    3654        document.UserList.UserToUpdate.value=UserId;document.UserList.submit();
    37 {rdelim}
     55}
     56{/literal}
    3857</script>
    3958
     
    6079          <li>
    6180            <label class="cluetip" title="{'LCAS_caseSensitiveTitle'|translate}|{'LCAS_caseSensitiveTitle_d'|translate}">
    62               {'LCAS_Case_Sensitive'|@translate}
    63             </label>
    64           <br><br>
    65             <input type="radio" value="false" {$LCAS_Case_Sensitive_FALSE} name="LCAS_Case_Sensitive">
    66               {'LCAS_DisableOption'|@translate}<br>
    67             <input type="radio" value="true" {$LCAS_Case_Sensitive_TRUE} name="LCAS_Case_Sensitive">
    68               {'LCAS_EnableOption'|@translate}
     81              {'LCAS option'|@translate}
     82            </label>
     83            <br><br>
     84            <label for = "LCAS_id_Option1" id ="LCAS_id_Opt1">
     85              <input type="radio" value="1" {if $LCAS_Option == '1'}checked="checked"{/if} id="LCAS_id_Option1" name="LCAS_Option">
     86              {'LCAS_Option1'|@translate}<br>
     87            </label>
     88            <label for = "LCAS_id_Option2" id ="LCAS_id_Opt2">
     89              <input type="radio" value="2" {if $LCAS_Option == '2'}checked="checked"{/if} id="LCAS_id_Option2" name="LCAS_Option">
     90              {'LCAS_Option2'|@translate}<br>
     91            </label>
     92            <label for = "LCAS_id_Option3" id ="LCAS_id_Opt3">
     93              <input type="radio" value="3" {if $LCAS_Option == '3'}checked="checked"{/if} id="LCAS_id_Option3" name="LCAS_Option">
     94              {'LCAS_Option3'|@translate}<br>
     95            </label>
     96            <label for = "LCAS_id_Option0" id ="LCAS_id_Opt0">
     97              <input type="radio" value="0" {if $LCAS_Option == '0'}checked="checked"{/if} id="LCAS_id_Option0" name="LCAS_Option">
     98              {'LCAS_Option0'|@translate}{if $Personalized_not_allowed}{'Personalized not allowed explanation'|@translate}{/if}<br>
     99            </label>
    69100            <br><br>
    70101          </li>
    71 
    72                 <li>
    73             <label class="cluetip" title="{'LCAS_accentSensitiveTitle'|translate}|{'LCAS_accentSensitiveTitle_d'|translate}">
    74               {'LCAS_Accent_Sensitive'|@translate}
    75             </label>
    76          <br><br>
    77             <input type="radio" value="false" {$LCAS_Accent_Sensitive_FALSE} name="LCAS_Accent_Sensitive">
    78               {'LCAS_DisableOption'|@translate}<br>
    79             <input type="radio" value="true" {$LCAS_Accent_Sensitive_TRUE} name="LCAS_Accent_Sensitive">
    80               {'LCAS_EnableOption'|@translate}<br>
    81             <br><br>
    82                 </li>
    83102
    84103          <li>
     
    127146          <label class="cluetip" title="{'LCAS_currentPWGConfig'|translate}|{'LCAS_currentPWGConfig_d'|translate}">
    128147            $conf['insensitive_case_logon'] =
    129 {if $PWG_insensitive_case_logon == 'true'}
    130         <span style="color: green;">{$PWG_insensitive_case_logon}</span>;
     148{if $PWG_insensitive_case_logon}
     149        <span style="color: green;">true</span>;
    131150{else}
    132         <span style="color: red;">{$PWG_insensitive_case_logon}</span>;
     151        <span style="color: red;">false</span>;
    133152{/if}
    134153          </label>
Note: See TracChangeset for help on using the changeset viewer.