1 | <?php |
---|
2 | |
---|
3 | if(!defined('UAM_PATH')) |
---|
4 | { |
---|
5 | define('UAM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
6 | } |
---|
7 | |
---|
8 | include_once (UAM_PATH.'include/constants.php'); |
---|
9 | include_once (UAM_PATH.'include/functions.inc.php'); |
---|
10 | |
---|
11 | load_language('plugin.lang', UAM_PATH); |
---|
12 | |
---|
13 | |
---|
14 | function plugin_install() |
---|
15 | { |
---|
16 | global $conf; |
---|
17 | |
---|
18 | /* ****************************************************************** */ |
---|
19 | /* **************** BEGIN - Data preparation in vars **************** */ |
---|
20 | /* ****************************************************************** */ |
---|
21 | |
---|
22 | $defaultUAM = array(); |
---|
23 | $defaultConfirmMail = array(); |
---|
24 | |
---|
25 | // Default global parameters for UserAdvManager conf |
---|
26 | // ------------------------------------------------- |
---|
27 | $defaultUAM[0] = 'false'; // UAM_MAIL_INFO_TRUE/FALSE |
---|
28 | $defaultUAM[1] = 'false'; // UAM_CONFIRM_MAIL_TRUE/FALSE |
---|
29 | $defaultUAM[2] = '-1'; // UAM_No_Confirm_Group |
---|
30 | $defaultUAM[3] = '-1'; // UAM_Validated_Group |
---|
31 | $defaultUAM[4] = '-1'; // UAM_Validated_Status |
---|
32 | $defaultUAM[5] = 'false'; // UAM_USERNAME_CHAR_TRUE |
---|
33 | $defaultUAM[6] = ''; // UAM_USERNAME_CHAR_LIST |
---|
34 | $defaultUAM[7] = '-1'; // UAM_No_Confirm_Status |
---|
35 | $defaultUAM[8] = l10n('UAM_Default_InfoMail_Txt'); // UAM_MAILINFO_TEXT |
---|
36 | $defaultUAM[9] = l10n('UAM_Default_ConfirmMail_Txt'); // UAM_CONFIRMMAIL_TEXT |
---|
37 | $defaultUAM[10] = 'false'; // UAM_MAILEXCLUSION_TRUE/FALSE |
---|
38 | $defaultUAM[11] = ''; // UAM_MAILEXCLUSION_LIST |
---|
39 | $defaultUAM[12] = 'false'; // UAM_PASSWORDENF_TRUE/FALSE |
---|
40 | $defaultUAM[13] = '100'; // UAM_PASSWORD_SCORE |
---|
41 | $defaultUAM[14] = 'false'; // UAM_ADMINPASSWENF_TRUE/FALSE |
---|
42 | $defaultUAM[15] = 'false'; // UAM_GHOSTRACKER_TRUE/FALSE |
---|
43 | $defaultUAM[16] = '10'; // UAM_GHOSTRACKER_DAYLIMIT |
---|
44 | $defaultUAM[17] = l10n('UAM_Default_GhstReminder_Txt'); // UAM_GHOSTRACKER_REMINDERTEXT |
---|
45 | $defaultUAM[18] = 'false'; // UAM_ADDLASTVISIT_TRUE/FALSE |
---|
46 | $defaultUAM[19] = 'false'; // UAM_ADMINCONFMAIL_TRUE/FALSE |
---|
47 | $defaultUAM[20] = 'false'; // UAM_REDIRTOPROFILE_TRUE/FALSE |
---|
48 | $defaultUAM[21] = 'false'; // UAM_GTAUTO_TRUE/FALSE |
---|
49 | $defaultUAM[22] = 'false'; // UAM_GTAUTOMAIL_TRUE/FALSE |
---|
50 | $defaultUAM[23] = l10n('UAM_Default_GhstDeletion_Txt'); // UAM_GTAUTODEL_TEXT |
---|
51 | $defaultUAM[24] = l10n('UAM_Default_GhstDemotion_Txt'); // UAM_GTAUTOMAILTEXT |
---|
52 | $defaultUAM[25] = '-1'; // UAM_Downgrade_Group |
---|
53 | $defaultUAM[26] = '-1'; // UAM_Downgrade_Status |
---|
54 | $defaultUAM[27] = l10n('UAM_Default_AdminValidation_Txt'); // UAM_ADMINVALIDATIONMAIL_TEXT |
---|
55 | $defaultUAM[28] = 'false'; // UAM_CUSTOMPASSWRETR_TRUE/FALSE |
---|
56 | $defaultUAM[29] = l10n('UAM_Default_PwdRequest_Txt'); // UAM_CUSTOMPASSWRETR_TEXT |
---|
57 | $defaultUAM[30] = 'false'; // UAM_USRAUTO_TRUE/FALSE |
---|
58 | $defaultUAM[31] = l10n('UAM_Default_ValidationTimeout_Txt'); // UAM_USRAUTODEL_TEXT |
---|
59 | $defaultUAM[32] = 'false'; // UAM_USRAUTOMAIL_TRUE/FALSE |
---|
60 | $defaultUAM[33] = 'false'; // UAM_STUFFS_TRUE/FALSE |
---|
61 | $defaultUAM[34] = 'false'; // UAM_HIDEPASSW_TRUE/FALSE |
---|
62 | $defaultUAM[35] = '-1'; // UAM_NO_VALID_LEVEL |
---|
63 | $defaultUAM[36] = '-1'; // UAM_VALID_LEVEL |
---|
64 | $defaultUAM[37] = '-1'; // UAM_DOWNGRADE_LEVEL |
---|
65 | $defaultUAM[38] = 'false'; // UAM_PWDRESET_TRUE/FALSE |
---|
66 | $defaultUAM[39] = 'false'; // UAM_REJECTCONNECT_TRUE/FALSE |
---|
67 | $defaultUAM[40] = l10n('UAM_Default_RejectConnexion_Txt'); // UAM_REJECTCONNECT_TEXT |
---|
68 | $defaultUAM[41] = l10n('UAM_Default_ConfirmMail_Subject'); // UAM_CONFIRMMAIL_SUBJECT |
---|
69 | $defaultUAM[42] = l10n('UAM_Default_ConfirmMail_Remail_Subject'); // UAM_CONFIRMMAIL_REMAIL_SUBJECT |
---|
70 | $defaultUAM[43] = l10n('UAM_Default_InfoMail_Subject'); // UAM_INFOMAIL_SUBJECT |
---|
71 | $defaultUAM[44] = l10n('UAM_Default_GTAutoMail_Subject'); // UAM_GTAUTOMAIL_SUBJECT |
---|
72 | $defaultUAM[45] = l10n('UAM_Default_GTReminder_Subject'); // UAM_GTREMINDER_SUBJECT |
---|
73 | $defaultUAM[46] = l10n('UAM_Default_AdminValidationMail_Subject');// UAM_ADMINVALIDATIONMAIL_SUBJECT |
---|
74 | |
---|
75 | // Default specific parameters for UserAdvManager ConfirmMail conf |
---|
76 | // --------------------------------------------------------------- |
---|
77 | $defaultConfirmMail[0] = 'false'; // UAM_CONFIRMMAIL_TIMEOUT_TRUE/FALSE |
---|
78 | $defaultConfirmMail[1] = '5'; // UAM_CONFIRMMAIL_DELAY |
---|
79 | $defaultConfirmMail[2] = l10n('UAM_Default_CfmMail_Remail_Txt1'); // UAM_CONFIRMMAIL_REMAIL_TXT1 |
---|
80 | $defaultConfirmMail[3] = 'false'; // UAM_CONFIRMMAIL_REMAIL_TRUE/FALSE |
---|
81 | $defaultConfirmMail[4] = l10n('UAM_Default_CfmMail_Remail_Txt2'); // UAM_CONFIRMMAIL_REMAIL_TXT2 |
---|
82 | $defaultConfirmMail[5] = l10n('UAM_Default_CfmMail_Custom_Txt1'); // UAM_CONFIRMMAIL_CUSTOM_TXT1 |
---|
83 | $defaultConfirmMail[6] = l10n('UAM_Default_CfmMail_Custom_Txt2'); // UAM_CONFIRMMAIL_CUSTOM_TXT2 |
---|
84 | |
---|
85 | // Set current plugin version in config table |
---|
86 | // ------------------------------------------ |
---|
87 | $plugin = PluginInfos(UAM_PATH); |
---|
88 | $version = $plugin['version']; |
---|
89 | |
---|
90 | /* **************************************************************** */ |
---|
91 | /* **************** END - Data preparation in vars **************** */ |
---|
92 | /* **************************************************************** */ |
---|
93 | |
---|
94 | |
---|
95 | /* ***************************************************************************** */ |
---|
96 | /* **************** BEGIN - Database actions and initialization **************** */ |
---|
97 | /* ***************************************************************************** */ |
---|
98 | |
---|
99 | // Create UserAdvManager conf if not already exists |
---|
100 | // ------------------------------------------------ |
---|
101 | $query = ' |
---|
102 | SELECT param |
---|
103 | FROM '.CONFIG_TABLE.' |
---|
104 | WHERE param = "UserAdvManager" |
---|
105 | ;'; |
---|
106 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
107 | |
---|
108 | if ($count == 0) |
---|
109 | { |
---|
110 | $q = ' |
---|
111 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
112 | VALUES ("UserAdvManager","'.pwg_db_real_escape_string(serialize($defaultUAM)).'","UAM parameters") |
---|
113 | ;'; |
---|
114 | pwg_query($q); |
---|
115 | } |
---|
116 | |
---|
117 | // Create UserAdvManager_ConfirmMail conf if not already exists |
---|
118 | // ------------------------------------------------------------ |
---|
119 | $query = ' |
---|
120 | SELECT param |
---|
121 | FROM '.CONFIG_TABLE.' |
---|
122 | WHERE param = "UserAdvManager_ConfirmMail" |
---|
123 | ;'; |
---|
124 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
125 | |
---|
126 | if ($count == 0) |
---|
127 | { |
---|
128 | $q = ' |
---|
129 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
130 | VALUES ("UserAdvManager_ConfirmMail","'.pwg_db_real_escape_string(serialize($defaultConfirmMail)).'","UAM ConfirmMail parameters") |
---|
131 | ;'; |
---|
132 | pwg_query($q); |
---|
133 | } |
---|
134 | |
---|
135 | // Create UserAdvManager_Redir conf if not already exists |
---|
136 | // ------------------------------------------------------ |
---|
137 | $query = ' |
---|
138 | SELECT param |
---|
139 | FROM '.CONFIG_TABLE.' |
---|
140 | WHERE param = "UserAdvManager_Redir" |
---|
141 | ;'; |
---|
142 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
143 | |
---|
144 | if ($count == 0) |
---|
145 | { |
---|
146 | $q = ' |
---|
147 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
148 | VALUES ("UserAdvManager_Redir","0","UAM Redirections") |
---|
149 | ;'; |
---|
150 | pwg_query($q); |
---|
151 | } |
---|
152 | |
---|
153 | // Create UserAdvManager_Version conf if not already exists |
---|
154 | // -------------------------------------------------------- |
---|
155 | $query = ' |
---|
156 | SELECT param |
---|
157 | FROM '.CONFIG_TABLE.' |
---|
158 | WHERE param = "UserAdvManager_Version" |
---|
159 | ;'; |
---|
160 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
161 | |
---|
162 | if ($count == 0) |
---|
163 | { |
---|
164 | $q = ' |
---|
165 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
166 | VALUES ("UserAdvManager_Version","'.$version.'","UAM version check") |
---|
167 | ;'; |
---|
168 | pwg_query($q); |
---|
169 | } |
---|
170 | |
---|
171 | // Create USER_CONFIRM_MAIL_TABLE |
---|
172 | // ------------------------------ |
---|
173 | $q = " |
---|
174 | CREATE TABLE IF NOT EXISTS ".USER_CONFIRM_MAIL_TABLE." ( |
---|
175 | id varchar(50) NOT NULL default '', |
---|
176 | user_id smallint(5) NOT NULL default '0', |
---|
177 | mail_address varchar(255) default NULL, |
---|
178 | status enum('webmaster','admin','normal','generic','guest') default NULL, |
---|
179 | date_check datetime default NULL, |
---|
180 | reminder ENUM('true','false') NULL, |
---|
181 | PRIMARY KEY (id) |
---|
182 | ) |
---|
183 | ENGINE=MyISAM;"; |
---|
184 | pwg_query($q); |
---|
185 | |
---|
186 | // Create USER_LASTVISIT_TABLE |
---|
187 | // --------------------------- |
---|
188 | $q = " |
---|
189 | CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." ( |
---|
190 | user_id SMALLINT(5) NOT NULL DEFAULT '0', |
---|
191 | lastvisit DATETIME NULL DEFAULT NULL, |
---|
192 | reminder ENUM('true','false') NULL, |
---|
193 | PRIMARY KEY (`user_id`) |
---|
194 | ) |
---|
195 | ENGINE=MyISAM;"; |
---|
196 | pwg_query($q); |
---|
197 | |
---|
198 | // Piwigo's native tables modifications for password reset function - Add pwdreset column if not already exists |
---|
199 | // ------------------------------------------------------------------------------------------------------------ |
---|
200 | $query = ' |
---|
201 | SHOW COLUMNS FROM '.USERS_TABLE.' |
---|
202 | LIKE "UAM_pwdreset" |
---|
203 | ;'; |
---|
204 | |
---|
205 | $result = pwg_query($query); |
---|
206 | |
---|
207 | if(!pwg_db_fetch_row($result)) |
---|
208 | { |
---|
209 | $q = ' |
---|
210 | ALTER TABLE '.USERS_TABLE.' |
---|
211 | ADD UAM_pwdreset enum("true","false") |
---|
212 | ;'; |
---|
213 | pwg_query($q); |
---|
214 | } |
---|
215 | |
---|
216 | /* *************************************************************************** */ |
---|
217 | /* **************** END - Database actions and initialization **************** */ |
---|
218 | /* *************************************************************************** */ |
---|
219 | } |
---|
220 | |
---|
221 | |
---|
222 | function plugin_activate() |
---|
223 | { |
---|
224 | global $conf; |
---|
225 | |
---|
226 | /* Cleaning obsolete files */ |
---|
227 | /* *********************** */ |
---|
228 | clean_obsolete_files(); |
---|
229 | |
---|
230 | include_once (UAM_PATH.'include/upgradedb.inc.php'); |
---|
231 | |
---|
232 | /* Check if old version is < 2.15 */ |
---|
233 | /* ****************************** */ |
---|
234 | $query = ' |
---|
235 | SELECT param |
---|
236 | FROM '.CONFIG_TABLE.' |
---|
237 | WHERE param = "nbc_UserAdvManager" |
---|
238 | ;'; |
---|
239 | $count1 = pwg_db_num_rows(pwg_query($query)); |
---|
240 | |
---|
241 | $query = ' |
---|
242 | SELECT * |
---|
243 | FROM '.CONFIG_TABLE.' |
---|
244 | WHERE param = "nbc_UserAdvManager_ConfirmMail" |
---|
245 | ;'; |
---|
246 | $count2 = pwg_db_num_rows(pwg_query($query)); |
---|
247 | |
---|
248 | /* If old params exist an upgrade is needed */ |
---|
249 | /* **************************************** */ |
---|
250 | if ($count1 == 1) |
---|
251 | { |
---|
252 | /* Check for upgrade from 2.10 to 2.11 */ |
---|
253 | /* *********************************** */ |
---|
254 | if ($count1 == 1 and $count2 == 0) |
---|
255 | { |
---|
256 | /* upgrade from branch 2.10 to 2.11 */ |
---|
257 | /* ******************************** */ |
---|
258 | upgrade_210_211(); |
---|
259 | } |
---|
260 | |
---|
261 | |
---|
262 | /* Check for upgrade from 2.11 to 2.12 */ |
---|
263 | /* *********************************** */ |
---|
264 | if (!table_exist(USER_LASTVISIT_TABLE)) |
---|
265 | { |
---|
266 | /* upgrade from branch 2.11 to 2.12 */ |
---|
267 | /* ******************************** */ |
---|
268 | upgrade_211_212(); |
---|
269 | } |
---|
270 | |
---|
271 | |
---|
272 | /* Check for upgrade from 2.12 to 2.13 */ |
---|
273 | /* *********************************** */ |
---|
274 | $fields = mysql_list_fields($conf['db_base'],USER_CONFIRM_MAIL_TABLE); |
---|
275 | $nb_fields = mysql_num_fields($fields); |
---|
276 | |
---|
277 | if ($nb_fields < 6) |
---|
278 | { |
---|
279 | /* upgrade from branch 2.12 to 2.13 */ |
---|
280 | /* ******************************** */ |
---|
281 | upgrade_212_213(); |
---|
282 | } |
---|
283 | |
---|
284 | |
---|
285 | /* Serializing conf parameters - Available since 2.14.0 */ |
---|
286 | /* **************************************************** */ |
---|
287 | if (unserialize($conf['nbc_UserAdvManager']) === false) |
---|
288 | { |
---|
289 | /* upgrade from branch 2.13 to 2.14 */ |
---|
290 | /* ******************************** */ |
---|
291 | upgrade_213_214(); |
---|
292 | } |
---|
293 | |
---|
294 | /* upgrade from branch 2.14 to 2.15 */ |
---|
295 | /* ******************************** */ |
---|
296 | upgrade_214_215(); |
---|
297 | } |
---|
298 | |
---|
299 | /* Old version is > 2.15 */ |
---|
300 | /* ********************* */ |
---|
301 | $query = ' |
---|
302 | SELECT param |
---|
303 | FROM '.CONFIG_TABLE.' |
---|
304 | WHERE param = "UserAdvManager_Redir" |
---|
305 | ;'; |
---|
306 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
307 | |
---|
308 | if ($count == 0) |
---|
309 | { |
---|
310 | upgrade_2153_2154(); |
---|
311 | } |
---|
312 | |
---|
313 | /* Check for upgrade from 2.15 to 2.16 */ |
---|
314 | /* *********************************** */ |
---|
315 | $query = ' |
---|
316 | SELECT param |
---|
317 | FROM '.CONFIG_TABLE.' |
---|
318 | WHERE param = "UserAdvManager_Version" |
---|
319 | ;'; |
---|
320 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
321 | |
---|
322 | if ($count == 0) |
---|
323 | { |
---|
324 | /* upgrade from branch 2.15 to 2.16 */ |
---|
325 | /* ******************************** */ |
---|
326 | upgrade_215_2160(); |
---|
327 | } |
---|
328 | |
---|
329 | /* Check database upgrade since version 2.16.0 */ |
---|
330 | /* ******************************************* */ |
---|
331 | if (isset($conf['UserAdvManager_Version'])) |
---|
332 | { |
---|
333 | if (version_compare($conf['UserAdvManager_Version'], '2.20.0') < 0) |
---|
334 | { |
---|
335 | /* upgrade from branch 2.16 to 2.20 */ |
---|
336 | /* ******************************** */ |
---|
337 | upgrade_216_220(); |
---|
338 | } |
---|
339 | |
---|
340 | if (version_compare($conf['UserAdvManager_Version'], '2.20.4') < 0) |
---|
341 | { |
---|
342 | /* upgrade from version 2.20.3 to 2.20.4 */ |
---|
343 | /* ************************************* */ |
---|
344 | upgrade_2203_2204(); |
---|
345 | } |
---|
346 | |
---|
347 | if (version_compare($conf['UserAdvManager_Version'], '2.20.7') < 0) |
---|
348 | { |
---|
349 | /* upgrade from version 2.20.4 to 2.20.7 */ |
---|
350 | /* ************************************* */ |
---|
351 | upgrade_2204_2207(); |
---|
352 | } |
---|
353 | |
---|
354 | if (version_compare($conf['UserAdvManager_Version'], '2.20.8') < 0) |
---|
355 | { |
---|
356 | /* upgrade from version 2.20.7 to 2.20.8 */ |
---|
357 | /* ************************************* */ |
---|
358 | upgrade_2207_2208(); |
---|
359 | } |
---|
360 | |
---|
361 | if (version_compare($conf['UserAdvManager_Version'], '2.30.0') < 0) |
---|
362 | { |
---|
363 | /* upgrade from version 2.20.8 to 2.30.0 */ |
---|
364 | /* ************************************* */ |
---|
365 | upgrade_2208_2300(); |
---|
366 | } |
---|
367 | |
---|
368 | if (version_compare($conf['UserAdvManager_Version'], '2.30.2') < 0) |
---|
369 | { |
---|
370 | /* upgrade from version 2.30.x to 2.30.2 */ |
---|
371 | /* ************************************* */ |
---|
372 | upgrade_2300_2302(); |
---|
373 | } |
---|
374 | |
---|
375 | if (version_compare($conf['UserAdvManager_Version'], '2.40.0') < 0) |
---|
376 | { |
---|
377 | /* upgrade from version 2.30.x to 2.40.0 */ |
---|
378 | /* ************************************* */ |
---|
379 | upgrade_2300_2400(); |
---|
380 | } |
---|
381 | } |
---|
382 | |
---|
383 | // Update plugin version number in #_config table and check consistency of #_plugins table |
---|
384 | // --------------------------------------------------------------------------------------- |
---|
385 | UAM_version_update(); |
---|
386 | |
---|
387 | load_conf_from_db('param like \'UserAdvManager\\_%\''); |
---|
388 | } |
---|
389 | |
---|
390 | |
---|
391 | function plugin_uninstall() |
---|
392 | { |
---|
393 | global $conf; |
---|
394 | |
---|
395 | if (isset($conf['UserAdvManager'])) |
---|
396 | { |
---|
397 | $q = ' |
---|
398 | DELETE FROM '.CONFIG_TABLE.' |
---|
399 | WHERE param="UserAdvManager" |
---|
400 | ;'; |
---|
401 | |
---|
402 | pwg_query($q); |
---|
403 | } |
---|
404 | |
---|
405 | if (isset($conf['UserAdvManager_ConfirmMail'])) |
---|
406 | { |
---|
407 | $q = ' |
---|
408 | DELETE FROM '.CONFIG_TABLE.' |
---|
409 | WHERE param="UserAdvManager_ConfirmMail" |
---|
410 | ;'; |
---|
411 | |
---|
412 | pwg_query($q); |
---|
413 | } |
---|
414 | |
---|
415 | if (isset($conf['UserAdvManager_Redir'])) |
---|
416 | { |
---|
417 | $q = ' |
---|
418 | DELETE FROM '.CONFIG_TABLE.' |
---|
419 | WHERE param="UserAdvManager_Redir" |
---|
420 | ;'; |
---|
421 | |
---|
422 | pwg_query($q); |
---|
423 | } |
---|
424 | |
---|
425 | if (isset($conf['UserAdvManager_Version'])) |
---|
426 | { |
---|
427 | $q = ' |
---|
428 | DELETE FROM '.CONFIG_TABLE.' |
---|
429 | WHERE param="UserAdvManager_Version" |
---|
430 | ;'; |
---|
431 | |
---|
432 | pwg_query($q); |
---|
433 | } |
---|
434 | |
---|
435 | $q = ' |
---|
436 | DROP TABLE '.USER_CONFIRM_MAIL_TABLE.' |
---|
437 | ;'; |
---|
438 | pwg_query( $q ); |
---|
439 | |
---|
440 | $q = ' |
---|
441 | DROP TABLE '.USER_LASTVISIT_TABLE.' |
---|
442 | ;'; |
---|
443 | pwg_query( $q ); |
---|
444 | |
---|
445 | $q = ' |
---|
446 | ALTER TABLE '.USERS_TABLE.' |
---|
447 | DROP UAM_pwdreset |
---|
448 | ;'; |
---|
449 | pwg_query($q); |
---|
450 | } |
---|
451 | ?> |
---|