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