source: extensions/Comments_Access_Manager/include/upgradedb.inc.php @ 11070

Last change on this file since 11070 was 11070, checked in by Eric, 13 years ago

-- Features refactory --
When "Comments for all" is disabled:

  • Users in a specified group can post comments without admin validation when admin validation is enabled.
  • Nickname is mandatory for guests comments

When "Comments for all" is enabled:

  • Users in a specified group can post comments without admin validation when admin validation is enabled.
  • Only a specified group can post comments

-- Admin panel refactory --
The admin panel displays option related with the state of "Comments for all" option.

New version 2.2.2 hard coded for publication

  • Property svn:eol-style set to LF
File size: 2.7 KB
Line 
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
10if(!defined('CM_PATH'))
11{
12  define('CM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
13}
14
15include_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/* *************************************** */
27function 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 = '
37SELECT value
38  FROM '.CONFIG_TABLE.'
39WHERE 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 = '
57SELECT version
58  FROM '.PLUGINS_TABLE.'
59WHERE 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 = '
67UPDATE '.PLUGINS_TABLE.'
68SET version="'.$version.'"
69WHERE id = "CommentsManager"
70LIMIT 1
71;';
72
73    pwg_query($query);
74  }
75}
76
77
78/* upgrade from 2.2.0 to 2.2.1 */
79/* *************************** */
80function upgradeCM_220_221()
81{
82  global $conf;
83
84  // Upgrading options
85  $query = '
86SELECT value
87  FROM '.CONFIG_TABLE.'
88WHERE 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/* *************************** */
107function upgradeCM_221_222()
108{
109  global $conf;
110
111  // Upgrading options
112  $query = '
113SELECT value
114  FROM '.CONFIG_TABLE.'
115WHERE 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?>
Note: See TracBrowser for help on using the repository browser.