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

Last change on this file since 6253 was 6253, 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.6 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  $count1 = pwg_db_num_rows(pwg_query($query));
94 
95  $query = '
96SELECT *
97  FROM '.CONFIG_TABLE.'
98WHERE param = "nbc_UserAdvManager_ConfirmMail"
99;';
100  $count2 = pwg_db_num_rows(pwg_query($query)); 
101
102/* If old params exist an upgrade is needed */
103/* **************************************** */
104  if ($count1 == 1)
105  {
106/* Check for upgrade from 2.10 to 2.11 */
107/* *********************************** */
108    if ($count1 == 1 and $count2 == 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    if ($nb_fields < 6)
132    {
133    /* upgrade from branch 2.12 to 2.13 */
134    /* ******************************** */
135      upgrade_212_213();
136    }
137
138
139/* Serializing conf parameters - Available since 2.14.0 */
140/* **************************************************** */
141    if (unserialize($conf['nbc_UserAdvManager']) === false)
142    {
143    /* upgrade from branch 2.13 to 2.14 */
144    /* ******************************** */
145      upgrade_213_214();
146    }
147   
148
149/* Check for upgrade from 2.14 to 2.15 */
150/* *********************************** */
151    //if ($count1 == 1 or $count2 == 1)
152    //{
153    /* upgrade from branch 2.14 to 2.15 */
154    /* ******************************** */
155      upgrade_214_215();
156    //}
157  }
158
159/* Check if old version is > 2.15 */
160/* ****************************** */
161   $query = '
162SELECT param
163  FROM '.CONFIG_TABLE.'
164WHERE param LIKE \"UserAdvManager%\"
165;';
166  $count = pwg_db_num_rows(pwg_query($query));
167 
168  if ($count == 2)
169  {
170    upgrade_2151_2152();
171  }
172
173load_conf_from_db('param like \'UserAdvManager\\_%\'');
174}
175
176
177function plugin_uninstall()
178{
179  global $conf;
180
181  if (isset($conf['UserAdvManager']))
182  {
183    $q = '
184DELETE FROM '.CONFIG_TABLE.'
185WHERE param="UserAdvManager"
186;';
187
188    pwg_query($q);
189  }
190
191  if (isset($conf['UserAdvManager_ConfirmMail']))
192  {
193    $q = '
194DELETE FROM '.CONFIG_TABLE.'
195WHERE param="UserAdvManager_ConfirmMail"
196;';
197
198    pwg_query($q);
199  }
200
201  $q = 'DROP TABLE '.USER_CONFIRM_MAIL_TABLE.';';
202  pwg_query( $q );
203
204  $q = 'DROP TABLE '.USER_LASTVISIT_TABLE.';';
205  pwg_query( $q );
206}
207?>
Note: See TracBrowser for help on using the repository browser.