1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | // Default config |
---|
5 | define('default_guestbook_config', serialize(array( |
---|
6 | 'comments_validation' => false, |
---|
7 | 'email_admin_on_comment' => false, |
---|
8 | 'email_admin_on_comment_validation' => false, |
---|
9 | 'nb_comment_page' => 15, |
---|
10 | 'activate_rating' => true, |
---|
11 | ))); |
---|
12 | |
---|
13 | // Installation |
---|
14 | function plugin_install() |
---|
15 | { |
---|
16 | global $prefixeTable; |
---|
17 | |
---|
18 | pwg_query(" |
---|
19 | CREATE TABLE `" . $prefixeTable . "guestbook` ( |
---|
20 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
---|
21 | `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
---|
22 | `author` varchar(255) NOT NULL, |
---|
23 | `author_id` smallint(5) DEFAULT NULL, |
---|
24 | `anonymous_id` varchar(45) NOT NULL, |
---|
25 | `email` varchar(255) DEFAULT NULL, |
---|
26 | `website` varchar(255) DEFAULT NULL, |
---|
27 | `content` longtext NOT NULL, |
---|
28 | `rate` float(5,2) unsigned DEFAULT NULL, |
---|
29 | `validated` enum('true','false') NOT NULL DEFAULT 'false', |
---|
30 | `validation_date` datetime DEFAULT NULL, |
---|
31 | PRIMARY KEY (`id`) |
---|
32 | ) DEFAULT CHARSET=utf8 |
---|
33 | ;"); |
---|
34 | |
---|
35 | conf_update_param('guestbook', default_guestbook_config); |
---|
36 | } |
---|
37 | |
---|
38 | // Activation |
---|
39 | function plugin_activate() |
---|
40 | { |
---|
41 | global $conf; |
---|
42 | |
---|
43 | if (!isset($conf['guestbook'])) |
---|
44 | { |
---|
45 | conf_update_param('guestbook', default_guestbook_config); |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | // Uninstallation |
---|
50 | function plugin_uninstall() |
---|
51 | { |
---|
52 | global $prefixeTable; |
---|
53 | |
---|
54 | pwg_query("DROP TABLE `" . $prefixeTable . "guestbook`;"); |
---|
55 | pwg_query("DELETE FROM " . CONFIG_TABLE . " WHERE `param` = 'guestbook';"); |
---|
56 | } |
---|
57 | ?> |
---|