source: extensions/skeleton/include/install.inc.php @ 17924

Last change on this file since 17924 was 17924, checked in by mistic100, 12 years ago
  • ENGINE=MyISAM for table creation
  • add simple prefilter example
  • don't hardcode plugin folder
  • define VERSION auto, implemented soon in PEM
File size: 1.6 KB
Line 
1<?php
2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
3
4/**
5 * The installation function is called by main.inc.php and maintain.inc.php
6 * in order to install and/or update the plugin.
7 *
8 * That's why all operations must be conditionned :
9 *    - use "if empty" for configuration vars
10 *    - use "IF NOT EXISTS" for table creation
11 *
12 * Unlike the functions in maintain.inc.php, the name of this function must be unique
13 * and not enter in conflict with other plugins.
14 */
15
16function skeleton_install() 
17{
18  global $conf, $prefixeTable;
19 
20  // add config parameter
21  if (empty($conf['skeleton']))
22  {
23    $skeleton_default_config = serialize(array(
24      'option1' => 10,
25      'option2' => true,
26      ));
27 
28    conf_update_param('skeleton', $skeleton_default_config);
29    $conf['skeleton'] = $skeleton_default_config;
30  }
31 
32  // add a new table
33        pwg_query('
34CREATE TABLE IF NOT EXISTS `'. $prefixeTable .'skeleton` (
35  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
36  `field1` mediumint(8) DEFAULT NULL,
37  `field2` varchar(64) NOT NULL,
38  PRIMARY KEY (`id`)
39) ENGINE=MyISAM DEFAULT CHARSET=utf8
40;');
41
42  // add a new column to existing table
43  $result = pwg_query('SHOW COLUMNS FROM `'.IMAGES_TABLE.'` LIKE "skeleton";');
44  if (!pwg_db_num_rows($result))
45  {     
46    pwg_query('ALTER TABLE `' . IMAGES_TABLE . '` ADD `skeleton` TINYINT(1) NOT NULL DEFAULT 0;');
47  }
48
49  // create a local directory
50  if ( file_exists(PWG_LOCAL_DIR) and !file_exists(PWG_LOCAL_DIR . 'skeleton/') ) 
51  {
52    mkdir(PWG_LOCAL_DIR . 'skeleton/', 0755);
53  }
54
55}
56
57?>
Note: See TracBrowser for help on using the repository browser.