source: extensions/UserAdvManager/branches/2.15/maintain.inc.php @ 15907

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

Merge from Trunk to Branch 2.15

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