1 | <?php |
---|
2 | /** |
---|
3 | * @author Eric@piwigo.org |
---|
4 | * |
---|
5 | * Upgrade processes for old plugin version |
---|
6 | * Called from maintain.inc.php on plugin activation |
---|
7 | * |
---|
8 | */ |
---|
9 | |
---|
10 | if(!defined('CM_PATH')) |
---|
11 | { |
---|
12 | define('CM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
13 | } |
---|
14 | |
---|
15 | include_once (CM_PATH.'include/functions.inc.php'); |
---|
16 | |
---|
17 | // +----------------------------------------------------------+ |
---|
18 | // | Upgrading database from old plugin versions | |
---|
19 | // +----------------------------------------------------------+ |
---|
20 | |
---|
21 | |
---|
22 | /* *************************************** */ |
---|
23 | /* Update plugin version in conf table */ |
---|
24 | /* Used everytime a new version is updated */ |
---|
25 | /* even if no database upgrade is needed */ |
---|
26 | /* *************************************** */ |
---|
27 | function CM_version_update() |
---|
28 | { |
---|
29 | global $conf; |
---|
30 | |
---|
31 | // Get current plugin version |
---|
32 | $plugin = CM_Infos(CM_PATH); |
---|
33 | $version = $plugin['version']; |
---|
34 | |
---|
35 | // Upgrading options |
---|
36 | $query = ' |
---|
37 | SELECT value |
---|
38 | FROM '.CONFIG_TABLE.' |
---|
39 | WHERE param = "CommentsManager" |
---|
40 | ;'; |
---|
41 | |
---|
42 | $result = pwg_query($query); |
---|
43 | $conf_CM = pwg_db_fetch_assoc($result); |
---|
44 | |
---|
45 | $Newconf_CM = unserialize($conf_CM['value']); |
---|
46 | |
---|
47 | $Newconf_CM[0] = $version; |
---|
48 | |
---|
49 | $update_conf = serialize($Newconf_CM); |
---|
50 | |
---|
51 | conf_update_param('CommentsManager', pwg_db_real_escape_string($update_conf)); |
---|
52 | |
---|
53 | |
---|
54 | // Check #_plugin table consistency |
---|
55 | // Only useful if a previous version upgrade has not worked correctly (rare case) |
---|
56 | $query = ' |
---|
57 | SELECT version |
---|
58 | FROM '.PLUGINS_TABLE.' |
---|
59 | WHERE id = "CommentsManager" |
---|
60 | ;'; |
---|
61 | |
---|
62 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
63 | |
---|
64 | if (empty($data['version']) or $data['version'] <> $version) |
---|
65 | { |
---|
66 | $query = ' |
---|
67 | UPDATE '.PLUGINS_TABLE.' |
---|
68 | SET version="'.$version.'" |
---|
69 | WHERE id = "CommentsManager" |
---|
70 | LIMIT 1 |
---|
71 | ;'; |
---|
72 | |
---|
73 | pwg_query($query); |
---|
74 | } |
---|
75 | } |
---|
76 | |
---|
77 | |
---|
78 | /* upgrade from 2.2.0 to 2.2.1 */ |
---|
79 | /* *************************** */ |
---|
80 | function upgradeCM_220_221() |
---|
81 | { |
---|
82 | global $conf; |
---|
83 | |
---|
84 | // Upgrading options |
---|
85 | $query = ' |
---|
86 | SELECT value |
---|
87 | FROM '.CONFIG_TABLE.' |
---|
88 | WHERE param = "CommentsManager" |
---|
89 | ;'; |
---|
90 | |
---|
91 | $result = pwg_query($query); |
---|
92 | $conf_CM = pwg_db_fetch_assoc($result); |
---|
93 | |
---|
94 | $Newconf_CM = unserialize($conf_CM['value']); |
---|
95 | |
---|
96 | $Newconf_CM[4] = 'false'; |
---|
97 | $Newconf_CM[5] = '-1'; |
---|
98 | |
---|
99 | $update_conf = serialize($Newconf_CM); |
---|
100 | |
---|
101 | conf_update_param('CommentsManager', pwg_db_real_escape_string($update_conf)); |
---|
102 | } |
---|
103 | |
---|
104 | |
---|
105 | /* upgrade from 2.2.1 to 2.2.2 */ |
---|
106 | /* *************************** */ |
---|
107 | function upgradeCM_221_222() |
---|
108 | { |
---|
109 | global $conf; |
---|
110 | |
---|
111 | // Upgrading options |
---|
112 | $query = ' |
---|
113 | SELECT value |
---|
114 | FROM '.CONFIG_TABLE.' |
---|
115 | WHERE param = "CommentsManager" |
---|
116 | ;'; |
---|
117 | |
---|
118 | $result = pwg_query($query); |
---|
119 | $conf_CM = pwg_db_fetch_assoc($result); |
---|
120 | |
---|
121 | $Newconf_CM = unserialize($conf_CM['value']); |
---|
122 | |
---|
123 | $Newconf_CM[6] = 'false'; |
---|
124 | $Newconf_CM[7] = '-1'; |
---|
125 | |
---|
126 | $update_conf = serialize($Newconf_CM); |
---|
127 | |
---|
128 | conf_update_param('CommentsManager', pwg_db_real_escape_string($update_conf)); |
---|
129 | } |
---|
130 | ?> |
---|