/**
 * Triggered on get_admin_plugin_menu_links
 * 
 * Plugin's administration menu 
 */
function CM_admin_menu($menu)
{
    // +-----------------------------------------------------------------------+
    // |                      Getting plugin name                              |
    // +-----------------------------------------------------------------------+
    $plugin = CM_Infos(CM_PATH);
    $name = $plugin['name'];
    array_push($menu, array('NAME' => $name, 'URL' => get_root_url() . 'admin.php?page=plugin-' . basename(CM_PATH)));
    return $menu;
}
function plugin_install($id, $version, &$errors)
{
    global $conf;
    // Set current plugin version in config table
    $plugin = CM_Infos(CM_PATH);
    $version = $plugin['version'];
    $default = array('CMVersion' => $version, 'CM_No_Comment_Anonymous' => 'false', 'CM_GROUPCOMM' => 'false', 'CM_ALLOWCOMM_GROUP' => -1, 'CM_GROUPVALID1' => 'false', 'CM_VALIDCOMM1_GROUP' => -1, 'CM_GROUPVALID2' => 'false', 'CM_VALIDCOMM2_GROUP' => -1);
    $query = '
SELECT param
  FROM ' . CONFIG_TABLE . '
WHERE param = "CommentsManager"
;';
    $count = pwg_db_num_rows(pwg_query($query));
    if ($count == 0) {
        $q = '
INSERT INTO ' . CONFIG_TABLE . ' (param, value, comment)
VALUES ("CommentsManager","' . pwg_db_real_escape_string(serialize($default)) . '","Comments Access Manager parameters")
  ;';
        pwg_query($q);
    }
}
function CM_version_update()
{
    global $conf;
    // Get current plugin version
    $plugin = CM_Infos(CM_PATH);
    $version = $plugin['version'];
    // Upgrading options
    $query = '
SELECT value
  FROM ' . CONFIG_TABLE . '
WHERE param = "CommentsManager"
;';
    $result = pwg_query($query);
    $conf_CM = pwg_db_fetch_assoc($result);
    $Newconf_CM = unserialize($conf_CM['value']);
    $Newconf_CM['CMVersion'] = $version;
    $update_conf = serialize($Newconf_CM);
    conf_update_param('CommentsManager', pwg_db_real_escape_string($update_conf));
    // Check #_plugin table consistency
    // Only useful if a previous version upgrade has not worked correctly (rare case)
    $query = '
SELECT version
  FROM ' . PLUGINS_TABLE . '
WHERE id = "CommentsManager"
;';
    $data = pwg_db_fetch_assoc(pwg_query($query));
    if (empty($data['version']) or $data['version'] != $version) {
        $query = '
UPDATE ' . PLUGINS_TABLE . '
SET version="' . $version . '"
WHERE id = "CommentsManager"
LIMIT 1
;';
        pwg_query($query);
    }
}
예제 #4
0
}
// +-----------------------------------------------------------------------+
// | Check Access and exit when user status is not ok                      |
// +-----------------------------------------------------------------------+
check_status(ACCESS_ADMINISTRATOR);
if (!defined('CM_PATH')) {
    define('CM_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
}
//ini_set('error_reporting', E_ALL);
//ini_set('display_errors', true);
include_once PHPWG_ROOT_PATH . '/include/constants.php';
load_language('plugin.lang', CM_PATH);
// +-----------------------------------------------------------------------+
// |                      Getting plugin version                           |
// +-----------------------------------------------------------------------+
$plugin = CM_Infos(CM_PATH);
$version = $plugin['version'];
// *************************************************************************
// +-----------------------------------------------------------------------+
// |                           Plugin Config                               |
// +-----------------------------------------------------------------------+
// *************************************************************************
if (isset($_POST['submit']) and isset($_POST['CM_No_Comment_Anonymous']) and isset($_POST['CM_GroupComm']) and isset($_POST['CM_GroupValid1']) and isset($_POST['CM_GroupValid2'])) {
    $newconf_CM['CMVersion'] = $version;
    $newconf_CM['CM_No_Comment_Anonymous'] = isset($_POST['CM_No_Comment_Anonymous']) ? $_POST['CM_No_Comment_Anonymous'] : 'false';
    $newconf_CM['CM_GROUPCOMM'] = isset($_POST['CM_GroupComm']) ? $_POST['CM_GroupComm'] : 'false';
    $newconf_CM['CM_ALLOWCOMM_GROUP'] = isset($_POST['CM_AllowComm_Group']) ? $_POST['CM_AllowComm_Group'] : '';
    $newconf_CM['CM_GROUPVALID1'] = isset($_POST['CM_GroupValid1']) ? $_POST['CM_GroupValid1'] : 'false';
    $newconf_CM['CM_VALIDCOMM1_GROUP'] = isset($_POST['CM_ValidComm_Group1']) ? $_POST['CM_ValidComm_Group1'] : '';
    $newconf_CM['CM_GROUPVALID2'] = isset($_POST['CM_GroupValid2']) ? $_POST['CM_GroupValid2'] : 'false';
    $newconf_CM['CM_VALIDCOMM2_GROUP'] = isset($_POST['CM_ValidComm_Group2']) ? $_POST['CM_ValidComm_Group2'] : '';