Changeset 4276 for extensions/event_cats


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
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • extensions/event_cats/admin/duplication.inc.php

    r4263 r4276  
    11<?php
     2
     3
     4
     5
     6
     7
     8/* */
     9
     10
     11
     12
     13
    214
    315
     
    1628
    1729
    18 /* */
    19 
    20 
    2130?>
  • extensions/event_cats/admin/evntcats_admin.php

    r4247 r4276  
    7171if (!isset($ec_debug)) $ec_debug = array();
    7272
     73// +-----------------------------------------------------------------------+
     74// | $_POST analysis, to determine which tab to display (tabsheet prep.)
     75// +-----------------------------------------------------------------------+
     76
     77// If needed, stores in the DB the new value of the number of digits of
     78// automatically created codes
    7379if (
    7480  isset($_POST['ec_in_up_auto_code_length']) and
     
    7682) change_ec_conf('auto_code_dg_nb', $_POST['ec_in_up_auto_code_length']);
    7783
     84
     85// If needed, stores in the DB that acknowledgement message has been displayed
    7886if ($ec_howto = (read_ec_conf('howto') == '0')) change_ec_conf('howto', '1');
    7987
    8088build_ec_lists(); // in evntcats_main_funcs.php
    8189
    82 // +-----------------------------------------------------------------------+
    83 // |                            Tabsheet
    84 // +-----------------------------------------------------------------------+
    85 
     90// If no entry exist, default page is 'autolog_new'.
    8691$page['tab'] = (!($ec_exist_entries = (mysql_num_rows(pwg_query("
    87   SELECT * FROM `".EVNTCATS_TABLE."`
    88   WHERE `code` IS NOT NULL
     92  SELECT * FROM `".EVNTCATS_AUTOLOG_TABLE."`
     93  WHERE `code` IS NOT NULL ;
    8994")) != 0))) ? 'autolog_new' : 'autolog_entries';
    9095
    91 // Rajouter un test pour que si $ec_exist_entries est faux, mais qu'il y a
    92 // quand même des entrées dans la table (donc pour gérer la duplication de
    93 // compte), l'onglet sélectionné par défaut soit celui de la gestion de la
    94 // duplication de compte.
     96$ec_exist_duplic = ((mysql_num_rows(pwg_query("
     97    SELECT * FROM `".EVNTCATS_DUPLIC_TABLE."` ;
     98  ")) != 0) or
     99  (read_ec_conf('duplic_gen') != 0) or
     100  (read_ec_conf('duplic_type') != 0)
     101);
     102
     103// If no entry exist, but some duplication management entries exist, default tab is 'duplication'.
     104if (!$ec_exist_entries and $ec_exist_duplic) $page['tab'] = 'duplication';
     105
     106
     107/*
     108
     109if (isset($_POST[''])) {
     110}
     111
     112
     113if (isset($_POST['ec_duplic_conf_submit'])) {
     114}
     115
     116if (isset($_POST['deny_groups_submit'])) {
     117}
     118
     119if (isset($_POST['grant_groups_submit'])) {
     120}
     121
     122if (isset($_POST['deny_types_submit'])) {
     123}
     124
     125if (isset($_POST['grant_types_submit'])) {
     126}
     127
     128if (isset($_POST['deny_users_submit'])) {
     129}
     130
     131if (isset($_POST['grant_users_submit'])) {
     132}
     133
     134
     135
     136
     137*/
     138
     139
     140
     141
    95142
    96143if (isset($_POST['ec_act1'])) {
     
    140187  if (isset($_GET['tab'])) switch ($_GET['tab']) {
    141188    case 'autolog_modif':
     189      if ($ec_exist_entries) $page['tab'] = $_GET['tab'];
     190    break;
     191    case 'duplication':
     192      if ($ec_exist_duplic) $page['tab'] = $_GET['tab'];
     193    break;
    142194    case 'autolog_new':
    143     case 'duplication':
    144195    case 'config':
    145196      $page['tab'] = $_GET['tab'];
     
    148199}
    149200
     201// +-----------------------------------------------------------------------+
     202// |                            Tabsheet
     203// +-----------------------------------------------------------------------+
     204
    150205$ec_exist_entries = (mysql_num_rows(pwg_query("
    151   SELECT * FROM `".EVNTCATS_TABLE."`
     206  SELECT * FROM `".EVNTCATS_AUTOLOG_TABLE."`
    152207  WHERE `code` IS NOT NULL
    153208")) != 0);
     209
     210$ec_exist_duplic = ((mysql_num_rows(pwg_query("
     211    SELECT * FROM `".EVNTCATS_DUPLIC_TABLE."` ;
     212  ")) != 0) or
     213  (read_ec_conf('duplic_gen') != 0) or
     214  (read_ec_conf('duplic_type') != 0)
     215);
    154216
    155217$tabsheet = new tabsheet();
     
    165227               l10n('ec_tab_autoid_new'),
    166228               $my_base_url.'&amp;tab=autolog_new');
    167 $tabsheet->add('duplication',
     229if ($ec_exist_duplic) $tabsheet->add('duplication',
    168230               l10n('ec_tab_duplication'),
    169231               $my_base_url.'&amp;tab=duplication');
  • extensions/event_cats/admin/template/duplication.tpl

    r4263 r4276  
    1212
    1313{* <!-- Duplication configuration parameters --> *}
    14 <form class = "titrePage" name = "ec_duplic_conf">
     14<form action = "" method = "post" class = "titrePage" name = "ec_duplic_conf">
    1515  <fieldset>
    1616    <legend>{'ec_duplication_config'|@translate}</legend>
     
    2222        <td>
    2323          <label for = "ec_dup_conf_none_id">
    24             <input type = "radio" name = "ec_dup_conf" id = "ec_dup_conf_none_id" />
     24            <input type = "radio" name = "ec_dup_conf[]" value = "none" id = "ec_dup_conf_none_id" />
    2525            {'ec_dup_allowance_none'|@translate}
    2626          </label><br>
    2727          <label for = "ec_dup_conf_group_id">
    28             <input type = "radio" name = "ec_dup_conf" id = "ec_dup_conf_group_id" />
     28            <input type = "radio" name = "ec_dup_conf[]" value = "group" id = "ec_dup_conf_group_id" />
    2929            {'ec_dup_allowance_group'|@translate}
    30           </label><br> {* <!--
    31           <label for = "ec_dup_conf_gen_id">
    32             <input type = "radio" name = "ec_dup_conf" id = "ec_dup_conf_gen_id" />
    33             {'ec_dup_allowance_gen'|@translate}
    34           </label><br> --> *}
     30          </label><br>
    3531          <label for = "ec_dup_conf_all_id">
    36             <input type = "radio" name = "ec_dup_conf" id = "ec_dup_conf_all_id" />
     32            <input type = "radio" name = "ec_dup_conf[]" value = "all" id = "ec_dup_conf_all_id" />
    3733            {'ec_dup_allowance_all'|@translate}
    3834          </label>
     
    4642{* <!-- Duplication settings by groups / types / user ids --> *}
    4743<form action = "" method = "post" name = "ec_duplic_set" id="categoryPermissions">
    48 
     44 
    4945  <h4>{'Groups'|@translate}</h4>
    50 
     46 
    5147  <fieldset>
    5248    <legend>{'ec_duplic_ok'|@translate}</legend>
    5349    <ul>
    54       {foreach from=$group_granted_ids item=id}
     50      {foreach from=$groups_granted_ids item=id}
    5551      <li><label><input type = "checkbox" name = "deny_groups[]" value = "{$id}" /> {$all_groups[$id]}</label></li>
    5652      {/foreach}
     
    5854    <input class = "submit" type = "submit" name = "deny_groups_submit" value = "{'ec_dup_grp_ok_sbmt_lbl'|@translate}" />
    5955  </fieldset>
    60 
     56 
    6157  <fieldset>
    6258    <legend>{'ec_duplic_nok'|@translate}</legend>
    6359    <ul>
    64       {foreach from=$group_denied_ids item=id}
     60      {foreach from=$groups_denied_ids item=id}
    6561      <li><label><input type = "checkbox" name = "grant_groups[]" value = "{$id}"> {$all_groups[$id]}</label></li>
    6662      {/foreach}
     
    6864    <input class = "submit" type = "submit" name = "grant_groups_submit" value = "{'ec_dup_grp_nok_sbmt_lbl'|@translate}" />
    6965  </fieldset>
    70 
     66 
    7167  <h4>{'ec_dup_types'|@translate}</h4>
    72 
     68 
    7369  <fieldset>
    7470    <legend>{'ec_duplic_ok'|@translate}</legend>
    7571    <ul>
    76       <li><label><input type = "checkbox" name = "ec_dup_types_generic_ok" value = "ec_dup_types_generic_ok_id" /> {'user_status_generic'|@translate}</label></li>
     72      {if $ec_gen_granted}
     73      <li><label><input type = "checkbox" name = "deny_generic" {* id = "ec_dup_types_generic_nok_id" *} /> {'user_status_generic'|@translate}</label></li>
    7774      <br />
    78       <li><label><input type = "checkbox" name = "ec_dup_types_contacts_ok" value = "ec_dup_types_contacts_ok_id" /> {'Level 1'|@translate}</label></li>
    79       <li><label><input type = "checkbox" name = "ec_dup_types_friends_ok" value = "ec_dup_types_friends_ok_id" /> {'Level 2'|@translate}</label></li>
    80       <li><label><input type = "checkbox" name = "ec_dup_types_family_ok" value = "ec_dup_types_family_ok_id" /> {'Level 4'|@translate}</label></li>
     75      {/if}
     76      {foreach from=$types_granted_ids item=id}
     77        <li><label><input type = "checkbox" name = "deny_types[]" value = "{$id}" /> {$all_types[$id]}</label></li>
     78      {/foreach}
    8179    </ul>
    82     <input class = "submit" type = "submit" name = "deny_users_submit" value = "{'ec_dup_typ_sbmt_lbl'|@translate}" />
     80    <input class = "submit" type = "submit" name = "deny_types_submit" value = "{'ec_dup_typ_sbmt_nok_lbl'|@translate}" />
    8381  </fieldset>
    84 
     82 
     83  <fieldset>
     84    <legend>{'ec_duplic_nok'|@translate}</legend>
     85    <ul>
     86      {if !$ec_gen_granted}
     87      <li><label><input type = "checkbox" name = "grant_generic" {* id = "ec_dup_types_generic_ok_id" *} /> {'user_status_generic'|@translate}</label></li>
     88      <br />
     89      {/if}
     90      {foreach from=$types_denied_ids item=id}
     91        <li><label><input type = "checkbox" name = "grant_types[]" value = "{$id}" /> {$all_types[$id]}</label></li>
     92      {/foreach}
     93    </ul>
     94    <input class = "submit" type = "submit" name = "grant_types_submit" value = "{'ec_dup_typ_sbmt_ok_lbl'|@translate}" />
     95  </fieldset>
     96 
    8597  <h4>{'Users'|@translate}</h4>
    86 
     98 
    8799  <fieldset>
    88100    <legend>{'ec_duplic_ok'|@translate}</legend>
    89101    <ul>
    90       {foreach from=$user_granted_direct_ids item=id}
     102      {foreach from=$users_granted_direct_ids item=id}
    91103      <li><label><input type = "checkbox" name = "deny_users[]" value = "{$id}" /> {$all_users[$id]}</label></li>
    92104      {/foreach}
     
    94106    <input class = "submit" type = "submit" name = "deny_users_submit" value = "{'ec_dup_usr_ok_sbmt_lbl'|@translate}" />
    95107  </fieldset>
    96 
     108 
    97109  <fieldset>
    98110    <legend>{'ec_duplic_ok_groups'|@translate}</legend>
     
    105117    {/if}
    106118  </fieldset>
    107 
     119 
    108120  <fieldset>
    109121    <legend>{'ec_duplic_nok'|@translate}</legend>
    110122    <ul>
    111       {foreach from=$user_denied_ids item=id}
     123      {foreach from=$users_denied_ids item=id}
    112124      <li><label><input type = "checkbox" name = "grant_users[]" value = "{$id}"> {$all_users[$id]}</label></li>
    113125      {/foreach}
     
    115127    <input class = "submit" type = "submit" name = "grant_users_submit" value = "{'ec_dup_usr_nok_sbmt_lbl'|@translate}" />
    116128  </fieldset>
    117 
     129 
    118130</form>
    119131
  • 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
  • extensions/event_cats/language/fr_FR/plugin.lang.php

    r4263 r4276  
    9393$lang['ec_dup_grp_ok_sbmt_lbl']   = 'Interdire la duplication aux groupes sélectionnés';
    9494$lang['ec_dup_grp_nok_sbmt_lbl']  = 'Autoriser la duplication aux groupes sélectionnés';
     95$lang['ec_dup_typ_sbmt_nok_lbl']  = 'Interdire la duplication aux types sélectionnés';
     96$lang['ec_dup_typ_sbmt_ok_lbl']   = 'Autoriser la duplication aux types sélectionnés';
    9597$lang['ec_dup_usr_ok_sbmt_lbl']   = 'Interdire la duplication aux utilisateurs sélectionnés';
    9698$lang['ec_dup_usr_nok_sbmt_lbl']  = 'Autoriser la duplication aux utilisateurs sélectionnés';
    97 $lang['ec_dup_typ_sbmt_lbl']      = 'Sauvegarder';
    9899$lang['ec_dup_conf_sbmt_lbl']     = 'Sauvegarder la configuration de la duplication';
    99100// JS checks
  • extensions/event_cats/main.inc.php

    r4263 r4276  
    4343define('EVNTCATS_INFO_VERSION','1.0.0');
    4444define('EVNTCATS_PATH',PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)). '/');
    45 define('EVNTCATS_TABLE',$prefixeTable.'event_cats');
     45define('EVNTCATS_AUTOLOG_TABLE', $prefixeTable.'event_cats_autolog');
     46define('EVNTCATS_DUPLIC_TABLE', $prefixeTable.'event_cats_duplic');
    4647define('ROOT_URL',get_absolute_root_url());
    4748
  • extensions/event_cats/maintain.inc.php

    r4239 r4276  
    3636include_once(EVNTCATS_PATH.'include/ec_conf.inc.php');
    3737
     38// ***********************************************************************
    3839function plugin_uninstall() {
    39   global $prefixeTable, $ec_conf;
     40  global $prefixeTable;
    4041
    41   unset($ec_conf);
    4242        pwg_query("DELETE FROM `".CONFIG_TABLE."` WHERE `param` = 'event_cats' LIMIT 1;");
    43         return pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'event_cats`;');
     43        pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'event_cats_duplic`;');
     44        return pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'event_cats_autolog`;');
    4445}
    4546
     47// ***********************************************************************
    4648function plugin_install() {
    4749  global $prefixeTable;
    4850 
    4951  plugin_uninstall();
     52 
    5053  // create table for plugin, if it doesn't exist yet
    51   $q = pwg_query("
    52     CREATE TABLE `".$prefixeTable."event_cats` (
     54  $r = (pwg_query("
     55    CREATE TABLE `".$prefixeTable."event_cats_autolog` (
    5356      `id`      SMALLINT(5)             UNSIGNED NOT NULL     AUTO_INCREMENT ,
    5457      `code`    VARCHAR(32)                               DEFAULT NULL ,
     
    6366    )
    6467    DEFAULT CHARACTER SET utf8;
    65   ");
     68  ") !== false);
    6669
    6770/*
     
    131134
    132135*/
    133   pwg_query("
     136 
     137  if ($r) $r = (pwg_query("
     138    CREATE TABLE `".$prefixeTable."event_cats_duplic` (
     139      `item`  VARCHAR(5) NOT NULL ,
     140      `val` VARCHAR(32) NOT NULL ,
     141      KEY `item` (`item`),
     142      KEY `val` (`val`)
     143    )
     144    DEFAULT CHARACTER SET utf8;
     145  ") !== false);
     146
     147/*
     148Explanations on table structure :
     149
     150item  : the code used as "autolog" argument. If thie code provided by the
     151          visitor does not exist in the table, the administrator can choose
     152          whether the visitor is redirected to the home page (nothing
     153          happens) or to the "access denied" page ;
     154value : the account concerned in following values ;
     155
     156*/
     157 
     158  if ($r) $r = (pwg_query("
    134159    INSERT INTO `".CONFIG_TABLE."` (`param`,`value`,`comment`)
    135160    VALUES ('event_cats','0','Paramètres du plugin Event Cats');
    136   ");
    137   change_ec_conf('activated', '0');
    138   return $q;
     161  ") !== false);
     162 
     163  if ($r) $r = (change_ec_conf('activated', '0'));
     164 
     165  if ($r) return true;
     166  else {
     167    plugin_uninstall();
     168    return false;
     169  }
    139170}
    140171
     172// ***********************************************************************
    141173function plugin_activate() {
    142174  change_ec_conf('activated', '1');
    143175}
    144176
     177// ***********************************************************************
    145178function plugin_deactivate() {
    146179  change_ec_conf('activated', '0');
Note: See TracChangeset for help on using the changeset viewer.