[16591] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | function plugin_install() |
---|
| 5 | { |
---|
| 6 | global $conf, $prefixeTable; |
---|
| 7 | |
---|
| 8 | $query = ' |
---|
| 9 | CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'collections` ( |
---|
| 10 | `id` mediumint(8) NOT NULL AUTO_INCREMENT, |
---|
| 11 | `user_id` smallint(5) DEFAULT NULL, |
---|
| 12 | `name` varchar(255) NOT NULL, |
---|
| 13 | `date_creation` datetime NOT NULL, |
---|
| 14 | `nb_images` mediumint(8) NOT NULL DEFAULT 0, |
---|
| 15 | `active` tinyint(1) DEFAULT 0, |
---|
| 16 | `public` tinyint(1) DEFAULT 0, |
---|
[16658] | 17 | `public_id` varchar(10) NULL, |
---|
[16591] | 18 | PRIMARY KEY (`id`) |
---|
| 19 | ) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 |
---|
| 20 | ;'; |
---|
| 21 | pwg_query($query); |
---|
| 22 | |
---|
| 23 | $query = ' |
---|
| 24 | CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'collection_images` ( |
---|
| 25 | `col_id` mediumint(8) NOT NULL, |
---|
| 26 | `image_id` mediumint(8) NOT NULL, |
---|
| 27 | UNIQUE KEY `UNIQUE` (`col_id`,`image_id`) |
---|
| 28 | ) DEFAULT CHARSET=utf8 |
---|
| 29 | ;'; |
---|
| 30 | pwg_query($query); |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | function plugin_activate() |
---|
[16658] | 34 | { |
---|
| 35 | global $prefixeTable; |
---|
| 36 | |
---|
| 37 | // new collumn in beta2 |
---|
| 38 | $query = 'SHOW COLUMNS FROM `'.$prefixeTable.'collections`;'; |
---|
| 39 | $columns = array_from_query($query, 'Field'); |
---|
| 40 | if (!in_array('public_id', $columns)) |
---|
| 41 | { |
---|
| 42 | pwg_query('ALTER TABLE `'.$prefixeTable.'collections` ADD `public_id` varchar(10) NULL;'); |
---|
| 43 | } |
---|
| 44 | } |
---|
[16591] | 45 | |
---|
| 46 | function plugin_uninstall() |
---|
| 47 | { |
---|
| 48 | global $prefixeTable; |
---|
| 49 | |
---|
| 50 | pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "user_collections" LIMIT 1;'); |
---|
| 51 | pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collections`;'); |
---|
| 52 | pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collection_images`;'); |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | ?> |
---|