source: extensions/GuestBook/include/install.inc.php @ 24889

Revision 24889, 1.8 KB checked in by mistic100, 6 years ago (diff)

use my plugin architecture, add options to hide the page for guests, fix admin links in mails

Line 
1<?php
2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
3
4function guestbook_install() 
5{
6  global $conf, $prefixeTable;
7 
8  if (empty($conf['guestbook']))
9  {
10    $new_conf = array(
11      'comments_validation' => false,
12      'email_admin_on_comment' => false,
13      'email_admin_on_comment_validation' => true,
14      'nb_comment_page' => 15,
15      'activate_rating' => true,
16      'guest_can_view' => true,
17      'guest_can_add' => true,
18      );
19 
20    $conf['guestbook'] = serialize($new_conf);
21    conf_update_param('guestbook', $conf['guestbook']);
22  }
23  else
24  {
25    $old_conf = is_string($conf['guestbook']) ? unserialize($conf['guestbook']) : $conf['guestbook'];
26   
27    if (!isset($old_conf['guest_can_view']))
28    {
29      $old_conf['guest_can_view'] = true;
30      $old_conf['guest_can_add'] = true;
31    }
32   
33    $conf['guestbook'] = serialize($old_conf);
34    conf_update_param('guestbook', $conf['guestbook']);
35  }
36 
37  pwg_query('
38CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'guestbook` (
39  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
40  `date` datetime NOT NULL DEFAULT "0000-00-00 00:00:00",
41  `author` varchar(255) NOT NULL,
42  `author_id` smallint(5) DEFAULT NULL,
43  `anonymous_id` varchar(45) NOT NULL,
44  `email` varchar(255) DEFAULT NULL,
45  `website` varchar(255) DEFAULT NULL,
46  `content` longtext NOT NULL,
47  `rate` float(5,2) unsigned DEFAULT NULL,
48  `validated` enum("true","false") NOT NULL DEFAULT "false",
49  `validation_date` datetime DEFAULT NULL,
50  PRIMARY KEY (`id`)
51) ENGINE=MyISAM DEFAULT CHARSET=utf8
52;');
53}
54
55function guestbook_uninstall()
56{
57  global $prefixeTable, $conf;
58 
59  pwg_query('DROP TABLE `' . $prefixeTable . 'guestbook`;');
60  pwg_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE `param` = "guestbook";');
61 
62  unset($conf['guestbook']);
63}
Note: See TracBrowser for help on using the repository browser.