Ignore:
Timestamp:
Dec 22, 2013, 8:30:51 PM (10 years ago)
Author:
mistic100
Message:

update for 2.6 + clean

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Comments_on_Albums/trunk/maintain.inc.php

    r19991 r26089  
    11<?php
    2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    33
    4 defined('COA_ID') or define('COA_ID', basename(dirname(__FILE__)));
    5 include_once(PHPWG_PLUGINS_PATH . COA_ID . '/include/install.inc.php');
     4class Comments_on_Albums_maintain extends PluginMaintain
     5{
     6  private $installed = false;
    67
    7 function plugin_install()
    8 {
    9   coa_install();
    10   define('coa_installed', true);
    11 }
     8  function install($plugin_version, &$errors=array())
     9  {
     10    global $prefixeTable;
    1211
    13 function plugin_activate()
    14 {
    15   if (!defined('coa_installed'))
     12    pwg_query('
     13CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'comments_categories` (
     14  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
     15  `category_id` mediumint(8) unsigned NOT NULL DEFAULT 0,
     16  `date` datetime NOT NULL DEFAULT "0000-00-00 00:00:00",
     17  `author` varchar(255) DEFAULT NULL,
     18  `email` varchar(255) DEFAULT NULL,
     19  `author_id` smallint(5) DEFAULT NULL,
     20  `anonymous_id` varchar(45) NOT NULL,
     21  `website_url` varchar(255) DEFAULT NULL,
     22  `content` longtext,
     23  `validated` enum("true","false") NOT NULL DEFAULT "false",
     24  `validation_date` datetime DEFAULT NULL,
     25  PRIMARY KEY (`id`),
     26  KEY `comments_i2` (`validation_date`),
     27  KEY `comments_i1` (`category_id`)
     28) ENGINE=MyISAM DEFAULT CHARSET=utf8');
     29
     30    $result = pwg_query('SHOW COLUMNS FROM `' . $prefixeTable . 'comments_categories` LIKE "anonymous_id";');
     31    if (!pwg_db_num_rows($result))
     32    {
     33      pwg_query('ALTER TABLE `' . $prefixeTable . 'comments_categories` ADD `anonymous_id` VARCHAR(45) DEFAULT NULL;');
     34    }
     35
     36    $result = pwg_query('SHOW COLUMNS FROM `' . $prefixeTable . 'comments_categories` LIKE "email";');
     37    if (!pwg_db_num_rows($result))
     38    {
     39      pwg_query('
     40ALTER TABLE `' . $prefixeTable . 'comments_categories`
     41  ADD `email` varchar(255) DEFAULT NULL,
     42  ADD `website_url` varchar(255) DEFAULT NULL,
     43  ADD KEY `comments_i2` (`validation_date`),
     44  ADD KEY `comments_i1` (`category_id`)
     45      ;');
     46    }
     47
     48    $this->installed = true;
     49  }
     50
     51  function activate($plugin_version, &$errors=array())
    1652  {
    17     coa_install();
     53    if (!$this->installed)
     54    {
     55      $this->install($plugin_version, $errors);
     56    }
     57  }
     58
     59  function deactivate()
     60  {
     61  }
     62
     63  function uninstall()
     64  {
     65    global $prefixeTable;
     66
     67    pwg_query('DROP TABLE `' . $prefixeTable . 'comments_categories`;');
    1868  }
    1969}
    20 
    21 function plugin_uninstall()
    22 {
    23   global $prefixeTable;
    24 
    25   pwg_query('DROP TABLE `' . $prefixeTable . 'comments_categories`;');
    26 }
    27 
    28 ?>
Note: See TracChangeset for help on using the changeset viewer.