source: extensions/HistoryIPExcluder/trunk/maintain.inc.php @ 15762

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

using conf_update_param() and pwg_db_real_escape_string()

  • Property svn:eol-style set to LF
File size: 2.5 KB
RevLine 
[5099]1<?php
2
[9870]3if (!defined('HIPE_PATH')) define('HIPE_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
4
5include_once (HIPE_PATH.'include/functions.inc.php');
6
[5099]7function plugin_install()
8{
9  global $conf;
10 
[9870]11// Set plugin parameters
[5099]12  $default= array();
13
[9870]14        $query = '
15SELECT param
16  FROM '.CONFIG_TABLE.'
17WHERE param = "HistoryIPExcluder"
18;';
19  $count = pwg_db_num_rows(pwg_query($query));
20 
21  if ($count == 0)
22  {
23    $q = '
[5099]24INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
[5162]25VALUES ("HistoryIPExcluder","","History IP Excluder parameters");
[5099]26';
27     
[9870]28    pwg_query($q);
29  }
[6758]30
[9870]31// Set plugin config
32  $plugin =  HIPE_infos(HIPE_PATH);
33  $version = $plugin['version'];
[6758]34
[9870]35  $default = array (
36    'Blacklist' => "0",
37    'Version'=> $version,
38  );
39
40        $query = '
41SELECT param
42  FROM '.CONFIG_TABLE.'
43WHERE param = "HistoryIPConfig"
44;';
45  $count = pwg_db_num_rows(pwg_query($query));
46 
47  if ($count == 0)
48  {
49    $q = '
[6758]50INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
[10978]51VALUES ("HistoryIPConfig","'.pwg_db_real_escape_string(serialize($default)).'","History IP Excluder options");
[6758]52';
[9870]53    pwg_query($q);
54  }
[5099]55}
56
57
[5162]58function plugin_activate()
59{
60  global $conf;
61 
[10045]62  include_once (HIPE_PATH.'include/dbupgrade.inc.php');
63 
[5162]64/* Check for upgrade from 2.0.0 to 2.0.1 */
65/* *************************************** */
66        $query = '
67SELECT param
68  FROM '.CONFIG_TABLE.'
69WHERE param = "nbc_HistoryIPExcluder"
70;';
[5615]71  $count = pwg_db_num_rows(pwg_query($query));
[5162]72 
73        if ($count == 1)
74        {
[9870]75  /* upgrade from version 2.0.0 to 2.0.1  */
[5162]76  /* ************************************ */
77                upgrade_200();
78        }
[6758]79
80        $query = '
81SELECT param
82  FROM '.CONFIG_TABLE.'
83WHERE param = "HistoryIPConfig"
84;';
85  $count = pwg_db_num_rows(pwg_query($query));
86
87        if ($count == 0)
88        {
[9870]89  /* upgrade from version 2.1.0 to 2.1.1  */
[6758]90  /* ************************************ */
91                upgrade_210();
92        }
[9870]93
94  /* upgrade from version 2.1.1 to 2.2.0 */
95  /* *********************************** */
96  $HIPE_Config = unserialize($conf['HistoryIPConfig']);
[10042]97  if ($HIPE_Config['Version'] == '2.1.1')
[9870]98  {
99    upgrade_211();
100  }
[9882]101
[10045]102  /* Global version number upgrade */
103  /* ***************************** */
104  global_version_update();
[5162]105}
106
107
[5099]108function plugin_uninstall()
109{
110  global $conf;
111
[6758]112  if (isset($conf['HistoryIPExcluder']))
[5099]113  {
114    $q = '
115DELETE FROM '.CONFIG_TABLE.'
[6758]116WHERE param="HistoryIPExcluder" LIMIT 1;
[5099]117';
118
119    pwg_query($q);
120  }
[6758]121  if (isset($conf['HistoryIPConfig']))
122  {
123    $q = '
124DELETE FROM '.CONFIG_TABLE.'
125WHERE param="HistoryIPConfig" LIMIT 1;
126';
127
128    pwg_query($q);
129  } 
[5099]130}
[5121]131?>
Note: See TracBrowser for help on using the repository browser.