Changeset 4115
- Timestamp:
- Oct 26, 2009, 1:36:23 AM (15 years ago)
- Location:
- extensions/event_cats
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/event_cats/admin/autolog_entries.inc.php
r4092 r4115 55 55 56 56 $code_list = array(); 57 build_ec_lists(); // in evntcats_funcs.inc.php58 57 59 58 /**************************************************************** -
extensions/event_cats/admin/autolog_new.inc.php
r4092 r4115 54 54 /****************************************************************************/ 55 55 56 build_ec_lists(); // in evntcats_funcs.php 57 58 $ec_lists['duplicable_codes'] = array(); 59 $t = array(); 60 61 foreach ($ec_lists['ec_table'] as $ec_entry) { 62 if ( 63 is_in($ec_entry['action'], 'ec_ok') and 64 $ec_entry['forced'] == 'false' 65 ) { 66 $t[$ec_entry['id']] = $ec_entry['code']; 67 $ec_lists['duplicable_codes']['codes'][$ec_entry['code']]['id'] = 68 $ec_entry['id']; 69 $ec_lists['duplicable_codes']['codes'][$ec_entry['code']]['user_id'] = 70 $ec_entry['user_id']; 71 } 72 } 73 foreach ($t as $ec_id => $ec_code) { 74 $ec_lists['duplicable_codes']['ids'][$ec_id] = 75 $ec_lists['duplicable_codes']['codes'][$ec_code]['id']; 76 } 77 78 $ec_def_vals = array(); 56 build_ec_duplicable_codes(); 79 57 80 58 $ec_default_action = 'create_ask'; -
extensions/event_cats/admin/evntcats_admin.php
r4092 r4115 76 76 if ($ec_howto) change_ec_conf('howto', '1'); 77 77 78 build_ec_lists(); // in evntcats_funcs.php 79 78 80 // +-----------------------------------------------------------------------+ 79 81 // | Tabsheet … … 105 107 elseif ($_POST['ec_act1'] == 'modify_entry_submit') $page['tab'] = 106 108 (ec_modify_entry_OK()) ? 'autolog_entries' : 'autolog_new'; 109 else { 110 $page['tab'] = 'autolog_entries'; 111 if ($_POST['ec_act1'] == 'delete') ec_delete_entry(); 112 } 107 113 } 108 114 } 109 else if (isset($_GET['tab'])) switch ($_GET['tab']) { 110 case 'autolog_new': 111 case 'duplication': 112 case 'config': 113 $page['tab'] = $_GET['tab']; 115 else { 116 if (isset($_GET['tab'])) switch ($_GET['tab']) { 117 case 'autolog_new': 118 case 'duplication': 119 case 'config': 120 $page['tab'] = $_GET['tab']; 121 } 114 122 } 115 123 -
extensions/event_cats/admin/template/autolog_new.js
r4112 r4115 115 115 ) { 116 116 var t1 = ''; 117 if (ec_id == 'ec_sel_code_old' && ec_selected_old_code == '-1') {117 /* if (ec_id == 'ec_sel_code_old' && ec_selected_old_code == '-1') { 118 118 ec_selected_code = 'ec_sel_code_new'; 119 119 ec_selected_old_code = ec_selected_old_code2; 120 120 } 121 else ec_selected_code = ec_id;121 else */ ec_selected_code = ec_id; 122 122 de(ec_selected_code).checked = 'checked'; 123 123 switch (ec_selected_code) { 124 124 case 'ec_sel_code_new': 125 de('ec_act1_id').value = 'create';125 de('ec_act1_id').value = 'create'; 126 126 de('ec_in_up_code_list_id').selectedIndex = '-1'; 127 de('ec_in_up_code_id').value = ec_new_code_text;128 de('ec_act2_id').value = '-1';127 de('ec_in_up_code_id').value = ec_new_code_text; 128 de('ec_act2_id').value = '-1'; 129 129 break; 130 130 case 'ec_sel_code_old': 131 de('ec_act1_id').value = 132 'duplicate_entry_submit'; 133 de('ec_act2_id').value = 134 ec_selected_old_code; 135 de('ec_in_up_code_list_id').value = 136 ec_selected_old_code; 137 de('ec_in_up_code_id').value = ''; 138 t1 = 'disabled'; 139 ec_selected_old_user = 131 de('ec_act1_id').value = 'duplicate_entry_submit'; 132 de('ec_act2_id').value = ec_selected_old_code; 133 de('ec_in_up_code_list_id').value = ec_selected_old_code; 134 de('ec_in_up_code_id').value = ''; 135 t1 = 'disabled'; 136 ec_selected_user = 'ec_sel_user_old'; 137 ec_selected_old_user = 140 138 d.ec_new_code.ec_in_up_code_list.options[ 141 139 d.ec_new_code.ec_in_up_code_list.selectedIndex 142 140 ].label; 143 de('ec_in_up_usr_list_id').value = ec_selected_old_user;141 ec_flag1 = ec_flag2; 144 142 ec_mark_user('ec_sel_user_old'); 143 ec_flag1 = false; 145 144 break; 146 145 } … … 174 173 de('ec_sel_user_old').disabled == true) 175 174 ) { 176 if (ec_id == 'ec_sel_user_old' && ec_selected_old_user == '-1') {175 /* if (ec_id == 'ec_sel_user_old' && ec_selected_old_user == '-1') { 177 176 ec_selected_user = 178 177 (ec_is_creation) ? 'ec_sel_user_new' : 'ec_sel_user_none'; 179 178 ec_selected_old_user = ec_selected_old_user2; 180 179 } 181 else ec_selected_user = ec_id;180 else */ ec_selected_user = ec_id; 182 181 de(ec_selected_user).checked = 'checked'; 183 182 switch (ec_selected_user) { … … 193 192 if (ec_selected_action == 'ec_input_action_refused') 194 193 ec_selected_action = 'ec_input_action_home'; 195 de('ec_in_up_usr_txt_id').value = 196 ec_new_user_text; 197 de('ec_in_up_psd_txt_id').value = 198 ec_new_psd_text; 194 de('ec_in_up_usr_txt_id').value = ec_new_user_text; 195 de('ec_in_up_psd_txt_id').value = ec_new_psd_text; 199 196 de('ec_in_up_usr_list_id').selectedIndex = '-1'; 200 197 break; … … 635 632 else { // Duplicate entry 636 633 de('ec_act1_id').value = 'duplicate_entry_submit'; 637 /* if (ec_default_entry == '-1')638 de('ec_in_up_code_list_id').selectedIndex = '-1';639 else640 de('ec_in_up_code_list_id').value = ec_default_entry; */641 634 de('ec_submit_gen_full_auto_id').disabled = 'disabled'; 642 635 de('ec_submit_gen_code_id').disabled = 'disabled'; … … 705 698 de('ec_in_up_imgs_id').disabled = 'disabled'; 706 699 de('ec_input_action_home').disabled = 'disabled'; 707 if (ec_default_entry == '-1') 708 de('ec_in_up_entry_list_id').selectedIndex = '-1'; 709 else 710 de('ec_in_up_entry_list_id').value = ec_default_entry; 700 de('ec_in_up_usr_list_id').selectedIndex = '-1'; 701 de('ec_in_up_entry_list_id').value = ec_default_entry; 711 702 } 712 703 ec_default_action = 'modify_entry_ask'; -
extensions/event_cats/admin/template/autolog_new.tpl
r4112 r4115 154 154 </label> 155 155 <span {$ec_hidden_when_no_user} > </span> 156 <label for = "ec_in_up_ code_id" style = "margin:0;">156 <label for = "ec_in_up_usr_txt_id" style = "margin:0;"> 157 157 <input class = "submit" type = "button" name = "ec_submit_gen_user" value = "{'ec_up_code_lbl_gen_user'|@translate}" 158 158 id = "ec_submit_gen_user_id" onclick = "ec_gen_user();" -
extensions/event_cats/include/evntcats_funcs.inc.php
r4092 r4115 32 32 33 33 /* 34 * ec_inspect() 35 * goes through ec_lists['ec_table'] to check errors on (multiple) entries 36 * using the same code. Cannot be used elsewhere than here in 37 * build_ec_table() . 38 * 39 * @param 40 * 41 * @return 42 * (no return value) 43 */ 44 function ec_inspect($checked_item, $new_action, $check_ec_nok = true) { 45 global $ec_lists; 46 $first = array(); 47 $to_correct = array(); 48 49 // $to_correct is needed cause following code would not work everywhere : 50 /* 51 foreach ($table as $value) { 52 if ($value == $value_to_check and $value == $problem) { 53 foreach ($table as &$value2) { // key index of $table can be reset 54 if ($value2 == $value_to_check) { 55 $value2 = $better_value; 56 } 57 } 58 } 59 } 60 // It works with WinAmp Server, but not on Apache server of Free (french 61 // Internet provider). 62 */ 63 64 foreach ($ec_lists['ec_table'] as &$ec_entry) { // & is not really needed 65 $ec_current_code = $ec_entry['code']; 66 if ( 67 $ec_entry['action'] == 'ec_ok' or 68 ($check_ec_nok and $ec_entry['action'] == 'ec_nok') 69 ) { 70 if (isset($first[$ec_current_code])) { 71 // $first[$ec_current_code] is set <=> code has already been met. 72 // Checked item MUST be equal to the first item (thus all items) for 73 // this code. 74 if ( 75 $first[$ec_current_code] != $ec_entry[$checked_item] or 76 ($new_action == '' and $ec_entry[$checked_item] == 'true') 77 ) { 78 $to_correct[$ec_current_code] = true; // value not used in fact 79 } // but using $ec_current_code as a key makes a smaller table 80 } // if the error comes back several times 81 else { 82 $first[$ec_current_code] = $ec_entry[$checked_item]; 83 } 84 } 85 } 86 foreach ($ec_lists['ec_table'] as &$ec_entry) { // & is needed here 87 if (isset($to_correct[$ec_entry['code']])) { 88 if ($new_action == '') { 89 if (!pwg_query(' 90 UPDATE `'.EVNTCATS_TABLE.'` 91 SET `forced` = "false" 92 WHERE `id` = '.$ec_entry['id'] 93 )) die('Could not fix a "_f_pb"'); 94 $ec_entry['forced'] = 'false'; 95 } 96 else $ec_entry['action'] = $new_action; 97 } 98 } 99 } 100 101 /* 34 102 * build_ec_table() 35 103 * builds a table showing the content of the <pwg>_event_cats database table, … … 110 178 // Construction of behaviour 111 179 112 /*113 * ec_inpect()114 * goes through ec_lists['ec_table'] to check errors on (multiple) entries115 * using the same code. Cannot be used elsewhere than here in116 * build_ec_table() .117 *118 * @param119 *120 * @return121 * (no return value)122 */123 function ec_inpect($checked_item, $new_action, $check_ec_nok = true) {124 global $ec_lists;125 $first = array();126 $to_correct = array();127 128 // $to_correct is needed cause following code would not work everywhere :129 /*130 foreach ($table as $value) {131 if ($value == $value_to_check and $value == $problem) {132 foreach ($table as &$value2) { // key index of $table can be reset133 if ($value2 == $value_to_check) {134 $value2 = $better_value;135 }136 }137 }138 }139 // It works with WinAmp Server, but not on Apache server of Free (french140 // Internet provider).141 */142 143 foreach ($ec_lists['ec_table'] as &$ec_entry) { // & is not really needed144 $ec_current_code = $ec_entry['code'];145 if (146 $ec_entry['action'] == 'ec_ok' or147 ($check_ec_nok and $ec_entry['action'] == 'ec_nok')148 ) {149 if (isset($first[$ec_current_code])) {150 // $first[$ec_current_code] is set <=> code has already been met.151 // Checked item MUST be equal to the first item (thus all items) for152 // this code.153 if (154 $first[$ec_current_code] != $ec_entry[$checked_item] or155 ($new_action == '' and $ec_entry[$checked_item] == 'true')156 ) {157 $to_correct[$ec_current_code] = true; // value not used in fact158 } // but using $ec_current_code as a key makes a smaller table159 } // if the error comes back several times160 else {161 $first[$ec_current_code] = $ec_entry[$checked_item];162 }163 }164 }165 foreach ($ec_lists['ec_table'] as &$ec_entry) { // & is needed here166 if (isset($to_correct[$ec_entry['code']])) {167 if ($new_action == '') {168 if (169 pwg_query('170 UPDATE `'.EVNTCATS_TABLE.'`171 SET `forced` = "false"172 WHERE `id` = '.$ec_entry['id']173 ) == null174 ) die('Could not fix a "_f_pb"');175 $ec_entry['forced'] = 'false';176 }177 else $ec_entry['action'] = $new_action;178 }179 }180 }181 182 180 // Multiple action params for a single code check 183 ec_in pect('action', 'ec_nok_action_pb');181 ec_inspect('action', 'ec_nok_action_pb'); 184 182 185 183 // Multiple user_ids for a single code check 186 ec_in pect('user_id', 'ec_nok_userid_pb', false);184 ec_inspect('user_id', 'ec_nok_userid_pb', false); 187 185 188 186 // Multiple "forced" params for a single code check 189 ec_in pect('forced', '');187 ec_inspect('forced', ''); 190 188 191 189 // User id and associated page validities checks … … 226 224 if (array_key_exists($ec_entry['arg1'], $ec_lists['categories'])) { 227 225 if ($a == 3) { // case 3: // Image 228 if (!mysql_fetch_row(pwg_query(' 229 SELECT * 230 FROM `'.IMAGE_CATEGORY_TABLE.'` 231 WHERE `category_id` = '.$ec_entry['arg1'].' 232 AND `image_id` = '.$ec_entry['arg2'] 233 ))) { 226 if (!ec_image_exists($ec_entry['arg1'], $ec_entry['arg2'])) { 234 227 $ec_entry['action'].= '_img_pb'; 235 228 } … … 242 235 break; 243 236 } 237 } 238 } 239 240 /* 241 * build_ec_duplicable_codes() 242 * 243 * 244 * @param 245 * no parameter passed, the main material on which works the function, is 246 * the global array variable $ec_lists. 247 * @return 248 * (no return value) 249 */ 250 function build_ec_duplicable_codes() { 251 global $ec_lists; 252 $ec_lists['duplicable_codes'] = array(); 253 $t = array(); 254 foreach ($ec_lists['ec_table'] as $ec_entry) { 255 if ( 256 is_in($ec_entry['action'], 'ec_ok') and 257 $ec_entry['forced'] == 'false' 258 ) { 259 $t[$ec_entry['id']] = $ec_entry['code']; 260 $ec_lists['duplicable_codes']['codes'][$ec_entry['code']]['id'] = 261 $ec_entry['id']; 262 $ec_lists['duplicable_codes']['codes'][$ec_entry['code']]['user_id'] = 263 $ec_entry['user_id']; 264 } 265 } 266 foreach ($t as $ec_id => $ec_code) { 267 $ec_lists['duplicable_codes']['ids'][$ec_id] = 268 $ec_lists['duplicable_codes']['codes'][$ec_code]['id']; 244 269 } 245 270 } … … 332 357 */ 333 358 function ec_duplicate_entry_OK() { 334 global $page; 335 $page['errors'][] = 'Y\'a sûrement eu une erreur...'; 359 global $page, $ec_lists; 360 361 build_ec_duplicable_codes(); 362 if (array_key_exists($_POST['ec_entry_sel'], 363 $ec_lists['duplicable_codes']['ids'])) { 364 $arg1 = ''; $arg2 = ''; 365 switch ($_POST['ec_input_action']) { 366 case 'add_p': 367 if (array_key_exists($_POST['ec_in_up_aps'], $ec_lists['add_pages'])) { 368 $arg2 = $_POST['ec_in_up_aps']; } 369 else { 370 $page['errors'][] = 371 l10n('ec_bad_argument1'). 372 '$_POST[\'ec_in_up_aps\'] = '. 373 $_POST['ec_in_up_aps'] 374 ; 375 return false; 376 } 377 case 'home': 378 break; 379 case 'img': 380 case 'cat': 381 if (array_key_exists($_POST['ec_in_up_cat'], 382 $ec_lists['categories'])) { 383 if ($_POST['ec_input_action'] == 'img') { 384 if ( 385 ec_image_exists($_POST['ec_in_up_cat'], $_POST['ec_in_up_img']) 386 ) $arg2 = $_POST['ec_in_up_img']; 387 else { 388 $page['errors'][] = 389 l10n('ec_bad_argument1'). 390 '$_POST[\'ec_in_up_img\'] = '. 391 $_POST['ec_in_up_img'] 392 ; 393 return false; 394 } 395 } 396 $arg1 = $_POST['ec_in_up_cat']; 397 } 398 else { 399 $page['errors'][] = 400 l10n('ec_bad_argument1'). 401 '$_POST[\'ec_in_up_cat\'] = '. 402 $_POST['ec_in_up_cat'] 403 ; 404 return false; 405 } 406 break; 407 default: 408 $page['errors'][] = 409 l10n('ec_bad_argument1'). 410 '$_POST[\'ec_input_action\'] = '. 411 $_POST['ec_input_action'] 412 ; 413 return false; 414 } 415 if (pwg_query(" 416 INSERT INTO `".EVNTCATS_TABLE."` 417 (`code`, `user_id`, `action`, `arg1`, `arg2`) 418 VALUES ( 419 '".$ec_lists['ec_table'][$_POST['ec_entry_sel']]['code']."', 420 '".$ec_lists['ec_table'][$_POST['ec_entry_sel']]['user_id']."', 421 'ec_ok', 422 '".$arg1."', 423 '".$arg2."' 424 ); 425 ")) { 426 $page['infos'][] = 427 l10n('ec_entry_dup_ok_pre'). 428 $_POST['ec_entry_sel'].' ('. 429 $ec_lists['ec_table'][$_POST['ec_entry_sel']]['code'].')'. 430 l10n('ec_entry_dup_ok_end') 431 ; 432 build_ec_table(); 433 return true; 434 } 435 else { 436 $page['errors'][] = 437 l10n('ec_entry_dup_nok_pre1'). 438 $_POST['ec_entry_sel']. 439 l10n('ec_entry_dup_nok_end1'). 440 'MySQL error '.mysql_errno().', "'.mysql_error().'"' 441 ; 442 return false; 443 } 444 } 445 else { 446 $page['errors'][] = 447 l10n('ec_bad_argument1'). 448 '$_POST[\'ec_entry_sel\'] = '. 449 $_POST['ec_entry_sel'] 450 ; 451 return false; 452 } 453 $page['errors'][] = '?!'; 336 454 return false; 337 455 } … … 351 469 $page['errors'][] = 'Y\'a pas eu une erreur ?...'; 352 470 return false; 471 } 472 473 /* 474 * ec_delete_entry() 475 * tries to delete an existing entry which # is given by 476 * $_POST['ec_entry_sel']. 477 * 478 * @param 479 * no param 480 * @return 481 * no return value : modifies $page['errors'] or $page['infos'] 482 */ 483 function ec_delete_entry() { 484 global $page, $ec_lists; 485 if (array_key_exists($_POST['ec_entry_sel'], $ec_lists['ec_table'])) { 486 if (!pwg_query(' 487 DELETE FROM `'.EVNTCATS_TABLE.'` 488 WHERE `id` = '.$_POST['ec_entry_sel'] 489 )) { 490 $page['errors'][] = 491 l10n('ec_entry_del_nok_pre'). 492 $_POST['ec_entry_sel']. 493 l10n('ec_entry_del_nok_end'). 494 'MySQL error '.mysql_errno().', "'.mysql_error().'"' 495 ; 496 } 497 else { 498 $page['infos'][] = 499 l10n('ec_entry_del_ok_pre'). 500 $_POST['ec_entry_sel']. 501 l10n('ec_entry_del_ok_end'); 502 build_ec_table(); 503 } 504 } 505 else { 506 $page['errors'][] = 507 l10n('ec_bad_argument1'). 508 '$_POST[\'ec_entry_sel\'] = '. 509 $_POST['ec_entry_sel'] 510 ; 511 } 512 } 513 514 /* 515 * ec_image_exists($cat, $img) 516 * returns true or false whether the image is associated with the category. 517 * 518 * @param 519 * $cat : the category 520 * $img : the image 521 * @return 522 * treu or false whether the image is associated with the category. 523 */ 524 function ec_image_exists($cat, $img) { 525 return (mysql_fetch_row(pwg_query(' 526 SELECT * 527 FROM `'.IMAGE_CATEGORY_TABLE.'` 528 WHERE `category_id` = '.$cat.' 529 AND `image_id` = '.$img 530 )) !== false); 353 531 } 354 532 -
extensions/event_cats/language/fr_FR/plugin.lang.php
r4092 r4115 95 95 $lang['ec_add_page_miss'] = 'page Additional Pages inexistante (probablement supprimée)'; 96 96 $lang['ec_entry_del_nok_pre'] = 'Problème avec suppression entrée '; 97 $lang['ec_entry_del_nok_end'] = ''; 97 $lang['ec_entry_del_nok_end'] = ' : '; 98 $lang['ec_entry_dup_nok_pre1'] = 'Problème avec tentative de rendre périmée entrée '; 99 $lang['ec_entry_dup_nok_end1'] = ' : '; 98 100 $lang['ec_entry_dis_nok_pre1'] = 'Problème avec tentative de rendre périmée entrée '; 99 $lang['ec_entry_dis_nok_end1'] = ' ';101 $lang['ec_entry_dis_nok_end1'] = ' : '; 100 102 $lang['ec_entry_dis_nok_pre2'] = 'Problème avec tentative de rendre périmée entrée '; 101 103 $lang['ec_entry_dis_nok_mid2'] = ' (lié à Add. Page n°'; … … 103 105 $lang['ec_entry_dis_nok_pre3'] = 'Problème avec tentative de rendre périmée entrée '; 104 106 $lang['ec_entry_dis_nok_end3'] = ' (arg1 = NULL)'; 107 $lang['ec_bad_argument1'] = 'Mauvais argument : '; 105 108 // Infos 106 109 $lang['ec_entry_del_ok_pre'] = 'Entrée '; 107 $lang['ec_entry_del_ok_end'] = ' supprimée'; 110 $lang['ec_entry_del_ok_end'] = ' supprimée.'; 111 $lang['ec_entry_dup_ok_pre'] = 'Entrée '; 112 $lang['ec_entry_dup_ok_end'] = ' dupliquée.'; 108 113 $lang['ec_entry_dis_ok_pre1'] = 'Entrée '; 109 114 $lang['ec_entry_dis_ok_end1'] = ' maintenant périmée'; … … 115 120 // actions 116 121 $lang['ec_ok'] = 'OUI'; 117 $lang['ec_ok_ap_pb'] = 'OUI (Add. Page inconnue)';118 $lang['ec_ok_cat_pb'] = 'OUI (catégorie inconnue)';119 $lang['ec_ok_img_pb'] = 'OUI (image inconnue)';122 $lang['ec_ok_ap_pb'] = 'OUI, mais Add. Page inconnue'; 123 $lang['ec_ok_cat_pb'] = 'OUI, mais catégorie inconnue'; 124 $lang['ec_ok_img_pb'] = 'OUI, mais image inconnue'; 120 125 $lang['ec_nok'] = 'NON'; 121 126 $lang['ec_nok_ap_pb'] = 'NON'; 122 $lang['ec_nok_userid_miss'] = 'NON (utilisateur inconnu)';123 $lang['ec_nok_action_pb'] = 'NON ("action" corrompu)';124 $lang['ec_nok_userid_pb'] = 'NON ("user_id" corrompu)';127 $lang['ec_nok_userid_miss'] = 'NON : utilisateur inconnu'; 128 $lang['ec_nok_action_pb'] = 'NON : "action" corrompu'; 129 $lang['ec_nok_userid_pb'] = 'NON : "user_id" corrompu'; 125 130 // Username can't be displayed 126 131 $lang['ec_dspl_nok_actn'] = '"action" inutilisable';
Note: See TracChangeset
for help on using the changeset viewer.