source: extensions/UserCollections/include/install.inc.php @ 24085

Last change on this file since 24085 was 23551, checked in by mistic100, 11 years ago

many corrections & optimizations + remove useless code + clean

File size: 1.7 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4function user_collections_install() 
5{
6  global $conf, $prefixeTable;
7 
8  if (empty($conf['user_collections']))
9  {
10    $default_config = serialize(array(
11      'allow_mails' => true,
12      'allow_public' => true,
13      ));
14     
15    conf_update_param('user_collections', $default_config);
16    $conf['user_collections'] = $default_config;
17  }
18 
19  // create tables
20  $query = '
21CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'collections` (
22  `id` mediumint(8) NOT NULL AUTO_INCREMENT,
23  `user_id` smallint(5) DEFAULT NULL,
24  `name` varchar(255) NOT NULL,
25  `date_creation` datetime NOT NULL,
26  `comment` text NULL,
27  `nb_images` mediumint(8) NOT NULL DEFAULT 0,
28  `public` tinyint(1) DEFAULT 0,
29  `public_id` varchar(10) NULL,
30  PRIMARY KEY (`id`)
31) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
32;';
33  pwg_query($query);
34 
35  $query = '
36CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'collection_images` (
37  `col_id` mediumint(8) NOT NULL,
38  `image_id` mediumint(8) NOT NULL,
39  `add_date` DATETIME NULL,
40  UNIQUE KEY `UNIQUE` (`col_id`,`image_id`)
41) DEFAULT CHARSET=utf8
42;';
43  pwg_query($query);
44 
45  $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'collection_images` LIKE "add_date";');
46  if (!pwg_db_num_rows($result))
47  {
48    pwg_query('ALTER TABLE `'.$prefixeTable.'collection_images` ADD `add_date` DATETIME NULL;');
49  }
50 
51  $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'collections` LIKE "comment";');
52  if (!pwg_db_num_rows($result))
53  {
54    pwg_query('ALTER TABLE `'.$prefixeTable.'collections` ADD `comment` TEXT NULL;');
55    pwg_query('ALTER TABLE `'.$prefixeTable.'collections` DROP `active`;');
56  }
57}
58
59?>
Note: See TracBrowser for help on using the repository browser.