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($version,'false','false',-1,'false',-1); |
---|
19 | |
---|
20 | $query = ' |
---|
21 | SELECT param |
---|
22 | FROM '.CONFIG_TABLE.' |
---|
23 | WHERE param = "CommentsManager" |
---|
24 | ;'; |
---|
25 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
26 | |
---|
27 | if ($count == 0) |
---|
28 | { |
---|
29 | $q = ' |
---|
30 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
31 | VALUES ("CommentsManager","'.pwg_db_real_escape_string(serialize($default)).'","Comments Access Manager parameters") |
---|
32 | ;'; |
---|
33 | pwg_query($q); |
---|
34 | } |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | function plugin_activate() |
---|
39 | { |
---|
40 | global $conf; |
---|
41 | |
---|
42 | /* Cleaning obsolete files */ |
---|
43 | /* *********************** */ |
---|
44 | CM_Obsolete_Files(); |
---|
45 | |
---|
46 | include_once (CM_PATH.'include/upgradedb.inc.php'); |
---|
47 | |
---|
48 | // Database upgrade process |
---|
49 | if (isset($conf['CommentsManager'])) |
---|
50 | { |
---|
51 | $conf_CM = unserialize($conf['CommentsManager']); |
---|
52 | |
---|
53 | // upgrade from 2.2.0 to 2.2.1 |
---|
54 | if (version_compare($conf_CM[0], '2.2.1') < 0) |
---|
55 | { |
---|
56 | upgradeCM_220_221(); |
---|
57 | } |
---|
58 | |
---|
59 | // upgrade from 2.2.1 to 2.2.2 |
---|
60 | if (version_compare($conf_CM[0], '2.2.2') < 0) |
---|
61 | { |
---|
62 | upgradeCM_221_222(); |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | // Update plugin version number in #_config table and check consistency of #_plugins table |
---|
67 | CM_version_update(); |
---|
68 | |
---|
69 | load_conf_from_db('param like \'CommentsManager\''); |
---|
70 | } |
---|
71 | |
---|
72 | |
---|
73 | function plugin_uninstall() |
---|
74 | { |
---|
75 | global $conf; |
---|
76 | |
---|
77 | if (isset($conf['CommentsManager'])) |
---|
78 | { |
---|
79 | $q = ' |
---|
80 | DELETE FROM '.CONFIG_TABLE.' |
---|
81 | WHERE param="CommentsManager" |
---|
82 | ;'; |
---|
83 | |
---|
84 | pwg_query($q); |
---|
85 | } |
---|
86 | } |
---|
87 | ?> |
---|