1 | <?php |
---|
2 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | class Comments_on_Albums_maintain extends PluginMaintain |
---|
5 | { |
---|
6 | private $installed = false; |
---|
7 | |
---|
8 | function install($plugin_version, &$errors=array()) |
---|
9 | { |
---|
10 | global $prefixeTable; |
---|
11 | |
---|
12 | pwg_query(' |
---|
13 | CREATE 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(' |
---|
40 | ALTER 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()) |
---|
52 | { |
---|
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`;'); |
---|
68 | } |
---|
69 | } |
---|