/
maintain.inc.php
109 lines (86 loc) · 2.23 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
102
103
104
105
106
107
108
109
<?php
if(!defined('CM_PATH'))
{
define('CM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
}
include_once (CM_PATH.'include/functions.inc.php');
function plugin_install($id, $version, &$errors)
{
global $conf;
// Set current plugin version in config table
$plugin = CM_Infos(CM_PATH);
$version = $plugin['version'];
$default = array(
'CMVersion' => $version,
'CM_No_Comment_Anonymous' => 'false',
'CM_GROUPCOMM' => 'false',
'CM_ALLOWCOMM_GROUP' => -1,
'CM_GROUPVALID1' => 'false',
'CM_VALIDCOMM1_GROUP' => -1,
'CM_GROUPVALID2' => 'false',
'CM_VALIDCOMM2_GROUP' => -1
);
$query = '
SELECT param
FROM '.CONFIG_TABLE.'
WHERE param = "CommentsManager"
;';
$count = pwg_db_num_rows(pwg_query($query));
if ($count == 0)
{
$q = '
INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
VALUES ("CommentsManager","'.pwg_db_real_escape_string(serialize($default)).'","Comments Access Manager parameters")
;';
pwg_query($q);
}
}
function plugin_activate($id, $version, &$errors)
{
global $conf;
/* Cleaning obsolete files */
/* *********************** */
CM_Obsolete_Files();
include_once (CM_PATH.'include/upgradedb.inc.php');
$conf_CM = unserialize($conf['CommentsManager']);
// Database upgrade process
if (isset($conf_CM[0]))
{
$conf_CM = unserialize($conf['CommentsManager']);
// upgrade from 2.2.0 to 2.2.1
if (version_compare($conf_CM[0], '2.2.1') < 0)
{
upgradeCM_220_221();
}
// upgrade from 2.2.1 to 2.2.2
if (version_compare($conf_CM[0], '2.2.2') < 0)
{
upgradeCM_221_222();
}
// upgrade from 2.4 to 2.5
if (version_compare($conf_CM[0], '2.5.0') < 0)
{
upgradeCM_240_250();
}
// Preset for future upgrades
// if (isset($conf_CM['CMVersion']))
// {
// }
}
// Update plugin version number in #_config table and check consistency of #_plugins table
CM_version_update();
load_conf_from_db('param like \'CommentsManager\'');
}
function plugin_uninstall()
{
global $conf;
if (isset($conf['CommentsManager']))
{
$q = '
DELETE FROM '.CONFIG_TABLE.'
WHERE param="CommentsManager"
;';
pwg_query($q);
}
}
?>