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

Last change on this file since 4161 was 4159, checked in by Eric, 15 years ago

[NBC_UserAdvManager] release 2.12.2 :
Bug 1221 fixed - Adding of a new funtion to populate the lastvisit table on Ghost Tracker activation

Bug 1224 fixed - Error in database after plugin activation

Bug 1225 fixed - "Reminder" status don't change from "false" to "true" after the sent of a reminder email

Some code beautify (SQL requests and HTML 4 strict for tpl)

  • Property svn:eol-style set to LF
File size: 6.0 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,
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/* Check for upgrade from 2.10 */
69          $query = '
70SELECT *
71  FROM '.CONFIG_TABLE.'
72WHERE param = "nbc_UserAdvManager_ConfirmMail"
73;';
74  $count = mysql_num_rows(pwg_query($query)); 
75 
76  /* upgrade from branch 2.10 */
77        if ($count == 0)
78        {
79                upgrade_210();
80        }
81
82/* Check for upgrade from 2.11 */
83  if (!table_exist(USER_LASTVISIT_TABLE))
84  {
85    /* upgrade from branch 2.11 */
86                upgrade_211();
87  }
88}
89
90
91function plugin_uninstall()
92{
93  global $conf;
94
95  if (isset($conf['nbc_UserAdvManager']))
96  {
97    $q = '
98DELETE FROM '.CONFIG_TABLE.'
99WHERE param="nbc_UserAdvManager"
100;';
101
102    pwg_query($q);
103  }
104
105  if (isset($conf['nbc_UserAdvManager_ConfirmMail']))
106  {
107    $q = '
108DELETE FROM '.CONFIG_TABLE.'
109WHERE param="nbc_UserAdvManager_ConfirmMail"
110;';
111
112    pwg_query($q);
113  }
114
115  $q = 'DROP TABLE '.USER_CONFIRM_MAIL_TABLE.';';
116  pwg_query( $q );
117
118  $q = 'DROP TABLE '.USER_LASTVISIT_TABLE.';';
119  pwg_query( $q );
120}
121
122/* upgrade from branch 2.10 */
123function upgrade_210()
124{
125        global $conf;
126         
127  $q = '
128INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
129VALUES ("nbc_UserAdvManager_ConfirmMail","false;5;Hello.
130               
131This 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.
132
133Note: After this period, your account will be permanently deleted.;false;Hello.
134
135This 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.
136
137Note: After this period, your account will be permanently deleted.","Parametres nbc_UserAdvManager - ConfirmMail")
138  ;';
139  pwg_query($q);
140
141upgrade_211();
142}
143
144/* upgrade from branch 2.11 */
145function upgrade_211()
146{
147        global $conf;
148
149  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
150
151  if ((!isset($conf_nbc_UserAdvManager[14]) and !isset($conf_nbc_UserAdvManager[15])) and !isset($conf_nbc_UserAdvManager[16]) and !isset($conf_nbc_UserAdvManager[17]))
152  {
153    $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.
154       
155This 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.
156
157On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account.
158
159Best regards,
160
161The admin of the gallery.';
162               
163                $query = '
164UPDATE '.CONFIG_TABLE.'
165SET value="'.$upgrade_nbc_UserAdvManager.'"
166WHERE param="nbc_UserAdvManager"
167LIMIT 1
168;';
169                pwg_query($query);
170  }
171 
172        $q = "
173CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
174  user_id SMALLINT(5) NOT NULL DEFAULT '0',
175  lastvisit DATETIME NULL DEFAULT NULL,
176  reminder ENUM('true','false') NULL,
177PRIMARY KEY (`user_id`)
178  )
179;";
180  pwg_query($q);
181}
182?>
Note: See TracBrowser for help on using the repository browser.