source: extensions/typetags/maintain.class.php @ 31061

Last change on this file since 31061 was 28853, checked in by mistic100, 10 years ago

use new maintain class

File size: 1.3 KB
Line 
1<?php
2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
3
4class typetags_maintain extends PluginMaintain
5{
6  private $default_conf = array(
7    'show_all'=>true,
8    );
9
10  private $table;
11
12  function __construct($plugin_id)
13  {
14    parent::__construct($plugin_id);
15
16    global $prefixeTable;
17    $this->table = $prefixeTable . 'typetags';
18  }
19
20  function install($plugin_version, &$errors=array())
21  {
22    global $conf;
23
24    if (empty($conf['TypeTags']))
25    {
26      conf_update_param('TypeTags', $this->default_conf, true);
27    }
28
29    $result = pwg_query('SHOW COLUMNS FROM `' . TAGS_TABLE . '` LIKE "id_typetags";');
30    if (!pwg_db_num_rows($result))
31    {
32      pwg_query('ALTER TABLE `' . TAGS_TABLE . '` ADD `id_typetags` SMALLINT(5) DEFAULT NULL;');
33    }
34
35    $query = '
36CREATE TABLE IF NOT EXISTS `' . $this->table . '` (
37  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
38  `name` varchar(255) NOT NULL,
39  `color` varchar(255) NOT NULL,
40  PRIMARY KEY (`id`)
41) DEFAULT CHARSET=utf8
42;';
43    pwg_query($query);
44  }
45
46  function update($old_version, $new_version, &$errors=array())
47  {
48    $this->install($new_version, $errors);
49  }
50
51  function uninstall()
52  {
53    conf_delete_param('TypeTags');
54
55    pwg_query('ALTER TABLE `' . TAGS_TABLE . '` DROP `id_typetags`');
56    pwg_query('DROP TABLE `' . $this->table . '`;');
57  }
58}
Note: See TracBrowser for help on using the repository browser.