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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.