source: extensions/Comments_on_Albums/trunk/maintain.class.php @ 28837

Last change on this file since 28837 was 28837, checked in by mistic100, 10 years ago

use new maintain class

File size: 1.8 KB
Line 
1<?php
2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
3
4class Comments_on_Albums_maintain extends PluginMaintain
5{
6  private $table;
7 
8  function __construct($id)
9  {
10    global $prefixeTable;
11   
12    parent::__construct($id);
13    $this->table = $prefixeTable.'comments_categories';
14  }
15
16  function install($plugin_version, &$errors=array())
17  {
18    pwg_query('
19CREATE TABLE IF NOT EXISTS `' . $this->table . '` (
20  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
21  `category_id` mediumint(8) unsigned NOT NULL DEFAULT 0,
22  `date` datetime NOT NULL DEFAULT "0000-00-00 00:00:00",
23  `author` varchar(255) DEFAULT NULL,
24  `email` varchar(255) DEFAULT NULL,
25  `author_id` smallint(5) DEFAULT NULL,
26  `anonymous_id` varchar(45) NOT NULL,
27  `website_url` varchar(255) DEFAULT NULL,
28  `content` longtext,
29  `validated` enum("true","false") NOT NULL DEFAULT "false",
30  `validation_date` datetime DEFAULT NULL,
31  PRIMARY KEY (`id`),
32  KEY `comments_i2` (`validation_date`),
33  KEY `comments_i1` (`category_id`)
34) ENGINE=MyISAM DEFAULT CHARSET=utf8
35;');
36
37    $result = pwg_query('SHOW COLUMNS FROM `' . $this->table . '` LIKE "anonymous_id";');
38    if (!pwg_db_num_rows($result))
39    {
40      pwg_query('ALTER TABLE `' . $this->table . '` ADD `anonymous_id` VARCHAR(45) DEFAULT NULL;');
41    }
42
43    $result = pwg_query('SHOW COLUMNS FROM `' . $this->table . '` LIKE "email";');
44    if (!pwg_db_num_rows($result))
45    {
46      pwg_query('
47ALTER TABLE `' . $this->table . '`
48  ADD `email` varchar(255) DEFAULT NULL,
49  ADD `website_url` varchar(255) DEFAULT NULL,
50  ADD KEY `comments_i2` (`validation_date`),
51  ADD KEY `comments_i1` (`category_id`)
52;');
53    }
54  }
55
56  function update($old_version, $new_version, &$errors=array())
57  {
58    $this->install($new_version, $errors);
59  }
60
61  function uninstall()
62  {
63    pwg_query('DROP TABLE `' . $this->table . '`;');
64  }
65}
Note: See TracBrowser for help on using the repository browser.