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[0] = $version; // Prune History version |
---|
27 | $defaultPH[1] = 'false'; // Enable automated prune |
---|
28 | $defaultPH[2] = '0'; // Range |
---|
29 | $defaultPH[3] = '0'; // Value (Year, month, day) |
---|
30 | |
---|
31 | // Create Prune History conf if not already exists |
---|
32 | // ------------------------------------------------ |
---|
33 | $query = ' |
---|
34 | SELECT param |
---|
35 | FROM '.CONFIG_TABLE.' |
---|
36 | WHERE param = "PruneHistory" |
---|
37 | ;'; |
---|
38 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
39 | |
---|
40 | if ($count == 0) |
---|
41 | { |
---|
42 | $q = ' |
---|
43 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
44 | VALUES ("PruneHistory","'.pwg_db_real_escape_string(serialize($defaultPH)).'","Prune History parameters") |
---|
45 | ;'; |
---|
46 | pwg_query($q); |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | |
---|
51 | function plugin_activate() |
---|
52 | { |
---|
53 | global $conf; |
---|
54 | |
---|
55 | /* Cleaning obsolete files */ |
---|
56 | /* *********************** */ |
---|
57 | PH_Obsolete_Files(); |
---|
58 | |
---|
59 | /* Update plugin version number in #_config table */ |
---|
60 | /* and check consistency of #_plugins table */ |
---|
61 | /* ********************************************** */ |
---|
62 | PH_version_update(); |
---|
63 | |
---|
64 | /* Reload plugin parameters */ |
---|
65 | /* ************************ */ |
---|
66 | load_conf_from_db('param like \'PruneHistory\''); |
---|
67 | } |
---|
68 | |
---|
69 | |
---|
70 | function plugin_uninstall() |
---|
71 | { |
---|
72 | global $conf; |
---|
73 | |
---|
74 | if (isset($conf['PruneHistory'])) |
---|
75 | { |
---|
76 | $q = ' |
---|
77 | DELETE FROM '.CONFIG_TABLE.' |
---|
78 | WHERE param="PruneHistory" |
---|
79 | ;'; |
---|
80 | |
---|
81 | pwg_query($q); |
---|
82 | } |
---|
83 | } |
---|
84 | ?> |
---|