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

Last change on this file since 17899 was 17899, checked in by mistic100, 12 years ago

first commit

File size: 1.4 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
13function skeleton_install() 
14{
15  global $conf, $prefixeTable;
16 
17  // add config parameter
18  if (empty($conf['skeleton']))
19  {
20    $skeleton_default_config = serialize(array(
21      'option1' => 10,
22      'option2' => true,
23      ));
24 
25    conf_update_param('skeleton', $skeleton_default_config);
26    $conf['skeleton'] = $skeleton_default_config;
27  }
28 
29  // add a new table
30        pwg_query('
31CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'skeleton` (
32  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
33  `field1` mediumint(8) DEFAULT NULL,
34  `field2` varchar(64) NOT NULL,
35  PRIMARY KEY (`id`)
36) DEFAULT CHARSET=utf8
37;');
38
39  // add a new column to existing table
40  $result = pwg_query('SHOW COLUMNS FROM `'.IMAGES_TABLE.'` LIKE "skeleton";');
41  if (!pwg_db_num_rows($result))
42  {     
43    pwg_query('ALTER TABLE `' . IMAGES_TABLE . '` ADD `skeleton` TINYINT(1) NOT NULL DEFAULT 0;');
44  }
45
46  // create a local directory
47  if ( file_exists(PWG_LOCAL_DIR) and !file_exists(PWG_LOCAL_DIR . 'skeleton/') ) 
48  {
49    mkdir(PWG_LOCAL_DIR . 'skeleton/', 0755);
50  }
51
52}
53
54?>
Note: See TracBrowser for help on using the repository browser.