Ejemplo n.º 1
0
function activate_rm_plugin($q)
{
    $name = rmc_server_var($_GET, 'plugin', '');
    if ($name == '') {
        redirectMsg('plugins.php', __('You must specify a existing plugin', 'rmcommon'), 1);
        die;
    }
    $plugin = new RMPlugin($name);
    if ($plugin->isNew()) {
        redirectMsg('plugins.php', __('Specified plugin is not installed yet!', 'rmcommon'), 1);
        die;
    }
    $plugin->setVar('status', $q);
    if (!$plugin->save()) {
        redirectMsg('plugins.php', __('Plugin could not be updated, please try again.', 'rmcommon'), 1);
        die;
    }
    if (!$plugin->on_activate()) {
        redirectMsg('plugins.php', __('The database has been updated, but erros ocurred on this process.', 'rmcommon') . '<br />' . $plugin->errors(), 1);
        die;
    }
    rm_reload_plugins();
    redirectMsg('plugins.php', __('Plugin status changed succesfully!', 'rmcommon'), 0);
}
Ejemplo n.º 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);
    }
}