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

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

[NBC_UserAdvManager] Pre-2.13.4 for testing only:

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