1 | <?php |
---|
2 | |
---|
3 | if(!defined('PH_PATH')) |
---|
4 | { |
---|
5 | define('PH_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
6 | } |
---|
7 | |
---|
8 | include_once (PH_PATH.'include/functions.inc.php'); |
---|
9 | |
---|
10 | function plugin_install() |
---|
11 | { |
---|
12 | global $conf; |
---|
13 | |
---|
14 | /* ****************************************************************** */ |
---|
15 | /* **************** BEGIN - Data preparation in vars **************** */ |
---|
16 | /* ****************************************************************** */ |
---|
17 | |
---|
18 | $defaultPH = array(); |
---|
19 | |
---|
20 | // Set current plugin version in config table |
---|
21 | $plugin = PHInfos(PH_PATH); |
---|
22 | $version = $plugin['version']; |
---|
23 | |
---|
24 | // Default global parameters for Prune History conf |
---|
25 | // ------------------------------------------------- |
---|
26 | $defaultPH = array( |
---|
27 | 'PHVersion' => $version, // Prune History version |
---|
28 | 'AUTOPRUNE' => 'false', // Enable automated prune |
---|
29 | 'RANGEVALUE' => '0', // Range |
---|
30 | 'RANGE' => '0' // Value (Year, month, day) |
---|
31 | ); |
---|
32 | // Create Prune History conf if not already exists |
---|
33 | // ------------------------------------------------ |
---|
34 | $query = ' |
---|
35 | SELECT param |
---|
36 | FROM '.CONFIG_TABLE.' |
---|
37 | WHERE param = "PruneHistory" |
---|
38 | ;'; |
---|
39 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
40 | |
---|
41 | if ($count == 0) |
---|
42 | { |
---|
43 | $q = ' |
---|
44 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
45 | VALUES ("PruneHistory","'.pwg_db_real_escape_string(serialize($defaultPH)).'","Prune History parameters") |
---|
46 | ;'; |
---|
47 | pwg_query($q); |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | function plugin_activate() |
---|
53 | { |
---|
54 | global $conf; |
---|
55 | |
---|
56 | /* Cleaning obsolete files */ |
---|
57 | /* *********************** */ |
---|
58 | PH_Obsolete_Files(); |
---|
59 | |
---|
60 | include_once (PH_PATH.'include/upgradedb.inc.php'); |
---|
61 | |
---|
62 | /* Check database upgrade */ |
---|
63 | /* ********************** */ |
---|
64 | $conf_PH = unserialize($conf['PruneHistory']); |
---|
65 | |
---|
66 | if (isset($conf_PH[0])) |
---|
67 | { |
---|
68 | if (version_compare($conf_PH['PHVersion'], '1.1.0') < 0) |
---|
69 | { |
---|
70 | /* upgrade from 1.0 to 1.1 */ |
---|
71 | /* *********************** */ |
---|
72 | upgrade_100_110(); |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | /* Update plugin version number in #_config table */ |
---|
77 | /* and check consistency of #_plugins table */ |
---|
78 | /* ********************************************** */ |
---|
79 | PH_version_update(); |
---|
80 | |
---|
81 | /* Reload plugin parameters */ |
---|
82 | /* ************************ */ |
---|
83 | load_conf_from_db('param like \'PruneHistory\''); |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | function plugin_uninstall() |
---|
88 | { |
---|
89 | global $conf; |
---|
90 | |
---|
91 | if (isset($conf['PruneHistory'])) |
---|
92 | { |
---|
93 | $q = ' |
---|
94 | DELETE FROM '.CONFIG_TABLE.' |
---|
95 | WHERE param="PruneHistory" |
---|
96 | ;'; |
---|
97 | |
---|
98 | pwg_query($q); |
---|
99 | } |
---|
100 | } |
---|
101 | ?> |
---|