/
maintain.inc.php
101 lines (81 loc) · 2.34 KB
/
maintain.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
if(!defined('PH_PATH'))
{
define('PH_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
}
include_once (PH_PATH.'include/functions.inc.php');
function plugin_install($id, $version, &$errors)
{
global $conf;
/* ****************************************************************** */
/* **************** BEGIN - Data preparation in vars **************** */
/* ****************************************************************** */
$defaultPH = array();
// Set current plugin version in config table
$plugin = PHInfos(PH_PATH);
$version = $plugin['version'];
// Default global parameters for Prune History conf
// -------------------------------------------------
$defaultPH = array(
'PHVersion' => $version, // Prune History version
'AUTOPRUNE' => 'false', // Enable automated prune
'RANGEVALUE' => '0', // Range
'RANGE' => '0' // Value (Year, month, day)
);
// Create Prune History conf if not already exists
// ------------------------------------------------
$query = '
SELECT param
FROM '.CONFIG_TABLE.'
WHERE param = "PruneHistory"
;';
$count = pwg_db_num_rows(pwg_query($query));
if ($count == 0)
{
$q = '
INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
VALUES ("PruneHistory","'.pwg_db_real_escape_string(serialize($defaultPH)).'","Prune History parameters")
;';
pwg_query($q);
}
}
function plugin_activate($id, $version, &$errors)
{
global $conf;
/* Cleaning obsolete files */
/* *********************** */
PH_Obsolete_Files();
include_once (PH_PATH.'include/upgradedb.inc.php');
/* Check database upgrade */
/* ********************** */
$conf_PH = unserialize($conf['PruneHistory']);
if (isset($conf_PH[0]))
{
if (version_compare($conf_PH['PHVersion'], '1.1.0') < 0)
{
/* upgrade from 1.0 to 1.1 */
/* *********************** */
upgrade_100_110();
}
}
/* Update plugin version number in #_config table */
/* and check consistency of #_plugins table */
/* ********************************************** */
PH_version_update();
/* Reload plugin parameters */
/* ************************ */
load_conf_from_db('param like \'PruneHistory\'');
}
function plugin_uninstall()
{
global $conf;
if (isset($conf['PruneHistory']))
{
$q = '
DELETE FROM '.CONFIG_TABLE.'
WHERE param="PruneHistory"
;';
pwg_query($q);
}
}
?>