source: extensions/GuestBook/maintain.class.php @ 28841

Revision 28841, 1.9 KB checked in by mistic100, 5 years ago (diff)

use new maintain class

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