Changeset 4333
- Timestamp:
- Nov 21, 2009, 6:59:31 PM (15 years ago)
- Location:
- extensions/event_cats
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/event_cats/admin/evntcats_admin.php
r4329 r4333 77 77 build_ec_lists(); // in evntcats_main_funcs.php 78 78 79 $dup_types_exist = false; 80 $dup_entries_exist = false; 81 $ec_exist_entries = false; 82 function check_DB() { 83 global $dup_types_exist, $dup_entries_exist, $ec_exist_entries, $ec_lists; 84 85 $dup_types_exist = build_dup_groups(); // build_dup_groups() returns 86 // true if an entry exists for duplication management for types 87 88 // both arrays below are built when executing build_dup_groups() function 89 $dup_entries_exist = ( 90 $dup_types_exist or 91 count($ec_lists['groups_granted_ids']) > 0 or 92 count($ec_lists['users_granted_direct_ids']) > 0 93 ); 94 95 $ec_exist_entries = (mysql_num_rows(pwg_query(" 96 SELECT * FROM `".EVNTCATS_TABLE."` 97 WHERE `code` IS NOT NULL ; 98 ")) != 0); 99 } 100 101 check_DB(); 102 79 103 // If no entry exist, default tab is 'autolog_new'. 80 $page['tab'] = (!($ec_exist_entries = (mysql_num_rows(pwg_query(" 81 SELECT * FROM `".EVNTCATS_TABLE."` 82 WHERE `code` IS NOT NULL ; 83 ")) != 0))) ? 'autolog_new' : 'autolog_entries'; 84 85 // If no entry exist, but some duplication management entries exist, default 86 // tab is 'duplication'. 87 if (!$ec_exist_entries and read_ec_conf('dup_allow') == '2') $page['tab'] = 'duplication'; 104 $page['tab'] = (!$ec_exist_entries) ? 'autolog_new' : 'autolog_entries'; 105 106 // If no entry exist, but some duplication management entries exist, and 107 // duplication setting is "managed per groups", default tab is 'duplication' 108 if ( 109 !$ec_exist_entries and 110 read_ec_conf('dup_allow') == '2' and 111 $dup_entries_exist 112 ) $page['tab'] = 'duplication'; 88 113 89 114 // If a modification of duplication management has been posted, default tab … … 166 191 ) 167 192 ) { 168 $c = ($no_previous = (count($t = mysql_fetch_row(pwg_query(" 169 SELECT `arg2` 170 FROM `".EVNTCATS_TABLE."` 171 WHERE `code` IS NULL 172 AND `arg1` = 3 173 AND `arg2` IS NOT NULL 174 LIMIT 1; 175 "))) == 0)) ? 0 : intval($t[0]); 193 $c = $ec_lists['types_granted']; 176 194 if (isset($_POST['deny_types'])) 177 195 foreach ($_POST['deny_types'] as $v) $c = $c & ~$v; 178 196 if (isset($_POST['deny_generic'])) $c = $c & 7; 179 $q = ($no_previous) ? " 180 INSERT INTO `".EVNTCATS_TABLE."` 181 (`arg1`, `arg2`) 182 VALUES (3, $c); 183 " : " 197 $q = ($dup_types_exist) ? " 184 198 UPDATE `".EVNTCATS_TABLE."` 185 199 SET `arg2` = $c 186 200 WHERE `arg1` = 3 187 201 LIMIT 1 ; 202 " : " 203 INSERT INTO `".EVNTCATS_TABLE."` 204 (`arg1`, `arg2`) 205 VALUES (3, $c); 188 206 "; 189 207 if (pwg_query($q) === false) ec_end2(3); … … 197 215 ) 198 216 ) { 199 $c = ($no_previous = (count($t = mysql_fetch_row(pwg_query(" 200 SELECT `arg2` 201 FROM `".EVNTCATS_TABLE."` 202 WHERE `code` IS NULL 203 AND `arg1` = 3 204 AND `arg2` IS NOT NULL 205 LIMIT 1; 206 "))) == 0)) ? 0 : intval($t[0]); 217 $c = $ec_lists['types_granted']; 207 218 if (isset($_POST['grant_types'])) 208 219 foreach ($_POST['grant_types'] as $v) $c = $c | $v; 209 220 if (isset($_POST['grant_generic'])) $c = $c | 8; 210 $q = ($no_previous) ? " 211 INSERT INTO `".EVNTCATS_TABLE."` 212 (`arg1`, `arg2`) 213 VALUES (3, $c); 214 " : " 221 $q = ($dup_types_exist) ? " 215 222 UPDATE `".EVNTCATS_TABLE."` 216 223 SET `arg2` = $c 217 224 WHERE `arg1` = 3 218 225 LIMIT 1 ; 226 " : " 227 INSERT INTO `".EVNTCATS_TABLE."` 228 (`arg1`, `arg2`) 229 VALUES (3, $c); 219 230 "; 220 231 if (pwg_query($q) === false) ec_end2(4); … … 309 320 // +-----------------------------------------------------------------------+ 310 321 311 $ec_exist_entries = (mysql_num_rows(pwg_query(" 312 SELECT * FROM `".EVNTCATS_TABLE."` 313 WHERE `code` IS NOT NULL 314 ")) != 0); 315 322 check_DB(); 323 316 324 if ( 317 325 $page['tab'] == 'duplication' and -
extensions/event_cats/include/ec_conf.inc.php
r4329 r4333 22 22 // | USA. | 23 23 // +-----------------------------------------------------------------------+ 24 25 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 24 26 25 27 global $ec_conf, $page, $ec_conf_index, $ec_conf_default, -
extensions/event_cats/include/evntcats_admin_funcs.inc.php
r4329 r4333 31 31 // | Header | 32 32 // +-----------------------------------------------------------------------+ 33 34 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 33 35 34 36 global $conf, $page; -
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.