source: extensions/NBC_UserAdvManager/branches/2.15/maintain.inc.php @ 5763

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

[NBC_UserAdvManager]

Merged from trunk to branch 2.15

  • Property svn:eol-style set to LF
File size: 5.8 KB
Line 
1<?php
2
3if(!defined("UAM_PATH")) define('UAM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
4if (!defined('UAM_ROOT'))
5{
6  define('UAM_ROOT', dirname(__FILE__).'/');
7}
8
9include_once (UAM_PATH.'include/constants.php');
10include_once (UAM_PATH.'include/functions.inc.php');
11
12
13function plugin_install()
14{
15        global $conf;
16       
17  $default1 = array('false','false','false',-1,-1,-1,'false','false','',-1,'','','false','','false',100,'false','false',10,'Hello.
18       
19This 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.
20
21On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account.
22
23Best regards,
24
25The admin of the gallery.','false','false');
26
27  $q = '
28INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
29VALUES ("UserAdvManager","'.addslashes(serialize($default1)).'","UAM parameters")
30  ;';
31  pwg_query($q);
32
33
34  $default2 = array('false',5,'Hello.
35               
36This 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.
37
38Note: After this period, your account will be permanently deleted.','false','Hello.
39
40This 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.
41
42Note: 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.');
43
44  $q = '
45INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
46VALUES ("UserAdvManager_ConfirmMail","'.addslashes(serialize($default2)).'","UAM ConfirmMail parameters")
47  ;';
48  pwg_query($q);
49
50
51        $q = "
52CREATE TABLE IF NOT EXISTS ".USER_CONFIRM_MAIL_TABLE." (
53  id varchar(50) NOT NULL default '',
54  user_id smallint(5) NOT NULL default '0',
55  mail_address varchar(255) default NULL,
56  status enum('webmaster','admin','normal','generic','guest') default NULL,
57  date_check datetime default NULL,
58  reminder ENUM('true','false') NULL,
59PRIMARY KEY  (id)
60  )
61;";
62  pwg_query($q);
63
64        $q = "
65CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
66  user_id SMALLINT(5) NOT NULL DEFAULT '0',
67  lastvisit DATETIME NULL DEFAULT NULL,
68  reminder ENUM('true','false') NULL,
69PRIMARY KEY (`user_id`)
70  )
71;";
72  pwg_query($q);
73}
74
75
76function plugin_activate()
77{
78  global $conf;
79
80/* Cleaning obsolete files */
81/* *********************** */
82  clean_obsolete_files();
83 
84  include_once (UAM_PATH.'include/upgradedb.inc.php');
85
86/* Check if old version is < 2.15 */
87/* ****************************** */
88        $query = '
89SELECT param
90  FROM '.CONFIG_TABLE.'
91WHERE param = "nbc_UserAdvManager"
92;';
93  $count = pwg_db_num_rows(pwg_query($query));
94
95/* If old params exist an upgrade is needed */
96/* **************************************** */
97  if ($count == 1)
98  {
99/* Check for upgrade from 2.10 to 2.11 */
100/* *********************************** */
101    $query = '
102SELECT *
103  FROM '.CONFIG_TABLE.'
104WHERE param = "nbc_UserAdvManager_ConfirmMail"
105;';
106    $count = pwg_db_num_rows(pwg_query($query)); 
107 
108    if ($count == 0)
109    {
110    /* upgrade from branch 2.10 to 2.11 */
111    /* ******************************** */
112      upgrade_210_211();
113    }
114
115
116/* Check for upgrade from 2.11 to 2.12 */
117/* *********************************** */
118    if (!table_exist(USER_LASTVISIT_TABLE))
119    {
120    /* upgrade from branch 2.11 to 2.12 */
121    /* ******************************** */
122                upgrade_211_212();
123    }
124
125
126/* Check for upgrade from 2.12 to 2.13 */
127/* *********************************** */
128    $fields = mysql_list_fields($conf['db_base'],USER_CONFIRM_MAIL_TABLE);
129    $nb_fields = mysql_num_fields($fields); 
130
131//  $query = '
132//SELECT *
133//FROM '.USER_CONFIRM_MAIL_TABLE.'
134//;';
135
136//  $result = pwg_query($query);
137       
138//      $numfields = mysql_num_fields($result);
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        $query1 = '
161SELECT param
162  FROM '.CONFIG_TABLE.'
163WHERE param = "nbc_UserAdvManager"
164;';
165    $count1 = mysql_num_rows(pwg_query($query1));
166 
167    $query1 = '
168SELECT param
169  FROM '.CONFIG_TABLE.'
170WHERE param = "nbc_UserAdvManager_ConfirmMail"
171;';
172    $count2 = mysql_num_rows(pwg_query($query1)); 
173 
174    if ($count1 == 1 or $count2 == 1)
175    {
176    /* upgrade from branch 2.14 to 2.15 */
177    /* ******************************** */
178      upgrade_214_215();
179    }
180  }
181 
182/* Check for upgrade from 2.15 to 2.xx */
183/* *********************************** */
184}
185
186
187function plugin_uninstall()
188{
189  global $conf;
190
191  if (isset($conf['UserAdvManager']))
192  {
193    $q = '
194DELETE FROM '.CONFIG_TABLE.'
195WHERE param="UserAdvManager"
196;';
197
198    pwg_query($q);
199  }
200
201  if (isset($conf['UserAdvManager_ConfirmMail']))
202  {
203    $q = '
204DELETE FROM '.CONFIG_TABLE.'
205WHERE param="UserAdvManager_ConfirmMail"
206;';
207
208    pwg_query($q);
209  }
210
211  $q = 'DROP TABLE '.USER_CONFIRM_MAIL_TABLE.';';
212  pwg_query( $q );
213
214  $q = 'DROP TABLE '.USER_LASTVISIT_TABLE.';';
215  pwg_query( $q );
216}
217?>
Note: See TracBrowser for help on using the repository browser.