[9624] | 1 | <?php |
---|
[26089] | 2 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
[9624] | 3 | |
---|
[26089] | 4 | class Comments_on_Albums_maintain extends PluginMaintain |
---|
[11267] | 5 | { |
---|
[26089] | 6 | private $installed = false; |
---|
[14528] | 7 | |
---|
[26089] | 8 | function install($plugin_version, &$errors=array()) |
---|
[14528] | 9 | { |
---|
[26089] | 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; |
---|
[14528] | 49 | } |
---|
[9624] | 50 | |
---|
[26089] | 51 | function activate($plugin_version, &$errors=array()) |
---|
| 52 | { |
---|
| 53 | if (!$this->installed) |
---|
| 54 | { |
---|
| 55 | $this->install($plugin_version, $errors); |
---|
| 56 | } |
---|
| 57 | } |
---|
[9624] | 58 | |
---|
[26089] | 59 | function deactivate() |
---|
| 60 | { |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | function uninstall() |
---|
| 64 | { |
---|
| 65 | global $prefixeTable; |
---|
| 66 | |
---|
| 67 | pwg_query('DROP TABLE `' . $prefixeTable . 'comments_categories`;'); |
---|
| 68 | } |
---|
[9624] | 69 | } |
---|