Ignore:
Timestamp:
Jan 12, 2014, 7:13:40 PM (10 years ago)
Author:
mistic100
Message:

integrate in new tags manager + rename in Coloured Tags
(my apologies to translators :-) )

File:
1 edited

Legend:

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

    r21361 r26665  
    11<?php
    2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    33
    4 function plugin_install()
     4class typetags_maintain extends PluginMaintain
    55{
    6   global $prefixeTable;
     6  private $installed = false;
    77
    8   $query = 'SHOW FULL COLUMNS FROM ' . TAGS_TABLE . ';';
    9   $result = array_from_query($query, 'Field');
    10   if (!in_array('id_typetags', $result))
     8  private $default_conf = array(
     9    'show_all'=>true,
     10    );
     11
     12  function install($plugin_version, &$errors=array())
    1113  {
    12     pwg_query('ALTER TABLE '.TAGS_TABLE.' ADD COLUMN `id_typetags` SMALLINT(5);');
    13   }
     14    global $conf, $prefixeTable;
    1415
    15   $result = pwg_query('SHOW TABLES LIKE "' . $prefixeTable .'typetags"');
    16   if (!pwg_db_num_rows($result))
    17   {
     16    if (empty($conf['TypeTags']))
     17    {
     18      $conf['TypeTags'] = serialize($this->default_conf);
     19      conf_update_param('TypeTags', $conf['TypeTags']);
     20    }
     21
     22    $result = pwg_query('SHOW COLUMNS FROM `' . TAGS_TABLE . '` LIKE "id_typetags";');
     23    if (!pwg_db_num_rows($result))
     24    {
     25      pwg_query('ALTER TABLE `' . TAGS_TABLE . '` ADD `id_typetags` SMALLINT(5) DEFAULT NULL;');
     26    }
     27
    1828    $query = '
    19 CREATE TABLE `'. $prefixeTable .'typetags` (
     29CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'typetags` (
    2030  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
    2131  `name` varchar(255) NOT NULL,
     
    2535;';
    2636    pwg_query($query);
     37
     38    $this->installed = true;
    2739  }
    28  
    29   conf_update_param('TypeTags', serialize(array('show_all'=>true)));
    30 }
    3140
    32 function plugin_activate()
    33 {
    34   global $conf;
    35  
    36   if (!isset($conf['TypeTags']))
     41  function activate($plugin_version, &$errors=array())
    3742  {
    38     conf_update_param('TypeTags', serialize(array('show_all'=>true)));
     43    if (!$this->installed)
     44    {
     45      $this->install($plugin_version, $errors);
     46    }
     47  }
     48
     49  function deactivate()
     50  {
     51  }
     52
     53  function uninstall()
     54  {
     55    global $prefixeTable;
     56
     57    conf_delete_param('TypeTags');
     58
     59    pwg_query('ALTER TABLE `' . TAGS_TABLE . '` DROP `id_typetags`');
     60    pwg_query('DROP TABLE `' . $prefixeTable . 'typetags`;');
    3961  }
    4062}
    41 
    42 function plugin_uninstall()
    43 {
    44   global $prefixeTable;
    45 
    46   pwg_query('ALTER TABLE '.TAGS_TABLE.' DROP COLUMN `id_typetags`');
    47   pwg_query('DROP TABLE '. $prefixeTable .'typetags;');
    48   pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param = "TypeTags" LIMIT 1;');
    49 }
    50 
    51 ?>
Note: See TracChangeset for help on using the changeset viewer.