1 | <?php |
---|
2 | |
---|
3 | if(!defined('CM_PATH')) |
---|
4 | { |
---|
5 | define('CM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
6 | } |
---|
7 | |
---|
8 | include_once (CM_PATH.'include/functions.inc.php'); |
---|
9 | |
---|
10 | function plugin_install() |
---|
11 | { |
---|
12 | global $conf; |
---|
13 | |
---|
14 | // Set current plugin version in config table |
---|
15 | $plugin = CM_Infos(CM_PATH); |
---|
16 | $version = $plugin['version']; |
---|
17 | |
---|
18 | $default = array( |
---|
19 | 'CMVersion' => $version, |
---|
20 | 'CM_No_Comment_Anonymous' => 'false', |
---|
21 | 'CM_GROUPCOMM' => 'false', |
---|
22 | 'CM_ALLOWCOMM_GROUP' => -1, |
---|
23 | 'CM_GROUPVALID1' => 'false', |
---|
24 | 'CM_VALIDCOMM1_GROUP' => -1, |
---|
25 | 'CM_GROUPVALID2' => 'false', |
---|
26 | 'CM_VALIDCOMM2_GROUP' => -1 |
---|
27 | ); |
---|
28 | |
---|
29 | $query = ' |
---|
30 | SELECT param |
---|
31 | FROM '.CONFIG_TABLE.' |
---|
32 | WHERE param = "CommentsManager" |
---|
33 | ;'; |
---|
34 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
35 | |
---|
36 | if ($count == 0) |
---|
37 | { |
---|
38 | $q = ' |
---|
39 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
40 | VALUES ("CommentsManager","'.pwg_db_real_escape_string(serialize($default)).'","Comments Access Manager parameters") |
---|
41 | ;'; |
---|
42 | pwg_query($q); |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | function plugin_activate() |
---|
48 | { |
---|
49 | global $conf; |
---|
50 | |
---|
51 | /* Cleaning obsolete files */ |
---|
52 | /* *********************** */ |
---|
53 | CM_Obsolete_Files(); |
---|
54 | |
---|
55 | include_once (CM_PATH.'include/upgradedb.inc.php'); |
---|
56 | |
---|
57 | // Database upgrade process |
---|
58 | if (isset($conf['CommentsManager'])) |
---|
59 | { |
---|
60 | $conf_CM = unserialize($conf['CommentsManager']); |
---|
61 | |
---|
62 | // upgrade from 2.2.0 to 2.2.1 |
---|
63 | if (version_compare($conf_CM[0], '2.2.1') < 0) |
---|
64 | { |
---|
65 | upgradeCM_220_221(); |
---|
66 | } |
---|
67 | |
---|
68 | // upgrade from 2.2.1 to 2.2.2 |
---|
69 | if (version_compare($conf_CM[0], '2.2.2') < 0) |
---|
70 | { |
---|
71 | upgradeCM_221_222(); |
---|
72 | } |
---|
73 | |
---|
74 | // upgrade from 2.4 to 2.5 |
---|
75 | if (version_compare($conf_CM[0], '2.5.0') < 0) |
---|
76 | { |
---|
77 | upgradeCM_240_250(); |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | // Update plugin version number in #_config table and check consistency of #_plugins table |
---|
82 | CM_version_update(); |
---|
83 | |
---|
84 | load_conf_from_db('param like \'CommentsManager\''); |
---|
85 | } |
---|
86 | |
---|
87 | |
---|
88 | function plugin_uninstall() |
---|
89 | { |
---|
90 | global $conf; |
---|
91 | |
---|
92 | if (isset($conf['CommentsManager'])) |
---|
93 | { |
---|
94 | $q = ' |
---|
95 | DELETE FROM '.CONFIG_TABLE.' |
---|
96 | WHERE param="CommentsManager" |
---|
97 | ;'; |
---|
98 | |
---|
99 | pwg_query($q); |
---|
100 | } |
---|
101 | } |
---|
102 | ?> |
---|