source: extensions/HistoryIPExcluder/maintain.inc.php @ 29761

Last change on this file since 29761 was 29341, checked in by Eric, 10 years ago

Next version will be 2.7.0 : Compatibility with Piwigo 2.7

  • Property svn:eol-style set to LF
File size: 2.5 KB
Line 
1<?php
2
3if (!defined('HIPE_PATH')) define('HIPE_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
4
5include_once (HIPE_PATH.'include/functions.inc.php');
6
7function plugin_install($id, $version, &$errors)
8{
9  global $conf;
10 
11// Set plugin parameters
12  $default= array();
13
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 = '
24INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
25VALUES ("HistoryIPExcluder","","History IP Excluder parameters");
26';
27     
28    pwg_query($q);
29  }
30
31// Set plugin config
32  $plugin =  HIPE_infos(HIPE_PATH);
33  $version = $plugin['version'];
34
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 = '
50INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
51VALUES ("HistoryIPConfig","'.pwg_db_real_escape_string(serialize($default)).'","History IP Excluder options");
52';
53    pwg_query($q);
54  }
55}
56
57
58function plugin_activate($id, $version, &$errors)
59{
60  global $conf;
61 
62  include_once (HIPE_PATH.'include/dbupgrade.inc.php');
63 
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;';
71  $count = pwg_db_num_rows(pwg_query($query));
72 
73        if ($count == 1)
74        {
75  /* upgrade from version 2.0.0 to 2.0.1  */
76  /* ************************************ */
77                upgrade_200();
78        }
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        {
89  /* upgrade from version 2.1.0 to 2.1.1  */
90  /* ************************************ */
91                upgrade_210();
92        }
93
94  /* upgrade from version 2.1.1 to 2.2.0 */
95  /* *********************************** */
96  $HIPE_Config = unserialize($conf['HistoryIPConfig']);
97  if ($HIPE_Config['Version'] == '2.1.1')
98  {
99    upgrade_211();
100  }
101
102  /* Global version number upgrade */
103  /* ***************************** */
104  global_version_update();
105}
106
107
108function plugin_uninstall()
109{
110  global $conf;
111
112  if (isset($conf['HistoryIPExcluder']))
113  {
114    $q = '
115DELETE FROM '.CONFIG_TABLE.'
116WHERE param="HistoryIPExcluder" LIMIT 1;
117';
118
119    pwg_query($q);
120  }
121  if (isset($conf['HistoryIPConfig']))
122  {
123    $q = '
124DELETE FROM '.CONFIG_TABLE.'
125WHERE param="HistoryIPConfig" LIMIT 1;
126';
127
128    pwg_query($q);
129  } 
130}
131?>
Note: See TracBrowser for help on using the repository browser.