Changeset 4329 for extensions/event_cats/include
- Timestamp:
- Nov 20, 2009, 10:56:32 PM (14 years ago)
- Location:
- extensions/event_cats/include
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/event_cats/include/ec_conf.inc.php
r4263 r4329 23 23 // +-----------------------------------------------------------------------+ 24 24 25 global $ec_conf, $page, $ec_conf_index; 25 global $ec_conf, $page, $ec_conf_index, $ec_conf_default, 26 $ec_conf_possible_values; 26 27 27 28 // $ec_conf initalization 28 29 30 // $ec_conf has numeric indexes (instead of string keys like 'activated', 31 // 'howto'...) because of its first reading, done with the "explode" function. 32 // It would be very easy to build a string keys indexed array, thanks to 33 // following instructions : 34 /* 35 $t = mysql_fetch_row(pwg_query(" 36 SELECT `value` 37 FROM `".CONFIG_TABLE."` 38 WHERE `param` = 'event_cats'; 39 ")); 40 $ec_conf_temp = explode(',', $t[0]); 41 $ec_conf = array(); $i = 0; 42 foreach ($ec_conf_default as $k => $v) $ec_conf[$k] = ec_conf_temp[$i++]; 43 */ 44 // Though, I prefer to keep $ec_conf with numeric indexes, so to be compelled 45 // to go through function change_ec_conf() to modify ec_conf, and thus update 46 // the DB at the same time. 47 29 48 $ec_conf_default = array( // PLUGIN CONFIGURATION ($ec_conf) : 30 49 // --------------------------------- 31 'activated' // plugin activated 50 'activated' // plugin activated, 0 or 1 32 51 => '0', // 33 52 // 53 'howto' // whether the small aknowledgement message has 54 => '0', // already been displayed, 0 or 1 55 // 34 56 'dup_allow' // duplication allowance : 35 => ' 0', // 0 : no account ;57 => '2', // 0 : no account ; 36 58 // 1 : all accounts ; 37 59 // 2 : specified by group and user ids ; 38 60 // 61 'duplic_display' // duplication link display in the menubar : 62 => '2', // 0 : "Register" for everybody ; 63 // 1 : "Duplicate" for everybody ; 64 // 2 : "Register" only for generic accounts, 65 // "Duplicate" for all other accounts ; 66 // 39 67 'auto_code_dg_nb' // number of digits when creating a new code 40 => '10', // automatically 41 // 42 'duplic_gen' // whether Generic accounts allow to be duplicated 43 => '0', // 44 // 45 'duplic_type' // the kind of account type (Contacts, Friends, 46 => '0', // Family) allowed to duplicate account 47 // 48 'howto' // whether the small aknowledgement message has 49 => '0', // already been displayed 68 => '10', // automatically, several values 50 69 // 51 70 'unknown_code' // what to do in case an unknown code is used with … … 57 76 // 58 77 'unknown_code_ap_id' // the id of the Additional Page which must be used 59 => '0', // in case of usage of an unknow code. 78 => '0', // in case of usage of an unknow code, several vals. 79 ); 80 81 $ec_conf_possible_values = array( 82 'activated' => array('0', '1'), 83 'howto' => array('0', '1'), 84 'dup_allow' => array('0', '1', '2'), 85 'duplic_display' => array('0', '1', '2'), 86 'auto_code_dg_nb' => array( '4', '5', '8', '10', '12', '15', 87 '16', '20', '24', '25', '30', '32'), 88 'unknown_code' => array('0', '1', '2'), 89 'unknown_code_ap_id' => array() 60 90 ); 61 91 … … 101 131 */ 102 132 function change_ec_conf($c, $v) { 103 global $ec_conf, $page, $ec_conf_index ;133 global $ec_conf, $page, $ec_conf_index, $ec_conf_possible_values; 104 134 if (array_key_exists($c, $ec_conf_index)) { 105 $ec_conf[$ec_conf_index[$c]] = $v; 106 return (pwg_query(" 107 UPDATE `".CONFIG_TABLE."` 108 SET `value` = \"".implode(',', $ec_conf)."\" 109 WHERE `param` = 'event_cats'; 110 ") !== false); 135 if ( 136 count($ec_conf_possible_values[$c]) == 0 or 137 in_array($v, $ec_conf_possible_values[$c]) 138 ) { 139 $ec_conf[$ec_conf_index[$c]] = $v; 140 return (pwg_query(" 141 UPDATE `".CONFIG_TABLE."` 142 SET `value` = \"".implode(',', $ec_conf)."\" 143 WHERE `param` = 'event_cats'; 144 ") !== false); 145 } 146 else { 147 $page['errors'][] = 'Bad change_ec_conf value'; 148 return false; 149 } 111 150 } 112 151 else { 113 $page['errors'][] = 'Bad change_ec_conf argument';152 $page['errors'][] = 'Bad change_ec_conf index'; 114 153 return false; 115 154 } … … 130 169 return $ec_conf[$ec_conf_index[$c]]; 131 170 else { 132 $page['errors'][] = 'Bad read_ec_conf argument';171 $page['errors'][] = 'Bad read_ec_conf index'; 133 172 return false; 134 173 } -
extensions/event_cats/include/evntcats_admin_funcs.inc.php
r4282 r4329 63 63 64 64 /* 65 * ec_end2() 66 * Process repetitive task when error in database modifying functions. 67 * 68 * @param 69 * $n : number to display 70 * @return 71 * false as this function is used when there is a problem 72 */ 73 function ec_end2($n) { 74 global $page; 75 $page['errors'][] = 76 sprintf(l10n('ec_DB_problem'), $n). 77 'MySQL error '.mysql_errno().', "'.mysql_error().'"'; 78 return false; 79 } 80 81 /* 65 82 * ec_create_user_OK() 66 83 * Creates new generic user and eventually new group as described in $_POST. … … 92 109 } 93 110 else 94 $page['infos'][] = l10n('ec_user_create_OK').$_POST['login'];111 $page['infos'][] = sprintf(l10n('ec_user_create_OK'), $_POST['login']); 95 112 if ( 96 113 pwg_query(" … … 100 117 ") !== false 101 118 ) 102 $page['infos'][] = l10n('ec_user_generic_OK').$_POST['login'];119 $page['infos'][] = sprintf(l10n('ec_user_generic_OK'), $_POST['login']); 103 120 else 104 $page['errors'][] = l10n('ec_user_generic_pb').$_POST['login'];121 $page['errors'][] = sprintf(l10n('ec_user_generic_pb'), $_POST['login']); 105 122 106 123 // New group creation if required, … … 124 141 "); 125 142 if ($t4) 126 $page['infos'][]=l10n('ec_group_create_OK').$_POST['groupname']; 143 $page['infos'][] = 144 sprintf(l10n('ec_group_create_OK'), $_POST['groupname']); 127 145 if (!$t3) 128 146 $page['errors'][] = 129 l10n('ec_group_create_pb').' (1) ;'.147 sprintf(l10n('ec_group_create_pb'), $_POST['groupname']).' (1) : '. 130 148 'MySQL error '.mysql_errno().', "'.mysql_error().'"'; 131 149 if ( … … 135 153 ") === false 136 154 ) $page['errors'][] = 137 l10n('ec_group_create_pb').' (2) ;'.155 sprintf(l10n('ec_group_create_pb'), $_POST['groupname']).' (2) : '. 138 156 'MySQL error '.mysql_errno().', "'.mysql_error().'"'; 139 else 140 $page['infos'][] = 141 $_POST['login']. 142 l10n('ec_group_create_OK2'). 143 $_POST['groupname'] 144 ; 157 else $page['infos'][] = sprintf( 158 l10n('ec_group_create_OK2'), 159 $_POST['login'], $_POST['groupname'] 160 ); 145 161 } 146 162 return $ec_user_id; … … 206 222 207 223 if (!isset($_POST['ec_act1'])) 208 return ec_end1('ec_act1', ' ec_bad_argument1');224 return ec_end1('ec_act1', 'Bad argument : '); 209 225 210 226 if ( 211 227 ($_POST['ec_act1']) != 'toggle_forced' and 212 228 !isset($_POST['ec_input_action']) 213 ) return ec_end1('ec_input_action', ' ec_bad_argument1');229 ) return ec_end1('ec_input_action', 'Bad argument : '); 214 230 215 231 $is_creation = true; … … 234 250 !isset($_POST['ec_in_up_code']) or 235 251 !ereg('^[a-zA-Z0-9_-]{4,32}$', $_POST['ec_in_up_code']) 236 ) return ec_end1('ec_in_up_code', ' ec_bad_argument7');252 ) return ec_end1('ec_in_up_code', 'Improper code : '); 237 253 else $ec_code = $_POST['ec_in_up_code']; 238 254 239 255 foreach ($ec_lists['ec_table'] as $ec_entry) 240 256 if ($ec_code == $ec_entry['code']) 241 return ec_end1('ec_in_up_code', ' ec_bad_argument2');257 return ec_end1('ec_in_up_code', 'Code already exists : '); 242 258 243 259 if ( … … 246 262 $_POST['ec_sel_user'] != 'old' 247 263 ) 248 ) return ec_end1('ec_sel_user', ' ec_bad_argument1');264 ) return ec_end1('ec_sel_user', 'Bad argument : '); 249 265 250 266 case 'modify_entry_submit': … … 256 272 !isset($_POST['login']) or 257 273 $_POST['login'] == '' 258 ) return ec_end1('login', ' ec_bad_argument1');274 ) return ec_end1('login', 'Bad argument : '); 259 275 if (in_array($_POST['login'], $ec_lists['user_ids'])) 260 return ec_end1('login', ' ec_bad_argument3');276 return ec_end1('login', 'User already exists : '); 261 277 } 262 278 elseif ($_POST['ec_sel_user'] == 'old') { 263 279 if (!isset($_POST['ec_in_up_usr_list'])) 264 return ec_end1('login', ' ec_bad_argument1');280 return ec_end1('login', 'Bad argument : '); 265 281 $ec_user_id = $_POST['ec_in_up_usr_list']; 266 282 if (!array_key_exists($ec_user_id, $ec_lists['user_ids'])) 267 return ec_end1('ec_in_up_usr_list', ' ec_bad_argument6');283 return ec_end1('ec_in_up_usr_list', 'User doesn\'t exist : '); 268 284 } 269 285 else $action = 'ec_nok'; … … 279 295 !isset($_POST['ec_entry_sel']) or 280 296 !array_key_exists($_POST['ec_entry_sel'], $ec_lists['ec_table']) 281 ) return ec_end1('ec_entry_sel', 'ec_bad_argument5'); 297 ) return ec_end1( 298 'ec_entry_sel', 'Code doesn\'t exist or non-duplicable code : ' 299 ); 282 300 283 301 // Other checks for user type and value … … 324 342 if (!array_key_exists($_POST['ec_entry_sel'], 325 343 $ec_lists['duplicable_codes']['ids']) 326 ) return ec_end1('ec_entry_sel', 'ec_bad_argument5'); 344 ) return ec_end1( 345 'ec_entry_sel', 'Code doesn\'t exist or non-duplicable code : ' 346 ); 327 347 328 348 break; 329 default: ec_end1('ec_act1', ' ec_bad_argument1');349 default: ec_end1('ec_act1', 'Bad argument : '); 330 350 } 331 351 // Pfew ! … … 336 356 case 'add_p': // Additional Page 337 357 if (isset($_POST['ec_in_up_aps'])) $arg2 = $_POST['ec_in_up_aps']; 338 else ec_end1('ec_in_up_aps', ' ec_bad_argument1');358 else ec_end1('ec_in_up_aps', 'Bad argument : '); 339 359 $arg1 = 'NULL'; 340 360 break; … … 345 365 if ($_POST['ec_input_action'] == 'img') { 346 366 if (isset($_POST['ec_in_up_img'])) $arg2 = $_POST['ec_in_up_img']; 347 else ec_end1('ec_in_up_img', ' ec_bad_argument1');367 else ec_end1('ec_in_up_img', 'Bad argument : '); 348 368 } 349 369 else $arg2 = 'NULL'; 350 370 } 351 else ec_end1('ec_in_up_cat', ' ec_bad_argument1');371 else ec_end1('ec_in_up_cat', 'Bad argument : '); 352 372 break; 353 373 case 'home': // Home : nothing to do : "arg"s are '' … … 355 375 $arg1 = 'NULL'; $arg2 = 'NULL'; 356 376 break; 357 default: ec_end1('ec_input_action', ' ec_bad_argument1');377 default: ec_end1('ec_input_action', 'Bad argument : '); 358 378 } 359 379 … … 361 381 $forced = (isset($_POST['ec_in_up_forced'])) ? 'true' : 'false'; 362 382 if ($_POST['ec_act1'] == 'duplicate_entry_submit' and $forced == 'true') 363 return ec_end1('ec_in_up_forced', ' ec_bad_argument1');383 return ec_end1('ec_in_up_forced', 'Bad argument : '); 364 384 365 385 // User and eventually group creation, if needed … … 384 404 AND `forced` = '".$forced."' 385 405 "))) !== false) { // print("<pre>$arg1 $arg2<br>$q</pre>"); 386 $page['errors'][] = l10n('ec_entry_already_exists').$t1[0];406 $page['errors'][] = sprintf(l10n('ec_entry_already_exists'), $t1[0]); 387 407 return false; 388 408 } … … 440 460 ) { 441 461 $page['errors'][] = 442 l10n('ec_entry_create_pb'). 462 l10n('ec_entry_create_pb').' : '. 443 463 'MySQL error '.mysql_errno().', "'.mysql_error().'"' 444 464 ; … … 449 469 $forced = ($forced == 'false') ? '' : l10n('ec_cnfrm_forced'); 450 470 $page['infos'][] = 451 l10n('ec_entry_create_OK').mysql_insert_id().' : '.471 sprintf(l10n('ec_entry_create_OK'), mysql_insert_id()).' : '. 452 472 $ec_code.' => '. 453 473 $ec_lists['user_ids'][$ec_user_id].$forced … … 470 490 ) { 471 491 $page['errors'][] = 472 l10n('ec_entry_create_pb'). 492 l10n('ec_entry_create_pb').' : '. 473 493 'MySQL error '.mysql_errno().', "'.mysql_error().'"' 474 494 ; 475 495 $ret = false; 476 496 } 477 else $page['infos'][] = l10n('ec_entry_modify_OK').$_POST['ec_entry_sel']; 497 else $page['infos'][] = sprintf( 498 l10n('ec_entry_modify_OK'), $_POST['ec_entry_sel'] 499 ); 478 500 } 479 501 build_ec_lists(); … … 492 514 function ec_delete_entry_OK($ec_id) { 493 515 global $page; 494 if ( !pwg_query("516 if (pwg_query(" 495 517 DELETE FROM `".EVNTCATS_TABLE."` 496 518 WHERE `id` = ".$ec_id 497 ) ) {519 ) === false) { 498 520 $page['errors'][] = 499 l10n('ec_entry_del_nok_pre'). 500 $ec_id. 501 l10n('ec_entry_del_nok_end'). 521 sprintf(l10n('ec_entry_del_nok'), 522 $ec_id). 502 523 'MySQL error '.mysql_errno().', "'.mysql_error().'"'; 503 524 return false; 504 525 } 505 else $page['infos'][] = 506 l10n('ec_entry_del_ok_pre'). 507 $ec_id. 508 l10n('ec_entry_del_ok_end'); 526 else $page['infos'][] = sprintf(l10n('ec_entry_del_ok'), $ec_id); 509 527 return true; 510 528 } -
extensions/event_cats/include/evntcats_main_funcs.inc.php
r4282 r4329 180 180 */ 181 181 function build_ec_addp() { 182 global $ec_lists , $ec_ap_ok;183 if ( $ec_ap_ok) {182 global $ec_lists; 183 if (EC_AP_OK) { 184 184 $res = pwg_query("SELECT `id`, `title` FROM `".ADD_PAGES_TABLE."`"); 185 185 while ($r = mysql_fetch_assoc($res)) { … … 244 244 */ 245 245 function build_ec_table() { 246 global $ec_lists , $ec_ap_ok;246 global $ec_lists; 247 247 248 248 $q = pwg_query(" … … 287 287 case 2: // Additional Page 288 288 if ( 289 $ec_ap_okand (289 EC_AP_OK and ( 290 290 is_in($ec_entry['action'], 'ec_ok') or 291 291 $ec_entry['action'] == 'ec_nok' … … 322 322 function build_ec_lists() { 323 323 324 global $ec_ap_ok, $template, $ec_lists, $conf;325 326 324 // Construction of $ec_lists['add_pages'] array var 327 325 build_ec_addp(); … … 373 371 FROM ".EVNTCATS_TABLE." 374 372 WHERE `code` IS NULL 375 AND `arg1` = '1'373 AND `arg1` = 1 376 374 AND `arg2` IS NOT NULL 377 375 ;", … … 385 383 array_from_query(" 386 384 SELECT `arg2` 387 FROM ".EVNTCATS_TABLE."385 FROM `".EVNTCATS_TABLE."` 388 386 WHERE `code` IS NULL 389 AND `arg1` = '2'387 AND `arg1` = 2 390 388 AND `arg2` IS NOT NULL 391 389 ;", … … 400 398 $users_granted_ids = array(); 401 399 400 $c = (count($t = mysql_fetch_row(pwg_query(" 401 SELECT `arg2` 402 FROM `".EVNTCATS_TABLE."` 403 WHERE `code` IS NULL 404 AND `arg1` = 3 405 AND `arg2` IS NOT NULL 406 LIMIT 1; 407 "))) == 0) ? 0 : intval($t[0]); 408 402 409 $users_granted_thks_gen_ids = array(); 403 if ($ec_gen_granted = ( read_ec_conf('duplic_gen') != '0')) {410 if ($ec_gen_granted = (($c & 8) != 0)) { 404 411 $users_granted_thks_gen_ids = order_by_name( 405 412 array_diff( … … 425 432 $types_granted_ids = array(); 426 433 $users_granted_thks_types_ids = array(); 427 $c = intval(read_ec_conf('duplic_type')); 428 if ($c != 0) { 434 if (($c & 7) != 0) { 429 435 if (($c & 1) != 0) $types_granted_ids[] = '1'; 430 436 if (($c & 2) != 0) $types_granted_ids[] = '2'; … … 547 553 // Returns an array which values are all the user_ids allowed to display a 548 554 // "duplicate" link. The keys of this array are strange (for direct allowed 549 // users, keys are usernames), but normallynot used555 // users, keys are usernames), but should not used 550 556 return $users_granted_ids; 551 557 } … … 561 567 */ 562 568 function dup_allowed($user_id) { 563 return true;569 return in_array($user_id, build_dup_arrays()); 564 570 } 565 571
Note: See TracChangeset
for help on using the changeset viewer.