1 | <?php |
---|
2 | |
---|
3 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
4 | |
---|
5 | class physical2virtual_maintain extends PluginMaintain |
---|
6 | { |
---|
7 | private $installed = false; |
---|
8 | |
---|
9 | private $default_conf = array( |
---|
10 | 'physical_prefix' => '', |
---|
11 | 'physical_postfix' => '', |
---|
12 | 'virtual_prefix' => '', |
---|
13 | 'virtual_postfix' => '', |
---|
14 | 'parent_cat' => null, |
---|
15 | 'lock_physical' => false, |
---|
16 | 'private_physical' => false, |
---|
17 | 'unlock_virtual' => false, |
---|
18 | 'inherit' => false, |
---|
19 | 'update_on_manual' => true, |
---|
20 | 'update_on_upload' => false, |
---|
21 | 'update_on_date' => false, |
---|
22 | 'update_timeout' => 3, |
---|
23 | 'last_update' => 0, |
---|
24 | 'store_structure' => true, |
---|
25 | ); |
---|
26 | |
---|
27 | function __construct($plugin_id) |
---|
28 | { |
---|
29 | global $prefixeTable; |
---|
30 | |
---|
31 | parent::__construct($plugin_id); |
---|
32 | |
---|
33 | $this->table = $prefixeTable . 'phy2virt_categories'; |
---|
34 | } |
---|
35 | |
---|
36 | function install($plugin_version, &$errors=array()) |
---|
37 | { |
---|
38 | global $conf, $prefixeTable; |
---|
39 | |
---|
40 | if (empty($conf['physical2virtual'])) |
---|
41 | { |
---|
42 | $conf['physical2virtual'] = serialize($this->default_conf); |
---|
43 | conf_update_param('physical2virtual', $conf['physical2virtual']); |
---|
44 | } |
---|
45 | else |
---|
46 | { |
---|
47 | $new_conf = is_string($conf['physical2virtual']) ? unserialize($conf['physical2virtual']) : $conf['physical2virtual']; |
---|
48 | |
---|
49 | $conf['physical2virtual'] = serialize($new_conf); |
---|
50 | conf_update_param('physical2virtual', $conf['physical2virtual']); |
---|
51 | } |
---|
52 | |
---|
53 | // new table |
---|
54 | pwg_query( |
---|
55 | 'CREATE TABLE IF NOT EXISTS `' . $this->table . '` ( |
---|
56 | `phy_category_id` smallint(5) unsigned NOT NULL, |
---|
57 | `virt_category_id` smallint(5) unsigned NOT NULL, |
---|
58 | `updated` DATETIME NOT NULL DEFAULT "1970-01-01 00:00:00", |
---|
59 | KEY `phy_category_id` (`phy_category_id`) |
---|
60 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
---|
61 | ;'); |
---|
62 | |
---|
63 | $this->installed = true; |
---|
64 | } |
---|
65 | |
---|
66 | function activate($plugin_version, &$errors=array()) |
---|
67 | { |
---|
68 | if (!$this->installed) |
---|
69 | { |
---|
70 | $this->install($plugin_version, $errors); |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | function deactivate() |
---|
75 | { |
---|
76 | } |
---|
77 | |
---|
78 | function uninstall() |
---|
79 | { |
---|
80 | conf_delete_param('physical2virtual'); |
---|
81 | |
---|
82 | pwg_query('DROP TABLE `' . $this->table . '`;'); |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | ?> |
---|