Changeset 4026


Ignore:
Timestamp:
Oct 12, 2009, 2:00:00 AM (11 years ago)
Author:
LucMorizur
Message:

[Event Cats] Continue $_POST analysis

Location:
extensions/event_cats
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/event_cats/admin/autolog_new.inc.php

    r4011 r4026  
    5656build_ec_lists(); // in evntcats_funcs.php
    5757
     58$ec_prop_code = '';
     59$ec_prop_user = '-1';
     60$ec_prop_act1 = 'create';
     61
    5862/*****************************************************************************
    5963* $_GET and $_POST analysis.                                                 *
     
    6367  if (isset($_POST['ec_entry_sel'])) {
    6468    if (array_key_exists($_POST['ec_entry_sel'], $ec_lists['ec_table'])) {
    65       // Des variables donnant les valeur par défaut des champs à modifier lors
    66       // d'une nouvelle entrée, prennent les valeurs établies trouvées dans la table
    67       // (si quelqu'un comprend cette phrase...)
     69      $ec_prop_code = $ec_lists['ec_table'][$_POST['ec_entry_sel']]['code'];
     70      $ec_prop_user = $ec_lists['ec_table'][$_POST['ec_entry_sel']]['user_id'];
     71      $ec_prop_act1 = $_POST['ec_entry_sel'];
    6872    }
    6973    else {
     
    8286$template->assign('ec_ap_ok',$ec_ap_ok);
    8387$template->assign('ec_lists',$ec_lists);
     88$template->assign('ec_prop_code',$ec_prop_code);
     89$template->assign('ec_prop_user',$ec_prop_user);
     90$template->assign('ec_prop_act1',$ec_prop_act1);
    8491
    8592?>
  • extensions/event_cats/admin/evntcats_admin.php

    r4019 r4026  
    8282  )
    8383   $page['tab'] = 'autolog_new';
    84   else if ($_POST['ec_act1'] == 'create')
     84  elseif ($_POST['ec_act1'] == 'create')
    8585   $page['tab'] = (ec_create_entry_OK()) ? 'autolog_entries' : 'autolog_new';
     86  elseif (is_numeric($_POST['ec_act1'])) // Entry duplication : $_POST['ec_act1'] is entry #
     87   $page['tab'] = (ec_duplicate_entry_OK()) ? 'autolog_entries' : 'autolog_new';
    8688}
    8789else if (isset($_GET['tab'])) switch ($_GET['tab']) {
  • extensions/event_cats/admin/template/autolog_new.js

    r4019 r4026  
    1010var ec_old_new_psd_text         = '';
    1111var ec_test_reg                 = '';
     12var ec_prop_code                = '';
     13var ec_prop_user                = '';
     14var ec_prop_act1                = '';
    1215var ec_selected_old_user        = '-1';
    1316var ec_selected_AP              = '-1';
     
    2023
    2124function ec_mark_user(ec_id) {
    22   ec_selected_user = ec_id;
    23   document.getElementById(ec_selected_user).checked = 'checked';
    24   switch (ec_selected_user) {
    25     /* case 'ec_sel_user_none': // None
    26       ec_selected_action =
    27        (ec_ap_ok && (ec_selected_action != 'ec_input_action_home')) ?
    28        'ec_input_action_add_p' : 'ec_input_action_home';
    29       document.getElementById('ec_in_up_usr_txt_id').value = '';
    30       document.getElementById('ec_in_up_psd_txt_id').value = '';
    31       document.getElementById('ec_in_up_usr_list_id').value = '-1';
    32     break; */
    33     case 'ec_sel_user_new': // New user
    34       document.getElementById('ec_in_up_usr_txt_id').value =
    35        ec_new_user_text;
    36       document.getElementById('ec_in_up_psd_txt_id').value =
    37        ec_new_psd_text;
    38       document.getElementById('ec_in_up_usr_list_id').value = '-1';
    39     break;
    40     case 'ec_sel_user_old': // "Old" user
    41       document.getElementById('ec_in_up_usr_txt_id').value = '';
    42       document.getElementById('ec_in_up_psd_txt_id').value = '';
    43       document.getElementById('ec_in_up_usr_list_id').value =
    44        ec_selected_old_user;
    45     break;
    46   }
    47   ec_check_pwd_text();
    48   if (ec_avoid_infinite_loop) {
    49     ec_avoid_infinite_loop = false;
    50     ec_mark_action(ec_selected_action);
    51     ec_avoid_infinite_loop = true;
     25  if (
     26   !(document.getElementById('ec_sel_user_old').disabled == 'disabled' ||
     27   document.getElementById('ec_sel_user_old').disabled == true)
     28  ) {
     29    ec_selected_user = ec_id;
     30    document.getElementById(ec_selected_user).checked = 'checked';
     31    switch (ec_selected_user) {
     32      /* case 'ec_sel_user_none': // None
     33        ec_selected_action =
     34         (ec_ap_ok && (ec_selected_action != 'ec_input_action_home')) ?
     35         'ec_input_action_add_p' : 'ec_input_action_home';
     36        document.getElementById('ec_in_up_usr_txt_id').value = '';
     37        document.getElementById('ec_in_up_psd_txt_id').value = '';
     38        document.getElementById('ec_in_up_usr_list_id').value = '-1';
     39      break; */
     40      case 'ec_sel_user_new': // New user
     41        document.getElementById('ec_in_up_usr_txt_id').value =
     42         ec_new_user_text;
     43        document.getElementById('ec_in_up_psd_txt_id').value =
     44         ec_new_psd_text;
     45        document.getElementById('ec_in_up_usr_list_id').value = '-1';
     46      break;
     47      case 'ec_sel_user_old': // "Old" user
     48        document.getElementById('ec_in_up_usr_txt_id').value = '';
     49        document.getElementById('ec_in_up_psd_txt_id').value = '';
     50        document.getElementById('ec_in_up_usr_list_id').value =
     51         ec_selected_old_user;
     52      break;
     53    }
     54    ec_check_pwd_text();
     55    if (ec_avoid_infinite_loop) {
     56      ec_avoid_infinite_loop = false;
     57      ec_mark_action(ec_selected_action);
     58      ec_avoid_infinite_loop = true;
     59    }
    5260  }
    5361}
     
    223231
    224232function ec_check_img_text() {
    225   document.getElementById('ec_in_up_imgs_warn').innerHTML = (
    226    document.getElementById('ec_in_up_imgs_id').value != '' &&
    227    document.getElementById('ec_in_up_cats_id').value == '-1'
    228   ) ? ec_JS_message['ec_act_cat_miss'] : '';
     233  if (isNaN(document.getElementById('ec_in_up_imgs_id').value)) {
     234    alert(ec_JS_message['ec_act_img_miss']);
     235    ec_selected_img = '';
     236    document.getElementById('ec_in_up_imgs_id').value = '';
     237  }
     238  else {
     239    document.getElementById('ec_in_up_imgs_warn').innerHTML = (
     240     document.getElementById('ec_in_up_imgs_id').value != '' &&
     241     document.getElementById('ec_in_up_cats_id').value == '-1'
     242    ) ? ec_JS_message['ec_act_cat_miss'] : '';
     243  }
    229244}
    230245
     
    256271    return false;
    257272  }
     273  if (
     274    document.ec_new_code.ec_in_up_aps.selectedIndex < 1 &&
     275    document.ec_new_code.ec_in_up_cat.selectedIndex < 1 && (
     276      document.getElementById('ec_in_up_imgs_id').value == '' || (
     277        document.getElementById('ec_in_up_imgs_id').value != '' &&
     278        isNaN(document.getElementById('ec_in_up_imgs_id').value) &&
     279        document.ec_new_code.ec_in_up_cat.selectedIndex < 1
     280      )
     281    ) &&
     282    document.getElementById('ec_input_action_home').checked == ''
     283  ) {
     284    alert(ec_JS_message['ec_submit_action_miss']);
     285    return false;
     286  }
    258287}
    259288
     
    263292
    264293function ec_init() {
     294  var t = (ec_prop_code == '') ? '' : 'disabled';
    265295  ec_err = '';
    266296  ec_selected_user = 'ec_sel_user_old';
     
    275305  ec_old_new_psd_text = '';
    276306  ec_test_reg = '';
    277   document.getElementById('ec_act1_id').value = 'create';
     307  document.getElementById('ec_act1_id').value = ec_prop_act1;
    278308  document.getElementById('ec_in_up_pwd_warn').innerHTML = '';
    279   document.getElementById('ec_sel_user_new').checked = 'checked';
    280   document.getElementById('ec_sel_user_new').checked = '';
     309  document.getElementById('ec_sel_user_old').checked = 'checked';
     310  document.getElementById('ec_sel_user_old').checked =
     311   (ec_prop_user == '-1') ? '' : 'checked';
    281312  document.getElementById('ec_input_action_home').checked = 'checked';
    282313  document.getElementById('ec_input_action_home').checked = '';
    283314  document.getElementById('ec_in_up_usr_txt_id').value = '';
    284315  document.getElementById('ec_in_up_psd_txt_id').value = '';
    285   document.getElementById('ec_in_up_usr_list_id').value = '-1';
    286   document.getElementById('ec_in_up_code_id').value = '';
     316  document.getElementById('ec_in_up_usr_list_id').value = ec_prop_user;
     317  document.getElementById('ec_in_up_code_id').value = ec_prop_code;
    287318  document.getElementById('ec_in_up_aps_id').value = '-1';
    288319  document.getElementById('ec_in_up_cats_id').value = '-1';
    289320  document.getElementById('ec_in_up_imgs_id').value = '';
    290 }
     321  document.getElementById('ec_submit_gen_full_auto_id').disabled = t;
     322  document.getElementById('ec_in_up_code_id').disabled = t;
     323  document.getElementById('ec_submit_gen_code_id').disabled = t;
     324  document.getElementById('ec_in_up_auto_code_length_id').disabled = t;
     325  document.getElementById('ec_sel_user_new').disabled = t;
     326  document.getElementById('ec_submit_gen_user_id').disabled = t;
     327  document.getElementById('ec_in_up_usr_txt_id').disabled = t;
     328  document.getElementById('ec_in_up_psd_txt_id').disabled = t;
     329  document.getElementById('ec_sel_user_old').disabled = t;
     330  document.getElementById('ec_in_up_usr_list_id').disabled = t;
     331  ec_prop_code = '';
     332  ec_prop_user = '-1';
     333  ec_prop_act1 = 'create';
     334}
  • extensions/event_cats/admin/template/autolog_new.tpl

    r4019 r4026  
    5050    <br>
    5151    <input class = "submit" type = "button" name = "ec_submit_gen_full_auto" value = "{'ec_new_full_auto'|@translate}"
    52      {* id = "ec_submit_gen_full_auto_id" *} onclick = "ec_gen_full_auto();" style = "margin-top:0;"/>
     52     id = "ec_submit_gen_full_auto_id" onclick = "ec_gen_full_auto();" style = "margin-top:0;"/>
    5353  </div>
    5454 
     
    6565        <label for = "ec_in_up_code_id" style = "margin:0;">
    6666          <input class = "submit" type = "button" name = "ec_submit_gen_code" value = "{'ec_new_entry_button'|@translate}"
    67            {* id = "ec_submit_gen_code_id" *} onclick = "ec_gen_code();" style = "margin:0;"
     67           id = "ec_submit_gen_code_id" onclick = "ec_gen_code();" style = "margin:0;"
    6868          />
    6969        </label>
     
    101101        &nbsp;
    102102        <input class = "submit" type = "button" name = "ec_submit_gen_user" value = "{'ec_up_code_lbl_gen_user'|@translate}"
    103          {* id = "ec_submit_gen_user_id" *} onclick = "ec_gen_user();"
     103         id = "ec_submit_gen_user_id" onclick = "ec_gen_user();"
    104104        /><br>
    105105        <ul><li>
     
    182182          />
    183183          {'ec_up_code_lbl_img'|@translate}<br>
    184           <input type = "text" name = "ec_in_up_imgs" id = "ec_in_up_imgs_id" maxlength = "6"
     184          <input type = "text" name = "ec_in_up_img" id = "ec_in_up_imgs_id" maxlength = "6"
    185185           size = "10" onblur = "ec_selected_img = this.value; ec_check_img_text();" onfocus = "ec_mark_action('ec_input_action_img');"
    186186          /><br>
     
    207207<script type = "text/javascript" src = "{$RACINE_URL}{$EVNTCATS_PATH}admin/template/autolog_new.js"></script>
    208208<script type = "text/javascript"><!--
    209   ec_JS_message['ec_gen_user_act_miss'] = "{'ec_gen_user_act_miss'|@translate|@escape:javascript}";
    210   ec_JS_message['ec_act_cat_miss']      = "{'ec_act_cat_miss'|@translate|@escape:javascript}";
    211   ec_JS_message['ec_new_pwd_gen']       = "{'ec_new_pwd_gen'|@translate|@escape:javascript}";
    212   ec_JS_message['ec_up_code_lbl_home']  = "{'ec_up_code_lbl_home'|@translate}";
    213   ec_JS_message['ec_submit_code_miss']  = "{'ec_submit_code_miss'|@translate}";
    214   ec_JS_message['ec_submit_user_miss']  = "{'ec_submit_user_miss'|@translate}";
     209  ec_JS_message['ec_gen_user_act_miss']  = "{'ec_gen_user_act_miss'|@translate|@escape:javascript}";
     210  ec_JS_message['ec_act_cat_miss']       = "{'ec_act_cat_miss'|@translate|@escape:javascript}";
     211  ec_JS_message['ec_act_img_miss']       = "{'ec_act_img_miss'|@translate|@escape:javascript}";
     212  ec_JS_message['ec_new_pwd_gen']        = "{'ec_new_pwd_gen'|@translate|@escape:javascript}";
     213  ec_JS_message['ec_up_code_lbl_home']   = "{'ec_up_code_lbl_home'|@translate}";
     214  ec_JS_message['ec_submit_code_miss']   = "{'ec_submit_code_miss'|@translate}";
     215  ec_JS_message['ec_submit_user_miss']   = "{'ec_submit_user_miss'|@translate}";
     216  ec_JS_message['ec_submit_action_miss'] = "{'ec_submit_action_miss'|@translate}";
     217  ec_prop_code                           = "{$ec_prop_code}";
     218  ec_prop_user                           = "{$ec_prop_user}";
     219  ec_prop_act1                           = "{$ec_prop_act1}";
    215220  ec_init();
    216221//--></script>
  • extensions/event_cats/include/evntcats_funcs.inc.php

    r4019 r4026  
    312312
    313313/*
     314 * ec_duplicate_entry_OK()
     315 * returns true or false whether the duplication of an existing entry which #
     316 * is given by $_POST['ec_act1'] was OK or not.
     317 *
     318 * @param
     319 *   no param
     320 * @return
     321 *   true if creation was OK ; false if not
     322 */
     323function ec_duplicate_entry_OK() {
     324  return false;
     325}
     326
     327/*
    314328 * str_from_var($var)
    315329 * returns a string easing array var informations displaying in Piwigo :
  • extensions/event_cats/language/fr_FR/plugin.lang.php

    r4019 r4026  
    6363$lang['ec_gen_user_act_miss']     = 'Sélectionnez d\'abord une page à afficher';
    6464$lang['ec_act_cat_miss']          = 'Catégorie ?';
     65$lang['ec_act_img_miss']          = 'L\'identifiant d\'une image doit être un nombre.';
    6566$lang['ec_new_pwd_gen']           = 'Pensez à NOTER le mot de passe !';
    6667$lang['ec_submit_code_miss']      = 'Vous devez fournir un code.';
    6768$lang['ec_submit_user_miss']      = 'Vous devez fournir un utilisateur.';
     69$lang['ec_submit_action_miss']    = 'Vous devez proposer une page à afficher.';
    6870
    6971// In PHP files
Note: See TracChangeset for help on using the changeset viewer.