source: extensions/UserAdvManager/branches/2.20/maintain.inc.php @ 11096

Last change on this file since 11096 was 11096, checked in by Eric, 13 years ago

r11095 merged from trunk to branch 2.20

  • Property svn:eol-style set to LF
File size: 9.1 KB
RevLine 
[3742]1<?php
2
[6255]3if(!defined('UAM_PATH'))
4{
5  define('UAM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
6}
[3742]7
[5181]8include_once (UAM_PATH.'include/constants.php');
9include_once (UAM_PATH.'include/functions.inc.php');
[3742]10
[5064]11
[3742]12function plugin_install()
13{
[3872]14        global $conf;
15       
[11019]16  $default1 = array('false','false',-1,-1,-1,'false','',-1,'','','false','','false',100,'false','false',10,'Hello [username].
[5056]17       
[9164]18This is a reminder because a very long time passed since your last visit on our gallery [mygallery]. 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.
[5056]19
20On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account.
21
22Best regards,
23
[10392]24The admin of the gallery.','false','false','false','false','false','Sorry [username], your account has been deleted due to a too long time passed since your last visit at [mygallery].','Sorry [username], your account has been deprecated due to a too long time passed since your last visit at [mygallery]. Please, use the following link to revalidate your account.',-1,-1,'Thank you for registering at [mygallery]. Your account has been manually validated by _admin_. You may now log in at _link_to_site_ and make any appropriate changes to your profile. Welcome to _name_of_site_!','false','You have requested a password reset on our gallery. Please, find below your new connection settings.','false','Sorry, your account has been deleted because you have not validated your registration in requested time. Please, try registration with a valid and non blocked email account.','false','false','false');
[5056]25
[9854]26        $query = '
27SELECT param
28  FROM '.CONFIG_TABLE.'
29WHERE param = "UserAdvManager"
30;';
31  $count = pwg_db_num_rows(pwg_query($query));
32 
33  if ($count == 0)
34  {
35    $q = '
[4143]36INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
[10943]37VALUES ("UserAdvManager","'.pwg_db_real_escape_string(serialize($default1)).'","UAM parameters")
[5056]38  ;';
[9854]39    pwg_query($q);
40  }
[4143]41
42
[9164]43  $default2 = array('false',5,'Hello [username].
[5056]44               
[9164]45This is a reminder message because you registered on our gallery [mygallery] 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.
[5056]46
[9164]47Note: After this period, your account will be permanently deleted.','false','Hello [username].
[5056]48
[9164]49This is a reminder message because you registered on our gallery [mygallery] 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.
[5056]50
[9164]51Note: After this period, your account will be permanently deleted.','You have confirmed that you are human and may now use [mygallery]! Welcome [username]!','Your activation key is incorrect or expired or you have already validated your account, please contact the webmaster to fix this problem.');
[5056]52
[9854]53        $query = '
54SELECT param
55  FROM '.CONFIG_TABLE.'
56WHERE param = "UserAdvManager_ConfirmMail"
57;';
58  $count = pwg_db_num_rows(pwg_query($query));
59 
60  if ($count == 0)
61  {
62    $q = '
[4143]63INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
[10943]64VALUES ("UserAdvManager_ConfirmMail","'.pwg_db_real_escape_string(serialize($default2)).'","UAM ConfirmMail parameters")
[5056]65  ;';
[9854]66    pwg_query($q);
67  }
68
69        $query = '
70SELECT param
71  FROM '.CONFIG_TABLE.'
72WHERE param = "UserAdvManager_Redir"
73;';
74  $count = pwg_db_num_rows(pwg_query($query));
[6775]75 
[9854]76  if ($count == 0)
77  {
78    $q = '
[6775]79INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
80VALUES ("UserAdvManager_Redir","0","UAM Redirections")
81  ;';
[9854]82    pwg_query($q);
83  }
[5056]84
[9854]85// Set current plugin version in config table
86  $plugin =  PluginInfos(UAM_PATH);
87  $version = $plugin['version'];
[5056]88
[9854]89        $query = '
90SELECT param
91  FROM '.CONFIG_TABLE.'
[11096]92WHERE param = "UserAdvManager_Version"
[9854]93;';
94  $count = pwg_db_num_rows(pwg_query($query));
95 
96  if ($count == 0)
97  {
98    $q = '
99INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
100VALUES ("UserAdvManager_Version","'.$version.'","UAM version check")
101  ;';
102    pwg_query($q);
103  }
104
105
[3742]106        $q = "
[4143]107CREATE TABLE IF NOT EXISTS ".USER_CONFIRM_MAIL_TABLE." (
108  id varchar(50) NOT NULL default '',
109  user_id smallint(5) NOT NULL default '0',
110  mail_address varchar(255) default NULL,
111  status enum('webmaster','admin','normal','generic','guest') default NULL,
112  date_check datetime default NULL,
[4380]113  reminder ENUM('true','false') NULL,
[4143]114PRIMARY KEY  (id)
115  )
[9091]116ENGINE=MyISAM;";
[3742]117  pwg_query($q);
[4135]118
119        $q = "
[4143]120CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." (
121  user_id SMALLINT(5) NOT NULL DEFAULT '0',
122  lastvisit DATETIME NULL DEFAULT NULL,
123  reminder ENUM('true','false') NULL,
124PRIMARY KEY (`user_id`)
125  )
[9091]126ENGINE=MyISAM;";
[4135]127  pwg_query($q);
[3742]128}
129
[5064]130
[3872]131function plugin_activate()
132{
[5064]133  global $conf;
[5056]134
[4952]135/* Cleaning obsolete files */
[5064]136/* *********************** */
137  clean_obsolete_files();
[5762]138 
139  include_once (UAM_PATH.'include/upgradedb.inc.php');
[5056]140
[5762]141/* Check if old version is < 2.15 */
142/* ****************************** */
[5593]143        $query = '
144SELECT param
145  FROM '.CONFIG_TABLE.'
[5762]146WHERE param = "nbc_UserAdvManager"
[5593]147;';
[6251]148  $count1 = pwg_db_num_rows(pwg_query($query));
149 
150  $query = '
151SELECT *
152  FROM '.CONFIG_TABLE.'
153WHERE param = "nbc_UserAdvManager_ConfirmMail"
154;';
155  $count2 = pwg_db_num_rows(pwg_query($query)); 
[5056]156
[5593]157/* If old params exist an upgrade is needed */
158/* **************************************** */
[6251]159  if ($count1 == 1)
[5593]160  {
[4380]161/* Check for upgrade from 2.10 to 2.11 */
[5064]162/* *********************************** */
[6251]163    if ($count1 == 1 and $count2 == 0)
[5593]164    {
165    /* upgrade from branch 2.10 to 2.11 */
166    /* ******************************** */
[5762]167      upgrade_210_211();
[5593]168    }
[4135]169
[4380]170
171/* Check for upgrade from 2.11 to 2.12 */
[5064]172/* *********************************** */
[5593]173    if (!table_exist(USER_LASTVISIT_TABLE))
174    {
175    /* upgrade from branch 2.11 to 2.12 */
176    /* ******************************** */
[5762]177                upgrade_211_212();
[5593]178    }
[4380]179
180
181/* Check for upgrade from 2.12 to 2.13 */
[5064]182/* *********************************** */
[5593]183    $fields = mysql_list_fields($conf['db_base'],USER_CONFIRM_MAIL_TABLE);
184    $nb_fields = mysql_num_fields($fields); 
[4380]185
[5593]186    if ($nb_fields < 6)
187    {
188    /* upgrade from branch 2.12 to 2.13 */
189    /* ******************************** */
[5762]190      upgrade_212_213();
[5593]191    }
[5056]192
193
[5064]194/* Serializing conf parameters - Available since 2.14.0 */
195/* **************************************************** */
[5593]196    if (unserialize($conf['nbc_UserAdvManager']) === false)
197    {
198    /* upgrade from branch 2.13 to 2.14 */
199    /* ******************************** */
[5762]200      upgrade_213_214();
[5593]201    }
[5762]202   
[6251]203    /* upgrade from branch 2.14 to 2.15 */
204    /* ******************************** */
205      upgrade_214_215();
206  }
207
[6775]208/* Old version is > 2.15 */
209/* ********************* */
210        $query = '
[5181]211SELECT param
212  FROM '.CONFIG_TABLE.'
[6775]213WHERE param = "UserAdvManager_Redir"
[5181]214;';
[6251]215  $count = pwg_db_num_rows(pwg_query($query));
[5181]216 
[6775]217  if ($count == 0)
[6251]218  {
[6775]219    upgrade_2153_2154();
[5593]220  }
[6354]221
[8065]222/* Check for upgrade from 2.15 to 2.16 */
223/* *********************************** */
[7955]224        $query = '
225SELECT param
226  FROM '.CONFIG_TABLE.'
227WHERE param = "UserAdvManager_Version"
228;';
229  $count = pwg_db_num_rows(pwg_query($query));
230 
231  if ($count == 0)
232  {
[8065]233    /* upgrade from branch 2.15 to 2.16 */
234    /* ******************************** */
235    upgrade_215_2160();
[7955]236  }
237
[10958]238/* Check database upgrade since version 2.16.0 */
239  if (isset($conf['UserAdvManager_Version']))
[9136]240  {
[10958]241    if (version_compare($conf['UserAdvManager_Version'], '2.20.0') < 0)
242    {
[9136]243    /* upgrade from branch 2.16 to 2.20 */
244    /* ******************************** */
[10958]245      upgrade_216_220();
246    }
247   
248    if (version_compare($conf['UserAdvManager_Version'], '2.20.4') < 0)
249    {
250    /* upgrade from version 2.20.3 to 2.20.4 */
251    /* ************************************* */
252      upgrade_2203_2204();
253    }
254   
255    if (version_compare($conf['UserAdvManager_Version'], '2.20.7') < 0)
256    {
257    /* upgrade from version 2.20.4 to 2.20.7 */
258    /* ************************************* */
259      upgrade_2204_2207();
260    }
[11019]261
262    if (version_compare($conf['UserAdvManager_Version'], '2.20.8') < 0)
263    {
264    /* upgrade from version 2.20.7 to 2.20.8 */
265    /* ************************************* */
266      upgrade_2207_2208();
267    }
[9136]268  }
269
[10707]270  // Update plugin version number in #_config table and check consistency of #_plugins table
[10145]271  UAM_version_update();
272
273  load_conf_from_db('param like \'UserAdvManager\\_%\'');
[3872]274}
[3742]275
[4135]276
[3742]277function plugin_uninstall()
278{
279  global $conf;
280
[5181]281  if (isset($conf['UserAdvManager']))
[3742]282  {
283    $q = '
[4143]284DELETE FROM '.CONFIG_TABLE.'
[5181]285WHERE param="UserAdvManager"
[4143]286;';
[3742]287
288    pwg_query($q);
289  }
290
[5181]291  if (isset($conf['UserAdvManager_ConfirmMail']))
[3881]292  {
293    $q = '
[4143]294DELETE FROM '.CONFIG_TABLE.'
[5181]295WHERE param="UserAdvManager_ConfirmMail"
[4143]296;';
[3742]297
[3881]298    pwg_query($q);
299  }
300
[6822]301  if (isset($conf['UserAdvManager_Redir']))
302  {
303    $q = '
304DELETE FROM '.CONFIG_TABLE.'
305WHERE param="UserAdvManager_Redir"
306;';
307
308    pwg_query($q);
309  }
310
[8110]311  if (isset($conf['UserAdvManager_Version']))
312  {
313    $q = '
314DELETE FROM '.CONFIG_TABLE.'
315WHERE param="UserAdvManager_Version"
316;';
317
318    pwg_query($q);
319  }
320
[3742]321  $q = 'DROP TABLE '.USER_CONFIRM_MAIL_TABLE.';';
322  pwg_query( $q );
[4135]323
324  $q = 'DROP TABLE '.USER_LASTVISIT_TABLE.';';
325  pwg_query( $q );
[3742]326}
327?>
Note: See TracBrowser for help on using the repository browser.