source: extensions/Prune_History/maintain.inc.php @ 14838

Last change on this file since 14838 was 14838, checked in by Eric, 12 years ago

Initial commit

  • Property svn:eol-style set to LF
File size: 1.9 KB
Line 
1<?php
2
3if(!defined('PH_PATH'))
4{
5  define('PH_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
6}
7
8include_once (PH_PATH.'include/functions.inc.php');
9
10function plugin_install()
11{
12        global $conf;
13
14/* ****************************************************************** */
15/* **************** BEGIN - Data preparation in vars **************** */
16/* ****************************************************************** */
17
18  $defaultPH = array();
19
20  // Set current plugin version in config table
21  $plugin =  PHInfos(PH_PATH);
22  $version = $plugin['version'];
23
24  // Default global parameters for Prune History conf
25  // -------------------------------------------------
26  $defaultPH[0] = $version;                                  // Prune History version
27  $defaultPH[1] = 'false';                                   // Enable automated prune
28
29  // Create Prune History conf if not already exists
30  // ------------------------------------------------
31        $query = '
32SELECT param
33  FROM '.CONFIG_TABLE.'
34WHERE param = "PruneHistory"
35;';
36  $count = pwg_db_num_rows(pwg_query($query));
37 
38  if ($count == 0)
39  {
40    $q = '
41INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
42VALUES ("PruneHistory","'.pwg_db_real_escape_string(serialize($defaultPH)).'","Prune History parameters")
43  ;';
44    pwg_query($q);
45  }
46}
47
48
49function plugin_activate()
50{
51  global $conf;
52
53/* Cleaning obsolete files */
54/* *********************** */
55  PH_Obsolete_Files();
56
57/* Update plugin version number in #_config table */
58/* and check consistency of #_plugins table       */
59/* ********************************************** */
60  PH_version_update();
61
62/* Reload plugin parameters */
63/* ************************ */
64  load_conf_from_db('param like \'PruneHistory\'');
65}
66
67
68function plugin_uninstall()
69{
70  global $conf;
71
72  if (isset($conf['PruneHistory']))
73  {
74    $q = '
75DELETE FROM '.CONFIG_TABLE.'
76WHERE param="PruneHistory"
77;';
78
79    pwg_query($q);
80  }
81}
82?>
Note: See TracBrowser for help on using the repository browser.