Ignore:
Timestamp:
Nov 21, 2009, 6:59:31 PM (15 years ago)
Author:
LucMorizur
Message:

[Event Cats] Remove bug types could not be granted to duplication when from blank

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/event_cats/include/evntcats_main_funcs.inc.php

    r4329 r4333  
    2222// | USA.                                                                  |
    2323// +-----------------------------------------------------------------------+
     24
     25if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    2426
    2527// ***************************************************************************
     
    311313
    312314/*
    313  * build_ec_lists()
    314  * builds the main array variable contaning all informations for the plugin
     315 * build_dup_groups()
     316 * builds the information telling who is allowed to duplicate
    315317 *
    316318 * @param
     
    320322 *   (no return value)
    321323 */
    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;
     324function build_dup_groups() {
     325  global $ec_lists;
    353326 
    354327  if (count($ec_lists['user_ids']) == 0) build_ec_userids();
    355328 
    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("
    360331    SELECT `id`, `name`
    361332      FROM `".GROUPS_TABLE."`
     
    366337 
    367338  // groups granted to duplication
    368   $groups_granted_ids = order_by_name(
     339  $ec_lists['groups_granted_ids'] = order_by_name(
    369340    array_from_query("
    370341      SELECT `arg2`
     
    376347      'arg2'
    377348    ),
    378     $groups
     349    $ec_lists['groups']
    379350  );
    380351 
    381352  // users directly granted to duplication
    382   $users_granted_direct_ids = order_by_name(
     353  $ec_lists['users_granted_direct_ids'] = order_by_name(
    383354    array_from_query("
    384355      SELECT `arg2`
     
    396367  // certain group (in groups, level (friends, family, contacts),
    397368  // 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("
    401370    SELECT `arg2`
    402371    FROM `".EVNTCATS_TABLE."`
     
    405374      AND `arg2` IS NOT NULL
    406375    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 */
     392function 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 */
     421function 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();
    408430 
    409431  $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)) {
    411433    $users_granted_thks_gen_ids = order_by_name(
    412434      array_diff(
     
    417439          'user_id'
    418440        ),
    419         $users_granted_direct_ids
     441        $ec_lists['users_granted_direct_ids']
    420442      ),
    421443      $ec_lists['user_ids']
     
    432454  $types_granted_ids = array();
    433455  $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';
    438460    if (count($types_granted_ids) > 0) {
    439461      $user_granted_from_type = array();
     
    458480        array_diff(
    459481          array_unique($user_granted_by_type_ids),
    460           $users_granted_direct_ids
     482          $ec_lists['users_granted_direct_ids']
    461483        ),
    462484        $ec_lists['user_ids']
     
    473495
    474496  $users_granted_thks_groups_ids = array();
    475   if (count($groups_granted_ids) > 0) {
     497  if (count($ec_lists['groups_granted_ids']) > 0) {
    476498    $granted_groups = array();
    477499
     
    479501      SELECT `user_id`, `group_id`
    480502      FROM `".USER_GROUP_TABLE."`
    481       WHERE `group_id` IN (".implode(',', $groups_granted_ids).");
     503      WHERE `group_id` IN (".implode(',', $ec_lists['groups_granted_ids']).");
    482504    ");
    483505    while ($row = mysql_fetch_array($result)) {
     
    498520      array_diff(
    499521        array_unique($user_granted_by_group_ids),
    500         $users_granted_direct_ids
     522        $ec_lists['users_granted_direct_ids']
    501523      ),
    502524      $ec_lists['user_ids']
     
    505527     foreach ($granted_groups as $group_id => $group_users)
    506528      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];
    508530        break;
    509531      }
     
    518540        $users_granted_thks_types_ids,
    519541        $users_granted_thks_groups_ids,
    520         $users_granted_direct_ids
     542        $ec_lists['users_granted_direct_ids']
    521543      ),
    522544      $ec_lists['user_ids']
     
    531553    );
    532554   
    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']);
    535557    $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']
    537563    ));
    538564    $template->assign('ec_gen_granted', $ec_gen_granted);
     
    543569    ));
    544570    $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    );
    546575    $template->assign('users_denied_ids', $users_denied_ids);
    547576  }
    548577  $users_granted_ids = array_merge(
    549578    array_keys($users_granted_ids),
    550     $users_granted_direct_ids
     579    $ec_lists['users_granted_direct_ids']
    551580  );
    552581 
Note: See TracChangeset for help on using the changeset viewer.