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

Last change on this file since 4135 was 4135, checked in by Eric, 15 years ago

[NBC_UserAdvManager] pre 2.12.0 identified as 2.12.0a :

  • Improving plugin upgrade process
  • Adding new function (Ghost Tracker - Tracking of ghost users) from bug 1194 : Only admin panel and database requests are coded.
  • Language files updated for new Ghost Tracker feature.
  • Property svn:eol-style set to LF
File size: 5.5 KB
Line 
1<?php
2
3if(!defined("NBC_UserAdvManager_PATH"))
4  define('NBC_UserAdvManager_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
5
6include_once (NBC_UserAdvManager_PATH.'include/constants.php');
7include_once (NBC_UserAdvManager_PATH.'include/functions_UserAdvManager.inc.php');
8
9function plugin_install()
10{
11        global $conf;
12       
13  $q = '
14    INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
15    VALUES ("nbc_UserAdvManager","true;false;false;-1;-1;-1;false;false;;-1;;;false;;false;100;false,false","Parametres du plugin nbc UserAdvManager")
16  ;';
17  pwg_query($q);
18
19  $q = '
20    INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
21    VALUES ("nbc_UserAdvManager_ConfirmMail","false;5;Hello.
22               
23This 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.
24
25Note: After this period, your account will be permanently deleted.;false;Hello.
26
27This 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.
28
29Note: After this period, your account will be permanently deleted.","Parametres nbc_UserAdvManager - ConfirmMail")
30  ;';
31  pwg_query($q);
32
33        $q = "
34    CREATE TABLE IF NOT EXISTS ".USER_CONFIRM_MAIL_TABLE." (
35      id varchar(50) NOT NULL default '',
36      user_id smallint(5) NOT NULL default '0',
37      mail_address varchar(255) default NULL,
38      status enum('webmaster','admin','normal','generic','guest') default NULL,
39      date_check datetime default NULL,
40      lastvisit DATETIME NULL DEFAULT NULL,
41      reminder ENUM('true','false') NULL DEFAULT NULL
42      PRIMARY KEY  (id)
43    )
44  ;";
45  pwg_query($q);
46
47        $q = "
48    CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
49      user_id SMALLINT(5) NOT NULL DEFAULT '0',
50      lastvisit DATETIME NULL DEFAULT NULL,
51      reminder ENUM('true','false') NULL,
52      PRIMARY KEY (`user_id`)
53    )
54  ;";
55  pwg_query($q);
56}
57
58function plugin_activate()
59{
60          global $conf;
61       
62/* Check for upgrade from 2.10 */
63          $query = '
64    SELECT *
65                  FROM '.CONFIG_TABLE.'
66    WHERE param = "nbc_UserAdvManager_ConfirmMail"
67  ;';
68  $count = mysql_num_rows(pwg_query($query)); 
69 
70  /* upgrade from branch 2.10 */
71        if ($count == 0)
72        {
73                upgrade_210();
74        }
75
76/* Check for upgrade from 2.11 */
77  if (!table_exist(USER_LASTVISIT_TABLE))
78  {
79    /* upgrade from branch 2.11 */
80                upgrade_211();
81  }
82}
83
84
85function plugin_uninstall()
86{
87  global $conf;
88
89  if (isset($conf['nbc_UserAdvManager']))
90  {
91    $q = '
92      DELETE FROM '.CONFIG_TABLE.'
93      WHERE param="nbc_UserAdvManager"
94    ;';
95
96    pwg_query($q);
97  }
98
99  if (isset($conf['nbc_UserAdvManager_ConfirmMail']))
100  {
101    $q = '
102      DELETE FROM '.CONFIG_TABLE.'
103      WHERE param="nbc_UserAdvManager_ConfirmMail"
104    ;';
105
106    pwg_query($q);
107  }
108
109  $q = 'DROP TABLE '.USER_CONFIRM_MAIL_TABLE.';';
110  pwg_query( $q );
111
112  $q = 'DROP TABLE '.USER_LASTVISIT_TABLE.';';
113  pwg_query( $q );
114}
115
116/* upgrade from branch 2.10 */
117function upgrade_210()
118{
119        global $conf;
120         
121  $q = '
122    INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
123    VALUES ("nbc_UserAdvManager_ConfirmMail","false;5;Hello.
124               
125This 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.
126
127Note: After this period, your account will be permanently deleted.;false;Hello.
128
129This 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.
130
131Note: After this period, your account will be permanently deleted.","Parametres nbc_UserAdvManager - ConfirmMail")
132  ;';
133  pwg_query($q);
134
135upgrade_211();
136}
137
138/* upgrade from branch 2.11 */
139function upgrade_211()
140{
141        global $conf;
142
143  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
144
145  if ((!isset($conf_nbc_UserAdvManager[14]) and !isset($conf_nbc_UserAdvManager[15])) and !isset($conf_nbc_UserAdvManager[16]) and !isset($conf_nbc_UserAdvManager[17]))
146  {
147    $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';
148               
149                $query = '
150                UPDATE '.CONFIG_TABLE.'
151                SET value="'.$upgrade_nbc_UserAdvManager.'"
152                WHERE param="nbc_UserAdvManager"
153                LIMIT 1
154                ;';
155               
156                pwg_query($query);
157  }
158 
159        $q = "
160    CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
161      user_id SMALLINT(5) NOT NULL DEFAULT '0',
162      lastvisit DATETIME NULL DEFAULT NULL,
163      reminder ENUM('true','false') NULL,
164      PRIMARY KEY (`user_id`)
165    )
166  ;";
167  pwg_query($q);
168}
169?>
Note: See TracBrowser for help on using the repository browser.