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

Last change on this file since 21117 was 21117, checked in by Eric, 11 years ago

Next version is 2.5.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 ;-)
Update zh_CN, thanks to : winson and dennisyan
Add pt_BR, thanks to : flaviove

  • Property svn:eol-style set to LF
File size: 2.1 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()
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()
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  // Database upgrade process
58  if (isset($conf['CommentsManager']))
59  {
60    $conf_CM = unserialize($conf['CommentsManager']);
61   
62    // upgrade from 2.2.0 to 2.2.1
63    if (version_compare($conf_CM[0], '2.2.1') < 0)
64    {
65      upgradeCM_220_221();
66    }
67
68    // upgrade from 2.2.1 to 2.2.2
69    if (version_compare($conf_CM[0], '2.2.2') < 0)
70    {
71      upgradeCM_221_222();
72    }
73
74    // upgrade from 2.4 to 2.5
75    if (version_compare($conf_CM[0], '2.5.0') < 0)
76    {
77      upgradeCM_240_250();
78    }
79  }
80 
81  // Update plugin version number in #_config table and check consistency of #_plugins table
82  CM_version_update();
83
84  load_conf_from_db('param like \'CommentsManager\'');
85}
86
87
88function plugin_uninstall()
89{
90  global $conf;
91
92  if (isset($conf['CommentsManager']))
93  {
94    $q = '
95DELETE FROM '.CONFIG_TABLE.'
96WHERE param="CommentsManager"
97;';
98
99    pwg_query($q);
100  }
101}
102?>
Note: See TracBrowser for help on using the repository browser.