source: extensions/User_Info_Tracking/include/install.inc.php @ 19909

Last change on this file since 19909 was 19701, checked in by Charles2012, 12 years ago

Upload to SVN.

File size: 2.1 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 user_info_tracking_install() 
17{
18  global $conf, $prefixeTable;
19 
20  // add config parameter
21  if (empty($conf['user_info_tracking']))
22  {
23    $user_info_tracking_default_config = serialize(array(
24      'rowId' => 10,
25      'uiPerPage' => 25,
26      'uiDefaultSortColumn' => timeStamp,
27      'uiDefaultSortOrder' => ASC,
28      'uiDateFormat' => '%c',
29      ));
30 
31    conf_update_param('user_info_tracking', $user_info_tracking_default_config);
32    $conf['user_info_tracking'] = $user_info_tracking_default_config;
33  }
34  else
35  {
36    // if you need to test the "old" configuration you must check if not yet unserialized
37    $old_conf = is_string($conf['user_info_tracking']) ? unserialize($conf['user_info_tracking']) : $conf['user_info_tracking'];
38  }
39 
40  // add a new table
41        pwg_query('
42CREATE TABLE IF NOT EXISTS `'. $prefixeTable .'user_info_tracking` (
43  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
44  `userId` int(11) DEFAULT NULL,
45  `userName` mediumtext DEFAULT NULL,
46  `ipAddress` mediumtext DEFAULT NULL,
47  `timeStamp` mediumtext DEFAULT NULL,
48  `action` mediumtext DEFAULT NULL,
49  PRIMARY KEY (`id`)
50) ENGINE=MyISAM DEFAULT CHARSET=utf8
51;');
52
53  // add a new column to existing table
54//  $result = pwg_query('SHOW COLUMNS FROM `'.IMAGES_TABLE.'` LIKE "skeleton";');
55//  if (!pwg_db_num_rows($result))
56//  {     
57//    pwg_query('ALTER TABLE `' . IMAGES_TABLE . '` ADD `skeleton` TINYINT(1) NOT NULL DEFAULT 0;');
58//  }
59
60  // create a local directory
61  if ( file_exists(PWG_LOCAL_DIR) and !file_exists(PWG_LOCAL_DIR . 'user_info_tracking/') ) 
62  {
63    mkdir(PWG_LOCAL_DIR . 'user_info_tracking/', 0755);
64  }
65
66}
67
68?>
Note: See TracBrowser for help on using the repository browser.