source: extensions/nbc_HistoryIPExcluder/branches/2.1/maintain.inc.php @ 6761

Last change on this file since 6761 was 6761, checked in by Eric, 14 years ago
  • Merge from Trunk to Branch 2.1
  • Property svn:eol-style set to LF
File size: 2.1 KB
Line 
1<?php
2
3function plugin_install()
4{
5  global $conf;
6 
7  $default= array();
8
9  $q = '
10INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
11VALUES ("HistoryIPExcluder","","History IP Excluder parameters");
12';
13     
14  pwg_query($q);
15
16$default = array (
17  'Blacklist' => "0",
18  'Version'=> "2.1.1",
19);
20
21  $q = '
22INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
23VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options");
24';
25     
26  pwg_query($q);
27}
28
29
30function plugin_activate()
31{
32  global $conf;
33 
34/* Check for upgrade from 2.0.0 to 2.0.1 */
35/* *************************************** */
36        $query = '
37SELECT param
38  FROM '.CONFIG_TABLE.'
39WHERE param = "nbc_HistoryIPExcluder"
40;';
41  $count = pwg_db_num_rows(pwg_query($query));
42 
43        if ($count == 1)
44        {
45  /* upgrade from branch 2.0.0 to 2.0.1   */
46  /* ************************************ */
47                upgrade_200();
48        }
49
50        $query = '
51SELECT param
52  FROM '.CONFIG_TABLE.'
53WHERE param = "HistoryIPConfig"
54;';
55  $count = pwg_db_num_rows(pwg_query($query));
56
57        if ($count == 0)
58        {
59  /* upgrade from branch 2.1.0 to 2.1.1   */
60  /* ************************************ */
61                upgrade_210();
62        }
63}
64
65
66function plugin_uninstall()
67{
68  global $conf;
69
70  if (isset($conf['HistoryIPExcluder']))
71  {
72    $q = '
73DELETE FROM '.CONFIG_TABLE.'
74WHERE param="HistoryIPExcluder" LIMIT 1;
75';
76
77    pwg_query($q);
78  }
79  if (isset($conf['HistoryIPConfig']))
80  {
81    $q = '
82DELETE FROM '.CONFIG_TABLE.'
83WHERE param="HistoryIPConfig" LIMIT 1;
84';
85
86    pwg_query($q);
87  } 
88}
89
90
91function upgrade_200()
92{
93  global $conf;
94 
95  $q = '
96UPDATE '.CONFIG_TABLE.'
97SET param = "HistoryIPExcluder"
98WHERE param = "nbc_HistoryIPExcluder"
99;';
100  pwg_query($q);
101
102  $q = '
103UPDATE '.CONFIG_TABLE.'
104SET comment = "History IP Excluder parameters"
105WHERE comment = "Parametres nbc History IP Excluder"
106;';
107  pwg_query($q);
108
109  upgrade_210();
110}
111
112function upgrade_210()
113{
114  global $conf;
115 
116  $default = array (
117    'Blacklist' => "0",
118    'Version'=> "2.1.1",
119  );
120
121  $q = '
122INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
123VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options");
124';
125     
126  pwg_query($q);
127}
128?>
Note: See TracBrowser for help on using the repository browser.