Ignore:
Timestamp:
Nov 21, 2009, 6:59:31 PM (14 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/admin/evntcats_admin.php

    r4329 r4333  
    7777build_ec_lists(); // in evntcats_main_funcs.php
    7878
     79$dup_types_exist = false;
     80$dup_entries_exist = false;
     81$ec_exist_entries = false;
     82function 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
     101check_DB();
     102
    79103// 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'
     108if (
     109  !$ec_exist_entries and
     110  read_ec_conf('dup_allow') == '2' and
     111  $dup_entries_exist
     112) $page['tab'] = 'duplication';
    88113
    89114// If a modification of duplication management has been posted, default tab
     
    166191  )
    167192) {
    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'];
    176194  if (isset($_POST['deny_types']))
    177195   foreach ($_POST['deny_types'] as $v) $c = $c & ~$v;
    178196  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) ? "
    184198    UPDATE `".EVNTCATS_TABLE."`
    185199    SET `arg2` = $c
    186200    WHERE `arg1` = 3
    187201    LIMIT 1 ;
     202  " : "
     203    INSERT INTO `".EVNTCATS_TABLE."`
     204    (`arg1`, `arg2`)
     205    VALUES (3, $c);
    188206  ";
    189207  if (pwg_query($q) === false) ec_end2(3);
     
    197215  )
    198216) {
    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'];
    207218  if (isset($_POST['grant_types']))
    208219   foreach ($_POST['grant_types'] as $v) $c = $c | $v;
    209220  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) ? "
    215222    UPDATE `".EVNTCATS_TABLE."`
    216223    SET `arg2` = $c
    217224    WHERE `arg1` = 3
    218225    LIMIT 1 ;
     226  " : "
     227    INSERT INTO `".EVNTCATS_TABLE."`
     228    (`arg1`, `arg2`)
     229    VALUES (3, $c);
    219230  ";
    220231  if (pwg_query($q) === false) ec_end2(4);
     
    309320// +-----------------------------------------------------------------------+
    310321
    311 $ec_exist_entries = (mysql_num_rows(pwg_query("
    312   SELECT * FROM `".EVNTCATS_TABLE."`
    313   WHERE `code` IS NOT NULL
    314 ")) != 0);
    315 
     322check_DB();
     323 
    316324if (
    317325  $page['tab'] == 'duplication' and
Note: See TracChangeset for help on using the changeset viewer.