Ignore:
Timestamp:
Jan 7, 2013, 10:26:35 PM (11 years ago)
Author:
julien1311
Message:

[piwecard] various improvements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Piwecard/maintain.inc.php

    r19925 r19956  
    11<?php
    2 /*
    3  * Plugin Name: Piwecard
    4  * File :  maintain.inc.php 
    5  */
    6 
    72if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    83
    94function plugin_install() {
    10         global $prefixeTable, $conf;
     5        global $prefixeTable;
    116
    12         $query = 'SHOW TABLES LIKE "' . $prefixeTable . 'ecard"';
     7        require_once('install/functions.inc.php');
     8       
     9        $query = 'SHOW TABLES LIKE "'.$prefixeTable.'piwecard"';
    1310        $result = pwg_query($query);
    14         if (!mysql_fetch_row($result)) {
    15 
    16         // ecard description
    17                 $q = 'CREATE TABLE `' . $prefixeTable . 'ecard` (
    18                                           `numero` CHAR(64) not null,
    19                                           `nomexp` CHAR(100) not null,
    20                                           `nomdest` CHAR(100) not null,
    21                                           `adrexp` CHAR(100) not null,
    22                                           `adrdest` CHAR(100) not null,
    23                                           `sujet` CHAR(100) not null,
    24                                           `message` TEXT not null,
    25                                           `image` smallint(5) not null,
    26                                           `date` datetime NOT NULL,
    27                                           `duration` smallint(5) not null default 10,
    28                                           PRIMARY KEY (`numero`),
    29                                           UNIQUE (`numero`)
    30                                         ) DEFAULT CHARSET=utf8;';
    31                 pwg_query($q);
    32 
    33     $q = '
    34     INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
    35     VALUES ("ecard","","Configuration ecard")
    36     ;';
    37 
    38     pwg_query($q);
     11        if (!pwg_db_fetch_row($result)) {
     12                piwecard_db_create($prefixeTable.'piwecard');
     13                piwecard_conf_create('piwecard');
    3914        }
    4015}
    4116
    4217function plugin_activate() {
    43  
     18        global $prefixeTable;
     19       
     20        require_once('install/functions.inc.php');
     21       
     22        $query_ecard = 'SHOW TABLES LIKE "'.$prefixeTable.'ecard"';
     23        $result_ecard = pwg_query($query_ecard);
     24        $query_piwecard = 'SHOW TABLES LIKE "'.$prefixeTable.'piwecard"';
     25        $result_piwecard = pwg_query($query_piwecard);
     26        if (pwg_db_num_rows($result_ecard) != 0) {              //Update old configs
     27                if (pwg_db_num_rows($result_piwecard) == 0){
     28                        piwecard_db_create($prefixeTable.'piwecard');
     29                        piwecard_db_populate($prefixeTable.'ecard', $prefixeTable.'piwecard');
     30                }
     31                piwecard_db_delete($prefixeTable.'ecard');
     32               
     33                piwecard_conf_rename('ecard', 'piwecard');
     34        }
    4435}
    4536
    4637function plugin_uninstall() {
    47     global $prefixeTable;
     38        global $prefixeTable;
    4839
    49         $q = 'DROP TABLE ' . $prefixeTable . 'ecard;';
    50     pwg_query($q);
    51 
    52     $q = '
    53       DELETE FROM '.CONFIG_TABLE.'
    54       WHERE param="ecard" LIMIT 1
    55     ;';
    56     pwg_query($q);
     40        require_once('install/functions.inc.php');
     41       
     42        piwecard_db_delete($prefixeTable.'piwecard');
     43        piwecard_conf_delete('piwecard');
    5744}
    5845?>
Note: See TracChangeset for help on using the changeset viewer.