source: extensions/Comments_Access_Manager/maintain.inc.php @ 32697

Last change on this file since 32697 was 29342, 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.2 KB
Line 
1<?php
2
3if(!defined('CM_PATH'))
4{
5  define('CM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
6}
7
8include_once (CM_PATH.'include/functions.inc.php');
9
10function plugin_install($id, $version, &$errors)
11{
12        global $conf;
13 
14  // Set current plugin version in config table
15  $plugin =  CM_Infos(CM_PATH);
16  $version = $plugin['version'];
17       
18  $default = array(
19    'CMVersion'               => $version,
20    'CM_No_Comment_Anonymous' => 'false',
21    'CM_GROUPCOMM'            => 'false',
22    'CM_ALLOWCOMM_GROUP'      => -1,
23    'CM_GROUPVALID1'          => 'false',
24    'CM_VALIDCOMM1_GROUP'     => -1,
25    'CM_GROUPVALID2'          => 'false',
26    'CM_VALIDCOMM2_GROUP'     => -1
27    );
28
29        $query = '
30SELECT param
31  FROM '.CONFIG_TABLE.'
32WHERE param = "CommentsManager"
33;';
34  $count = pwg_db_num_rows(pwg_query($query));
35 
36  if ($count == 0)
37  {
38    $q = '
39INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
40VALUES ("CommentsManager","'.pwg_db_real_escape_string(serialize($default)).'","Comments Access Manager parameters")
41  ;';
42    pwg_query($q);
43  }
44}
45
46
47function plugin_activate($id, $version, &$errors)
48{
49  global $conf;
50
51/* Cleaning obsolete files */
52/* *********************** */
53  CM_Obsolete_Files();
54 
55  include_once (CM_PATH.'include/upgradedb.inc.php');
56 
57  $conf_CM = unserialize($conf['CommentsManager']);
58
59  // Database upgrade process
60  if (isset($conf_CM[0]))
61  {
62    $conf_CM = unserialize($conf['CommentsManager']);
63   
64    // upgrade from 2.2.0 to 2.2.1
65    if (version_compare($conf_CM[0], '2.2.1') < 0)
66    {
67      upgradeCM_220_221();
68    }
69
70    // upgrade from 2.2.1 to 2.2.2
71    if (version_compare($conf_CM[0], '2.2.2') < 0)
72    {
73      upgradeCM_221_222();
74    }
75
76    // upgrade from 2.4 to 2.5
77    if (version_compare($conf_CM[0], '2.5.0') < 0)
78    {
79      upgradeCM_240_250();
80    }
81    // Preset for future upgrades
82//  if (isset($conf_CM['CMVersion']))
83//  {
84
85//  }
86  }
87 
88  // Update plugin version number in #_config table and check consistency of #_plugins table
89  CM_version_update();
90
91  load_conf_from_db('param like \'CommentsManager\'');
92}
93
94
95function plugin_uninstall()
96{
97  global $conf;
98
99  if (isset($conf['CommentsManager']))
100  {
101    $q = '
102DELETE FROM '.CONFIG_TABLE.'
103WHERE param="CommentsManager"
104;';
105
106    pwg_query($q);
107  }
108}
109?>
Note: See TracBrowser for help on using the repository browser.