source: extensions/NBC_UserAdvManager/trunk/maintain.inc.php @ 5427

Last change on this file since 5427 was 5181, checked in by Eric, 15 years ago

[NBC_UserAdvManager]

  • Bug 1474 fixed : Customizable text for ConfirmMail.tpl
  • Bug 1467 fixed : FCK Editor's functionnalities are available on registration's confirmation return page customization fields
  • Bug 1508 fixed : Plugin's name'll now be UserAdvManager (deletion of "nbc_" in code and PEM). Plugin's name is correctly displayed in plugins manager.
  • Property svn:eol-style set to LF
File size: 10.6 KB
Line 
1<?php
2
3if(!defined("UAM_PATH")) define('UAM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
4if (!defined('UAM_ROOT')) {
5  define('UAM_ROOT',     dirname(__FILE__).'/');
6}
7
8include_once (UAM_PATH.'include/constants.php');
9include_once (UAM_PATH.'include/functions.inc.php');
10
11
12function plugin_install()
13{
14        global $conf;
15       
16  $default1 = array('false','false','false',-1,-1,-1,'false','false','',-1,'','','false','','false',100,'false','false',10,'Hello.
17       
18This 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.
19
20On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account.
21
22Best regards,
23
24The admin of the gallery.','false','false');
25
26  $q = '
27INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
28VALUES ("UserAdvManager","'.addslashes(serialize($default1)).'","UAM parameters")
29  ;';
30  pwg_query($q);
31
32
33  $default2 = array('false',5,'Hello.
34               
35This 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.
36
37Note: After this period, your account will be permanently deleted.','false','Hello.
38
39This 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.
40
41Note: After this period, your account will be permanently deleted.','Thank you to have confirmed your email address and your registration on the gallery. Have fun !','Your activation key is incorrect or expired or you have already validated your account, please contact the webmaster to fix this problem.');
42
43  $q = '
44INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
45VALUES ("UserAdvManager_ConfirmMail","'.addslashes(serialize($default2)).'","UAM ConfirmMail parameters")
46  ;';
47  pwg_query($q);
48
49
50        $q = "
51CREATE TABLE IF NOT EXISTS ".USER_CONFIRM_MAIL_TABLE." (
52  id varchar(50) NOT NULL default '',
53  user_id smallint(5) NOT NULL default '0',
54  mail_address varchar(255) default NULL,
55  status enum('webmaster','admin','normal','generic','guest') default NULL,
56  date_check datetime default NULL,
57  reminder ENUM('true','false') NULL,
58PRIMARY KEY  (id)
59  )
60;";
61  pwg_query($q);
62
63        $q = "
64CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
65  user_id SMALLINT(5) NOT NULL DEFAULT '0',
66  lastvisit DATETIME NULL DEFAULT NULL,
67  reminder ENUM('true','false') NULL,
68PRIMARY KEY (`user_id`)
69  )
70;";
71  pwg_query($q);
72}
73
74
75function plugin_activate()
76{
77  global $conf;
78
79/* Cleaning obsolete files */
80/* *********************** */
81  clean_obsolete_files();
82
83
84/* Check for upgrade from 2.10 to 2.11 */
85/* *********************************** */
86        $query = '
87SELECT *
88  FROM '.CONFIG_TABLE.'
89WHERE param = "nbc_UserAdvManager_ConfirmMail"
90;';
91  $count = mysql_num_rows(pwg_query($query)); 
92 
93        if ($count == 0)
94        {
95  /* upgrade from branch 2.10 to 2.11 */
96  /* ******************************** */
97                upgrade_210();
98        }
99
100
101/* Check for upgrade from 2.11 to 2.12 */
102/* *********************************** */
103  if (!table_exist(USER_LASTVISIT_TABLE))
104  {
105  /* upgrade from branch 2.11 to 2.12 */
106  /* ******************************** */
107                upgrade_211();
108  }
109
110
111/* Check for upgrade from 2.12 to 2.13 */
112/* *********************************** */
113  $query = '
114SELECT *
115FROM '.USER_CONFIRM_MAIL_TABLE.'
116;';
117
118  $result = pwg_query($query);
119       
120        $numfields = mysql_num_fields($result);
121
122  if ($numfields < 6)
123  {
124  /* upgrade from branch 2.12 to 2.13 */
125  /* ******************************** */
126    upgrade_212();
127  }
128
129
130/* Serializing conf parameters - Available since 2.14.0 */
131/* **************************************************** */
132  if (unserialize($conf['nbc_UserAdvManager']) === false)
133  {
134  /* upgrade from branch 2.13 to 2.14 */
135  /* ******************************** */
136    upgrade_213();
137  }
138
139
140/* Check for upgrade from 2.14.1 to 2.14.2 */
141/* *************************************** */
142        $query1 = '
143SELECT param
144  FROM '.CONFIG_TABLE.'
145WHERE param = "nbc_UserAdvManager_ConfirmMail"
146;';
147  $count1 = mysql_num_rows(pwg_query($query1));
148 
149        $query1 = '
150SELECT param
151  FROM '.CONFIG_TABLE.'
152WHERE param = "nbc_UserAdvManager_ConfirmMail"
153;';
154  $count2 = mysql_num_rows(pwg_query($query1)); 
155 
156        if ($count1 == 1 or $count2 == 1)
157        {
158  /* upgrade from branch 2.14.1 to 2.14.2 */
159  /* ************************************ */
160                upgrade_214_1();
161        }
162}
163
164
165function plugin_uninstall()
166{
167  global $conf;
168
169  if (isset($conf['UserAdvManager']))
170  {
171    $q = '
172DELETE FROM '.CONFIG_TABLE.'
173WHERE param="UserAdvManager"
174;';
175
176    pwg_query($q);
177  }
178
179  if (isset($conf['UserAdvManager_ConfirmMail']))
180  {
181    $q = '
182DELETE FROM '.CONFIG_TABLE.'
183WHERE param="UserAdvManager_ConfirmMail"
184;';
185
186    pwg_query($q);
187  }
188
189  $q = 'DROP TABLE '.USER_CONFIRM_MAIL_TABLE.';';
190  pwg_query( $q );
191
192  $q = 'DROP TABLE '.USER_LASTVISIT_TABLE.';';
193  pwg_query( $q );
194}
195
196
197// +----------------------------------------------------------+
198// |       Upgrading database from old plugin versions        |
199// +----------------------------------------------------------+
200
201/* upgrade from branch 2.10 to 2.11 */
202/* ******************************** */
203function upgrade_210()
204{
205        global $conf;
206         
207  $q = '
208INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
209VALUES ("nbc_UserAdvManager_ConfirmMail","false;5;Hello.
210               
211This 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.
212
213Note: After this period, your account will be permanently deleted.;false;Hello.
214
215This 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.
216
217Note: After this period, your account will be permanently deleted.","Parametres nbc_UserAdvManager - ConfirmMail")
218  ;';
219  pwg_query($q);
220
221  upgrade_211();
222}
223
224
225/* upgrade from branch 2.11 to 2.12 */
226/* ******************************** */
227function upgrade_211()
228{
229        global $conf;
230
231  $conf_UAM = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
232
233  if ((!isset($conf_UAM[14]) and !isset($conf_UAM[15])) and !isset($conf_UAM[16]) and !isset($conf_UAM[17]))
234  {
235    $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.
236       
237This 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.
238
239On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account.
240
241Best regards,
242
243The admin of the gallery.';
244               
245                $query = '
246UPDATE '.CONFIG_TABLE.'
247SET value="'.$upgrade_UAM.'"
248WHERE param="nbc_UserAdvManager"
249LIMIT 1
250;';
251                pwg_query($query);
252  }
253 
254        $q = "
255CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
256  user_id SMALLINT(5) NOT NULL DEFAULT '0',
257  lastvisit DATETIME NULL DEFAULT NULL,
258  reminder ENUM('true','false') NULL,
259PRIMARY KEY (`user_id`)
260  )
261;";
262  pwg_query($q);
263
264  upgrade_212();
265}
266
267
268/* upgrade from branch 2.12 to 2.13 */
269/* ******************************** */
270function upgrade_212()
271{
272/* Create missing table */
273  $query = "
274ALTER TABLE ".USER_CONFIRM_MAIL_TABLE."
275ADD reminder ENUM('true', 'false') NULL DEFAULT NULL
276;";
277 
278  pwg_query($query);
279
280/* Upgrade plugin configuration */
281        global $conf;
282
283  $conf_UAM = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
284
285  if ((!isset($conf_UAM[20])))
286  {
287    $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';
288               
289                $query = '
290UPDATE '.CONFIG_TABLE.'
291SET value="'.$upgrade_UAM.'"
292WHERE param="nbc_UserAdvManager"
293LIMIT 1
294;';
295                pwg_query($query);
296   
297    upgrade_213();
298  }
299}
300
301
302/* upgrade from branch 2.13 to 2.14 */
303/* ******************************** */
304function upgrade_213()
305{
306        global $conf;
307 
308  $conf_UAM = explode(';', $conf['nbc_UserAdvManager']);
309
310  $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');
311
312  $query = '
313UPDATE '.CONFIG_TABLE.'
314  SET value = "'.addslashes(serialize($upgrade_UAM)).'"
315  WHERE param = "nbc_UserAdvManager"
316;';
317  pwg_query($query);
318 
319  if (unserialize($conf['nbc_UserAdvManager_ConfirmMail']) === false)
320  {
321    $data = explode(';', $conf['nbc_UserAdvManager_ConfirmMail']);
322
323    $query = '
324UPDATE '.CONFIG_TABLE.'
325  SET value = "'.addslashes(serialize($data)).'"
326  WHERE param = "nbc_UserAdvManager_ConfirmMail"
327;';
328    pwg_query($query);
329   
330    upgrade_214_1();
331  }
332}
333
334function upgrade_214_1()
335{
336  global $conf;
337
338/* Changing parameter name */
339  $q = '
340UPDATE '.CONFIG_TABLE.'
341SET param = "UserAdvManager"
342WHERE param = "nbc_UserAdvManager"
343;';
344  pwg_query($q);
345 
346  $q = '
347UPDATE '.CONFIG_TABLE.'
348SET param = "UserAdvManager_ConfirmMail"
349WHERE param = "nbc_UserAdvManager_ConfirmMail"
350;';
351  pwg_query($q);
352
353/* Upgrading ConfirmMail options */
354  $conf_UAM2 = explode(';', $conf['UserAdvManager_ConfirmMail']);
355
356  $upgrade_UAM2 = array($conf_UAM2[0],$conf_UAM2[1],$conf_UAM2[2],$conf_UAM2[3],$conf_UAM2[4],'Thank you to have confirmed your email address and your registration on the gallery. Have fun !','Your activation key is incorrect or expired or you have already validated your account, please contact the webmaster to fix this problem.');
357
358  $query = '
359UPDATE '.CONFIG_TABLE.'
360  SET value = "'.addslashes(serialize($upgrade_UAM2)).'"
361  WHERE param = "UserAdvManager_ConfirmMail"
362;';
363  pwg_query($query);
364}
365?>
Note: See TracBrowser for help on using the repository browser.