- Timestamp:
- Nov 21, 2009, 6:59:31 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/event_cats/include/evntcats_main_funcs.inc.php
r4329 r4333 22 22 // | USA. | 23 23 // +-----------------------------------------------------------------------+ 24 25 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 24 26 25 27 // *************************************************************************** … … 311 313 312 314 /* 313 * build_ ec_lists()314 * builds the main array variable contaning all informations for the plugin315 * build_dup_groups() 316 * builds the information telling who is allowed to duplicate 315 317 * 316 318 * @param … … 320 322 * (no return value) 321 323 */ 322 function build_ec_lists() { 323 324 // Construction of $ec_lists['add_pages'] array var 325 build_ec_addp(); 326 327 // Construction of $ec_lists['categories'] array var 328 build_ec_categories(true); 329 330 // Construction of $ec_lists['user_ids'] array var 331 build_ec_userids(); 332 333 // Construction of $ec_lists['ec_table'] array var 334 build_ec_table(); 335 } 336 337 // +-----------------------------------------------------------------------+ 338 // | Duplication analysis functions | 339 // +-----------------------------------------------------------------------+ 340 341 /* 342 * build_dup_arrays($append_tpl = false) 343 * builds arrays telling which accounts are allowed to display a duplicate 344 * account link. Returns an array of all the user ids allowed to duplicate. 345 * 346 * @param 347 * $append_tpl : tells if $template must be appended with built arrays 348 * @return 349 * (no return value) 350 */ 351 function build_dup_arrays($append_tpl = false) { 352 global $template, $ec_lists, $conf; 324 function build_dup_groups() { 325 global $ec_lists; 353 326 354 327 if (count($ec_lists['user_ids']) == 0) build_ec_userids(); 355 328 356 // A lot of below code has simply been copied from file cat_perm.php . 357 // Many thanks to people who wrote it ! 358 359 $groups = simple_hash_from_query(" 329 // Existing groups (needed later) 330 $ec_lists['groups'] = simple_hash_from_query(" 360 331 SELECT `id`, `name` 361 332 FROM `".GROUPS_TABLE."` … … 366 337 367 338 // groups granted to duplication 368 $ groups_granted_ids= order_by_name(339 $ec_lists['groups_granted_ids'] = order_by_name( 369 340 array_from_query(" 370 341 SELECT `arg2` … … 376 347 'arg2' 377 348 ), 378 $ groups349 $ec_lists['groups'] 379 350 ); 380 351 381 352 // users directly granted to duplication 382 $ users_granted_direct_ids= order_by_name(353 $ec_lists['users_granted_direct_ids'] = order_by_name( 383 354 array_from_query(" 384 355 SELECT `arg2` … … 396 367 // certain group (in groups, level (friends, family, contacts), 397 368 // or user status (generic)) 398 $users_granted_ids = array(); 399 400 $c = (count($t = mysql_fetch_row(pwg_query(" 369 $types_entry_exists = (($t = mysql_fetch_row(pwg_query(" 401 370 SELECT `arg2` 402 371 FROM `".EVNTCATS_TABLE."` … … 405 374 AND `arg2` IS NOT NULL 406 375 LIMIT 1; 407 "))) == 0) ? 0 : intval($t[0]); 376 "))) !== false); 377 $ec_lists['types_granted'] = ($types_entry_exists) ? $t[0] : 0; 378 379 return $types_entry_exists; 380 } 381 382 /* 383 * build_ec_lists() 384 * builds the main array variable contaning all informations for the plugin 385 * 386 * @param 387 * no parameter passed, the main material on which works the function, is 388 * the global array variable $ec_lists. 389 * @return 390 * (no return value) 391 */ 392 function build_ec_lists() { 393 394 // Construction of $ec_lists['add_pages'] array var 395 build_ec_addp(); 396 397 // Construction of $ec_lists['categories'] array var 398 build_ec_categories(true); 399 400 // Construction of $ec_lists['user_ids'] array var 401 build_ec_userids(); 402 403 // Construction of $ec_lists['ec_table'] array var 404 build_ec_table(); 405 } 406 407 // +-----------------------------------------------------------------------+ 408 // | Duplication analysis functions | 409 // +-----------------------------------------------------------------------+ 410 411 /* 412 * build_dup_arrays($append_tpl = false) 413 * builds arrays telling which accounts are allowed to display a duplicate 414 * account link. Returns an array of all the user ids allowed to duplicate. 415 * 416 * @param 417 * $append_tpl : tells if $template must be appended with built arrays 418 * @return 419 * (no return value) 420 */ 421 function build_dup_arrays($append_tpl = false) { 422 global $template, $ec_lists, $conf; 423 424 // A lot of below code has simply been copied from file cat_perm.php . 425 // Many thanks to people who wrote it ! 426 427 build_dup_groups(); 428 429 $users_granted_ids = array(); 408 430 409 431 $users_granted_thks_gen_ids = array(); 410 if ($ec_gen_granted = (($ c& 8) != 0)) {432 if ($ec_gen_granted = (($ec_lists['types_granted'] & 8) != 0)) { 411 433 $users_granted_thks_gen_ids = order_by_name( 412 434 array_diff( … … 417 439 'user_id' 418 440 ), 419 $ users_granted_direct_ids441 $ec_lists['users_granted_direct_ids'] 420 442 ), 421 443 $ec_lists['user_ids'] … … 432 454 $types_granted_ids = array(); 433 455 $users_granted_thks_types_ids = array(); 434 if (($ c& 7) != 0) {435 if (($ c& 1) != 0) $types_granted_ids[] = '1';436 if (($ c& 2) != 0) $types_granted_ids[] = '2';437 if (($ c& 4) != 0) $types_granted_ids[] = '4';456 if (($ec_lists['types_granted'] & 7) != 0) { 457 if (($ec_lists['types_granted'] & 1) != 0) $types_granted_ids[] = '1'; 458 if (($ec_lists['types_granted'] & 2) != 0) $types_granted_ids[] = '2'; 459 if (($ec_lists['types_granted'] & 4) != 0) $types_granted_ids[] = '4'; 438 460 if (count($types_granted_ids) > 0) { 439 461 $user_granted_from_type = array(); … … 458 480 array_diff( 459 481 array_unique($user_granted_by_type_ids), 460 $ users_granted_direct_ids482 $ec_lists['users_granted_direct_ids'] 461 483 ), 462 484 $ec_lists['user_ids'] … … 473 495 474 496 $users_granted_thks_groups_ids = array(); 475 if (count($ groups_granted_ids) > 0) {497 if (count($ec_lists['groups_granted_ids']) > 0) { 476 498 $granted_groups = array(); 477 499 … … 479 501 SELECT `user_id`, `group_id` 480 502 FROM `".USER_GROUP_TABLE."` 481 WHERE `group_id` IN (".implode(',', $ groups_granted_ids).");503 WHERE `group_id` IN (".implode(',', $ec_lists['groups_granted_ids'])."); 482 504 "); 483 505 while ($row = mysql_fetch_array($result)) { … … 498 520 array_diff( 499 521 array_unique($user_granted_by_group_ids), 500 $ users_granted_direct_ids522 $ec_lists['users_granted_direct_ids'] 501 523 ), 502 524 $ec_lists['user_ids'] … … 505 527 foreach ($granted_groups as $group_id => $group_users) 506 528 if (in_array($user_id, $group_users)) { 507 $users_granted_ids[$user_id]= $ groups[$group_id];529 $users_granted_ids[$user_id]= $ec_lists['groups'][$group_id]; 508 530 break; 509 531 } … … 518 540 $users_granted_thks_types_ids, 519 541 $users_granted_thks_groups_ids, 520 $ users_granted_direct_ids542 $ec_lists['users_granted_direct_ids'] 521 543 ), 522 544 $ec_lists['user_ids'] … … 531 553 ); 532 554 533 $template->assign('all_groups', $ groups);534 $template->assign('groups_granted_ids', $ groups_granted_ids);555 $template->assign('all_groups', $ec_lists['groups']); 556 $template->assign('groups_granted_ids', $ec_lists['groups_granted_ids']); 535 557 $template->assign('groups_denied_ids', order_by_name( 536 array_diff(array_keys($groups), $groups_granted_ids), $groups 558 array_diff( 559 array_keys($ec_lists['groups']), 560 $ec_lists['groups_granted_ids'] 561 ), 562 $ec_lists['groups'] 537 563 )); 538 564 $template->assign('ec_gen_granted', $ec_gen_granted); … … 543 569 )); 544 570 $template->assign('all_users', $ec_lists['user_ids']); 545 $template->assign('users_granted_direct_ids', $users_granted_direct_ids); 571 $template->assign( 572 'users_granted_direct_ids', 573 $ec_lists['users_granted_direct_ids'] 574 ); 546 575 $template->assign('users_denied_ids', $users_denied_ids); 547 576 } 548 577 $users_granted_ids = array_merge( 549 578 array_keys($users_granted_ids), 550 $ users_granted_direct_ids579 $ec_lists['users_granted_direct_ids'] 551 580 ); 552 581
Note: See TracChangeset
for help on using the changeset viewer.