source: extensions/NBC_UserAdvManager/branches/2.20/maintain.inc.php @ 9254

Last change on this file since 9254 was 9254, checked in by Eric, 13 years ago

r9253 merged from trunk to branch 2.20

  • Property svn:eol-style set to LF
File size: 7.7 KB
Line 
1<?php
2
3if(!defined('UAM_PATH'))
4{
5  define('UAM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
6}
7if (!defined('UAM_ROOT'))
8{
9  define('UAM_ROOT', dirname(__FILE__).'/');
10}
11
12include_once (UAM_PATH.'include/constants.php');
13include_once (UAM_PATH.'include/functions.inc.php');
14
15
16function plugin_install()
17{
18        global $conf;
19       
20  $default1 = array('false','false',-1,-1,-1,'false','false','',-1,'','','false','','false',100,'false','false',10,'Hello [username].
21       
22This is a reminder because a very long time passed since your last visit on our gallery [mygallery]. 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.
23
24On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account.
25
26Best regards,
27
28The admin of the gallery.','false','false','false','false','false','Sorry [username], your account has been deleted due to a too long time passed since your last visit at [mygallery].','Sorry [username], your account has been deprecated due to a too long time passed since your last visit at [mygallery]. Please, use the following link to revalidate your account.',-1,-1,'Thank you for registering at [mygallery]. Your account has been manually validated by _admin_. You may now log in at _link_to_site_ and make any appropriate changes to your profile. Welcome to _name_of_site_!','false','You have requested a password reset on our gallery. Please, find below your new connection settings.','false','Sorry, your account has been deleted because you have not validated your registration in requested time. Please, try registration with a valid and non blocked email account.','false');
29
30  $q = '
31INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
32VALUES ("UserAdvManager","'.addslashes(serialize($default1)).'","UAM parameters")
33  ;';
34  pwg_query($q);
35
36
37  $default2 = array('false',5,'Hello [username].
38               
39This is a reminder message because you registered on our gallery [mygallery] 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.
40
41Note: After this period, your account will be permanently deleted.','false','Hello [username].
42
43This is a reminder message because you registered on our gallery [mygallery] 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.
44
45Note: After this period, your account will be permanently deleted.','You have confirmed that you are human and may now use [mygallery]! Welcome [username]!','Your activation key is incorrect or expired or you have already validated your account, please contact the webmaster to fix this problem.');
46
47  $q = '
48INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
49VALUES ("UserAdvManager_ConfirmMail","'.addslashes(serialize($default2)).'","UAM ConfirmMail parameters")
50  ;';
51  pwg_query($q);
52 
53  $q = '
54INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
55VALUES ("UserAdvManager_Redir","0","UAM Redirections")
56  ;';
57  pwg_query($q);
58
59
60        $q = "
61CREATE TABLE IF NOT EXISTS ".USER_CONFIRM_MAIL_TABLE." (
62  id varchar(50) NOT NULL default '',
63  user_id smallint(5) NOT NULL default '0',
64  mail_address varchar(255) default NULL,
65  status enum('webmaster','admin','normal','generic','guest') default NULL,
66  date_check datetime default NULL,
67  reminder ENUM('true','false') NULL,
68PRIMARY KEY  (id)
69  )
70ENGINE=MyISAM;";
71  pwg_query($q);
72
73        $q = "
74CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
75  user_id SMALLINT(5) NOT NULL DEFAULT '0',
76  lastvisit DATETIME NULL DEFAULT NULL,
77  reminder ENUM('true','false') NULL,
78PRIMARY KEY (`user_id`)
79  )
80ENGINE=MyISAM;";
81  pwg_query($q);
82}
83
84
85function plugin_activate()
86{
87  global $conf;
88
89/* Cleaning obsolete files */
90/* *********************** */
91  clean_obsolete_files();
92 
93  include_once (UAM_PATH.'include/upgradedb.inc.php');
94
95/* Check if old version is < 2.15 */
96/* ****************************** */
97        $query = '
98SELECT param
99  FROM '.CONFIG_TABLE.'
100WHERE param = "nbc_UserAdvManager"
101;';
102  $count1 = pwg_db_num_rows(pwg_query($query));
103 
104  $query = '
105SELECT *
106  FROM '.CONFIG_TABLE.'
107WHERE param = "nbc_UserAdvManager_ConfirmMail"
108;';
109  $count2 = pwg_db_num_rows(pwg_query($query)); 
110
111/* If old params exist an upgrade is needed */
112/* **************************************** */
113  if ($count1 == 1)
114  {
115/* Check for upgrade from 2.10 to 2.11 */
116/* *********************************** */
117    if ($count1 == 1 and $count2 == 0)
118    {
119    /* upgrade from branch 2.10 to 2.11 */
120    /* ******************************** */
121      upgrade_210_211();
122    }
123
124
125/* Check for upgrade from 2.11 to 2.12 */
126/* *********************************** */
127    if (!table_exist(USER_LASTVISIT_TABLE))
128    {
129    /* upgrade from branch 2.11 to 2.12 */
130    /* ******************************** */
131                upgrade_211_212();
132    }
133
134
135/* Check for upgrade from 2.12 to 2.13 */
136/* *********************************** */
137    $fields = mysql_list_fields($conf['db_base'],USER_CONFIRM_MAIL_TABLE);
138    $nb_fields = mysql_num_fields($fields); 
139
140    if ($nb_fields < 6)
141    {
142    /* upgrade from branch 2.12 to 2.13 */
143    /* ******************************** */
144      upgrade_212_213();
145    }
146
147
148/* Serializing conf parameters - Available since 2.14.0 */
149/* **************************************************** */
150    if (unserialize($conf['nbc_UserAdvManager']) === false)
151    {
152    /* upgrade from branch 2.13 to 2.14 */
153    /* ******************************** */
154      upgrade_213_214();
155    }
156   
157
158/* Check for upgrade from 2.14 to 2.15 */
159/* *********************************** */
160    //if ($count1 == 1 or $count2 == 1)
161    //{
162    /* upgrade from branch 2.14 to 2.15 */
163    /* ******************************** */
164      upgrade_214_215();
165    //}
166  }
167
168/* Old version is > 2.15 */
169/* ********************* */
170        $query = '
171SELECT param
172  FROM '.CONFIG_TABLE.'
173WHERE param = "UserAdvManager_Redir"
174;';
175  $count = pwg_db_num_rows(pwg_query($query));
176 
177  if ($count == 0)
178  {
179    upgrade_2153_2154();
180  }
181
182/* Check for upgrade from 2.15 to 2.16 */
183/* *********************************** */
184        $query = '
185SELECT param
186  FROM '.CONFIG_TABLE.'
187WHERE param = "UserAdvManager_Version"
188;';
189  $count = pwg_db_num_rows(pwg_query($query));
190 
191  if ($count == 0)
192  {
193    /* upgrade from branch 2.15 to 2.16 */
194    /* ******************************** */
195    upgrade_215_2160();
196  }
197
198/* Check for upgrade from 2.16 to 2.20 */
199/* *********************************** */
200        $query = '
201SELECT value
202  FROM '.CONFIG_TABLE.'
203WHERE param = "UserAdvManager_Version"
204;';
205
206  $data = pwg_db_fetch_assoc(pwg_query($query));
207 
208  if ($data['value'] != '2.20.0')
209  {
210    /* upgrade from branch 2.16 to 2.20 */
211    /* ******************************** */
212    upgrade_216_220();
213  }
214
215load_conf_from_db('param like \'UserAdvManager\\_%\'');
216}
217
218
219function plugin_uninstall()
220{
221  global $conf;
222
223  if (isset($conf['UserAdvManager']))
224  {
225    $q = '
226DELETE FROM '.CONFIG_TABLE.'
227WHERE param="UserAdvManager"
228;';
229
230    pwg_query($q);
231  }
232
233  if (isset($conf['UserAdvManager_ConfirmMail']))
234  {
235    $q = '
236DELETE FROM '.CONFIG_TABLE.'
237WHERE param="UserAdvManager_ConfirmMail"
238;';
239
240    pwg_query($q);
241  }
242
243  if (isset($conf['UserAdvManager_Redir']))
244  {
245    $q = '
246DELETE FROM '.CONFIG_TABLE.'
247WHERE param="UserAdvManager_Redir"
248;';
249
250    pwg_query($q);
251  }
252
253  if (isset($conf['UserAdvManager_Version']))
254  {
255    $q = '
256DELETE FROM '.CONFIG_TABLE.'
257WHERE param="UserAdvManager_Version"
258;';
259
260    pwg_query($q);
261  }
262
263  $q = 'DROP TABLE '.USER_CONFIRM_MAIL_TABLE.';';
264  pwg_query( $q );
265
266  $q = 'DROP TABLE '.USER_LASTVISIT_TABLE.';';
267  pwg_query( $q );
268}
269?>
Note: See TracBrowser for help on using the repository browser.