Changeset 4219
- Timestamp:
- Nov 6, 2009, 1:41:47 PM (15 years ago)
- Location:
- extensions/event_cats
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/event_cats/admin/evntcats_admin.php
r4218 r4219 38 38 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 39 39 40 global $template, $conf, $lang, $test1, $prefixeTable, $ec_conf, $page, 40 global $template, $conf, $lang, $test1, $prefixeTable, $ec_conf, $page, $ec_debug, 41 41 $ec_lists, // array of following arrays : 42 42 // $ec_lists['ec_table'] : … … 68 68 EVNTCATS_PATH.'admin/evntcats_theme.css">' 69 69 ); 70 $ec_debug = array(); 70 71 71 72 if ( … … 83 84 // +-----------------------------------------------------------------------+ 84 85 85 $page['tab'] = (!($ec_exist_entries = (mysql_ fetch_row(pwg_query('86 SELECT * FROM ` '.EVNTCATS_TABLE.'`86 $page['tab'] = (!($ec_exist_entries = (mysql_num_rows(pwg_query(" 87 SELECT * FROM `".EVNTCATS_TABLE."` 87 88 WHERE `code` IS NOT NULL 88 '))))) ? 'autolog_new' : 'autolog_entries';89 ")) != 0))) ? 'autolog_new' : 'autolog_entries'; 89 90 90 91 // Rajouter un test pour que si $ec_exist_entries est faux, mais qu'il y a … … 118 119 is_numeric($_POST['ec_entry_sel']) 119 120 ) { 120 if ( 121 $_POST['ec_act1'] == 'duplicate_entry_submit' or 122 $_POST['ec_act1'] == 'modify_entry_submit' 123 ) $page['tab'] = (ec_create_modify_entry_OK()) ? 124 'autolog_entries' : 'autolog_modif'; 121 if ($_POST['ec_act1'] == 'duplicate_entry_submit') $page['tab'] = 122 (ec_create_modify_entry_OK()) ? 'autolog_entries' : 'autolog_new'; 123 elseif ($_POST['ec_act1'] == 'modify_entry_submit') $page['tab'] = 124 (ec_create_modify_entry_OK()) ? 'autolog_entries' : 'autolog_modif'; 125 125 else { 126 126 $page['tab'] = 'autolog_entries'; … … 132 132 else ec_end1('ec_entry_sel', 'ec_bad_argument1'); 133 133 } 134 elseif ($_POST['ec_act1'] == 'toggle_forced') ec_toggle_forced_entry(); 134 else if ($_POST['ec_act1'] == 'toggle_forced') 135 ec_create_modify_entry_OK(); 135 136 } 136 137 } … … 146 147 } 147 148 } 149 150 $ec_exist_entries = (mysql_num_rows(pwg_query(" 151 SELECT * FROM `".EVNTCATS_TABLE."` 152 WHERE `code` IS NOT NULL 153 ")) != 0); 148 154 149 155 $tabsheet = new tabsheet(); … … 196 202 197 203 if (isset($conf['ec_debug1'])) $template->assign('ec_debug1', array( 204 'POST' => str_from_var($_POST), 205 'ec_debug' => (isset($ec_debug)) ? str_from_var($ec_debug) : '(unset)', 198 206 'GET' => str_from_var($_GET), 199 'POST' => str_from_var($_POST),200 207 'page' => str_from_var($page), 201 208 'ec_conf' => str_from_var($ec_conf), -
extensions/event_cats/admin/template/autolog_new.js
r4218 r4219 593 593 } 594 594 if ( 595 de('ec_sel_user_new').checked != '' || ( 596 de('ec_sel_user_old').checked != '' && 597 ec_original_old_user != d.ec_new_code.ec_in_up_usr_list.value 595 ec_original_old_user != '' && ( 596 de('ec_sel_user_new').checked != '' || ( 597 de('ec_sel_user_old').checked != '' && 598 ec_original_old_user != d.ec_new_code.ec_in_up_usr_list.value 599 ) 598 600 ) 599 601 ) if (!confirm(ec_JS_message['ec_confirm_change_user'])) return false; -
extensions/event_cats/include/evntcats_admin_funcs.inc.php
r4218 r4219 201 201 */ 202 202 function ec_create_modify_entry_OK() { 203 global $page, $ec_lists ;203 global $page, $ec_lists, $ec_debug; 204 204 205 205 // $_POST validity checks : action prevented in case of bad arguments … … 208 208 return ec_end1('ec_act1', 'ec_bad_argument1'); 209 209 210 if (!isset($_POST['ec_input_action'])) 211 return ec_end1('ec_input_action', 'ec_bad_argument1'); 210 if ( 211 ($_POST['ec_act1']) != 'toggle_forced' and 212 !isset($_POST['ec_input_action']) 213 ) return ec_end1('ec_input_action', 'ec_bad_argument1'); 212 214 213 215 $is_creation = true; 216 $ec_user_id = 'NULL'; 214 217 $action = 'ec_ok'; 215 $arg1 = ''; 216 $arg2 = ''; 218 $del_other = false; 217 219 switch ($_POST['ec_act1']) { 218 220 … … 238 240 case 'modify_entry_submit': 239 241 240 $ec_user_id = '';241 242 if (isset($_POST['ec_sel_user'])) { 242 243 if ($_POST['ec_sel_user'] == 'new') { … … 259 260 else $action = 'ec_nok'; 260 261 261 if ($_POST['ec_act1'] == 'create') break; 262 263 $is_creation = false; 262 if ($_POST['ec_act1'] == 'create') break; 264 263 265 264 case 'duplicate_entry_submit': … … 270 269 ) return ec_end1('ec_entry_sel', 'ec_bad_argument5'); 271 270 272 if ($_POST['ec_act1'] == 'modify_entry_submit') break; 271 if ($_POST['ec_act1'] == 'modify_entry_submit') if ( 272 !isset($_POST['ec_sel_user']) or ( 273 $_POST['ec_sel_user'] == 'new' or 274 $_POST['ec_sel_user'] == 'none' or ( 275 $_POST['ec_sel_user'] == 'old' and 276 $_POST['ec_in_up_usr_list'] != 277 $ec_lists['ec_table'][$_POST['ec_entry_sel']]['user_id'] 278 ) 279 ) 280 ) $del_other = true; 281 282 case 'toggle_forced': 283 284 $ec_code = $ec_lists['ec_table'][$_POST['ec_entry_sel']]['code']; 285 if ($action == 'ec_ok' and $ec_user_id == 'NULL') 286 $ec_user_id = $ec_lists['ec_table'][$_POST['ec_entry_sel']]['user_id']; 287 $arg1 = $ec_lists['ec_table'][$_POST['ec_entry_sel']]['arg1']; 288 $arg2 = $ec_lists['ec_table'][$_POST['ec_entry_sel']]['arg2']; 289 if (empty($arg1)) $arg1 = 'NULL'; 290 if (empty($arg2)) $arg2 = 'NULL'; 291 if (empty($ec_user_id)) $ec_user_id = 'NULL'; 292 if ($_POST['ec_act1'] == 'toggle_forced') { 293 $forced = ( 294 $ec_lists['ec_table'][$_POST['ec_entry_sel']]['forced'] == 'true' 295 ) ? 'false' : 'true'; 296 $del_other = ($forced == 'true'); 297 $action = $ec_lists['ec_table'][$_POST['ec_entry_sel']]['action']; 298 } 299 300 if ( 301 $_POST['ec_act1'] == 'toggle_forced' or 302 $_POST['ec_act1'] == 'modify_entry_submit' 303 ) { 304 $is_creation = false; 305 break; 306 } 273 307 274 308 build_ec_duplicable_codes(); … … 276 310 $ec_lists['duplicable_codes']['ids']) 277 311 ) return ec_end1('ec_entry_sel', 'ec_bad_argument5'); 278 $ec_code = $ec_lists['ec_table'][$_POST['ec_entry_sel']]['code'];279 $ec_user_id = $ec_lists['ec_table'][$_POST['ec_entry_sel']]['user_id'];280 312 281 313 break; … … 283 315 } 284 316 285 // Preparation of $arg1, $arg2 and $forced 286 switch ($_POST['ec_input_action']) { 287 // case 'home': // Home : nothing to do : "arg"s are '' 288 // case 'refused': $_POST['ec_sel_user'] unset, nothing to do 289 case 'add_p': // Additional Page 290 if (isset($_POST['ec_in_up_aps'])) $arg2 = $_POST['ec_in_up_aps']; 291 else ec_end1('ec_in_up_aps', 'ec_bad_argument1'); 292 break; 293 case 'cat': // Category 294 case 'img': // Image 295 if (isset($_POST['ec_in_up_cat'])) { 296 $arg1 = $_POST['ec_in_up_cat']; 297 if ($_POST['ec_input_action'] == 'img') { 298 if (isset($_POST['ec_in_up_img'])) $arg2 = $_POST['ec_in_up_img']; 299 else ec_end1('ec_in_up_img', 'ec_bad_argument1'); 317 if ($_POST['ec_act1'] != 'toggle_forced') { 318 // Preparation of $arg1, $arg2 319 switch ($_POST['ec_input_action']) { 320 case 'add_p': // Additional Page 321 if (isset($_POST['ec_in_up_aps'])) $arg2 = $_POST['ec_in_up_aps']; 322 else ec_end1('ec_in_up_aps', 'ec_bad_argument1'); 323 $arg1 = 'NULL'; 324 break; 325 case 'cat': // Category 326 case 'img': // Image 327 if (isset($_POST['ec_in_up_cat'])) { 328 $arg1 = $_POST['ec_in_up_cat']; 329 if ($_POST['ec_input_action'] == 'img') { 330 if (isset($_POST['ec_in_up_img'])) $arg2 = $_POST['ec_in_up_img']; 331 else ec_end1('ec_in_up_img', 'ec_bad_argument1'); 332 } 333 else $arg2 = 'NULL'; 300 334 } 301 } 302 else ec_end1('ec_in_up_cat', 'ec_bad_argument1'); 303 break; 304 default: ec_end1('ec_input_action', 'ec_bad_argument1'); 305 } 306 307 if (isset($_POST['ec_in_up_forced'])) { 308 if ($_POST['ec_act1'] == 'duplicate_entry_submit') 309 ec_end1('ec_in_up_forced', 'ec_bad_argument1'); 310 if (!$is_creation) { 311 if ( 312 $t1 = mysql_fetch_row(pwg_query(" 313 SELECT `code` 314 FROM `".EVNTCATS_TABLE."` 315 WHERE `id` = '".$_POST['ec_entry_sel']."' 316 ")) === false 317 ) die('Code not found in DB ?!'); 318 $r = pwg_query(" 319 SELECT `id` 335 else ec_end1('ec_in_up_cat', 'ec_bad_argument1'); 336 break; 337 case 'home': // Home : nothing to do : "arg"s are '' 338 case 'refused': // $_POST['ec_sel_user'] unset, nothing to do 339 $arg1 = 'NULL'; $arg2 = 'NULL'; 340 break; 341 default: ec_end1('ec_input_action', 'ec_bad_argument1'); 342 } 343 344 // Preparation of $forced 345 $forced = (isset($_POST['ec_in_up_forced'])) ? 'true' : 'false'; 346 if ($_POST['ec_act1'] == 'duplicate_entry_submit' and $forced == 'true') 347 return ec_end1('ec_in_up_forced', 'ec_bad_argument1'); 348 349 // User and eventually group creation, if needed 350 if ($_POST['ec_act1'] != 'duplicate_entry_submit') 351 if (isset($_POST['ec_sel_user']) and $_POST['ec_sel_user'] == 'new') 352 if (!($ec_user_id = ec_create_user_OK())) return false; 353 } 354 355 // Now we have all infos : check that future entry doesn't exist already 356 $arg1p = ($arg1 == 'NULL') ? 'IS NULL' : ' = '.$arg1; 357 $arg2p = ($arg2 == 'NULL') ? 'IS NULL' : ' = '.$arg2; 358 $ec_user_idp = ($ec_user_id == 'NULL') ? 'IS NULL' : ' = '.$ec_user_id; 359 if (($t1 = mysql_fetch_row(pwg_query(// $q = 360 " 361 SELECT `id` 362 FROM `".EVNTCATS_TABLE."` 363 WHERE `code` = '".$ec_code."' 364 AND `user_id` ".$ec_user_idp." 365 AND `action` = '".$action."' 366 AND `arg1` ".$arg1p." 367 AND `arg2` ".$arg2p." 368 AND `forced` = '".$forced."' 369 "))) !== false) { // print("<pre>$arg1 $arg2<br>$q</pre>"); 370 $page['errors'][] = l10n('ec_entry_already_exists').$t1[0]; 371 return false; 372 } 373 374 // Delete other entries using the same code, if needed 375 if ($del_other) { 376 if (( 377 $t1 = mysql_fetch_row(pwg_query(" 378 SELECT `code` 320 379 FROM `".EVNTCATS_TABLE."` 321 WHERE `code` = '".$t1[0]."' 322 AND `id` <> '".$_POST['ec_entry_sel']."' 323 "); 324 while ($t2 = mysql_fetch_row($r)) if (!ec_delete_entry_OK($t2[0])) 325 return false; 326 } 327 $forced = 'true'; 328 } 329 else $forced = 'false'; 330 331 // User and eventually group creation, if needed 332 if ($_POST['ec_act1'] != 'duplicate_entry_submit') 333 if ($_POST['ec_sel_user'] == 'new') 334 if (!($ec_user_id = ec_create_user_OK())) return false; 335 336 // Now we have all infos 380 WHERE `id` = ".$_POST['ec_entry_sel'] 381 ))) === false 382 ) die('Entry not found in DB ?!'); 383 $r = pwg_query(" 384 SELECT `id` 385 FROM `".EVNTCATS_TABLE."` 386 WHERE `code` = '".$t1[0]."' 387 AND `id` <> ".$_POST['ec_entry_sel'] 388 ); 389 while ($t2 = mysql_fetch_row($r)) if (!ec_delete_entry_OK($t2[0])) 390 return false; 391 } 392 393 $ec_debug[] = array( 394 'del_other' => $del_other, 395 'code' => $ec_code, 396 'user_id' => $ec_user_id, 397 'user_idp' => $ec_user_idp, 398 'action' => $action, 399 'arg1' => $arg1, 400 'arg2' => $arg2, 401 'arg1p' => $arg1p, 402 'arg2p' => $arg2p, 403 'forced' => $forced, 404 ); 405 406 // Action ! 407 $ret = true; 337 408 if ($is_creation) { 338 409 if ( … … 346 417 VALUES ( 347 418 '".$ec_code."', 348 '".$ec_user_id."',419 ".$ec_user_id.", 349 420 '".$action."', 350 '".$arg1."', '".$arg2."', '".$forced."'421 ".$arg1.", ".$arg2.", '".$forced."' 351 422 ); 352 423 ") === false … … 356 427 'MySQL error '.mysql_errno().', "'.mysql_error().'"' 357 428 ; 358 returnfalse;429 $ret = false; 359 430 } 360 431 else { … … 363 434 $page['infos'][] = 364 435 l10n('ec_entry_create_OK').mysql_insert_id().' : '. 365 $ _POST['ec_in_up_code'].' => '.436 $ec_code.' => '. 366 437 $ec_lists['user_ids'][$ec_user_id].$forced 367 438 ; 439 return true; 368 440 } 369 441 } … … 373 445 UPDATE `".EVNTCATS_TABLE."` 374 446 SET 375 `user_id` = '".$ec_user_id."',447 `user_id` = ".$ec_user_id.", 376 448 `action` = '".$action."', 377 `arg1` = '".$arg1."',378 `arg2` = '".$arg2."',449 `arg1` = ".$arg1.", 450 `arg2` = ".$arg2.", 379 451 `forced` = '".$forced."' 380 452 WHERE `id` = '".$_POST['ec_entry_sel']."' … … 385 457 'MySQL error '.mysql_errno().', "'.mysql_error().'"' 386 458 ; 387 return false; 388 } 389 else { 390 $page['infos'][] = l10n('ec_entry_modify_OK').$_POST['ec_entry_sel']; 391 build_ec_lists(); 392 } 393 } 394 return true; 395 } 396 397 /* 398 * ec_toggle_forced_entry() 399 * Toggles the 'forced' property of an entry, provided it complies to the 400 * rules. 401 * 402 * @param 403 * no param 404 * @return 405 * no return value 406 */ 407 function ec_toggle_forced_entry() { 408 global $page; 409 $page['errors'][] = 'ec_toggle_forced_entry'; 459 $ret = false; 460 } 461 else $page['infos'][] = l10n('ec_entry_modify_OK').$_POST['ec_entry_sel']; 462 } 463 build_ec_lists(); 464 return $ret; 410 465 } 411 466 -
extensions/event_cats/include/evntcats_main_funcs.inc.php
r4218 r4219 69 69 FROM `".IMAGE_CATEGORY_TABLE."` 70 70 WHERE `category_id` = ".$cat." 71 AND `image_id` = ".$img ."`72 ")) !== false);71 AND `image_id` = ".$img 72 )) !== false); 73 73 } 74 74 -
extensions/event_cats/language/fr_FR/plugin.lang.php
r4218 r4219 124 124 $lang['ec_cnfrm_forced'] = ' (affichage forcé)'; 125 125 $lang['ec_entry_modify_OK'] = 'Modification entrée '; 126 $lang['ec_entry_already_exists'] = 'Entrée déjà existante : '; 126 127 $lang['ec_bad_argument1'] = 'Mauvais argument : '; 127 128 $lang['ec_bad_argument2'] = 'Code déjà existant : ';
Note: See TracChangeset
for help on using the changeset viewer.