Changeset 4179 for extensions


Ignore:
Timestamp:
Nov 4, 2009, 12:28:23 AM (14 years ago)
Author:
LucMorizur
Message:

[Event Cats] Entry creation in DB OK.

Location:
extensions/event_cats
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/event_cats/admin/template/autolog_new.js

    r4178 r4179  
    436436           ].label
    437437          )[0];
    438           ec_new_user_text = ec_new_user_text.substr(0, 32);
     438          ec_new_user_text = ec_new_user_text.substr(0, 50);
    439439          t2 = ec_new_user_text;
    440440        break;
     
    449449          else */ ec_new_user_text = ec_reg_cat3.exec(ec_cat_sel)[1];
    450450          ec_new_user_text = ec_new_user_text.replace(/\s/g, '_');
    451           ec_new_user_text = ec_new_user_text.substr(0, 32);
     451          ec_new_user_text = ec_new_user_text.substr(0, 50);
    452452          t2 = ec_new_user_text;
    453453        if (ec_selected_action == 'ec_input_action_img') {
  • extensions/event_cats/admin/template/autolog_new.tpl

    r4173 r4179  
    153153          <ul><li>
    154154            <label class = "ec_block" onclick = "return ec_mark_user('ec_sel_user_new');">{'ec_new_user_name'|@translate}<br>
    155               <input type = "text" name = "ec_in_up_usr_txt" id = "ec_in_up_usr_txt_id" maxlength = "32"
     155              <input type = "text" name = "login" id = "ec_in_up_usr_txt_id" maxlength = "50"
    156156               size = "20" onblur = "ec_new_user_text = this.value; ec_check_user_text();"
    157157              />
    158158            </label>
    159159            <label class = "ec_block" onclick = "return ec_mark_user('ec_sel_user_new');">{'ec_new_user_pswd'|@translate}<br>
    160               <input type = "text" name = "ec_in_up_psd_txt" id = "ec_in_up_psd_txt_id" maxlength = "32"
     160              <input type = "text" name = "password" id = "ec_in_up_psd_txt_id" maxlength = "32"
    161161               size = "20" onblur = "ec_new_psd_text = this.value; ec_check_pwd_text();"
    162162              />
  • extensions/event_cats/include/evntcats_admin_funcs.inc.php

    r4178 r4179  
    134134  global $page, $ec_lists;
    135135 
    136 /*
    137 
    138 (
    139     [ec_act1] => create
    140     [ec_entry_sel] => -1
    141     [ec_sel_code] => new
    142     [ec_in_up_auto_code_length] => 10
    143     [ec_in_up_code] => 94q0V1067D
    144     [ec_sel_user] => new
    145     [ec_in_up_usr_txt] => san_gimi
    146     [ec_in_up_psd_txt] => 7Mv8QxZV
    147     [ec_in_up_newgroup] => on
    148     [ec_in_up_grp_txt] => EC_san_gimi
    149     [ec_input_action] => cat
    150     [ec_in_up_cat] => 6
    151     [ec_in_up_img] =>
    152 )
    153 
    154 (
    155     [ec_act1] => create
    156     [ec_entry_sel] => -1
    157     [ec_sel_code] => new
    158     [ec_in_up_auto_code_length] => 10
    159     [ec_in_up_code] => NU1pah0qVJ
    160     [ec_in_up_usr_txt] =>
    161     [ec_in_up_psd_txt] =>
    162     [ec_in_up_grp_txt] =>
    163     [ec_sel_user] => old
    164     [ec_in_up_usr_list] => 9
    165     [ec_input_action] => cat
    166     [ec_in_up_cat] => 6
    167     [ec_in_up_img] =>
    168 )
    169 
    170 */
    171136  // $_POST validity checks : creation prevented in case of bad arguments
    172   /* if (
     137  if (
    173138    !isset($_POST['ec_in_up_code']) or
    174139    !ereg('^[a-zA-Z0-9_-]{4,32}$', $_POST['ec_in_up_code'])
     
    188153  if ($_POST['ec_sel_user'] == 'new') {
    189154    if (
    190       !isset($_POST['ec_in_up_usr_txt']) or
    191       $_POST['ec_in_up_usr_txt'] == ''
    192     ) return ec_end1('ec_in_up_usr_txt', 'ec_bad_argument1');
    193     $t1 = (in_array($_POST['ec_in_up_usr_txt'], $ec_lists['user_ids']));
    194     if ($t1) return ec_end1('ec_in_up_usr_txt', 'ec_bad_argument3');
     155      !isset($_POST['login']) or
     156      $_POST['login'] == ''
     157    ) return ec_end1('login', 'ec_bad_argument1');
     158    if (in_array($_POST['login'], $ec_lists['user_ids']))
     159     return ec_end1('login', 'ec_bad_argument3');
    195160  }
    196161  else {
    197162    if (!isset($_POST['ec_in_up_usr_list']))
    198      return ec_end1('ec_in_up_usr_txt', 'ec_bad_argument1');
     163     return ec_end1('login', 'ec_bad_argument1');
    199164    $ec_user_id = $_POST['ec_in_up_usr_list'];
    200     $t1 = (array_key_exists($ec_user_id, $ec_lists['user_ids']));
    201     if (!$t1) return ec_end1('ec_in_up_usr_list', 'ec_bad_argument6');
     165    if (!array_key_exists($ec_user_id, $ec_lists['user_ids']))
     166    return ec_end1('ec_in_up_usr_list', 'ec_bad_argument6');
    202167  }
    203168 
     
    207172    // User creation, as generic
    208173    $page['errors'] = register_user(
    209      $_POST['ec_in_up_usr_txt'], $_POST['ec_in_up_psd_txt'], '', false
     174     $_POST['login'], $_POST['password'], '', false
    210175    );
    211176    if (
    212177      count($page['errors']) != 0 or
    213       !($ec_user_id = get_userid($_POST['ec_in_up_usr_txt']))
     178      !($ec_user_id = get_userid($_POST['login']))
    214179    ) {
    215180      array_unshift($page['errors'], l10n('ec_user_create_pb'));
     
    217182    }
    218183    else
    219      $page['infos'][] = l10n('ec_user_create_OK').$_POST['ec_in_up_usr_txt'];
     184     $page['infos'][] = l10n('ec_user_create_OK').$_POST['login'];
    220185    if (
    221186      pwg_query("
     
    225190      ") !== false
    226191    )
    227      $page['infos'][] = l10n('ec_user_generic_OK').$_POST['ec_in_up_usr_txt'];
     192     $page['infos'][] = l10n('ec_user_generic_OK').$_POST['login'];
    228193    else
    229      $page['errors'][] =l10n('ec_user_generic_pb').$_POST['ec_in_up_usr_txt'];
     194     $page['errors'][] =l10n('ec_user_generic_pb').$_POST['login'];
    230195   
    231196    // New group creation if required,
     
    256221      if (
    257222        pwg_query("
    258           INSERT INTO `".USER_GROUP_TABLE."` (`user_id `, `group_id`)
    259           VALUES ('".$ec_user_id."', '".$t3['id']."');
     223          INSERT INTO `".USER_GROUP_TABLE."` (`user_id`, `group_id`)
     224          VALUES ('".$ec_user_id."', '".$t3[0]."');
    260225        ") === false
    261       ) $page['errors'][] = ;
     226      ) $page['errors'][] =
    262227       l10n('ec_group_create_pb').' (2) ; '.
    263228       'MySQL error '.mysql_errno().', "'.mysql_error().'"';
    264229      else
    265230       $page['infos'][] =
    266         $_POST['ec_in_up_usr_txt'].
     231        $_POST['login'].
    267232        l10n('ec_group_create_OK2').
    268233        $_POST['ec_in_up_grp_txt']
     
    271236  }
    272237 
    273   // Creation of new line in DB event_cats table with all arguments
     238  // Preparation of $arg1, $arg2 and $forced
    274239  $arg1 = ''; $arg2 = '';
    275240  if (isset($_POST['ec_input_action'])) switch ($_POST['ec_input_action']) {
     
    282247    case 'img':   // Image
    283248      if (isset($_POST['ec_in_up_cat'])) {
    284         $arg2 = $_POST['ec_in_up_cat'];
     249        $arg1 = $_POST['ec_in_up_cat'];
    285250        if ($_POST['ec_input_action'] == 'img') {
    286251          if (isset($_POST['ec_in_up_img'])) $arg2 = $_POST['ec_in_up_img'];
     
    290255      else ec_end1('ec_in_up_cat', 'ec_bad_argument1');
    291256    break;
    292     default : ec_end1('ec_input_action', 'ec_bad_argument1');
     257    default: ec_end1('ec_input_action', 'ec_bad_argument1');
    293258  }
    294259  else ec_end1('ec_input_action', 'ec_bad_argument1');
    295  
    296   $forced = (isset($_POST['[ec_in_up_forced]'])) ? 'true' : 'false';
     260  $forced = (isset($_POST['ec_in_up_forced'])) ? 'true' : 'false';
    297261 
    298262  // Now we have the code, the user_id, arg1, arg2, and forced arguments
    299   */
     263  if (
     264    pwg_query("
     265      INSERT INTO `".EVNTCATS_TABLE."` (
     266        `code`,
     267        `user_id`,
     268        `action`,
     269        `arg1`, `arg2`, `forced`
     270      )
     271      VALUES (
     272        '".$_POST['ec_in_up_code']."',
     273        '".$ec_user_id."',
     274        'ec_ok',
     275        '".$arg1."', '".$arg2."', '".$forced."'
     276      );
     277    ") === false
     278  ) {
     279    $page['errors'][] =
     280     l10n('ec_entry_create_pb').
     281     'MySQL error '.mysql_errno().', "'.mysql_error().'"'
     282    ;
     283    return false;
     284  }
     285  else {
     286    build_ec_lists();
     287    $forced = ($forced == 'false') ? '' : l10n('ec_cnfrm_forced');
     288    $page['infos'][] =
     289     l10n('ec_entry_create_OK').mysql_insert_id().' : '.
     290     $_POST['ec_in_up_code'].' => '.
     291     $ec_lists['user_ids'][$ec_user_id].$forced
     292    ;
     293    return true;
     294  }
     295  /*
    300296 
    301297  $page['errors'][] = 'Y\'a p\'têt\' ben eu une erreur...';
     298 
     299   */
    302300}
    303301
     
    342340      default: return ec_end1('ec_input_action', 'ec_bad_argument1');
    343341    }
    344     if (pwg_query("
    345       INSERT INTO `".EVNTCATS_TABLE."`
    346        (`code`, `user_id`, `action`, `arg1`, `arg2`)
    347       VALUES (
    348         '".$ec_lists['ec_table'][$_POST['ec_entry_sel']]['code']."',
    349         '".$ec_lists['ec_table'][$_POST['ec_entry_sel']]['user_id']."',
    350         'ec_ok',
    351         '".$arg1."',
    352         '".$arg2."'
    353       );
    354     ")) {
     342    if (
     343      pwg_query("
     344        INSERT INTO `".EVNTCATS_TABLE."`
     345         (`code`, `user_id`, `action`, `arg1`, `arg2`)
     346        VALUES (
     347          '".$ec_lists['ec_table'][$_POST['ec_entry_sel']]['code']."',
     348          '".$ec_lists['ec_table'][$_POST['ec_entry_sel']]['user_id']."',
     349          'ec_ok',
     350          '".$arg1."',
     351          '".$arg2."'
     352        );
     353      ") === false
     354    ) {
     355      $page['errors'][] =
     356       l10n('ec_entry_dup_nok_pre1').
     357       $_POST['ec_entry_sel'].
     358       l10n('ec_entry_dup_nok_end1').
     359       'MySQL error '.mysql_errno().', "'.mysql_error().'"'
     360      ;
     361      return false;
     362    }
     363    else {
    355364      $page['infos'][] =
    356365       l10n('ec_entry_dup_ok_pre').
     
    361370      build_ec_table();
    362371      return true;
    363     }
    364     else {
    365       $page['errors'][] =
    366        l10n('ec_entry_dup_nok_pre1').
    367        $_POST['ec_entry_sel'].
    368        l10n('ec_entry_dup_nok_end1').
    369        'MySQL error '.mysql_errno().', "'.mysql_error().'"'
    370       ;
    371       return false;
    372372    }
    373373  }
  • extensions/event_cats/include/evntcats_main_funcs.inc.php

    r4173 r4179  
    211211      )) - 1;
    212212      $ec_lists['ec_table'][$ec_current_entry]['id'] = $ec_current_entry;
    213       if (isset($conf['prior_page'])) {
    214         if (array_key_exists($ec_current_code, $conf['prior_page'])) {
    215           $ec_lists['ec_table'][$ec_current_entry]['arg2'] =
    216            $conf['prior_page'][$ec_current_code];
    217           $ec_lists['ec_table'][$ec_current_entry]['forced'] = 'true';
    218         }
     213      if (isset($conf['prior_page']))
     214       if (array_key_exists($ec_current_code, $conf['prior_page'])) {
     215         $ec_lists['ec_table'][$ec_current_entry]['arg2'] =
     216          $conf['prior_page'][$ec_current_code];
     217         $ec_lists['ec_table'][$ec_current_entry]['forced'] = 'true';
     218       }
     219      if (isset($conf['outdated_page']))
     220       if (array_key_exists($ec_current_code, $conf['outdated_page'])) {
     221         $ec_lists['ec_table'][$ec_current_entry]['action'] = 'ec_nok';
     222         $ec_lists['ec_table'][$ec_current_entry]['arg2'] =
     223          $conf['outdated_page'][$ec_current_code];
     224         $ec_lists['ec_table'][$ec_current_entry]['forced'] = 'true';
     225       }
     226    }
     227   
     228    // Inspection of $conf['outdated_page']
     229    if (isset($conf['outdated_page']))
     230     foreach ($conf['outdated_page'] as $ec_current_code => $ec_current_AP)
     231      if (!array_key_exists($ec_current_code, $conf['auto_log'])) {
     232        $ec_current_entry = array_push($ec_lists['ec_table'], array(
     233         'code'    => $ec_current_code,
     234         'user_id' => '',
     235         'action'  => 'ec_nok',
     236         'arg1'    => NULL,
     237         'arg2'    => $ec_current_AP,
     238         'forced'  => 'true',
     239        )) - 1;
     240        $ec_lists['ec_table'][$ec_current_entry]['id'] = $ec_current_entry;
    219241      }
    220       if (isset($conf['outdated_page'])) {
    221         if (array_key_exists($ec_current_code, $conf['outdated_page'])) {
    222           $ec_lists['ec_table'][$ec_current_entry]['action'] = 'ec_nok';
    223           $ec_lists['ec_table'][$ec_current_entry]['arg2'] =
    224            $conf['outdated_page'][$ec_current_code];
    225           $ec_lists['ec_table'][$ec_current_entry]['forced'] = 'true';
    226         }
    227       }
    228     }
    229    
    230     // Inspection of $conf['outdated_page']
    231     if (isset($conf['outdated_page'])) {
    232       foreach ($conf['outdated_page'] as $ec_current_code => $ec_current_AP) {
    233         if (!array_key_exists($ec_current_code, $conf['auto_log'])) {
    234           $ec_current_entry = array_push($ec_lists['ec_table'], array(
    235            'code'    => $ec_current_code,
    236            'user_id' => '',
    237            'action'  => 'ec_nok',
    238            'arg1'    => NULL,
    239            'arg2'    => $ec_current_AP,
    240            'forced'  => 'true',
    241           )) - 1;
    242           $ec_lists['ec_table'][$ec_current_entry]['id'] = $ec_current_entry;
    243         }
    244       }
    245     }
    246242   
    247243  }
    248244  else { // in "normal" use ($conf['auto_log'] NOT set), $ec_lists['ec_table']
    249245         // is built thanks to below code only. A little bit more simple...
    250     $q = pwg_query('
    251      SELECT * FROM `'.EVNTCATS_TABLE.'`
     246    $q = pwg_query("
     247     SELECT * FROM `".EVNTCATS_TABLE."`
    252248     WHERE `code` IS NOT NULL
    253249     ORDER BY `id`
    254     ');
    255     while ($r = mysql_fetch_assoc($q)) {
    256       $ec_lists['ec_table'][intval($r['id'])] = $r;
    257     }
     250    ");
     251    while ($r = mysql_fetch_assoc($q))
     252     $ec_lists['ec_table'][intval($r['id'])] = $r;
    258253  }
    259254 
     
    294289          ) and
    295290          !array_key_exists($ec_entry['arg2'], $ec_lists['add_pages'])
    296         ) {
    297           $ec_entry['action'].= '_ap_pb';
    298         }
     291        ) $ec_entry['action'].= '_ap_pb';
    299292      break;
    300293     
     
    309302            }
    310303          }
    311           else {
    312             $ec_entry['action'].= '_cat_pb';
    313           }
     304          else $ec_entry['action'].= '_cat_pb';
    314305        }
    315306      break;
  • extensions/event_cats/language/fr_FR/plugin.lang.php

    r4178 r4179  
    119119$lang['ec_group_create_OK2']      = ' associé à ';
    120120$lang['ec_group_create_pb']       = 'Création nouveau groupe impossible : ';
     121$lang['ec_entry_create_OK']       = 'Création entrée ';
     122$lang['ec_entry_create_pb']       = 'Création nouvelle entrée impossible : ';
     123$lang['ec_cnfrm_forced']          = ' (affichage forcé)';
    121124$lang['ec_bad_argument1']         = 'Mauvais argument : ';
    122125$lang['ec_bad_argument2']         = 'Code déjà existant : ';
Note: See TracChangeset for help on using the changeset viewer.