[10871] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
[16104] | 4 | global $prefixeTable; |
---|
| 5 | define('smart_table', $prefixeTable . 'category_filters'); |
---|
| 6 | |
---|
| 7 | define('smart_default_config', serialize(array( |
---|
| 8 | 'update_on_upload' => false, |
---|
| 9 | 'show_list_messages' => true, |
---|
| 10 | ))); |
---|
| 11 | |
---|
[11376] | 12 | function plugin_install() |
---|
| 13 | { |
---|
[10871] | 14 | /* create table to store filters */ |
---|
[11333] | 15 | pwg_query( |
---|
[16104] | 16 | 'CREATE TABLE IF NOT EXISTS `' . smart_table . '` ( |
---|
[11333] | 17 | `category_id` smallint(5) unsigned NOT NULL, |
---|
| 18 | `type` varchar(16) NOT NULL, |
---|
| 19 | `cond` varchar(16) NULL, |
---|
| 20 | `value` text |
---|
| 21 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
---|
| 22 | ;'); |
---|
[10871] | 23 | |
---|
| 24 | /* add a collumn to image_category_table */ |
---|
[11376] | 25 | pwg_query('ALTER TABLE `' . IMAGE_CATEGORY_TABLE . '` ADD `smart` ENUM(\'true\', \'false\') NOT NULL DEFAULT \'false\';'); |
---|
[10871] | 26 | |
---|
| 27 | /* config parameter */ |
---|
[16104] | 28 | conf_update_param('SmartAlbums', smart_default_config); |
---|
[10871] | 29 | } |
---|
| 30 | |
---|
[11376] | 31 | function plugin_activate() |
---|
[11381] | 32 | { |
---|
[11438] | 33 | global $conf; |
---|
| 34 | |
---|
[11392] | 35 | if (!isset($conf['SmartAlbums'])) |
---|
[11376] | 36 | { |
---|
[16104] | 37 | conf_update_param('SmartAlbums', smart_default_config); |
---|
[11376] | 38 | } |
---|
[16104] | 39 | |
---|
| 40 | /* some filters renamed in 1.2 */ |
---|
| 41 | $name_changes = array( |
---|
| 42 | 'the' => 'the_post', |
---|
| 43 | 'before' => 'before_post', |
---|
| 44 | 'after' => 'after_post', |
---|
| 45 | 'the_crea' => 'the_taken', |
---|
| 46 | 'before_crea' => 'before_taken', |
---|
| 47 | 'after_crea' => 'after_taken', |
---|
| 48 | ); |
---|
| 49 | foreach ($name_changes as $old => $new) |
---|
| 50 | { |
---|
| 51 | pwg_query('UPDATE TABLE ' . smart_table . ' SET cond = "'.$new.'" WHERE cond = "'.$old.'";'); |
---|
| 52 | } |
---|
[11376] | 53 | } |
---|
| 54 | |
---|
| 55 | function plugin_uninstall() |
---|
[16104] | 56 | { |
---|
| 57 | pwg_query('DROP TABLE `' . smart_table . '`;'); |
---|
[11333] | 58 | pwg_query('ALTER TABLE `' . IMAGE_CATEGORY_TABLE . '` DROP `smart`;'); |
---|
[16104] | 59 | pwg_query('DELETE FROM `' . CONFIG_TABLE . '` WHERE param = \'SmartAlbums\' LIMIT 1;'); |
---|
[10871] | 60 | } |
---|
[16104] | 61 | |
---|
[10871] | 62 | ?> |
---|