Пример #1
0
/**
* This function allows to plugins to show their own options
*/
function main_rm_plugin($dir)
{
    $path = RMCPATH . '/plugins';
    if (!file_exists($path . '/' . $dir . '/' . strtolower($dir) . '-plugin.php')) {
        header("location: plugins.php");
        die;
    }
    $plugin = new RMPlugin($dir);
    if ($plugin->isNew()) {
        header("location: plugins.php");
        die;
    }
    if (!$plugin->get_info('hasmain')) {
        header("location: plugins.php");
        die;
    }
    $class = ucfirst($dir) . 'CUPlugin';
    $plugin = new $class();
    if (!method_exists($plugin, 'main')) {
        header("location: plugins.php");
        die;
    }
    load_plugin_locale($dir);
    $plugin->main();
}
Пример #2
0
function update_locally()
{
    global $xoopsSecurity, $xoopsLogger, $xoopsConfig;
    $xoopsLogger->activated = false;
    if (!$xoopsSecurity->check()) {
        jsonReturn(__('Wrong action!', 'rmcommon'), 1, array(), 0);
    }
    $dir = RMHttpRequest::post('module', 'string', '');
    $type = RMHttpRequest::post('type', 'string', '');
    if ('' == $dir || '' == $type) {
        jsonReturn(__('Data not valid!', 'rmcommon'));
    }
    if ('module' == $type) {
        if (!is_dir(XOOPS_ROOT_PATH . '/modules/' . $dir)) {
            jsonReturn(__('Module does not exists!', 'rmcommon'));
        }
        xoops_loadLanguage('admin', 'system');
        $file = XOOPS_ROOT_PATH . '/modules/system/language/' . $xoopsConfig['language'] . '/admin/modulesadmin.php';
        if (file_exists($file)) {
            include_once $file;
        } else {
            include_once str_replace($xoopsConfig['language'], 'english', $file);
        }
        include_once XOOPS_ROOT_PATH . '/modules/system/admin/modulesadmin/modulesadmin.php';
        $log = xoops_module_update($dir);
        jsonReturn(__('Module updated locally', 'rmcommon'), 0, array('log' => $log));
    } elseif ('plugin' == $type) {
        if (!is_dir(XOOPS_ROOT_PATH . '/modules/rmcommon/plugins/' . $dir)) {
            jsonReturn(__('Plugin does not exists!', 'rmcommon'));
        }
        $plugin = new RMPlugin($dir);
        if ($plugin->isNew()) {
            jsonReturn(__('Plugin does not exists!', 'rmcommon'));
        }
        if (!$plugin->on_update()) {
            jsonReturn(sprintf(__('Plugins manager could not update the plugin: %s', 'rmcommon'), $plugin->errors()));
        }
        jsonReturn(__('Plugin updated locally', 'rmcommon'), 0);
    }
}