Changeset 3985


Ignore:
Timestamp:
Oct 7, 2009, 9:31:04 AM (15 years ago)
Author:
LucMorizur
Message:

[Event Cats] Form submit beginning, "forced problem" improvement

Location:
extensions/event_cats
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/event_cats/admin/evntcats_admin.js

    r3970 r3985  
    1010var ec_selected_action = '';
    1111var ec_selected_img = '';
    12 var ec_auto_code_digits_nb = '8';
     12var ec_auto_code_digits_default =
     13 document.getElementById('ec_in_up_auto_code_length_id').value;
     14var ec_auto_code_digits_nb = ec_auto_code_digits_default;
    1315var ec_new_code_text = '';
    1416var ec_new_user_text = '';
     
    265267}
    266268
    267 function ec_check_dis(ec_id) {
     269function ec_check_d(ec_id, ec_act) {
    268270  ec_mark_line(ec_id);
    269   return confirm(ec_JS_message['ec_confirm_disable']);
    270 }
    271 
    272 function ec_check_del(ec_id) {
    273   ec_mark_line(ec_id);
    274   return confirm(ec_JS_message['ec_confirm_delete']);
     271  if (confirm(ec_JS_message['ec_confirm_' + ec_act])) {
     272    document.getElementById('ec_act1_id').value = ec_act;
     273    document.forms['ec_up_code'].submit();
     274    /* return true;
     275  }
     276  else {
     277    return false; */
     278  }
    275279}
    276280
     
    285289
    286290function ec_init() {
     291  ec_err = '';
     292  ec_checked_line = 0;
     293  ec_selected_user = 'ec_sel_user_old';
     294  ec_selected_old_user = '-1';
     295  ec_selected_AP = '-1';
     296  ec_selected_cat = '-1';
     297  ec_selected_action = '';
     298  ec_selected_img = '';
     299  ec_new_code_text = '';
     300  ec_new_user_text = '';
     301  ec_new_psd_text = '';
     302  ec_old_new_psd_text = '';
     303  ec_test_reg = '';
     304  document.getElementById('ec_act1_id').value = '';
     305  document.getElementById('ec_in_up_pwd_warn').innerHTML = '';
    287306  ec_mark_line(0);
    288307}
  • extensions/event_cats/admin/evntcats_admin.php

    r3971 r3985  
    209209  $arg2     = $ec_entry['arg2'];
    210210  $arg2_int = intval($arg2);
    211   $log_OK   = (strpos($ec_entry['action'], 'ec_ok') !== false);
     211  $log_OK   = is_in($ec_entry['action'], 'ec_ok');
    212212 
    213213  // No specific need for "code" displaying
     
    222222  switch ($ec_entry['action']) {
    223223   
    224     case 'ec_ok_forced_pb' :
    225       $page['errors'][$ec_entry['code']] = l10n('ec_forced_pb');
     224    case 'ec_ok_f_pb' :
     225    case 'ec_ok_f_pb_img_pb' :
     226      $page['errors'][$ec_entry['code']] =
     227       $ec_entry['code'].' : '.l10n('ec_forced_pb');
    226228    case 'ec_ok' :
    227229    case 'ec_ok_img_pb' :
     
    243245           l10n('ec_dspl_ok_cat_end')
    244246          ;
    245           if ($ec_entry['action'] == 'ec_ok_img_pb') {
     247          if (is_in($ec_entry['action'], '_img_pb')) {
    246248            $url_end.= '&img='.$arg2;
    247             $page['errors'][] = l10n('ec_image_miss');
     249            $page['errors'][] =
     250             $ec_entry['code'].' : '.l10n('ec_image_miss');
    248251            $dspl.=
    249252             '<br>'.$span_err_pre.
     
    307310    break;
    308311   
     312    case 'ec_ok_f_pb_ap_pb' :
     313      $page['errors'][$ec_entry['code']] =
     314       $ec_entry['code'].' : '.l10n('ec_forced_pb');
    309315    case 'ec_nok_ap_pb' : // No need to check here if Additional Pages is
    310316    case 'ec_ok_ap_pb' :  // active : we can arrive here only when it is.
    311       $page['errors'][] = l10n('ec_add_page_miss');
    312       if ($ec_entry['action'] == 'ec_ok_ap_pb') {
     317      $page['errors'][] =
     318       $ec_entry['code'].' : '.l10n('ec_add_page_miss');
     319      if (is_in($ec_entry['action'], 'ec_ok')) {
    313320        $url_end = '&ap='.$arg2;
    314321        $dspl = l10n('ec_dspl_ok_home');
     
    326333    break;
    327334   
     335    case 'ec_ok_f_pb_cat_pb' :
     336      $page['errors'][$ec_entry['code']] =
     337       $ec_entry['code'].' : '.l10n('ec_forced_pb');
    328338    case 'ec_ok_cat_pb' :
    329339      $url_end = '&cat='.$arg1;
    330       $page['errors'][] = l10n('ec_category_miss');
     340      $page['errors'][] =
     341       $ec_entry['code'].' : '.l10n('ec_category_miss');
    331342      $dspl =
    332343       l10n('ec_dspl_nok_home').
     
    340351   
    341352    case 'ec_nok_action_pb' :
    342       $page['errors'][$ec_entry['code']] = l10n('ec_action_pb');
     353      $page['errors'][$ec_entry['code']] =
     354       $ec_entry['code'].' : '.l10n('ec_action_pb');
    343355      $username =
    344356       $span_err_pre.
     
    350362   
    351363    case 'ec_nok_userid_pb' :
    352       $page['errors'][$ec_entry['code']] = l10n('ec_username_pb');
     364      $page['errors'][$ec_entry['code']] =
     365       $ec_entry['code'].' : '.l10n('ec_username_pb');
    353366      $username =
    354367       $span_err_pre.
     
    360373   
    361374    case 'ec_nok_userid_miss' :
    362       $page['errors'][$ec_entry['code']] = l10n('ec_username_miss');
     375      $page['errors'][$ec_entry['code']] =
     376       $ec_entry['code'].' : '.l10n('ec_username_miss');
    363377      $username =
    364378       $span_err_pre.
     
    382396  $code_list[$i] = array(
    383397   'id'       => $i,
    384    'Code'     => $ec_entry['code'],
     398   'Code'     => (isset($page['errors'][$ec_entry['code']])) ?
     399    $span_err_pre.$ec_entry['code'].$span_err_end : $ec_entry['code'],
    385400   'Username' => $username,
    386    'Action'   => $ec_entry['action'],
     401   'Action'   => (is_in($ec_entry['action'], 'ec_nok_')) ?
     402    $span_err_pre.$ec_entry['action'].$span_err_end : $ec_entry['action'],
    387403   'Arg1'     => $dspl,
    388404   'Forced'   => $ec_entry['forced'],
    389405   'code_URL' => $code_URL,
    390406   'log_OK'   => $log_OK,
     407   'f_pb'     => is_in($ec_entry['action'], '_f_pb'),
    391408  );
    392409}
     
    407424$template->assign('RACINE_URL',ROOT_URL);
    408425
    409 // $template->assign('test0tpl',str_from_var($ec_lists['ec_codes']));
     426$template->assign('GET',str_from_var($_GET));
     427$template->assign('POST',str_from_var($_POST));
    410428$template->assign('test1tpl',str_from_var($ec_lists));
    411429$template->assign('test2tpl',str_from_var($page['errors']));
    412430$template->assign('test3tpl',str_from_var($code_list));
    413431
    414 /* C'est quoi, ça ?...
    415 if ( isset($_POST['submit']) )
    416   {
    417     if (isset($_POST['account']) and isset($_POST['code']))
    418       {
    419         $conf['auto_log'][$_POST['code']] = $_POST['account'];
    420       }
    421     else
    422       {
    423         $page['errors']='arg_missing';
    424       }
    425 
    426     if (isset($_POST['duplication']))
    427       {
    428         $conf['allow_user_registration'] = ($_POST['duplication'] == '1');
    429       }
    430   }
    431 */
    432 
    433432$template->set_filenames(array('evntcats_admin_content' => dirname(__FILE__).'/evntcats_admin.tpl'));
    434433$template->assign_var_from_handle('ADMIN_CONTENT','evntcats_admin_content');
  • extensions/event_cats/admin/evntcats_admin.tpl

    r3970 r3985  
    11{* <!-- Event Cats (event categories) LucMorizur June - ... 2009 --> *}
    2 
    3 {* <!-- Tabs for admin page surfing --> *} {*
    4 <ul class = "tabsheet">
    5   <li class = "selected_tab">
    6     <a href = "??...">
    7       <span>{'ec_tab_autoid'|@translate}</span>
    8     </a>
    9   </li>
    10   <li class = "normal_tab">
    11     <a href = "??...">
    12       <span>{'ec_tab_config'|@translate}</span>
    13     </a>
    14   </li>
    15 </ul> *}
    16 
    17 {* <!-- Help button --> *} {*
    18 <ul class = "HelpActions">
    19   <li>
    20     <a href = "aide" onclick = "popuphelp(this.href); return false;" title = "{'ec_help'|@translate}" style = "margin-top: -28px;" >
    21       <img src = "{$ROOT_URL}{$themeconf.admin_icon_dir}/help.png" class = "button" alt = "(?)" />
    22     </a>
    23   </li>
    24 </ul> *}
    252
    263{* <!-- Page title --> *}
     
    3714</script>
    3815
    39 {* <!-- Upper banner : infos, errors... --> *}
     16{* <!-- EC Presentation --> *}
    4017{if $ec_howto}
    4118  <div>
     
    4825</p>
    4926
     27{* <!-- Whether plugin Additionnal Pages is active or not --> *}
     28<div style = "text-align:right; font-style:italic;">
     29  {if $ec_ap_ok}
     30    {'ec_plugin_ap_ok'|@translate}
     31    <script type = "text/javascript"><!--
     32      var ec_ap_ok = true; //-->
     33    </script>
     34  {else}
     35    {'ec_plugin_ap_nok'|@translate}
     36    <script type = "text/javascript"><!--
     37      var ec_ap_ok = false; //-->
     38    </script>
     39  {/if}
     40</div>
     41
    5042{* <!-- First section : form to view and modify codes, or create a new one --> *}
    5143<form class = "filter" method = "post" name = "ec_up_code" action = "">
    52  
    53   <div style = "text-align:right; font-style:italic;">
    54     {if $ec_ap_ok}
    55       {'ec_plugin_ap_ok'|@translate}
    56       <script type = "text/javascript"><!--
    57         var ec_ap_ok = true; //-->
    58       </script>
    59     {else}
    60       {'ec_plugin_ap_nok'|@translate}
    61       <script type = "text/javascript"><!--
    62         var ec_ap_ok = false; //-->
    63       </script>
    64     {/if}
    65   </div>
     44  <input type = "hidden" id = "ec_act1_id" name = "ec_act1" />
    6645 
    6746  <div style = "text-align:center; font-weight:bold; font-size:120%;">{'ec_entry_table_title'|@translate}</div><br>
     
    10079          </a>
    10180          &nbsp;
    102           <a href = "javascript:void()" onclick = "return ec_check_del({$code_line.id});">
    103      {* envoi formulaire par JS : document.forms[nom_formulaire].submit() ( http://www.toutjavascript.com/reference/reference.php?iref=178 ) *}
    104             <img src = "{$EVNTCATS_URLS.ROOT}icon/delete.png" class = "button" style = "border:none"
     81          <a href = "javascript:void();" onclick = "ec_check_d({$code_line.id}, 'delete');">
     82            <img src = "{$EVNTCATS_URLS.ROOT}icon/delete.png" class = "button"
    10583             alt = "{'ec_url_delete'|@translate}" title = "{'ec_url_delete'|@translate}" />
    10684          </a>
    10785          {if $code_line.log_OK}
    10886            &nbsp;
    109             <a href = "javascript:void()" onclick = "return ec_check_dis({$code_line.id});">
    110               <img src = "{$EVNTCATS_URLS.ROOT}icon/disable.png" class = "button" style = "border:none"
     87            <a href = "javascript:void();" onclick = "ec_check_d({$code_line.id}, 'disable');">
     88              <img src = "{$EVNTCATS_URLS.ROOT}icon/disable.png" class = "button"
    11189               alt = "{'ec_url_disable'|@translate}" title = "{'ec_url_disable'|@translate}" />
    11290            </a>
     
    11492              &nbsp;
    11593              <a href = "javascript:void()" title = "{'ec_toggle_forced'|@translate}" onclick = "return ec_toggle_forced({$code_line.id});">
    116                 <img class = "button" style = "border:none" src = "{$EVNTCATS_URLS.ROOT}icon/forced.png"
    117                  alt = "{'ec_url_forced'|@translate}" title = "{'ec_url_forced'|@translate}"/>
     94                <img class = "button" src = "{$EVNTCATS_URLS.ROOT}icon/forced.png"
     95                 {if $code_line.f_pb} style = "border:solid medium red;" {/if}
     96                 alt = "{'ec_url_forced'|@translate}" title = "{'ec_url_forced'|@translate}"
     97                />
    11898              </a>
    11999            {else}
    120100              &nbsp;
    121101              <a href = "javascript:void()" title = "{'ec_toggle_forced'|@translate}" onclick = "return ec_toggle_forced({$code_line.id});">
    122                 <img class = "button" style = "border:none" src = "{$EVNTCATS_URLS.ROOT}icon/nforced.png"
     102                <img class = "button" src = "{$EVNTCATS_URLS.ROOT}icon/nforced.png"
    123103                 alt = "{'ec_url_nforced'|@translate}" title = "{'ec_url_nforced'|@translate}"/>
    124104              </a>
    125               &nbsp;
    126               <a href = "javascript:void()" title = "{'ec_duplicate_entry'|@translate}" onclick = "return ec_duplicate_entry({$code_line.id});">
    127                 <img src = "{$EVNTCATS_URLS.ROOT}icon/duplicate.png" class = "button" style = "border:none"
    128                  alt = "{'ec_url_duplicate'|@translate}" title = "{'ec_url_duplicate'|@translate}" />
    129               </a>
     105              {if !$code_line.f_pb}
     106                &nbsp;
     107                <a href = "javascript:void()" title = "{'ec_duplicate_entry'|@translate}" onclick = "return ec_duplicate_entry({$code_line.id});">
     108                  <img src = "{$EVNTCATS_URLS.ROOT}icon/duplicate.png" class = "button" style = "border:none"
     109                   alt = "{'ec_url_duplicate'|@translate}" title = "{'ec_url_duplicate'|@translate}" />
     110                </a>
     111              {/if}
    130112            {/if}
    131113          {/if}
     
    319301    </tr>
    320302  </table>
     303  <p>
     304    <input class = "submit" type = "submit" name = "ec_submit" value = "{'Submit'|@translate}"/>
     305    <input class = "submit" type = "reset" name = "ec_reset" value = "{'Reset'|@translate}" onclick = "ec_init();"/>
     306  </p>
    321307</form>
    322308
     
    333319  {/foreach}
    334320 
    335   ec_JS_message['ec_confirm_disable'] = "{'ec_confirm_disable'|@translate|@escape:javascript}";
    336   ec_JS_message['ec_confirm_delete'] = "{'ec_confirm_delete'|@translate|@escape:javascript}";
    337   ec_JS_message['ec_confirm_test'] = "{'ec_confirm_test'|@translate|@escape:javascript}";
     321  ec_JS_message['ec_confirm_disable']   = "{'ec_confirm_disable'|@translate|@escape:javascript}";
     322  ec_JS_message['ec_confirm_delete']    = "{'ec_confirm_delete'|@translate|@escape:javascript}";
     323  ec_JS_message['ec_confirm_test']      = "{'ec_confirm_test'|@translate|@escape:javascript}";
    338324  ec_JS_message['ec_gen_user_act_miss'] = "{'ec_gen_user_act_miss'|@translate|@escape:javascript}";
    339   ec_JS_message['ec_act_cat_miss'] = "{'ec_act_cat_miss'|@translate|@escape:javascript}";
    340   ec_JS_message['ec_new_pwd_gen'] = "{'ec_new_pwd_gen'|@translate|@escape:javascript}";
     325  ec_JS_message['ec_act_cat_miss']      = "{'ec_act_cat_miss'|@translate|@escape:javascript}";
     326  ec_JS_message['ec_new_pwd_gen']       = "{'ec_new_pwd_gen'|@translate|@escape:javascript}";
    341327 
    342328  ec_init();
     
    354340
    355341{* <!-- {$test0tpl} --> *}
     342<p>$_GET :</p>
     343{$GET}
     344<p>$_POST :</p>
     345{$POST}
     346<p>Autres :</p>
    356347{$test1tpl}
    357348{$test2tpl}
  • extensions/event_cats/include/evntcats_funcs.inc.php

    r3971 r3985  
    183183    foreach ($ec_lists['ec_table'] as &$ec_entry) { // & is needed here
    184184      if (isset($to_correct[$ec_entry['code']])) {
    185         $ec_entry['action'] = $new_action;
     185        $ec_entry['action'] = ($check_forced) ?
     186         $ec_entry['action'].$new_action : $new_action;
    186187      }
    187188    }
     
    195196 
    196197  // Multiple "forced" params for a single code check
    197   ec_inpect('forced', 'ec_ok_forced_pb', true, true);
     198  ec_inpect('forced', '_f_pb', true, true);
    198199 
    199200  // User id and associated page validities checks
     
    202203    // Check if associated user_id exists
    203204    if (
    204      $ec_entry['action'] == 'ec_ok' and
     205     is_in($ec_entry['action'], 'ec_ok') and
    205206     !array_key_exists($ec_entry['user_id'], $ec_lists['user_ids'])
    206207    ) {
     
    211212    $a = 0;
    212213    if (!empty($ec_entry['arg1']) and
    213      (strpos($ec_entry['action'], 'ec_ok') !== false)) $a++; // Only arg2
     214     is_in($ec_entry['action'], 'ec_ok')) $a++; // Only arg2
    214215    // is significant if action is ec_nok[_xxx] .
    215216    if (!empty($ec_entry['arg2'])) $a+= 2;
     
    220221        if (
    221222          $ec_ap_ok and (
    222             $ec_entry['action'] == 'ec_ok' or
     223            is_in($ec_entry['action'], 'ec_ok') or
    223224            $ec_entry['action'] == 'ec_nok'
    224225          ) and
     
    231232      case 1: // Category
    232233      case 3: // Image
    233         if ($ec_entry['action'] == 'ec_ok') {
     234        if (is_in($ec_entry['action'], 'ec_ok')) {
    234235          if (array_key_exists($ec_entry['arg1'], $ec_lists['categories'])) {
    235236            if ($a == 3) { // case 3: // Image
     
    274275    $res = pwg_query('SELECT id,title FROM '.ADD_PAGES_TABLE);
    275276    while ($r = mysql_fetch_assoc($res)) {
    276       $c = (strpos($r['title'], '/user_id=')) ? '/user_id=' : '/group_id=';
     277      $c = (is_in($r['title'], '/user_id=')) ? '/user_id=' : '/group_id=';
    277278      $a = explode($c ,$r['title']);
    278279      $ec_lists['add_pages'][$r['id']] = $a[0];
     
    297298  // Construction of $ec_lists['ec_table'] array var
    298299  build_ec_table();
     300}
     301
     302/*
     303 * is_in($haystack, $needle)
     304 * returns true or false whether $needle is a string found in string $haystack
     305 *
     306 * @param
     307 *   $haystack : the string in which to search
     308 *   $needle   : the string looked for
     309 * @return
     310 *   true if $needle is found in $haystack ; false if not
     311 */
     312function is_in($haystack, $needle) {
     313  return (strpos($haystack, $needle) !== false);
    299314}
    300315
  • extensions/event_cats/language/fr_FR/plugin.lang.php

    r3970 r3985  
    6464// In PHP files
    6565// Errors
    66 $lang['ec_action_pb']             = 'Champ "action" corrompu (plusieurs valeurs pour un même code dans la base de données)';
    67 $lang['ec_username_pb']           = 'Champ "user_id" corrompu (plusieurs valeurs pour un même code dans la base de données)';
    68 $lang['ec_forced_pb']             = 'Champ "forced" corrompu (au moins une fois "true" pour un même code dans la base de données)';
    69 $lang['ec_username_miss']         = 'Utilisateur inexistant (probablement supprimé)';
    70 $lang['ec_category_miss']         = 'Catégorie inexistante (probablement supprimée)';
    71 $lang['ec_image_miss']            = 'Image inexistante (probablement supprimée)';
    72 $lang['ec_add_page_miss']         = 'Page Additional Pages inexistante (probablement supprimée)';
     66$lang['ec_action_pb']             = 'champ "action" corrompu (plusieurs valeurs pour un code ayant plusieurs entrées)';
     67$lang['ec_username_pb']           = 'champ "user_id" corrompu (plusieurs valeurs pour un code ayant plusieurs entrées)';
     68$lang['ec_forced_pb']             = 'champ "forced" corrompu (au moins une fois "true" pour un code ayant plusieurs entrées)';
     69$lang['ec_username_miss']         = 'utilisateur inexistant (probablement supprimé)';
     70$lang['ec_category_miss']         = 'catégorie inexistante (probablement supprimée)';
     71$lang['ec_image_miss']            = 'image inexistante (probablement supprimée)';
     72$lang['ec_add_page_miss']         = 'page Additional Pages inexistante (probablement supprimée)';
    7373$lang['ec_entry_del_nok_pre']     = 'Problème avec suppression entrée ';
    7474$lang['ec_entry_del_nok_end']     = '';
     
    9292//   actions
    9393$lang['ec_ok']                    = 'OUI';
    94 $lang['ec_ok_forced_pb']          = 'OUI (page non forcée)';
     94$lang['ec_ok_f_pb']               = 'OUI (page non forcée)';
    9595$lang['ec_ok_ap_pb']              = 'OUI (Add. Page inconnue)';
    9696$lang['ec_ok_cat_pb']             = 'OUI (catégorie inconnue)';
    9797$lang['ec_ok_img_pb']             = 'OUI (image inconnue)';
     98$lang['ec_ok_f_pb_ap_pb']         = 'OUI (page non forcée et Add. Page inconnue)';
     99$lang['ec_ok_f_pb_cat_pb']        = 'OUI (page non forcée et catégorie inconnue)';
     100$lang['ec_ok_f_pb_img_pb']        = 'OUI (page non forcée et image inconnue)';
    98101$lang['ec_nok']                   = 'NON';
    99102$lang['ec_nok_ap_pb']             = 'NON';
  • extensions/event_cats/main.inc.php

    r3975 r3985  
    117117    }
    118118    if ($code_exists) {
    119       if (strpos($ec_entry['action'], 'ec_ok') !== false) {
     119      if (is_in($ec_entry['action'], 'ec_ok')) {
    120120        log_user($ec_entry['user_id'], false);
    121121        if (isset($_GET['ap'])) $ec_ap = $_GET['ap'];
     
    124124        if (
    125125         $ec_entry['forced'] == 'true' and
    126          $ec_entry['action'] != 'ec_forced_pb'
     126         !is_in($ec_entry['action'], '_f_pb')
    127127        ) {
    128128          if (empty($ec_entry['arg1']) and !empty($ec_entry['arg2'])) {
  • extensions/event_cats/maintain.inc.php

    r3971 r3985  
    110110                       the user ids table ;
    111111  ec_nok_ap_pb       : not valid Additional Page id -> access denied ;
    112   ec_ok_forced_pb    : the same "code" is used in more than one entries in the
     112  ec_ok_f_pb         : the same "code" is used in more than one entries in the
    113113                       DB (which is allowed) and the "forced" argument is
    114114                       "true" for at least one of these entries, which should
     
    119119  ec_ok_cat_pb       : not valid category id -> home page ;
    120120  ec_ok_img_pb       : not valid image id -> category page ;
     121  ec_ok_f_pb_ap_pb   : ec_ok_ap_pb + "forced problem" -> home page ;
     122  ec_ok_f_pb_cat_pb  : ec_ok_cat_pb + "forced problem" -> home page ;
     123  ec_ok_f_pb_img_pb  : ec_ok_img_pb + "forced problem" -> category page ;
    121124
    122125_ the two main fields are "user_id" and "code", as the main purpose of the
Note: See TracChangeset for help on using the changeset viewer.