source: extensions/NBC_UserAdvManager/branches/2.15/include/upgradedb.inc.php @ 6256

Last change on this file since 6256 was 6256, checked in by Eric, 10 years ago

[NBC_UserAdvManager]

Merged from trunk to branch 2.15

  • 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'))
12{
13  define('UAM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
14}
15if (!defined('UAM_ROOT'))
16{
17  define('UAM_ROOT', dirname(__FILE__).'/');
18}
19
20include_once (UAM_PATH.'include/constants.php');
21include_once (UAM_PATH.'include/functions.inc.php');
22
23// +----------------------------------------------------------+
24// |       Upgrading database from old plugin versions        |
25// +----------------------------------------------------------+
26
27/* upgrade from branch 2.10 to 2.11 */
28/* ******************************** */
29function upgrade_210_211()
30{
31        global $conf;
32         
33  $q = '
34INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
35VALUES ("nbc_UserAdvManager_ConfirmMail","false;5;Hello.
36               
37This 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.
38
39Note: After this period, your account will be permanently deleted.;false;Hello.
40
41This 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.
42
43Note: After this period, your account will be permanently deleted.","Parametres nbc_UserAdvManager - ConfirmMail")
44  ;';
45  pwg_query($q);
46
47  upgrade_211_212();
48}
49
50
51/* upgrade from branch 2.11 to 2.12 */
52/* ******************************** */
53function upgrade_211_212()
54{
55        global $conf;
56
57  $conf_UAM = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
58
59  if ((!isset($conf_UAM[14]) and !isset($conf_UAM[15])) and !isset($conf_UAM[16]) and !isset($conf_UAM[17]))
60  {
61    $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.
62       
63This 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.
64
65On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account.
66
67Best regards,
68
69The admin of the gallery.';
70               
71                $query = '
72UPDATE '.CONFIG_TABLE.'
73SET value="'.$upgrade_UAM.'"
74WHERE param="nbc_UserAdvManager"
75LIMIT 1
76;';
77                pwg_query($query);
78  }
79 
80        $q = "
81CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
82  user_id SMALLINT(5) NOT NULL DEFAULT '0',
83  lastvisit DATETIME NULL DEFAULT NULL,
84  reminder ENUM('true','false') NULL,
85PRIMARY KEY (`user_id`)
86  )
87;";
88  pwg_query($q);
89
90  upgrade_212_213();
91}
92
93
94/* upgrade from branch 2.12 to 2.13 */
95/* ******************************** */
96function upgrade_212_213()
97{
98/* Create missing table */
99  $query = "
100ALTER TABLE ".USER_CONFIRM_MAIL_TABLE."
101ADD reminder ENUM('true', 'false') NULL DEFAULT NULL
102;";
103 
104  pwg_query($query);
105
106/* Upgrade plugin configuration */
107        global $conf;
108
109  $conf_UAM = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
110
111  if ((!isset($conf_UAM[20])))
112  {
113    $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';
114               
115                $query = '
116UPDATE '.CONFIG_TABLE.'
117SET value="'.$upgrade_UAM.'"
118WHERE param="nbc_UserAdvManager"
119LIMIT 1
120;';
121                pwg_query($query);
122   
123    upgrade_213_214();
124  }
125}
126
127
128/* upgrade from branch 2.13 to 2.14 */
129/* ******************************** */
130function upgrade_213_214()
131{
132        global $conf;
133 
134  $conf_UAM = explode(';', $conf['nbc_UserAdvManager']);
135
136  $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');
137
138  $query = '
139UPDATE '.CONFIG_TABLE.'
140  SET value = "'.addslashes(serialize($upgrade_UAM)).'"
141  WHERE param = "nbc_UserAdvManager"
142;';
143  pwg_query($query);
144 
145  if (unserialize($conf['nbc_UserAdvManager_ConfirmMail']) === false)
146  {
147    $data = explode(';', $conf['nbc_UserAdvManager_ConfirmMail']);
148
149    $query = '
150UPDATE '.CONFIG_TABLE.'
151  SET value = "'.addslashes(serialize($data)).'"
152  WHERE param = "nbc_UserAdvManager_ConfirmMail"
153;';
154    pwg_query($query);
155   
156    upgrade_214_215();
157  }
158}
159
160/* upgrade from branch 2.14 to 2.15 */
161/* ******************************** */
162function upgrade_214_215()
163{
164  global $conf;
165
166/* Changing parameter name */
167  $q = '
168UPDATE '.CONFIG_TABLE.'
169SET param = "UserAdvManager"
170WHERE param = "nbc_UserAdvManager"
171;';
172  pwg_query($q);
173 
174  $q = '
175UPDATE '.CONFIG_TABLE.'
176SET param = "UserAdvManager_ConfirmMail"
177WHERE param = "nbc_UserAdvManager_ConfirmMail"
178;';
179  pwg_query($q);
180
181/* Upgrading ConfirmMail options */
182  $query = '
183SELECT value
184  FROM '.CONFIG_TABLE.'
185WHERE param = "UserAdvManager_ConfirmMail"
186;';
187
188  $result = pwg_query($query);
189  $conf_UAM_ConfirmMail = pwg_db_fetch_assoc($result);
190   
191  $conf_ConfirmMail = unserialize($conf_UAM_ConfirmMail['value']);
192 
193  $conf_ConfirmMail[5] ='Thank you to have confirmed your email address and your registration on the gallery. Have fun !';
194  $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.';
195 
196  $update_conf = serialize($conf_ConfirmMail);
197   
198  $query = '
199      UPDATE '.CONFIG_TABLE.'
200                        SET value="'.addslashes($update_conf).'"
201                        WHERE param="UserAdvManager_ConfirmMail"
202                        LIMIT 1
203                ;';
204
205                pwg_query($query);
206}
207?>
Note: See TracBrowser for help on using the repository browser.