source: extensions/NBC_UserAdvManager/trunk/include/upgradedb.inc.php @ 5762

Last change on this file since 5762 was 5762, checked in by Eric, 14 years ago

[NBC_UserAdvManager]

Bug 1576 partially fixed - Compatibility with other database systems than MySql like PostgreSql or Sqlite. Using Piwigo's pwg_db_### integrated functions. There are 2 php functions for mysql still missing for PostgreSql and Sqlite

  • Bug 1586 fixed - Links to official forum topic support and bugtacker were added in plugin's admin page
  • Moving database upgrade function from maintain.inc.php to include/upgradedb.inc.php
  • Property svn:eol-style set to LF
File size: 6.2 KB
Line 
1<?php
2/**
3 * @author Eric@piwigo.org
4 * @copyright 2010
5 *
6 * Upgrade processes for old plugin version
7 * Called from maintain.inc.php on plugin activation
8 *
9 */
10
11if(!defined("UAM_PATH")) define('UAM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
12if (!defined('UAM_ROOT'))
13{
14  define('UAM_ROOT', dirname(__FILE__).'/');
15}
16
17include_once (UAM_PATH.'include/constants.php');
18include_once (UAM_PATH.'include/functions.inc.php');
19
20// +----------------------------------------------------------+
21// |       Upgrading database from old plugin versions        |
22// +----------------------------------------------------------+
23
24/* upgrade from branch 2.10 to 2.11 */
25/* ******************************** */
26function upgrade_210_211()
27{
28        global $conf;
29         
30  $q = '
31INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
32VALUES ("nbc_UserAdvManager_ConfirmMail","false;5;Hello.
33               
34This is a reminder message because you registered on our gallery but you do not validate your registration and your validation key has expired. To still allow you to access to our gallery, your validation period has been reset. You have again 5 days to validate your registration.
35
36Note: After this period, your account will be permanently deleted.;false;Hello.
37
38This is a reminder message because you registered on our gallery but you do not validate your registration and your validation key will expire. To allow you access to our gallery, you have 2 days to confirm your registration by clicking on the link in the message you should have received when you registered.
39
40Note: After this period, your account will be permanently deleted.","Parametres nbc_UserAdvManager - ConfirmMail")
41  ;';
42  pwg_query($q);
43
44  upgrade_211_212();
45}
46
47
48/* upgrade from branch 2.11 to 2.12 */
49/* ******************************** */
50function upgrade_211_212()
51{
52        global $conf;
53
54  $conf_UAM = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
55
56  if ((!isset($conf_UAM[14]) and !isset($conf_UAM[15])) and !isset($conf_UAM[16]) and !isset($conf_UAM[17]))
57  {
58    $upgrade_UAM = $conf_UAM[0].';'.$conf_UAM[1].';'.$conf_UAM[2].';'.$conf_UAM[3].';'.$conf_UAM[4].';'.$conf_UAM[5].';'.$conf_UAM[6].';'.$conf_UAM[7].';'.$conf_UAM[8].';'.$conf_UAM[9].';'.$conf_UAM[10].';'.$conf_UAM[11].';'.$conf_UAM[12].';'.$conf_UAM[13].';false;100;false;false;10;Hello.
59       
60This is a reminder because a very long time passed since your last visit on our gallery. If you do not want anymore to use your access account, please let us know by replying to this email. Your account will be deleted.
61
62On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account.
63
64Best regards,
65
66The admin of the gallery.';
67               
68                $query = '
69UPDATE '.CONFIG_TABLE.'
70SET value="'.$upgrade_UAM.'"
71WHERE param="nbc_UserAdvManager"
72LIMIT 1
73;';
74                pwg_query($query);
75  }
76 
77        $q = "
78CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
79  user_id SMALLINT(5) NOT NULL DEFAULT '0',
80  lastvisit DATETIME NULL DEFAULT NULL,
81  reminder ENUM('true','false') NULL,
82PRIMARY KEY (`user_id`)
83  )
84;";
85  pwg_query($q);
86
87  upgrade_212_213();
88}
89
90
91/* upgrade from branch 2.12 to 2.13 */
92/* ******************************** */
93function upgrade_212_213()
94{
95/* Create missing table */
96  $query = "
97ALTER TABLE ".USER_CONFIRM_MAIL_TABLE."
98ADD reminder ENUM('true', 'false') NULL DEFAULT NULL
99;";
100 
101  pwg_query($query);
102
103/* Upgrade plugin configuration */
104        global $conf;
105
106  $conf_UAM = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
107
108  if ((!isset($conf_UAM[20])))
109  {
110    $upgrade_UAM = $conf_UAM[0].';'.$conf_UAM[1].';'.$conf_UAM[2].';'.$conf_UAM[3].';'.$conf_UAM[4].';'.$conf_UAM[5].';'.$conf_UAM[6].';'.$conf_UAM[7].';'.$conf_UAM[8].';'.$conf_UAM[9].';'.$conf_UAM[10].';'.$conf_UAM[11].';'.$conf_UAM[12].';'.$conf_UAM[13].';'.$conf_UAM[14].';'.$conf_UAM[15].';'.$conf_UAM[16].';'.$conf_UAM[17].';'.$conf_UAM[18].';'.$conf_UAM[19].';false';
111               
112                $query = '
113UPDATE '.CONFIG_TABLE.'
114SET value="'.$upgrade_UAM.'"
115WHERE param="nbc_UserAdvManager"
116LIMIT 1
117;';
118                pwg_query($query);
119   
120    upgrade_213_214();
121  }
122}
123
124
125/* upgrade from branch 2.13 to 2.14 */
126/* ******************************** */
127function upgrade_213_214()
128{
129        global $conf;
130 
131  $conf_UAM = explode(';', $conf['nbc_UserAdvManager']);
132
133  $upgrade_UAM = array($conf_UAM[0],$conf_UAM[1],$conf_UAM[2],$conf_UAM[3],$conf_UAM[4],$conf_UAM[5],$conf_UAM[6],$conf_UAM[7],$conf_UAM[8],$conf_UAM[9],$conf_UAM[10],$conf_UAM[11],$conf_UAM[12],$conf_UAM[13],$conf_UAM[14],$conf_UAM[15],$conf_UAM[16],$conf_UAM[17],$conf_UAM[18],$conf_UAM[19],$conf_UAM[20],'false');
134
135  $query = '
136UPDATE '.CONFIG_TABLE.'
137  SET value = "'.addslashes(serialize($upgrade_UAM)).'"
138  WHERE param = "nbc_UserAdvManager"
139;';
140  pwg_query($query);
141 
142  if (unserialize($conf['nbc_UserAdvManager_ConfirmMail']) === false)
143  {
144    $data = explode(';', $conf['nbc_UserAdvManager_ConfirmMail']);
145
146    $query = '
147UPDATE '.CONFIG_TABLE.'
148  SET value = "'.addslashes(serialize($data)).'"
149  WHERE param = "nbc_UserAdvManager_ConfirmMail"
150;';
151    pwg_query($query);
152   
153    upgrade_214_215();
154  }
155}
156
157/* upgrade from branch 2.14 to 2.15 */
158/* ******************************** */
159function upgrade_214_215()
160{
161  global $conf;
162
163/* Changing parameter name */
164  $q = '
165UPDATE '.CONFIG_TABLE.'
166SET param = "UserAdvManager"
167WHERE param = "nbc_UserAdvManager"
168;';
169  pwg_query($q);
170 
171  $q = '
172UPDATE '.CONFIG_TABLE.'
173SET param = "UserAdvManager_ConfirmMail"
174WHERE param = "nbc_UserAdvManager_ConfirmMail"
175;';
176  pwg_query($q);
177
178/* Upgrading ConfirmMail options */
179  $query = '
180SELECT value
181  FROM '.CONFIG_TABLE.'
182WHERE param = "UserAdvManager_ConfirmMail"
183;';
184
185  $result = pwg_query($query);
186  $conf_UAM_ConfirmMail = pwg_db_fetch_assoc($result);
187   
188  $conf_ConfirmMail = unserialize($conf_UAM_ConfirmMail['value']);
189 
190  $conf_ConfirmMail[5] ='Thank you to have confirmed your email address and your registration on the gallery. Have fun !';
191  $conf_ConfirmMail[6] ='Your activation key is incorrect or expired or you have already validated your account, please contact the webmaster to fix this problem.';
192 
193  $update_conf = serialize($conf_ConfirmMail);
194   
195  $query = '
196      UPDATE '.CONFIG_TABLE.'
197                        SET value="'.addslashes($update_conf).'"
198                        WHERE param="UserAdvManager_ConfirmMail"
199                        LIMIT 1
200                ;';
201
202                pwg_query($query);
203}
204?>
Note: See TracBrowser for help on using the repository browser.