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

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

[NBC_UserAdvManager] Pre-2.13.4 for testing only:

  • Bug 1303 and 1387 fixed : There is a bug in Piwigo 2.0.8 about switch_lang() function. This may be fixed in the next Piwigo release. These UAM fix are available only for Piwigo 2.0.8 and have to be recoded for the next Piwigo release. (Thx to Rub and cljosse for their usefull help).
  • Bug 1444 fixed
  • Bug 1445 pre-fixed : Begining of plugin's admin panel improvement. Add of new help language files (FR for the moment), deletion of ConfirmMail tab, mix all config in one tab, add of cuetips. This is for testing !
  • Property svn:eol-style set to LF
File size: 7.6 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","true;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.","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/* Check for upgrade from 2.10 to 2.11 */
69          $query = '
70SELECT *
71  FROM '.CONFIG_TABLE.'
72WHERE param = "nbc_UserAdvManager_ConfirmMail"
73;';
74  $count = mysql_num_rows(pwg_query($query)); 
75 
76        if ($count == 0)
77        {
78         /* upgrade from branch 2.10 to 2.11 */
79                upgrade_210();
80        }
81
82
83/* Check for upgrade from 2.11 to 2.12 */
84  if (!table_exist(USER_LASTVISIT_TABLE))
85  {
86    /* upgrade from branch 2.11 to 2.12 */
87                upgrade_211();
88  }
89
90
91/* Check for upgrade from 2.12 to 2.13 */
92  $query = '
93SELECT *
94FROM '.USER_CONFIRM_MAIL_TABLE.'
95;';
96
97  $result = pwg_query($query);
98       
99        $numfields = mysql_num_fields($result);
100
101  if ($numfields < 6)
102  {
103    /* upgrade from branch 2.12 to 2.13 */
104    upgrade_212();
105  }
106}
107
108
109function plugin_uninstall()
110{
111  global $conf;
112
113  if (isset($conf['nbc_UserAdvManager']))
114  {
115    $q = '
116DELETE FROM '.CONFIG_TABLE.'
117WHERE param="nbc_UserAdvManager"
118;';
119
120    pwg_query($q);
121  }
122
123  if (isset($conf['nbc_UserAdvManager_ConfirmMail']))
124  {
125    $q = '
126DELETE FROM '.CONFIG_TABLE.'
127WHERE param="nbc_UserAdvManager_ConfirmMail"
128;';
129
130    pwg_query($q);
131  }
132
133  $q = 'DROP TABLE '.USER_CONFIRM_MAIL_TABLE.';';
134  pwg_query( $q );
135
136  $q = 'DROP TABLE '.USER_LASTVISIT_TABLE.';';
137  pwg_query( $q );
138}
139
140
141/* upgrade from branch 2.10 to 2.11 */
142function upgrade_210()
143{
144        global $conf;
145         
146  $q = '
147INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
148VALUES ("nbc_UserAdvManager_ConfirmMail","false;5;Hello.
149               
150This 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.
151
152Note: After this period, your account will be permanently deleted.;false;Hello.
153
154This 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.
155
156Note: After this period, your account will be permanently deleted.","Parametres nbc_UserAdvManager - ConfirmMail")
157  ;';
158  pwg_query($q);
159
160  upgrade_211();
161}
162
163
164/* upgrade from branch 2.11 to 2.12 */
165function upgrade_211()
166{
167        global $conf;
168
169  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
170
171  if ((!isset($conf_nbc_UserAdvManager[14]) and !isset($conf_nbc_UserAdvManager[15])) and !isset($conf_nbc_UserAdvManager[16]) and !isset($conf_nbc_UserAdvManager[17]))
172  {
173    $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.
174       
175This 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.
176
177On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account.
178
179Best regards,
180
181The admin of the gallery.';
182               
183                $query = '
184UPDATE '.CONFIG_TABLE.'
185SET value="'.$upgrade_nbc_UserAdvManager.'"
186WHERE param="nbc_UserAdvManager"
187LIMIT 1
188;';
189                pwg_query($query);
190  }
191 
192        $q = "
193CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
194  user_id SMALLINT(5) NOT NULL DEFAULT '0',
195  lastvisit DATETIME NULL DEFAULT NULL,
196  reminder ENUM('true','false') NULL,
197PRIMARY KEY (`user_id`)
198  )
199;";
200  pwg_query($q);
201
202  upgrade_212();
203}
204
205
206/* upgrade from branch 2.12 to 2.13 */
207function upgrade_212()
208{
209/* Create missing table */
210  $query = "
211ALTER TABLE ".USER_CONFIRM_MAIL_TABLE."
212ADD reminder ENUM('true', 'false') NULL DEFAULT NULL
213;";
214 
215  pwg_query($query);
216
217/* Upgrade plugin configuration */
218        global $conf;
219
220  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
221
222  if ((!isset($conf_nbc_UserAdvManager[20])))
223  {
224    $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';
225               
226                $query = '
227UPDATE '.CONFIG_TABLE.'
228SET value="'.$upgrade_nbc_UserAdvManager.'"
229WHERE param="nbc_UserAdvManager"
230LIMIT 1
231;';
232                pwg_query($query);
233  }
234}
235?>
Note: See TracBrowser for help on using the repository browser.