source: extensions/NBC_UserAdvManager/tags/2.13.3/maintain.inc.php @ 4552

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

[NBC_UserAdvManager] Build release 2.13.3 merged from branch to tag 2.13.3

  • Property svn:eol-style set to LF
File size: 7.6 KB
Line 
1<?php
2
3if(!defined("NBC_UserAdvManager_PATH"))
4  define('NBC_UserAdvManager_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
5
6include_once (NBC_UserAdvManager_PATH.'include/constants.php');
7include_once (NBC_UserAdvManager_PATH.'include/functions_UserAdvManager.inc.php');
8
9function plugin_install()
10{
11        global $conf;
12       
13  $q = '
14INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
15VALUES ("nbc_UserAdvManager","true;false;false;-1;-1;-1;false;false;;-1;;;false;;false;100;false;false;10;Hello.
16       
17This 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.
18
19On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account.
20
21Best regards,
22
23The admin of the gallery.","Parametres du plugin nbc UserAdvManager")
24  ;';
25  pwg_query($q);
26
27  $q = '
28INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
29VALUES ("nbc_UserAdvManager_ConfirmMail","false;5;Hello.
30               
31This 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.
32
33Note: After this period, your account will be permanently deleted.;false;Hello.
34
35This 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.
36
37Note: After this period, your account will be permanently deleted.","Parametres nbc_UserAdvManager - ConfirmMail")
38  ;';
39  pwg_query($q);
40
41        $q = "
42CREATE TABLE IF NOT EXISTS ".USER_CONFIRM_MAIL_TABLE." (
43  id varchar(50) NOT NULL default '',
44  user_id smallint(5) NOT NULL default '0',
45  mail_address varchar(255) default NULL,
46  status enum('webmaster','admin','normal','generic','guest') default NULL,
47  date_check datetime default NULL,
48  reminder ENUM('true','false') NULL,
49PRIMARY KEY  (id)
50  )
51;";
52  pwg_query($q);
53
54        $q = "
55CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
56  user_id SMALLINT(5) NOT NULL DEFAULT '0',
57  lastvisit DATETIME NULL DEFAULT NULL,
58  reminder ENUM('true','false') NULL,
59PRIMARY KEY (`user_id`)
60  )
61;";
62  pwg_query($q);
63}
64
65function plugin_activate()
66{
67          global $conf;
68       
69/* Check for upgrade from 2.10 to 2.11 */
70          $query = '
71SELECT *
72  FROM '.CONFIG_TABLE.'
73WHERE param = "nbc_UserAdvManager_ConfirmMail"
74;';
75  $count = mysql_num_rows(pwg_query($query)); 
76 
77        if ($count == 0)
78        {
79         /* upgrade from branch 2.10 to 2.11 */
80                upgrade_210();
81        }
82
83
84/* Check for upgrade from 2.11 to 2.12 */
85  if (!table_exist(USER_LASTVISIT_TABLE))
86  {
87    /* upgrade from branch 2.11 to 2.12 */
88                upgrade_211();
89  }
90
91
92/* Check for upgrade from 2.12 to 2.13 */
93  $query = '
94SELECT *
95FROM '.USER_CONFIRM_MAIL_TABLE.'
96;';
97
98  $result = pwg_query($query);
99       
100        $numfields = mysql_num_fields($result);
101
102  if ($numfields < 6)
103  {
104    /* upgrade from branch 2.12 to 2.13 */
105    upgrade_212();
106  }
107}
108
109
110function plugin_uninstall()
111{
112  global $conf;
113
114  if (isset($conf['nbc_UserAdvManager']))
115  {
116    $q = '
117DELETE FROM '.CONFIG_TABLE.'
118WHERE param="nbc_UserAdvManager"
119;';
120
121    pwg_query($q);
122  }
123
124  if (isset($conf['nbc_UserAdvManager_ConfirmMail']))
125  {
126    $q = '
127DELETE FROM '.CONFIG_TABLE.'
128WHERE param="nbc_UserAdvManager_ConfirmMail"
129;';
130
131    pwg_query($q);
132  }
133
134  $q = 'DROP TABLE '.USER_CONFIRM_MAIL_TABLE.';';
135  pwg_query( $q );
136
137  $q = 'DROP TABLE '.USER_LASTVISIT_TABLE.';';
138  pwg_query( $q );
139}
140
141
142/* upgrade from branch 2.10 to 2.11 */
143function upgrade_210()
144{
145        global $conf;
146         
147  $q = '
148INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
149VALUES ("nbc_UserAdvManager_ConfirmMail","false;5;Hello.
150               
151This 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.
152
153Note: After this period, your account will be permanently deleted.;false;Hello.
154
155This 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.
156
157Note: After this period, your account will be permanently deleted.","Parametres nbc_UserAdvManager - ConfirmMail")
158  ;';
159  pwg_query($q);
160
161  upgrade_211();
162}
163
164
165/* upgrade from branch 2.11 to 2.12 */
166function upgrade_211()
167{
168        global $conf;
169
170  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
171
172  if ((!isset($conf_nbc_UserAdvManager[14]) and !isset($conf_nbc_UserAdvManager[15])) and !isset($conf_nbc_UserAdvManager[16]) and !isset($conf_nbc_UserAdvManager[17]))
173  {
174    $upgrade_nbc_UserAdvManager = $conf_nbc_UserAdvManager[0].';'.$conf_nbc_UserAdvManager[1].';'.$conf_nbc_UserAdvManager[2].';'.$conf_nbc_UserAdvManager[3].';'.$conf_nbc_UserAdvManager[4].';'.$conf_nbc_UserAdvManager[5].';'.$conf_nbc_UserAdvManager[6].';'.$conf_nbc_UserAdvManager[7].';'.$conf_nbc_UserAdvManager[8].';'.$conf_nbc_UserAdvManager[9].';'.$conf_nbc_UserAdvManager[10].';'.$conf_nbc_UserAdvManager[11].';'.$conf_nbc_UserAdvManager[12].';'.$conf_nbc_UserAdvManager[13].';false;100;false;false;10;Hello.
175       
176This 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.
177
178On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account.
179
180Best regards,
181
182The admin of the gallery.';
183               
184                $query = '
185UPDATE '.CONFIG_TABLE.'
186SET value="'.$upgrade_nbc_UserAdvManager.'"
187WHERE param="nbc_UserAdvManager"
188LIMIT 1
189;';
190                pwg_query($query);
191  }
192 
193        $q = "
194CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
195  user_id SMALLINT(5) NOT NULL DEFAULT '0',
196  lastvisit DATETIME NULL DEFAULT NULL,
197  reminder ENUM('true','false') NULL,
198PRIMARY KEY (`user_id`)
199  )
200;";
201  pwg_query($q);
202
203  upgrade_212();
204}
205
206
207/* upgrade from branch 2.12 to 2.13 */
208function upgrade_212()
209{
210/* Create missing table */
211  $query = "
212ALTER TABLE ".USER_CONFIRM_MAIL_TABLE."
213ADD reminder ENUM('true', 'false') NULL DEFAULT NULL
214;";
215 
216  pwg_query($query);
217
218/* Upgrade plugin configuration */
219        global $conf;
220
221  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
222
223  if ((!isset($conf_nbc_UserAdvManager[20])))
224  {
225    $upgrade_nbc_UserAdvManager = $conf_nbc_UserAdvManager[0].';'.$conf_nbc_UserAdvManager[1].';'.$conf_nbc_UserAdvManager[2].';'.$conf_nbc_UserAdvManager[3].';'.$conf_nbc_UserAdvManager[4].';'.$conf_nbc_UserAdvManager[5].';'.$conf_nbc_UserAdvManager[6].';'.$conf_nbc_UserAdvManager[7].';'.$conf_nbc_UserAdvManager[8].';'.$conf_nbc_UserAdvManager[9].';'.$conf_nbc_UserAdvManager[10].';'.$conf_nbc_UserAdvManager[11].';'.$conf_nbc_UserAdvManager[12].';'.$conf_nbc_UserAdvManager[13].';'.$conf_nbc_UserAdvManager[14].';'.$conf_nbc_UserAdvManager[15].';'.$conf_nbc_UserAdvManager[16].';'.$conf_nbc_UserAdvManager[17].';'.$conf_nbc_UserAdvManager[18].';'.$conf_nbc_UserAdvManager[19].';false';
226               
227                $query = '
228UPDATE '.CONFIG_TABLE.'
229SET value="'.$upgrade_nbc_UserAdvManager.'"
230WHERE param="nbc_UserAdvManager"
231LIMIT 1
232;';
233                pwg_query($query);
234  }
235}
236?>
Note: See TracBrowser for help on using the repository browser.