source: extensions/Prune_History/maintain.inc.php @ 15651

Last change on this file since 15651 was 14854, checked in by Eric, 9 years ago

Fist 1.0.0 release

  • Property svn:eol-style set to LF
File size: 2.0 KB
Line 
1<?php
2
3if(!defined('PH_PATH'))
4{
5  define('PH_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
6}
7
8include_once (PH_PATH.'include/functions.inc.php');
9
10function 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 = '
34SELECT param
35  FROM '.CONFIG_TABLE.'
36WHERE param = "PruneHistory"
37;';
38  $count = pwg_db_num_rows(pwg_query($query));
39 
40  if ($count == 0)
41  {
42    $q = '
43INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
44VALUES ("PruneHistory","'.pwg_db_real_escape_string(serialize($defaultPH)).'","Prune History parameters")
45  ;';
46    pwg_query($q);
47  }
48}
49
50
51function 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
70function plugin_uninstall()
71{
72  global $conf;
73
74  if (isset($conf['PruneHistory']))
75  {
76    $q = '
77DELETE FROM '.CONFIG_TABLE.'
78WHERE param="PruneHistory"
79;';
80
81    pwg_query($q);
82  }
83}
84?>
Note: See TracBrowser for help on using the repository browser.