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

Last change on this file since 26149 was 21100, checked in by Eric, 12 years ago

Next version will be 1.1.0 :

  • Compliance with Piwigo 2.5
  • Code refactory : Change config variables to assoc array and $_POST vars control before writing conf in database - Thx to flop25 for his advices ;-)
  • Bug fixed : Unable to restore an history backup file
  • Property svn:eol-style set to LF
File size: 2.3 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 = 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 = '
35SELECT param
36  FROM '.CONFIG_TABLE.'
37WHERE param = "PruneHistory"
38;';
39  $count = pwg_db_num_rows(pwg_query($query));
40 
41  if ($count == 0)
42  {
43    $q = '
44INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
45VALUES ("PruneHistory","'.pwg_db_real_escape_string(serialize($defaultPH)).'","Prune History parameters")
46  ;';
47    pwg_query($q);
48  }
49}
50
51
52function 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
87function plugin_uninstall()
88{
89  global $conf;
90
91  if (isset($conf['PruneHistory']))
92  {
93    $q = '
94DELETE FROM '.CONFIG_TABLE.'
95WHERE param="PruneHistory"
96;';
97
98    pwg_query($q);
99  }
100}
101?>
Note: See TracBrowser for help on using the repository browser.