Changeset 9158


Ignore:
Timestamp:
Feb 10, 2011, 9:31:02 PM (9 years ago)
Author:
LucMorizur
Message:

LCAS takes completely care for case sensitivity: $confinsensitive_case_logon set to false by LCAS

Location:
extensions/LCAS/trunk
Files:
4 edited

Legend:

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

    r8845 r9158  
    3838$version = $plugin['version'];
    3939
    40         if (isset($_POST['submit']) and isset($_POST['LCAS_Option']) and isset($_POST['LCAS_Mail']))
     40        if (isset($_POST['submit']) and !is_adviser() and isset($_POST['LCAS_Option']) and isset($_POST['LCAS_Mail']))
    4141  {
    4242
     
    4545   
    4646                // LCAS configuration is now hereby defined :
    47     // $conf_LCAS[0] : "final case", describe how LCAS should behave;
     47    // $conf_LCAS[0] : spare // quite lazy, but convenient to not have to
     48      // decrease index of each option below everywhere :-/ ...
    4849    // $conf_LCAS[1] : LCAS option, describe the choice of the webmaster;
    4950    // $conf_LCAS[2] : LCAS_Mail;
    5051    // $conf_LCAS[3] : LCAS_MailText.
    5152    $newconf_LCAS= array(
    52       LCAS_final_case($_POST['LCAS_Option']),
     53      '', // quite lazy, but convenient to not have to
     54      // decrease index of each option everywhere :-/ ...
    5355      $_POST['LCAS_Option'],
    54       // $_POST['LCAS__spare'] : quite lazy, but convenient to not have to
    55       // decrease index of each option below everywhere :-/ ...
    5656      $_POST['LCAS_Mail'],
    5757      $_POST['LCAS_MailText']);
     
    7272
    7373        $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
    74   $conf_LCAS[0] = LCAS_final_case($conf_LCAS[1]);
    7574 
    76   if (isset($conf_LCAS[0]))
     75  if (isset($conf_LCAS[1]))
    7776  {
    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')));
     77    $case_ins = ($conf_LCAS[1] == '1' or $conf_LCAS[1] == '3');
     78    $acc_ins = ($conf_LCAS[1] == '2' or $conf_LCAS[1] == '3');
    8679
    8780    if ($case_ins or $acc_ins)
     
    128121// +-----------------------------------------------------------------------+
    129122
    130       $page['all_users'] = LCAS_get_user_list($conf_LCAS[0]);
     123      $page['all_users'] = LCAS_get_user_list($conf_LCAS[1]);
    131124
    132125// +-----------------------------------------------------------------------+
     
    157150        );
    158151      }
    159       /* Plugin version insert */
    160       $template->assign(
    161         array(
    162           'LCAS_VERSION'  => $version,
    163           'LCAS_PATH'     => LCAS_PATH,
    164         )
    165       );   
    166 
    167152     
    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 
    180153    }
    181154  }
     
    189162    'LCAS_VERSION'                  => $version,
    190163    'LCAS_PATH'                     => LCAS_PATH,
    191     'PWG_insensitive_case_logon'    => ($conf['insensitive_case_logon']),
    192164    'Personalized_not_allowed'      => (!isset($conf['LCAS_replacement_set'][0])),
    193                 'LCAS_final_case'               => $conf_LCAS[0],
    194165                'LCAS_Option'                   => $conf_LCAS[1],
    195                 'LCAS_MAIL_TRUE'                => $conf_LCAS[2]=='true'          ? 'checked="checked"' : '' ,
    196                 'LCAS_MAIL_FALSE'               => $conf_LCAS[2]=='false'         ? 'checked="checked"' : '' ,
     166                'LCAS_MAIL_TRUE'                => $conf_LCAS[2] == 'true'  ? 'checked = "checked"' : '' ,
     167                'LCAS_MAIL_FALSE'               => $conf_LCAS[2] == 'false' ? 'checked = "checked"' : '' ,
    197168    'LCAS_MAILTEXT'                 => $conf_LCAS[3]
    198169    )
  • extensions/LCAS/trunk/admin/template/global.tpl

    r8840 r9158  
     1{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"}
     2{known_script id="jquery.cluetip" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.cluetip.packed.js"}
     3{known_script id="jquery.tablesorter" src=$LCAS_PATH|@cat:"admin/template/js/jquery.tablesorter.js"}
     4{known_script id="jquery.tablesorter.pager" src=$LCAS_PATH|@cat:"admin/template/js/jquery.tablesorter.pager.js"}
     5{*
    16{combine_script id="jquery" path=$ROOT_URL|@cat:"themes/default/js/jquery.js"}
    27{combine_script id="jquery.cluetip" path=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.cluetip.packed.js"}
    38{combine_script id="jquery.tablesorter" path=$LCAS_PATH|@cat:"admin/template/js/jquery.tablesorter.js"}
    49{combine_script id="jquery.tablesorter.pager" path=$LCAS_PATH|@cat:"admin/template/js/jquery.tablesorter.pager.js"}
     10*}
    511
    612{html_head}<link rel="stylesheet" type="text/css" href="{$LCAS_PATH}admin/template/lcas.css">{/html_head}
    713
    814<script type="text/javascript">
    9 var LCAS_final_case = '{$LCAS_final_case}';
    10 var PWG_insensitive_case_logon = {if $PWG_insensitive_case_logon}true{else}false{/if};
    1115var Personalized_not_allowed = {if $Personalized_not_allowed}true{else}false{/if};
    1216{literal}
     
    1721    splitTitle: '|'
    1822  });
    19 });
    20 
    21 jQuery().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   }
    3423});
    3524
     
    4938      .tablesorter({sortList:[[3,0]], headers: { 1: { sorter: false }, 4: { sorter: false }, 5: { sorter: false } } })
    5039      .tablesorterPager({container: jQuery("#pager"), positionFixed: false, size: 20, totalPages: 0});
     40      if (Personalized_not_allowed) {
     41        jQuery('#LCAS_id_Option0').attr('disabled', 'disabled');
     42        jQuery('#LCAS_id_Opt0').attr("title", "{/literal}{'Personalized not allowed tooltip'|@translate}{literal}");
     43      }
    5144    }
    5245);
     
    9487              {'LCAS_Option3'|@translate}<br>
    9588            </label>
     89            {* <!-- Shall be implemented later
    9690            <label for = "LCAS_id_Option0" id ="LCAS_id_Opt0">
    9791              <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>
     92              {'LCAS_Option0'|@translate}<br>{if $Personalized_not_allowed}{'Personalized not allowed explanation'|@translate}{/if}<br>
     93            </label>
     94            --> *}
    10095            <br><br>
    10196          </li>
  • extensions/LCAS/trunk/include/functions.inc.php

    r8643 r9158  
    3333 * @return : string modified as stated
    3434*/
    35 function LCAS_change_case($Username, $Opt, $At_login=true)
     35function LCAS_change_case($Username, $Opt)
    3636{
    3737  global $conf;
     
    3939  if ($Opt == '0' and !isset($conf['LCAS_replacement_set'][0]))
    4040   return $Username;
     41  if ($Opt == '0') return $Username; // to be removed once rule 0 is done
    4142  $Option = intval($Opt);
    42   if (!isset($Opt) or ($Option < 0) or ($Option > 7)) return $Username;
    43   if ($Option > 3) {
    44     // Management of bad setting of $conf['insensitive_case_logon']
    45     switch ($Opt) {
    46       case '4':
    47         // LCAS set to case insensitive, but $conf['insensitive_case_logon']
    48         // is false : exit immediately, LCAS actually inactive
    49         return $Username;
    50       break;
    51       case '5':
    52         // LCAS set to case and accents insensitive, but
    53         // $conf['insensitive_case_logon'] is false : only accents are
    54         // insensitive
    55         $Option = 2;
    56       break;
    57       case '6':
    58         // LCAS set to accents only insensitive, but
    59         // $conf['insensitive_case_logon'] is true : if check is done at
    60         // login, LCAS cares for both case and accents insensitivity, but
    61         // using strtolower() as does Piwigo at register; in case the check is
    62         // done at register, Piwigo cares for the case, thus LCAS cares only
    63         // for the accents.
    64         $Option = 2;
    65         if ($At_login) $Username = strtolower($Username);
    66       break;
    67       case '7':
    68         // LCAS set to personal, but $conf['insensitive_case_logon'] is true :
    69         // if check is done at login, LCAS cares for both case and personal
    70         // insensitivity, but using strtolower() as does Piwigo at register;
    71         // in case the check is done at register, Piwigo cares for the case,
    72         // thus LCAS cares only for the personal setting.
    73         $Option = 0;
    74         if ($At_login) $Username = strtolower($Username);
    75       break;
    76     }
    77   }
     43  if (!isset($Opt) or ($Option < 0) or ($Option > 3)) return $Username;
    7844 
    7945  include(LCAS_PATH.'include/LCAS_replacement_set.inc.php');
    8046
    81   // Builds an array of characters that must be replaced
     47  // Build an array of characters that must be replaced
    8248  // $rep_char is the replacement character ; $char_rep_arr is an array of
    8349  // characters which have to be replaced. ie :
     
    320286 *
    321287 */
    322 function LCAS_SearchCaseUsername($username, $rule, $At_login=true)
     288function LCAS_SearchCaseUsername($username, $rule)
    323289{
    324290  global $conf;
    325291
    326   $username_c = LCAS_change_case($username, $rule, $At_login);
     292  $username_c = LCAS_change_case($username, $rule);
    327293
    328294  if (isset($username))
     
    336302    while ($r = pwg_db_fetch_assoc($q))
    337303     $LCAS_users[$r['username']] =
    338       LCAS_change_case($r['username'], $rule, $At_login);
     304      LCAS_change_case($r['username'], $rule);
    339305     // $LCAS_users is now an associative table where the key is the account
    340306     // as registered in the DB, and the value is this same account,
     
    349315     return $users_found[0];
    350316  }
    351 }
    352 
    353 
    354 /*
    355  * LCAS_final_case($var)
    356  * return the value of the case in which is the gallery, regarding
    357  * case and accents sensitivity
    358  *
    359  * @param $var
    360  *   the inital proposal from the webmaster
    361  * @return
    362  *   string being an image of the case and accents sensitivity
    363  */
    364 function LCAS_final_case($var) {
    365 
    366   global $conf;
    367  
    368   if (isset($conf['insensitive_case_logon']) and $conf['insensitive_case_logon'] == true)
    369   {
    370     // Uncomfortable status if $conf['insensitive_case_logon'] is true and
    371     // case insensitivity is not set in LCAS
    372     if ($var == '2') return '6';
    373     elseif  ($var == '0') return '7';
    374   }
    375   else
    376   {
    377     // Uncomfortable status if $conf['insensitive_case_logon'] is false and
    378     // case insensitivity is set in LCAS
    379     if ($var == '1') return '4';
    380     elseif  ($var == '3') return '5';
    381   }
    382  
    383   return $var;
    384 
    385317}
    386318
  • extensions/LCAS/trunk/main.inc.php

    r8638 r9158  
    6363
    6464  $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
     65 
     66  // Set $conf['insensitive_case_logon'] to false, as LCAS takes completely
     67  // in charge everything around the case and the accents
     68  $conf['insensitive_case_logon'] = false;
    6569 
    6670/* User identification */
    6771  if (script_basename() == 'identification')
    6872  {
    69     if (isset($_POST['username']) and isset($conf_LCAS[0]))
     73    if (isset($_POST['username']) and isset($conf_LCAS[1]))
    7074    {
    71       $new_username = LCAS_SearchCaseUsername($_POST['username'],$conf_LCAS[0]);
     75      $new_username = LCAS_SearchCaseUsername($_POST['username'],$conf_LCAS[1]);
    7276      $_POST['username'] = $new_username == '' ? $_POST['username'] : $new_username;
    7377    }
     
    8791  load_language('plugin.lang', LCAS_PATH);
    8892
    89   if (isset($conf_LCAS[0]))
    90    $NewPostLogin = LCAS_SearchCaseUsername($_POST['login'], $conf_LCAS[0], false);
     93  if (isset($conf_LCAS[1]))
     94   $NewPostLogin = LCAS_SearchCaseUsername($_POST['login'], $conf_LCAS[1]);
    9195 
    9296  if (isset($NewPostLogin) and get_userid($NewPostLogin))
Note: See TracChangeset for help on using the changeset viewer.