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

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

[NBC_UserAdvManager]

  • Bug 1687 fixed: Case sensitivity function removed because intégrated Piwigo's core
  • Property svn:eol-style set to LF
File size: 6.0 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','false',-1,-1,-1,'false','false','',-1,'','','false','','false',100,'false','false',10,'Hello.
21       
22This 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.
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');
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.
38               
39This 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.
40
41Note: After this period, your account will be permanently deleted.','false','Hello.
42
43This 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.
44
45Note: After this period, your account will be permanently deleted.','Thank you to have confirmed your email address and your registration on the gallery. Have fun !','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
54        $q = "
55CREATE TABLE IF NOT EXISTS ".USER_CONFIRM_MAIL_TABLE." (
56  id varchar(50) NOT NULL default '',
57  user_id smallint(5) NOT NULL default '0',
58  mail_address varchar(255) default NULL,
59  status enum('webmaster','admin','normal','generic','guest') default NULL,
60  date_check datetime default NULL,
61  reminder ENUM('true','false') NULL,
62PRIMARY KEY  (id)
63  )
64;";
65  pwg_query($q);
66
67        $q = "
68CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
69  user_id SMALLINT(5) NOT NULL DEFAULT '0',
70  lastvisit DATETIME NULL DEFAULT NULL,
71  reminder ENUM('true','false') NULL,
72PRIMARY KEY (`user_id`)
73  )
74;";
75  pwg_query($q);
76}
77
78
79function plugin_activate()
80{
81  global $conf;
82
83/* Cleaning obsolete files */
84/* *********************** */
85  clean_obsolete_files();
86 
87  include_once (UAM_PATH.'include/upgradedb.inc.php');
88
89/* Check if old version is < 2.15 */
90/* ****************************** */
91        $query = '
92SELECT param
93  FROM '.CONFIG_TABLE.'
94WHERE param = "nbc_UserAdvManager"
95;';
96  $count1 = pwg_db_num_rows(pwg_query($query));
97 
98  $query = '
99SELECT *
100  FROM '.CONFIG_TABLE.'
101WHERE param = "nbc_UserAdvManager_ConfirmMail"
102;';
103  $count2 = pwg_db_num_rows(pwg_query($query)); 
104
105/* If old params exist an upgrade is needed */
106/* **************************************** */
107  if ($count1 == 1)
108  {
109/* Check for upgrade from 2.10 to 2.11 */
110/* *********************************** */
111    if ($count1 == 1 and $count2 == 0)
112    {
113    /* upgrade from branch 2.10 to 2.11 */
114    /* ******************************** */
115      upgrade_210_211();
116    }
117
118
119/* Check for upgrade from 2.11 to 2.12 */
120/* *********************************** */
121    if (!table_exist(USER_LASTVISIT_TABLE))
122    {
123    /* upgrade from branch 2.11 to 2.12 */
124    /* ******************************** */
125                upgrade_211_212();
126    }
127
128
129/* Check for upgrade from 2.12 to 2.13 */
130/* *********************************** */
131    $fields = mysql_list_fields($conf['db_base'],USER_CONFIRM_MAIL_TABLE);
132    $nb_fields = mysql_num_fields($fields); 
133
134    if ($nb_fields < 6)
135    {
136    /* upgrade from branch 2.12 to 2.13 */
137    /* ******************************** */
138      upgrade_212_213();
139    }
140
141
142/* Serializing conf parameters - Available since 2.14.0 */
143/* **************************************************** */
144    if (unserialize($conf['nbc_UserAdvManager']) === false)
145    {
146    /* upgrade from branch 2.13 to 2.14 */
147    /* ******************************** */
148      upgrade_213_214();
149    }
150   
151
152/* Check for upgrade from 2.14 to 2.15 */
153/* *********************************** */
154    //if ($count1 == 1 or $count2 == 1)
155    //{
156    /* upgrade from branch 2.14 to 2.15 */
157    /* ******************************** */
158      upgrade_214_215();
159    //}
160  }
161
162/* Check if old version is > 2.15 */
163/* ****************************** */
164// In preparation of next releases
165   $query = '
166SELECT param
167  FROM '.CONFIG_TABLE.'
168WHERE param LIKE "UserAdvManager%"
169;';
170  $count = pwg_db_num_rows(pwg_query($query));
171 
172  if ($count == 2)
173  {
174    $query = '
175SELECT value
176  FROM '.CONFIG_TABLE.'
177WHERE param = "UserAdvManager"
178;';
179
180    $result = pwg_query($query);
181    $conf = pwg_db_fetch_assoc($result);
182   
183    $conf_UAM = unserialize($conf['value']);
184    $Nb_values = count($conf_UAM);
185    if ($Nb_values = 22)
186    {
187      upgrade_2153_2154();
188    }
189  }
190
191load_conf_from_db('param like \'UserAdvManager\\_%\'');
192}
193
194
195function plugin_uninstall()
196{
197  global $conf;
198
199  if (isset($conf['UserAdvManager']))
200  {
201    $q = '
202DELETE FROM '.CONFIG_TABLE.'
203WHERE param="UserAdvManager"
204;';
205
206    pwg_query($q);
207  }
208
209  if (isset($conf['UserAdvManager_ConfirmMail']))
210  {
211    $q = '
212DELETE FROM '.CONFIG_TABLE.'
213WHERE param="UserAdvManager_ConfirmMail"
214;';
215
216    pwg_query($q);
217  }
218
219  $q = 'DROP TABLE '.USER_CONFIRM_MAIL_TABLE.';';
220  pwg_query( $q );
221
222  $q = 'DROP TABLE '.USER_LASTVISIT_TABLE.';';
223  pwg_query( $q );
224}
225?>
Note: See TracBrowser for help on using the repository browser.