source: extensions/PWG_Stuffs/maintain.inc.php @ 9383

Last change on this file since 9383 was 9383, checked in by patdenice, 13 years ago

Add display option. Optimizations.

File size: 1.9 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5function plugin_install()
6{
7  global $prefixeTable, $conf;
8
9  $query = 'SHOW TABLES LIKE "' . $prefixeTable . 'stuffs"';
10  $result = pwg_query($query);
11  if (!mysql_fetch_row($result))
12  {
13    $q = 'CREATE TABLE `' . $prefixeTable . 'stuffs` (
14`id` smallint(5) NOT NULL,
15`pos` smallint(5) NOT NULL,
16`name` text NOT NULL,
17`descr` varchar(255) default NULL,
18`path` varchar(255) default NULL,
19`parent` varchar(255) default NULL,
20`datas` longtext default NULL,
21`users` varchar(255) default NULL,
22`groups` varchar(255) default NULL,
23`level` TINYINT( 3 ) NOT NULL default "0",
24`show_title` enum(\'true\',\'false\') NOT NULL,
25`on_home` enum(\'true\',\'false\') NOT NULL,
26`on_root` enum(\'true\',\'false\') NOT NULL,
27`on_cats` enum(\'true\',\'false\') NOT NULL,
28`on_picture` enum(\'true\',\'false\') NOT NULL,
29`id_line` varchar(1) default NULL,
30`width` smallint(9) default NULL,
31PRIMARY KEY  (`id`),
32KEY `on_home` (`on_home`),
33KEY `on_cats` (`on_cats`),
34KEY `on_picture` (`on_picture`)
35) DEFAULT CHARSET=utf8;';
36    pwg_query($q);
37 
38    $q = "INSERT INTO `" . $prefixeTable . "stuffs` (`id`, `pos`, `name`, `users`, `show_title`, `on_home`, `on_cats`, `on_picture`)
39VALUES (0, 1, 'MainBlock', 'guest,generic,normal,admin,webmaster', 'true', 'true', 'true', 'true');";
40    pwg_query($q);
41  }
42
43  if (!isset($conf['PWG_Stuffs']))
44  {
45    $config = array(
46      'level_perm' => false,
47      'group_perm' => false,
48      'user_perm' => false,
49    );
50
51    $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
52VALUES ("PWG_Stuffs" , "'.pwg_db_real_escape_string(serialize($config)).'" , "PWG Stuffs configuration");';
53    pwg_query($query);
54  }
55}
56
57function plugin_uninstall()
58{
59  global $prefixeTable;
60
61  $q = 'DROP TABLE ' . $prefixeTable . 'stuffs;';
62  pwg_query($q);
63
64        $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="PWG_Stuffs";';
65  pwg_query($q);
66}
67
68?>
Note: See TracBrowser for help on using the repository browser.