source: extensions/UserAdvManager/trunk/include/upgradedb.inc.php @ 24212

Last change on this file since 24212 was 24212, checked in by Eric, 11 years ago

Next version is 2.50.11 :
Evolution 2951 fixed - Add an option to add the gallery URL at the end of emails sent by UAM
Update ru_RU, thanks to : Konve
Update lv_LV, thanks to : agrisans
Add pt_PT, thanks to : ANO

  • Property svn:eol-style set to LF
File size: 23.9 KB
Line 
1<?php
2/**
3 * @author Eric@piwigo.org
4 * 
5 * Upgrade processes for old plugin version
6 * Called from maintain.inc.php on plugin activation
7 *
8 */
9
10if(!defined('UAM_PATH'))
11{
12  define('UAM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
13}
14
15include_once (UAM_PATH.'include/constants.php');
16include_once (UAM_PATH.'include/functions.inc.php');
17
18// +----------------------------------------------------------+
19// |       Upgrading database from old plugin versions        |
20// +----------------------------------------------------------+
21
22
23/* *************************************** */
24/* Update plugin version in conf table     */
25/* Used everytime a new version is updated */
26/* even if no database upgrade is needed   */
27/* *************************************** */
28
29function UAM_version_update()
30{
31  // Get current plugin version
32  // --------------------------
33  $plugin =  PluginInfos(UAM_PATH);
34  $version = $plugin['version'];
35
36  // Update plugin version in #_config table
37  // ---------------------------------------
38  $query = '
39UPDATE '.CONFIG_TABLE.'
40SET value="'.$version.'"
41WHERE param="UserAdvManager_Version"
42LIMIT 1
43;';
44
45  pwg_query($query);
46
47
48// Check #_plugin table consistency
49// Only useful if a previous version upgrade has not worked correctly (rare case)
50// ------------------------------------------------------------------------------
51  $query = '
52SELECT version
53  FROM '.PLUGINS_TABLE.'
54WHERE id = "UserAdvManager"
55;';
56 
57  $data = pwg_db_fetch_assoc(pwg_query($query));
58 
59  if (empty($data['version']) or $data['version'] <> $version)
60  {
61    $query = '
62UPDATE '.PLUGINS_TABLE.'
63SET version="'.$version.'"
64WHERE id = "UserAdvManager"
65LIMIT 1
66;';
67
68    pwg_query($query);
69  }
70}
71
72
73/* upgrade from branch 2.10 to 2.11 */
74/* ******************************** */
75function upgrade_210_211()
76{
77        global $conf;
78         
79  $q = '
80INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
81VALUES ("nbc_UserAdvManager_ConfirmMail","false;5;Hello.
82               
83This 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.
84
85Note: After this period, your account will be permanently deleted.;false;Hello.
86
87This 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.
88
89Note: After this period, your account will be permanently deleted.","Parametres nbc_UserAdvManager - ConfirmMail")
90  ;';
91  pwg_query($q);
92
93  upgrade_211_212();
94}
95
96
97/* upgrade from branch 2.11 to 2.12 */
98/* ******************************** */
99function upgrade_211_212()
100{
101        global $conf;
102
103  $conf_UAM = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
104
105  if ((!isset($conf_UAM[14]) and !isset($conf_UAM[15])) and !isset($conf_UAM[16]) and !isset($conf_UAM[17]))
106  {
107    $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.
108       
109This 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.
110
111On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account.
112
113Best regards,
114
115The admin of the gallery.';
116
117    conf_update_param('nbc_UserAdvManager', pwg_db_real_escape_string($upgrade_UAM));
118  }
119 
120        $q = "
121CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
122  user_id SMALLINT(5) NOT NULL DEFAULT '0',
123  lastvisit DATETIME NULL DEFAULT NULL,
124  reminder ENUM('true','false') NULL,
125PRIMARY KEY (`user_id`)
126  )
127;";
128  pwg_query($q);
129
130  upgrade_212_213();
131}
132
133
134/* upgrade from branch 2.12 to 2.13 */
135/* ******************************** */
136function upgrade_212_213()
137{
138  // Create missing table
139  // --------------------
140  $query = '
141ALTER TABLE '.USER_CONFIRM_MAIL_TABLE.'
142ADD reminder ENUM("true", "false") NULL DEFAULT NULL
143;';
144 
145  pwg_query($query);
146
147  // Upgrade plugin configuration
148  // ----------------------------
149        global $conf;
150
151  $conf_UAM = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
152
153  if ((!isset($conf_UAM[20])))
154  {
155    $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';
156               
157                conf_update_param('nbc_UserAdvManager', pwg_db_real_escape_string($upgrade_UAM));
158   
159    upgrade_213_214();
160  }
161}
162
163
164/* upgrade from branch 2.13 to 2.14 */
165/* ******************************** */
166function upgrade_213_214()
167{
168        global $conf;
169 
170  $conf_UAM = explode(';', $conf['nbc_UserAdvManager']);
171
172  $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');
173
174  $query = '
175UPDATE '.CONFIG_TABLE.'
176  SET value = "'.pwg_db_real_escape_string(serialize($upgrade_UAM)).'"
177  WHERE param = "nbc_UserAdvManager"
178;';
179  pwg_query($query);
180 
181  if (unserialize($conf['nbc_UserAdvManager_ConfirmMail']) === false)
182  {
183    $data = explode(';', $conf['nbc_UserAdvManager_ConfirmMail']);
184
185    conf_update_param('nbc_UserAdvManager_ConfirmMail', pwg_db_real_escape_string(serialize($data)));
186   
187    upgrade_214_215();
188  }
189}
190
191
192/* upgrade from branch 2.14 to 2.15 */
193/* ******************************** */
194function upgrade_214_215()
195{
196  global $conf;
197
198  // Changing parameter name
199  // -----------------------
200  $q = '
201UPDATE '.CONFIG_TABLE.'
202SET param = "UserAdvManager"
203WHERE param = "nbc_UserAdvManager"
204;';
205  pwg_query($q);
206 
207  $q = '
208UPDATE '.CONFIG_TABLE.'
209SET param = "UserAdvManager_ConfirmMail"
210WHERE param = "nbc_UserAdvManager_ConfirmMail"
211;';
212  pwg_query($q);
213
214  // Upgrading ConfirmMail options
215  // -----------------------------
216  $query = '
217SELECT value
218  FROM '.CONFIG_TABLE.'
219WHERE param = "UserAdvManager_ConfirmMail"
220;';
221
222  $result = pwg_query($query);
223  $conf_UAM_ConfirmMail = pwg_db_fetch_assoc($result);
224   
225  $conf_ConfirmMail = unserialize($conf_UAM_ConfirmMail['value']);
226 
227  $conf_ConfirmMail[5] ='Thank you to have confirmed your email address and your registration on the gallery. Have fun !';
228  $conf_ConfirmMail[6] ='Your activation key is incorrect or expired or you have already validated your account, please contact the webmaster to fix this problem.';
229 
230  $update_conf = serialize($conf_ConfirmMail);
231 
232  conf_update_param('UserAdvManager_ConfirmMail', pwg_db_real_escape_string($update_conf));
233   
234  upgrade_2153_2154();
235}
236
237
238/* upgrade from 2.15.3 to 2.15.4 */
239/* ***************************** */
240function upgrade_2153_2154()
241{
242  global $conf;
243
244  // Upgrading options
245  // -----------------
246  $query = '
247SELECT value
248  FROM '.CONFIG_TABLE.'
249WHERE param = "UserAdvManager"
250;';
251
252  $result = pwg_query($query);
253  $conf_UAM = pwg_db_fetch_assoc($result);
254   
255  $Newconf_UAM = unserialize($conf_UAM['value']);
256 
257  $Newconf_UAM[0] = $Newconf_UAM[0];
258  $Newconf_UAM[1] = $Newconf_UAM[2];
259  $Newconf_UAM[2] = $Newconf_UAM[3];
260  $Newconf_UAM[3] = $Newconf_UAM[4];
261  $Newconf_UAM[4] = $Newconf_UAM[5];
262  $Newconf_UAM[5] = $Newconf_UAM[6];
263  $Newconf_UAM[6] = $Newconf_UAM[7];
264  $Newconf_UAM[7] = $Newconf_UAM[8];
265  $Newconf_UAM[8] = $Newconf_UAM[9];
266  $Newconf_UAM[9] = $Newconf_UAM[10];
267  $Newconf_UAM[10] = $Newconf_UAM[11];
268  $Newconf_UAM[11] = $Newconf_UAM[12];
269  $Newconf_UAM[12] = $Newconf_UAM[13];
270  $Newconf_UAM[13] = $Newconf_UAM[14];
271  $Newconf_UAM[14] = $Newconf_UAM[15];
272  $Newconf_UAM[15] = $Newconf_UAM[16];
273  $Newconf_UAM[16] = $Newconf_UAM[17];
274  $Newconf_UAM[17] = $Newconf_UAM[18];
275  $Newconf_UAM[18] = $Newconf_UAM[19];
276  $Newconf_UAM[19] = $Newconf_UAM[20];
277  $Newconf_UAM[20] = $Newconf_UAM[21];
278  $Newconf_UAM[21] = 'false';
279 
280  $update_conf = serialize($Newconf_UAM);
281 
282  conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf));
283
284  $query = '
285INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
286VALUES ("UserAdvManager_Redir","0","UAM Redirections")
287  ;';
288 
289  pwg_query($query);
290}
291
292
293/* upgrade from 2.15.x to 2.16.0 */
294/* ***************************** */
295function upgrade_215_2160()
296{
297  global $conf;
298
299  // Upgrading options
300  // -----------------
301  $query = '
302SELECT value
303  FROM '.CONFIG_TABLE.'
304WHERE param = "UserAdvManager"
305;';
306
307  $result = pwg_query($query);
308  $conf_UAM = pwg_db_fetch_assoc($result);
309   
310  $Newconf_UAM = unserialize($conf_UAM['value']);
311 
312  $Newconf_UAM[22] = 'false';
313  $Newconf_UAM[23] = 'false';
314  $Newconf_UAM[24] = 'Sorry, your account has been deleted due to a too long time passed since your last visit.';
315  $Newconf_UAM[25] = 'Sorry, your account has been deprecated due to a too long time passed since your last visit. Please, use the following link to revalidate your account.';
316  $Newconf_UAM[26] = '-1';
317  $Newconf_UAM[27] = '-1';
318  $Newconf_UAM[28] = 'Thank you to have registered the gallery. Your account has been manually validated by admin. You can now visit all the gallery for free !';
319 
320  $update_conf = serialize($Newconf_UAM);
321 
322  conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf));
323
324  // Insert a new config entry for futur plugin's version check
325  // ----------------------------------------------------------
326  $query = '
327INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
328VALUES ("UserAdvManager_Version","2.16.0","UAM version check")
329  ;';
330 
331  pwg_query($query);
332}
333
334
335/* upgrade from 2.16.x to 2.20.0 */
336/* ***************************** */
337function upgrade_216_220()
338{
339  global $conf;
340
341  // Upgrading options
342  // -----------------
343  $query = '
344SELECT value
345  FROM '.CONFIG_TABLE.'
346WHERE param = "UserAdvManager"
347;';
348
349  $result = pwg_query($query);
350  $conf_UAM = pwg_db_fetch_assoc($result);
351   
352  $Newconf_UAM = unserialize($conf_UAM['value']);
353 
354  $Newconf_UAM[29] = 'false';
355  $Newconf_UAM[30] = 'You have requested a password reset on our gallery. Please, find below your new connection settings.';
356  $Newconf_UAM[31] = 'false';
357  $Newconf_UAM[32] = '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.';
358  $Newconf_UAM[33] = 'false';
359  $Newconf_UAM[34] = 'false';
360 
361  $update_conf = serialize($Newconf_UAM);
362 
363  conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf));
364
365  // Create new UAM entry in plugins table
366  // -------------------------------------
367  $uam_new_version = "2.20.0";
368
369  $query = '
370INSERT INTO '.PLUGINS_TABLE.' (id, state, version)
371VALUES ("UserAdvManager","active","'.$uam_new_version.'")
372;';
373 
374  pwg_query($query);
375
376  // Delete old plugin entry in plugins table
377  // ----------------------------------------
378  $query = '
379DELETE FROM '.PLUGINS_TABLE.'
380WHERE id="NBC_UserAdvManager"
381LIMIT 1
382;';
383 
384  pwg_query($query);
385
386  // Rename directory
387  // ----------------
388  if (!rename(PHPWG_PLUGINS_PATH.'NBC_UserAdvManager', PHPWG_PLUGINS_PATH.'UserAdvManager'))
389  {
390    die('Fatal error on plugin upgrade process : Unable to rename directory ! Please, rename manualy the plugin directory name from ../plugins/NBC_UserAdvManager to ../plugins/UserAdvManager.');
391  }
392}
393
394/* upgrade from 2.20.3 to 2.20.4 */
395/* ***************************** */
396function upgrade_2203_2204()
397{
398  global $conf;
399
400  // Upgrading options
401  // -----------------
402  $query = '
403SELECT value
404  FROM '.CONFIG_TABLE.'
405WHERE param = "UserAdvManager"
406;';
407
408  $result = pwg_query($query);
409  $conf_UAM = pwg_db_fetch_assoc($result);
410   
411  $Newconf_UAM = unserialize($conf_UAM['value']);
412 
413  $Newconf_UAM[35] = 'false';
414 
415  $update_conf = serialize($Newconf_UAM);
416 
417  conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf));
418}
419
420/* upgrade from 2.20.4 to 2.20.7 */
421/* ***************************** */
422function upgrade_2204_2207()
423{
424  global $conf;
425
426  // Upgrading options
427  // -----------------
428  $query = '
429SELECT value
430  FROM '.CONFIG_TABLE.'
431WHERE param = "UserAdvManager"
432;';
433
434  $result = pwg_query($query);
435  $conf_UAM = pwg_db_fetch_assoc($result);
436   
437  $Newconf_UAM = unserialize($conf_UAM['value']);
438 
439  $Newconf_UAM[36] = 'false';
440  $Newconf_UAM[37] = '-1';
441 
442  $update_conf = serialize($Newconf_UAM);
443
444  conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf));
445}
446
447/* upgrade from 2.20.7 to 2.20.8 */
448/* ***************************** */
449function upgrade_2207_2208()
450{
451  global $conf;
452
453  // Upgrading options
454  // -----------------
455  $query = '
456SELECT value
457  FROM '.CONFIG_TABLE.'
458WHERE param = "UserAdvManager"
459;';
460
461  $result = pwg_query($query);
462  $conf_UAM = pwg_db_fetch_assoc($result);
463   
464  $Newconf_UAM = unserialize($conf_UAM['value']);
465
466  // Refactoring all configuration options
467  // -------------------------------------
468  $Newconf_UAM[0] = $Newconf_UAM[0];
469  $Newconf_UAM[1] = $Newconf_UAM[1];
470  $Newconf_UAM[2] = $Newconf_UAM[2];
471  $Newconf_UAM[3] = $Newconf_UAM[3];
472  $Newconf_UAM[4] = $Newconf_UAM[4];
473  $Newconf_UAM[5] = $Newconf_UAM[6]; //remove osolete anonymus comments option
474  $Newconf_UAM[6] = $Newconf_UAM[7];
475  $Newconf_UAM[7] = $Newconf_UAM[8];
476  $Newconf_UAM[8] = $Newconf_UAM[9];
477  $Newconf_UAM[9] = $Newconf_UAM[10];
478  $Newconf_UAM[10] = $Newconf_UAM[11];
479  $Newconf_UAM[11] = $Newconf_UAM[12];
480  $Newconf_UAM[12] = $Newconf_UAM[13];
481  $Newconf_UAM[13] = $Newconf_UAM[14];
482  $Newconf_UAM[14] = $Newconf_UAM[15];
483  $Newconf_UAM[15] = $Newconf_UAM[16];
484  $Newconf_UAM[16] = $Newconf_UAM[17];
485  $Newconf_UAM[17] = $Newconf_UAM[18];
486  $Newconf_UAM[18] = $Newconf_UAM[19];
487  $Newconf_UAM[19] = $Newconf_UAM[20];
488  $Newconf_UAM[20] = $Newconf_UAM[21];
489  $Newconf_UAM[21] = $Newconf_UAM[22];
490  $Newconf_UAM[22] = $Newconf_UAM[23];
491  $Newconf_UAM[23] = $Newconf_UAM[24];
492  $Newconf_UAM[24] = $Newconf_UAM[25];
493  $Newconf_UAM[25] = $Newconf_UAM[26];
494  $Newconf_UAM[26] = $Newconf_UAM[27];
495  $Newconf_UAM[27] = $Newconf_UAM[28];
496  $Newconf_UAM[28] = $Newconf_UAM[29];
497  $Newconf_UAM[29] = $Newconf_UAM[30];
498  $Newconf_UAM[30] = $Newconf_UAM[31];
499  $Newconf_UAM[31] = $Newconf_UAM[32];
500  $Newconf_UAM[32] = $Newconf_UAM[33];
501  $Newconf_UAM[33] = $Newconf_UAM[34];
502  $Newconf_UAM[34] = $Newconf_UAM[35];
503 
504  // unset obsolete conf
505  // -------------------
506  unset ($Newconf_UAM[35]);
507  unset ($Newconf_UAM[36]);
508  unset ($Newconf_UAM[37]);
509 
510  $update_conf = serialize($Newconf_UAM);
511
512  conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf));
513}
514
515
516/* upgrade from 2.20.8 to 2.30.0 */
517/* ***************************** */
518function upgrade_2208_2300()
519{
520  global $conf;
521
522  // Upgrading options
523  // -----------------
524  $query = '
525SELECT value
526  FROM '.CONFIG_TABLE.'
527WHERE param = "UserAdvManager"
528;';
529
530  $result = pwg_query($query);
531  $conf_UAM = pwg_db_fetch_assoc($result);
532   
533  $Newconf_UAM = unserialize($conf_UAM['value']);
534 
535  $Newconf_UAM[35] = '-1';
536  $Newconf_UAM[36] = '-1';
537  $Newconf_UAM[37] = '-1';
538  $Newconf_UAM[38] = 'false';
539
540  $update_conf = serialize($Newconf_UAM);
541
542  conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf));
543
544  // Piwigo's native tables modifications for password reset function - Add pwdreset column
545  // --------------------------------------------------------------------------------------
546  $query = '
547SHOW COLUMNS FROM '.USERS_TABLE.'
548LIKE "UAM_pwdreset"
549;';
550 
551  $result = pwg_query($query);
552
553  if(!pwg_db_fetch_row($result))
554  {
555    $q = '
556ALTER TABLE '.USERS_TABLE.'
557ADD UAM_pwdreset enum("true","false")
558;';
559    pwg_query($q);
560  }
561}
562
563
564/* upgrade from 2.30.x to 2.30.2 */
565/* ***************************** */
566function upgrade_2300_2302()
567{
568  global $conf;
569 
570  load_language('plugin.lang', UAM_PATH);
571
572  // Upgrading options
573  // -----------------
574  $query = '
575SELECT value
576  FROM '.CONFIG_TABLE.'
577WHERE param = "UserAdvManager"
578;';
579
580  $result = pwg_query($query);
581  $conf_UAM = pwg_db_fetch_assoc($result);
582   
583  $Newconf_UAM = unserialize($conf_UAM['value']);
584 
585  $Newconf_UAM[39] = 'false';
586  $Newconf_UAM[40] = l10n('UAM_Default_RejectConnexion_Txt');
587
588  $update_conf = serialize($Newconf_UAM);
589
590  conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf));
591}
592
593
594/* upgrade from 2.30.x to 2.40.0 */
595/* ***************************** */
596function upgrade_2300_2400()
597{
598  global $conf;
599 
600  load_language('plugin.lang', UAM_PATH);
601
602  // Upgrading options
603  // -----------------
604  $query = '
605SELECT value
606  FROM '.CONFIG_TABLE.'
607WHERE param = "UserAdvManager"
608;';
609
610  $result = pwg_query($query);
611  $conf_UAM = pwg_db_fetch_assoc($result);
612   
613  $Newconf_UAM = unserialize($conf_UAM['value']);
614
615  $Newconf_UAM[41] = l10n('UAM_Default_ConfirmMail_Subject');        // UAM_CONFIRMMAIL_SUBJECT
616  $Newconf_UAM[42] = l10n('UAM_Default_ConfirmMail_Remail_Subject'); // UAM_CONFIRMMAIL_REMAIL_SUBJECT
617  $Newconf_UAM[43] = l10n('UAM_Default_InfoMail_Subject');           // UAM_INFOMAIL_SUBJECT
618  $Newconf_UAM[44] = l10n('UAM_Default_GTAutoMail_Subject');         // UAM_GTAUTOMAIL_SUBJECT
619  $Newconf_UAM[45] = l10n('UAM_Default_GTReminder_Subject');         // UAM_GTREMINDER_SUBJECT
620  $Newconf_UAM[46] = l10n('UAM_Default_AdminValidationMail_Subject');// UAM_ADMINVALIDATIONMAIL_SUBJECT
621
622  $update_conf = serialize($Newconf_UAM);
623
624  conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf));
625}
626
627
628/* upgrade from 2.40.x to 2.41.0 */
629/* ***************************** */
630function upgrade_2400_2410()
631{
632  global $conf;
633  $conf_UAM = unserialize($conf['UserAdvManager']);
634 
635  // Piwigo's native tables modifications for validation status - Add UAM_validated column
636  // -------------------------------------------------------------------------------------
637  $query = '
638SHOW COLUMNS FROM '.USERS_TABLE.'
639LIKE "UAM_validated"
640;';
641 
642  $result = pwg_query($query);
643
644  if(!pwg_db_fetch_row($result))
645  {
646    $q = '
647ALTER TABLE '.USERS_TABLE.'
648ADD UAM_validated enum("true","false")
649;';
650    pwg_query($q);
651  }
652
653  // Fill UAM_validated column with correct information for registered and validated  users
654  // --------------------------------------------------------------------------------------
655               
656                // It goes for everybody registered in the gallery except for Guest and AC users (16 and 18)
657  $query = '
658SELECT DISTINCT u.id AS id, u.username AS username
659FROM '.USERS_TABLE.' AS u
660                INNER JOIN '.USER_INFOS_TABLE.' AS ui
661                                ON u.id = ui.user_id
662                LEFT JOIN '.USER_GROUP_TABLE.' AS ug
663                                ON u.id = ug.user_id
664WHERE u.id != 2
665                AND u.username != \'16\'
666                AND u.username != \'18\'';
667
668                if ($conf_UAM[3] <> '-1' and $conf_UAM[4] == '-1')
669                {
670                                $query.= '
671AND ug.group_id = '.$conf_UAM[3];
672                }
673                if ($conf_UAM[3] == '-1' and $conf_UAM[4] <> '-1')
674                {
675                                $query.= '
676AND ui.status = \''.$conf_UAM[4]."'";
677                }
678                if ($conf_UAM[3] <> '-1' and $conf_UAM[4] <> '-1')
679                {
680                                $query.= '
681AND ug.group_id = '.$conf_UAM[3];
682                }
683                $query.= ';';
684
685                $result = pwg_query($query);
686
687                while($row = pwg_db_fetch_assoc($result))
688                {
689                                $query = '
690UPDATE '.USERS_TABLE.'
691SET UAM_validated=true
692WHERE id = '.$row['id'].'
693;';
694                                pwg_query($query);
695                }
696
697                // It goes to Webmaster too
698                $query = '
699UPDATE '.USERS_TABLE.'
700SET UAM_validated=true
701WHERE id = 1
702;';
703                pwg_query($query);
704}
705
706
707/* upgrade from 2.41.x to 2.50.0 */
708/* ***************************** */
709function upgrade_2410_2500()
710{
711  global $conf;
712 
713  load_language('plugin.lang', UAM_PATH);
714
715  // Upgrading options - Changing config variables to assoc array
716  // ------------------------------------------------------------
717 
718  // Upgrade $conf_UAM options
719  $conf_UAM = unserialize($conf['UserAdvManager']);
720
721  $Newconf_UAM = array(
722    'MAIL_INFO'                   => $conf_UAM[0],
723    'CONFIRM_MAIL'                => $conf_UAM[1],
724    'NO_CONFIRM_GROUP'            => $conf_UAM[2],
725    'VALIDATED_GROUP'             => $conf_UAM[3],
726    'VALIDATED_STATUS'            => $conf_UAM[4],
727    'USERNAME_CHAR'               => $conf_UAM[5],
728    'USERNAME_CHAR_LIST'          => $conf_UAM[6],
729    'NO_CONFIRM_STATUS'           => $conf_UAM[7],
730    'MAILINFO_TEXT'               => $conf_UAM[8],
731    'CONFIRMMAIL_TEXT'            => $conf_UAM[9],
732    'MAILEXCLUSION'               => $conf_UAM[10],
733    'MAILEXCLUSION_LIST'          => $conf_UAM[11],
734    'PASSWORDENF'                 => $conf_UAM[12],
735    'PASSWORD_SCORE'              => $conf_UAM[13],
736    'ADMINPASSWENF'               => $conf_UAM[14],
737    'GHOSTRACKER'                 => $conf_UAM[15],
738    'GHOSTRACKER_DAYLIMIT'        => $conf_UAM[16],
739    'GHOSTRACKER_REMINDERTEXT'    => $conf_UAM[17],
740    'ADDLASTVISIT'                => $conf_UAM[18],
741    'ADMINCONFMAIL'               => $conf_UAM[19],
742    'REDIRTOPROFILE'              => $conf_UAM[20],
743    'GTAUTO'                      => $conf_UAM[21],
744    'GTAUTOMAIL'                  => $conf_UAM[22],
745    'GTAUTODEL'                   => $conf_UAM[23],
746    'GTAUTOMAILTEXT'              => $conf_UAM[24],
747    'DOWNGRADE_GROUP'             => $conf_UAM[25],
748    'DOWNGRADE_STATUS'            => $conf_UAM[26],
749    'ADMINVALIDATIONMAIL'         => $conf_UAM[27],
750    'CUSTOMPASSWRETR'             => $conf_UAM[28],
751    'CUSTOMPASSWRETR_TEXT'        => $conf_UAM[29],
752    'USRAUTO'                     => $conf_UAM[30],
753    'USRAUTODEL'                  => $conf_UAM[31],
754    'USRAUTOMAIL'                 => $conf_UAM[32],
755    'STUFFS'                      => $conf_UAM[33],
756    'HIDEPASSW'                   => $conf_UAM[34],
757    'NO_VALID_LEVEL'              => $conf_UAM[35],
758    'VALID_LEVEL'                 => $conf_UAM[36],
759    'DOWNGRADE_LEVEL'             => $conf_UAM[37],
760    'PWDRESET'                    => $conf_UAM[38],
761    'REJECTCONNECT'               => $conf_UAM[39],
762    'REJECTCONNECT_TEXT'          => $conf_UAM[40],
763    'CONFIRMMAIL_SUBJECT'         => $conf_UAM[41],
764    'CONFIRMMAIL_REMAIL_SUBJECT'  => $conf_UAM[42],
765    'INFOMAIL_SUBJECT'            => $conf_UAM[43],
766    'GTAUTOMAIL_SUBJECT'          => $conf_UAM[44],
767    'GTREMINDER_SUBJECT'          => $conf_UAM[45],
768    'ADMINVALIDATIONMAIL_SUBJECT' => $conf_UAM[46]
769  );
770
771  // unset obsolete conf
772  // -------------------
773  for ($i = 0; $i <= 46; $i++)
774  {
775    unset ($conf_UAM[$i]);
776  }
777
778  $update_conf = serialize($Newconf_UAM);
779
780  conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf));
781
782
783  // Upgrade $conf_UAM_ConfirmMail
784  $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
785
786  $Newconf_UAM_ConfirmMail = array (
787    'CONFIRMMAIL_TIMEOUT'     => $conf_UAM_ConfirmMail[0],
788    'CONFIRMMAIL_DELAY'       => $conf_UAM_ConfirmMail[1],
789    'CONFIRMMAIL_REMAIL_TXT1' => $conf_UAM_ConfirmMail[2],
790    'CONFIRMMAIL_REMAIL'      => $conf_UAM_ConfirmMail[3],
791    'CONFIRMMAIL_REMAIL_TXT2' => $conf_UAM_ConfirmMail[4],
792    'CONFIRMMAIL_CUSTOM_TXT1' => $conf_UAM_ConfirmMail[5],
793    'CONFIRMMAIL_CUSTOM_TXT2' => $conf_UAM_ConfirmMail[6]
794  );
795
796  // unset obsolete conf
797  // -------------------
798  for ($i = 0; $i <= 6; $i++)
799  {
800    unset ($conf_UAM_ConfirmMail[$i]);
801  }
802
803  $update_conf = serialize($Newconf_UAM_ConfirmMail);
804
805  conf_update_param('UserAdvManager_ConfirmMail', pwg_db_real_escape_string($update_conf));
806}
807
808
809/* upgrade from 2.50.x to 2.50.11 */
810/* ***************************** */
811function upgrade_2500_25011()
812{
813  global $conf;
814 
815  load_language('plugin.lang', UAM_PATH);
816
817  // Upgrading options
818  // -----------------
819  $query = '
820SELECT value
821  FROM '.CONFIG_TABLE.'
822WHERE param = "UserAdvManager"
823;';
824
825  $result = pwg_query($query);
826  $conf_UAM = pwg_db_fetch_assoc($result);
827   
828  $Newconf_UAM = unserialize($conf_UAM['value']);
829
830  $Newconf_UAM['ADD_GALLERY_URL_TO_EMAILS'] = 'false';
831
832  $update_conf = serialize($Newconf_UAM);
833
834  conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf));
835}
836?>
Note: See TracBrowser for help on using the repository browser.