source: extensions/GuestBook/maintain.inc.php @ 26237

Last change on this file since 26237 was 26065, checked in by mistic100, 11 years ago

update for Piwigo 2.6 + code clean

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