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

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

Plugins can add their own modules.

File size: 1.7 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`type` varchar(255) NOT NULL,
19`path` varchar(255) default NULL,
20`datas` longtext default NULL,
21`users` varchar(255) default NULL,
22`groups` varchar(255) default NULL,
23`show_title` enum(\'true\',\'false\') NOT NULL,
24`on_home` enum(\'true\',\'false\') NOT NULL,
25`on_cats` enum(\'true\',\'false\') NOT NULL,
26`on_picture` enum(\'true\',\'false\') NOT NULL,
27`id_line` varchar(1) default NULL,
28`width` smallint(9) default NULL,
29PRIMARY KEY  (`id`),
30KEY `on_home` (`on_home`),
31KEY `on_cats` (`on_cats`),
32KEY `on_picture` (`on_picture`)
33) DEFAULT CHARSET=utf8;';
34    pwg_query($q);
35 
36    $q = "INSERT INTO `" . $prefixeTable . "stuffs` (`id`, `pos`, `name`, `descr`, `type`, `path`, `datas`, `users`, `groups`, `show_title`, `on_home`, `on_cats`, `on_picture`, `id_line`, `width`)
37VALUES (0, 1, 'MainBlock', NULL, 'MainBlock', NULL, NULL, 'guest,generic,normal,admin,webmaster', NULL, 'true', 'true', 'true', 'true', NULL, NULL);";
38    pwg_query($q);
39  }
40}
41
42function plugin_activate($id, $version)
43{
44  global $plugins, $prefixeTable;
45
46  // Check if upgrade is needed
47  if ($version != $plugins->fs_plugins[$id]['version'])
48  {
49    define('STUFFS_VERSION', $plugins->fs_plugins[$id]['version']);
50    include('admin/upgrade.inc.php');
51  }
52}
53
54function plugin_uninstall()
55{
56    global $prefixeTable;
57
58  $q = 'DROP TABLE ' . $prefixeTable . 'stuffs;';
59    pwg_query($q);
60}
61
62?>
Note: See TracBrowser for help on using the repository browser.