Ignore:
Timestamp:
Dec 3, 2009, 10:01:37 PM (14 years ago)
Author:
LucMorizur
Message:

[Event Cats] Adaptation for PEM

Location:
extensions/event_cats/include
Files:
2 edited

Legend:

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

    r4333 r4418  
    7979  'unknown_code_ap_id'    // the id of the Additional Page which must be used
    8080    => '0',               // in case of usage of an unknow code, several vals.
     81                          //
     82  'comment_display'       // the way the comment is displayed in "entries"
     83    => '0',               // tab : 0, as tooltip ; 1, on a line under code
    8184);
    8285
     
    8992                                '16', '20', '24', '25', '30', '32'),
    9093  'unknown_code'       => array('0', '1', '2'),
    91   'unknown_code_ap_id' => array()
     94  'unknown_code_ap_id' => array(),
     95  'comment_display'    => array('0', '1')
    9296);
    9397
  • extensions/event_cats/include/evntcats_admin_funcs.inc.php

    r4333 r4418  
    9797  // This function assumes that the validity of the different indexes of
    9898  // $_POST it uses, have already been checked.
     99 
     100  // Check if a category id has been posted, and if yes if this category is
     101  // private.
     102  /* $cat_assoc_needed = (
     103  ); */
     104 
     105  // Check if an add. p. id has been posted, and if yes if this add. p. is
     106  // private.
     107  /* $ap_assoc_needed = (
     108  ); */
    99109 
    100110  // User creation, as generic
     
    161171      $_POST['login'], $_POST['groupname']
    162172    );
     173   
     174    // If a category id has been posted, the newly created group must be
     175    // allowed to navigate in this category
     176   
     177    /*
     178   
     179    if (isset($_POST['ec_in_up_cat'])) {
     180      if (mysql_num_rows(pwg_query("
     181        SELECT `id`
     182        FROM `".CATEGORIES_TABLE."`
     183        WHERE `id` = '".$_POST['ec_in_up_cat']."';
     184      ")) == 0) return ec_end1('ec_in_up_cat', 'Category doesn\'t exist : ');
     185      else {
     186   
     187  $query = '
     188SELECT id
     189  FROM '.CATEGORIES_TABLE.'
     190  WHERE id IN ('.implode(',', get_uppercat_ids(array($page['cat']))).')
     191  AND status = \'private\'
     192;';
     193  $private_uppercats = array_from_query($query, 'id');
     194
     195  // We must not reinsert already existing lines in group_access table
     196  $granteds = array();
     197  foreach ($private_uppercats as $cat_id)
     198  {
     199    $granteds[$cat_id] = array();
     200  }
     201 
     202  $query = '
     203SELECT group_id, cat_id
     204  FROM '.GROUP_ACCESS_TABLE.'
     205  WHERE cat_id IN ('.implode(',', $private_uppercats).')
     206    AND group_id IN ('.implode(',', $_POST['grant_groups']).')
     207;';
     208  $result = pwg_query($query);
     209  while ($row = mysql_fetch_array($result))
     210  {
     211    array_push($granteds[$row['cat_id']], $row['group_id']);
     212  }
     213
     214  $inserts = array();
     215 
     216  foreach ($private_uppercats as $cat_id)
     217  {
     218    $group_ids = array_diff($_POST['grant_groups'], $granteds[$cat_id]);
     219    foreach ($group_ids as $group_id)
     220    {
     221      array_push($inserts, array('group_id' => $group_id,
     222                                 'cat_id' => $cat_id));
     223    }
     224  }
     225
     226  mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $inserts);
     227   
     228   
     229      }
     230    }
     231   
     232    */
     233   
     234    // If an add. p. id has been posted, the newly created group must be
     235    // allowed to navigate in this additional page
     236  }
     237  else {
     238    // If a category id has been posted, the newly created user must be
     239    // allowed to navigate in this category
     240   
     241    // If an add. p. id has been posted, the newly created user must be
     242    // allowed to navigate in this additional page => not possible to
     243    // allow individually => must give a warning message
     244   
    163245  }
    164246  return $ec_user_id;
     
    191273      $ec_lists['duplicable_codes']['codes'][$ec_entry['code']]['id'] =
    192274       $ec_entry['id'];
     275      $ec_lists['duplicable_codes']['codes'][$ec_entry['code']]['comment'] =
     276       $ec_entry['comment'];
    193277      $ec_lists['duplicable_codes']['codes'][$ec_entry['code']]['user_id'] =
    194278       $ec_entry['user_id'];
     
    198282    $ec_lists['duplicable_codes']['ids'][$ec_id] =
    199283     $ec_lists['duplicable_codes']['codes'][$ec_code]['id'];
     284    $ec_lists['duplicable_codes']['comment'][$ec_id] =
     285     $ec_lists['duplicable_codes']['codes'][$ec_code]['comment'];
    200286  }
    201287 
     
    235321  $action = 'ec_ok';
    236322  $del_other = false;
     323  $comment = '';
    237324  switch ($_POST['ec_act1']) {
    238325   
    239     // This "switch" command is a little bit tricky... it has been a pain to
     326    // This "switch" statement is a little bit tricky... it has been a pain to
    240327    // debug, and I wish to nobody to have to modify it :-\ !
    241328    // Its principle is that it manages checks for four occurrences of
     
    321408      $arg1       = $ec_lists['ec_table'][$_POST['ec_entry_sel']]['arg1'];
    322409      $arg2       = $ec_lists['ec_table'][$_POST['ec_entry_sel']]['arg2'];
     410      $comment    = $ec_lists['ec_table'][$_POST['ec_entry_sel']]['comment'];
    323411      if (empty($arg1)) $arg1 = 'NULL';
    324412      if (empty($arg2)) $arg2 = 'NULL';
     
    385473     return ec_end1('ec_in_up_forced', 'Bad argument : ');
    386474   
     475    // Preparation of $comment
     476    $comment = (isset($_POST['ec_in_up_comment'])) ?
     477     $_POST['ec_in_up_comment'] : $comment;
     478   
    387479    // User and eventually group creation, if needed
    388480    if ($_POST['ec_act1'] != 'duplicate_entry_submit')
     
    405497      AND `arg2`       ".$arg2p."
    406498      AND `forced`  = '".$forced."'
     499      AND `comment` = '".$comment."'
    407500  "))) !== false) { // print("<pre>$arg1 $arg2<br>$q</pre>");
    408501    $page['errors'][] = sprintf(l10n('ec_entry_already_exists'), $t1[0]);
     
    440533    'arg2p' => $arg2p,
    441534    'forced' => $forced,
     535    'comment' => $comment,
    442536  );
    443537 
     
    451545          `user_id`,
    452546          `action`,
    453           `arg1`, `arg2`, `forced`
     547          `arg1`, `arg2`, `forced`, `comment`
    454548        )
    455549        VALUES (
     
    457551           ".$ec_user_id.",
    458552          '".$action."',
    459           ".$arg1.", ".$arg2.", '".$forced."'
     553          ".$arg1.", ".$arg2.", '".$forced."', '".$comment."'
    460554        );
    461555      ") === false
     
    487581          `arg1`    =  ".$arg1.",
    488582          `arg2`    =  ".$arg2.",
    489           `forced`  = '".$forced."'
     583          `forced`  = '".$forced."',
     584          `comment` = '".$comment."'
    490585        WHERE `id`  = '".$_POST['ec_entry_sel']."'
    491586      ") === false
Note: See TracChangeset for help on using the changeset viewer.