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

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

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`datas` longtext default NULL,
20`users` varchar(255) default NULL,
21`groups` varchar(255) default NULL,
22`level` TINYINT( 3 ) NOT NULL default "0",
23`show_title` enum(\'true\',\'false\') NOT NULL,
24`on_home` enum(\'true\',\'false\') NOT NULL,
25`on_root` enum(\'true\',\'false\') NOT NULL,
26`on_cats` enum(\'true\',\'false\') NOT NULL,
27`on_picture` enum(\'true\',\'false\') NOT NULL,
28`id_line` varchar(1) default NULL,
29`width` smallint(9) default NULL,
30PRIMARY KEY  (`id`),
31KEY `on_home` (`on_home`),
32KEY `on_cats` (`on_cats`),
33KEY `on_picture` (`on_picture`)
34) DEFAULT CHARSET=utf8;';
35    pwg_query($q);
36 
37    $q = "INSERT INTO `" . $prefixeTable . "stuffs` (`id`, `pos`, `name`, `datas`, `users`, `show_title`, `on_home`, `on_cats`, `on_picture`)
38VALUES (0, 1, 'MainBlock', '".addslashes(serialize(true))."', 'guest,generic,normal,admin,webmaster', 'true', 'true', 'true', 'true');";
39    pwg_query($q);
40  }
41
42  if (!isset($conf['PWG_Stuffs']))
43  {
44    $config = array(
45      'level_perm' => false,
46      'group_perm' => false,
47      'user_perm' => false,
48    );
49
50    $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
51VALUES ("PWG_Stuffs" , "'.pwg_db_real_escape_string(serialize($config)).'" , "PWG Stuffs plugin configuration");';
52    pwg_query($query);
53  }
54}
55
56function plugin_uninstall()
57{
58  global $prefixeTable;
59
60  $q = 'DROP TABLE ' . $prefixeTable . 'stuffs;';
61  pwg_query($q);
62
63        $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="PWG_Stuffs";';
64  pwg_query($q);
65}
66
67?>
Note: See TracBrowser for help on using the repository browser.