[11017] | 1 | <?php |
---|
| 2 | |
---|
| 3 | if(!defined('CM_PATH')) |
---|
| 4 | { |
---|
| 5 | define('CM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
| 6 | } |
---|
| 7 | |
---|
| 8 | include_once (CM_PATH.'include/functions.inc.php'); |
---|
| 9 | |
---|
| 10 | function 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 | |
---|
[21117] | 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 | ); |
---|
[11017] | 28 | |
---|
| 29 | $query = ' |
---|
| 30 | SELECT param |
---|
| 31 | FROM '.CONFIG_TABLE.' |
---|
| 32 | WHERE param = "CommentsManager" |
---|
| 33 | ;'; |
---|
| 34 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
| 35 | |
---|
| 36 | if ($count == 0) |
---|
| 37 | { |
---|
| 38 | $q = ' |
---|
| 39 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
| 40 | VALUES ("CommentsManager","'.pwg_db_real_escape_string(serialize($default)).'","Comments Access Manager parameters") |
---|
| 41 | ;'; |
---|
| 42 | pwg_query($q); |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | function 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'); |
---|
[21118] | 56 | |
---|
| 57 | $conf_CM = unserialize($conf['CommentsManager']); |
---|
[11017] | 58 | |
---|
[11069] | 59 | // Database upgrade process |
---|
[21118] | 60 | if (isset($conf_CM[0])) |
---|
[11069] | 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 | } |
---|
[11070] | 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 | } |
---|
[21117] | 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 | } |
---|
[21118] | 81 | // Preset for future upgrades |
---|
| 82 | // if (isset($conf_CM['CMVersion'])) |
---|
| 83 | // { |
---|
| 84 | |
---|
| 85 | // } |
---|
[11069] | 86 | } |
---|
| 87 | |
---|
[11017] | 88 | // Update plugin version number in #_config table and check consistency of #_plugins table |
---|
| 89 | CM_version_update(); |
---|
| 90 | |
---|
[11069] | 91 | load_conf_from_db('param like \'CommentsManager\''); |
---|
[11017] | 92 | } |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | function plugin_uninstall() |
---|
| 96 | { |
---|
| 97 | global $conf; |
---|
| 98 | |
---|
| 99 | if (isset($conf['CommentsManager'])) |
---|
| 100 | { |
---|
| 101 | $q = ' |
---|
| 102 | DELETE FROM '.CONFIG_TABLE.' |
---|
| 103 | WHERE param="CommentsManager" |
---|
| 104 | ;'; |
---|
| 105 | |
---|
| 106 | pwg_query($q); |
---|
| 107 | } |
---|
| 108 | } |
---|
| 109 | ?> |
---|