Ignore:
Timestamp:
Nov 16, 2009, 1:26:06 AM (14 years ago)
Author:
LucMorizur
Message:

[Event Cats] Duplication management, add table and begin $_POST analysis

Location:
extensions/event_cats/include
Files:
2 edited

Legend:

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

    r4221 r4276  
    376376  "
    377377    SELECT `id`
    378     FROM `".EVNTCATS_TABLE."`
     378    FROM `".EVNTCATS_AUTOLOG_TABLE."`
    379379    WHERE `code`    = '".$ec_code."'
    380380      AND `user_id`    ".$ec_user_idp."
     
    393393      $t1 = mysql_fetch_row(pwg_query("
    394394        SELECT `code`
    395         FROM `".EVNTCATS_TABLE."`
     395        FROM `".EVNTCATS_AUTOLOG_TABLE."`
    396396        WHERE `id` = ".$_POST['ec_entry_sel']
    397397      ))) === false
     
    399399    $r = pwg_query("
    400400      SELECT `id`
    401       FROM `".EVNTCATS_TABLE."`
     401      FROM `".EVNTCATS_AUTOLOG_TABLE."`
    402402      WHERE `code` = '".$t1[0]."'
    403403       AND `id` <> ".$_POST['ec_entry_sel']
     
    425425    if (
    426426      pwg_query("
    427         INSERT INTO `".EVNTCATS_TABLE."` (
     427        INSERT INTO `".EVNTCATS_AUTOLOG_TABLE."` (
    428428          `code`,
    429429          `user_id`,
     
    459459    if (
    460460      pwg_query("
    461         UPDATE `".EVNTCATS_TABLE."`
     461        UPDATE `".EVNTCATS_AUTOLOG_TABLE."`
    462462        SET
    463463          `user_id` =  ".$ec_user_id.",
     
    493493  global $page;
    494494  if (!pwg_query("
    495     DELETE FROM `".EVNTCATS_TABLE."`
     495    DELETE FROM `".EVNTCATS_AUTOLOG_TABLE."`
    496496    WHERE `id` = ".$ec_id
    497497  )) {
  • extensions/event_cats/include/evntcats_main_funcs.inc.php

    r4263 r4276  
    155155      if ($new_action == '') {
    156156        if (!pwg_query("
    157           UPDATE `".EVNTCATS_TABLE."`
     157          UPDATE `".EVNTCATS_AUTOLOG_TABLE."`
    158158          SET `forced` = 'false'
    159159          WHERE `id` = ".$ec_entry['id']
     
    247247 
    248248  $q = pwg_query("
    249     SELECT * FROM `".EVNTCATS_TABLE."`
     249    SELECT * FROM `".EVNTCATS_AUTOLOG_TABLE."`
    250250    WHERE `code` IS NOT NULL
    251251    ORDER BY `id`
     
    352352 */
    353353function build_dup_arrays($append_tpl = false) {
    354   global $template, $ec_lists, $conf, $ec_debug;
     354  global $template, $ec_lists, $conf;
    355355 
    356356  if (count($ec_lists['user_ids']) == 0) build_ec_userids();
     
    368368 
    369369  // groups granted to duplication
    370   $group_granted_ids = order_by_name(
     370  $groups_granted_ids = order_by_name(
    371371    array_from_query("
    372       SELECT `arg2`
    373         FROM ".EVNTCATS_TABLE."
    374         WHERE `code` IS NULL
    375           AND `arg1` = '1'
    376           AND `arg2` IS NOT NULL
     372      SELECT `val`
     373        FROM ".EVNTCATS_DUPLIC_TABLE."
     374        WHERE `item` = 'grp'
    377375      ;",
    378       'arg2'
     376      'val'
    379377    ),
    380378    $groups
     
    384382  $users_granted_direct_ids = order_by_name(
    385383    array_from_query("
    386       SELECT `arg2`
    387         FROM ".EVNTCATS_TABLE."
    388         WHERE `code` IS NULL
    389           AND `arg1` = '2'
    390           AND `arg2` IS NOT NULL
     384      SELECT `val`
     385        FROM ".EVNTCATS_DUPLIC_TABLE."
     386        WHERE `item` = 'usr'
    391387      ;",
    392       'arg2'
     388      'val'
    393389    ),
    394390    $ec_lists['user_ids']
     
    398394  // certain group (in groups, level (friends, family, contacts),
    399395  // or user status (generic))
    400   $user_granted_ids = array();
    401 
     396  $users_granted_ids = array();
     397 
    402398  $users_granted_thks_gen_ids = array();
    403   if (read_ec_conf('duplic_gen') != '0') {
     399  if ($ec_gen_granted = (read_ec_conf('duplic_gen') != '0')) {
    404400    $users_granted_thks_gen_ids = order_by_name(
    405401      array_diff(
     
    415411    );
    416412    foreach ($users_granted_thks_gen_ids as $user_id)
    417      $user_granted_ids[$user_id] = l10n('user_status_generic');
    418   } global $ec_debug; $ec_debug['1'] = $user_granted_ids;
    419 
     413     $users_granted_ids[$user_id] = l10n('user_status_generic');
     414  }
     415
     416  $types = array(
     417    '1' => l10n('Level 1'),
     418    '2' => l10n('Level 2'),
     419    '4' => l10n('Level 4'),
     420  );
     421  $types_granted_ids = array();
    420422  $users_granted_thks_types_ids = array();
    421423  $c = intval(read_ec_conf('duplic_type'));
    422424  if ($c != 0) {
    423     $t = array();
    424     if (($c & 1) != 0) $t[] = '1';
    425     if (($c & 2) != 0) $t[] = '2';
    426     if (($c & 4) != 0) $t[] = '4';
    427     if (count($t) > 0) {
    428       $types = array(
    429         '1' => l10n('Level 1'),
    430         '2' => l10n('Level 2'),
    431         '4' => l10n('Level 4'),
    432       );
     425    if (($c & 1) != 0) $types_granted_ids[] = '1';
     426    if (($c & 2) != 0) $types_granted_ids[] = '2';
     427    if (($c & 4) != 0) $types_granted_ids[] = '4';
     428    if (count($types_granted_ids) > 0) {
    433429      $user_granted_from_type = array();
    434430      $result = pwg_query("
    435431        SELECT `user_id`, `level`
    436432        FROM `".USER_INFOS_TABLE."`
    437         WHERE `level` IN (".implode(',', $t).");
     433        WHERE `level` IN (".implode(',', $types_granted_ids).");
    438434      ");
    439435      while ($row = mysql_fetch_array($result)) {
     
    459455       foreach ($user_granted_from_type as $type_id => $type_users) {
    460456        if (in_array($user_id, $type_users)) {
    461           $user_granted_ids[$user_id]= $types[$type_id];
     457          $users_granted_ids[$user_id]= $types[$type_id];
    462458          break;
    463459        }
    464460       }
    465461    }
    466   } $ec_debug['2'] = $user_granted_ids;
     462  }
    467463
    468464  $users_granted_thks_groups_ids = array();
    469   if (count($group_granted_ids) > 0) {
     465  if (count($groups_granted_ids) > 0) {
    470466    $granted_groups = array();
    471467
     
    473469      SELECT `user_id`, `group_id`
    474470      FROM `".USER_GROUP_TABLE."`
    475       WHERE `group_id` IN (".implode(',', $group_granted_ids).");
     471      WHERE `group_id` IN (".implode(',', $groups_granted_ids).");
    476472    ");
    477473    while ($row = mysql_fetch_array($result)) {
     
    499495     foreach ($granted_groups as $group_id => $group_users)
    500496      if (in_array($user_id, $group_users)) {
    501         $user_granted_ids[$user_id]= $groups[$group_id];
     497        $users_granted_ids[$user_id]= $groups[$group_id];
    502498        break;
    503499      }
    504500   
    505   } $ec_debug['3'] = $user_granted_ids;
     501  }
    506502
    507503  if ($append_tpl) {
    508     $user_denied_ids = order_by_name(
     504    $users_denied_ids = order_by_name(
    509505      array_diff(
    510506        array_keys($ec_lists['user_ids']),
     
    517513    );
    518514   
    519     foreach ($user_granted_ids as $u => $g) $template->append(
     515    foreach ($users_granted_ids as $u => $g) $template->append(
    520516      'user_granted_indirects',
    521517      array(
     
    525521    );
    526522   
    527     $ec_debug['4'] = $user_granted_ids;
    528523    $template->assign('all_groups', $groups);
    529     $template->assign('group_granted_ids', $group_granted_ids);
    530     $template->assign('group_denied_ids',order_by_name(
    531       array_diff(array_keys($groups), $group_granted_ids), $groups
     524    $template->assign('groups_granted_ids', $groups_granted_ids);
     525    $template->assign('groups_denied_ids', order_by_name(
     526      array_diff(array_keys($groups), $groups_granted_ids), $groups
     527    ));
     528    $template->assign('ec_gen_granted', $ec_gen_granted);
     529    $template->assign('all_types', $types);
     530    $template->assign('types_granted_ids', $types_granted_ids);
     531    $template->assign('types_denied_ids', order_by_name(
     532      array_diff(array_keys($types), $types_granted_ids), $types
    532533    ));
    533534    $template->assign('all_users', $ec_lists['user_ids']);
    534535    $template->assign('users_granted_direct_ids', $users_granted_direct_ids);
    535     $template->assign('user_denied_ids', $user_denied_ids);
    536   }
    537    $user_granted_ids = array_merge(
    538     $user_granted_ids,
     536    $template->assign('users_denied_ids', $users_denied_ids);
     537  }
     538  $users_granted_ids = array_merge(
     539    array_keys($users_granted_ids),
    539540    $users_granted_direct_ids
    540    );
    541   return $user_granted_ids;
     541  );
     542 
     543  // Returns an array which values are all the user_ids allowed to display a
     544  // "duplicate" link. The keys of this array are strange (for direct allowed
     545  // users, keys are usernames), but normally not used
     546  return $users_granted_ids;
    542547}
    543548
Note: See TracChangeset for help on using the changeset viewer.