1 | <?php |
---|
2 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | class GuestBook_maintain extends PluginMaintain |
---|
5 | { |
---|
6 | private $table; |
---|
7 | |
---|
8 | private $default_conf = array( |
---|
9 | 'comments_validation' => false, |
---|
10 | 'email_admin_on_comment' => false, |
---|
11 | 'email_admin_on_comment_validation' => true, |
---|
12 | 'nb_comment_page' => 15, |
---|
13 | 'activate_rating' => true, |
---|
14 | 'guest_can_view' => true, |
---|
15 | 'guest_can_add' => true, |
---|
16 | 'menu_link' => true, |
---|
17 | ); |
---|
18 | |
---|
19 | function __construct($id) |
---|
20 | { |
---|
21 | global $prefixeTable; |
---|
22 | |
---|
23 | parent::__construct($id); |
---|
24 | $this->table = $prefixeTable.'guestbook'; |
---|
25 | } |
---|
26 | |
---|
27 | function install($plugin_version, &$errors=array()) |
---|
28 | { |
---|
29 | global $conf; |
---|
30 | |
---|
31 | if (empty($conf['guestbook'])) |
---|
32 | { |
---|
33 | conf_update_param('guestbook', $this->default_conf, true); |
---|
34 | } |
---|
35 | else |
---|
36 | { |
---|
37 | $old_conf = safe_unserialize($conf['guestbook']); |
---|
38 | |
---|
39 | if (!isset($old_conf['guest_can_view'])) |
---|
40 | { |
---|
41 | $old_conf['guest_can_view'] = true; |
---|
42 | $old_conf['guest_can_add'] = true; |
---|
43 | } |
---|
44 | if (!isset($old_conf['menu_link'])) |
---|
45 | { |
---|
46 | $old_conf['menu_link'] = true; |
---|
47 | } |
---|
48 | |
---|
49 | conf_update_param('guestbook', $old_conf, true); |
---|
50 | } |
---|
51 | |
---|
52 | pwg_query(' |
---|
53 | CREATE TABLE IF NOT EXISTS `' . $this->table . '` ( |
---|
54 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
---|
55 | `date` datetime NOT NULL DEFAULT "0000-00-00 00:00:00", |
---|
56 | `author` varchar(255) NOT NULL, |
---|
57 | `author_id` smallint(5) DEFAULT NULL, |
---|
58 | `anonymous_id` varchar(45) NOT NULL, |
---|
59 | `email` varchar(255) DEFAULT NULL, |
---|
60 | `website` varchar(255) DEFAULT NULL, |
---|
61 | `content` longtext NOT NULL, |
---|
62 | `rate` float(5,2) unsigned DEFAULT NULL, |
---|
63 | `validated` enum("true","false") NOT NULL DEFAULT "false", |
---|
64 | `validation_date` datetime DEFAULT NULL, |
---|
65 | PRIMARY KEY (`id`) |
---|
66 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
---|
67 | ;'); |
---|
68 | } |
---|
69 | |
---|
70 | function update($old_version, $new_version, &$errors=array()) |
---|
71 | { |
---|
72 | $this->install($new_version, $errors); |
---|
73 | } |
---|
74 | |
---|
75 | function uninstall() |
---|
76 | { |
---|
77 | pwg_query('DROP TABLE `' . $this->table . '`;'); |
---|
78 | |
---|
79 | conf_delete_param('guestbook'); |
---|
80 | } |
---|
81 | } |
---|