Esempio n. 1
0
 function doenable($id)
 {
     $success = -1;
     $fp_plugins = $this->fp_plugins;
     if (plugin_exists($id)) {
         $success = 1;
         if (!in_array($id, $fp_plugins)) {
             $fp_plugins[] = $id;
             sort($fp_plugins);
             plugin_load($id, false, false);
             do_action('activate_' . $id);
             $success = system_save(CONFIG_DIR . 'plugins.conf.php', compact('fp_plugins'));
         } else {
             $success = -1;
         }
     }
     if ($success) {
         $this->smarty->assign('success', $success);
     }
     return PANEL_REDIRECT_CURRENT;
 }
Esempio n. 2
0
<?php

/**
 * Delete Plugin, Furasta.Org
 *
 * Deletes a plugin. First it deactivates the plugin, then
 * it removes all the plugin files. This page is accessed
 * via AJAX.
 *
 * @author     Conor Mac Aoidh <*****@*****.**>
 * @license    http://furasta.org/licence.txt The BSD License
 * @version    1.0
 * @package    admin_settings
 */
$p_name = addslashes(@$_GET['p_name']);
if (!plugin_exists($p_name)) {
    error('Plugin does not exist. Please contact bugs@furasta.org for more details.', 'Plugin Error');
}
/**
 * run uninstall script 
 */
$plugin_dir = HOME . '_plugins/' . $p_name;
$file = $plugin_dir . '/uninstall.php';
if (file_exists($file)) {
    require $file;
}
/**
 * remove the plugin's files 
 */
remove_dir($plugin_dir);
/**
Esempio n. 3
0
/**
 * resolve_dependencies
 *
 * Takes an array of plugin data and adds
 * plugins to the list which are dependencies
 * of other plugins
 *
 * This function is run when the settings.php file
 * is rewritten and automatically adds dependencies
 * to the list of installed plugins
 *
 * @param array $plugins
 * @param array $NEWPLUGINS
 * @return array
 */
function resolve_dependencies($plugins, $NEWPLUGINS)
{
    global $PLUGINS;
    /**
     * build list of dependencies
     */
    $dependencies = array();
    $resolved = array();
    $Plugins = Plugins::getInstance();
    for ($i = 0; $i < count($plugins); ++$i) {
        if (is_array($plugins[$i]['dependencies'])) {
            array_merge($dependencies, $plugins[$i]['dependencies']);
            foreach ($plugins[$i]['dependencies'] as $dependency) {
                /**
                 * if dependency was already resolved, skip
                 */
                if (in_array($dependency, $dependencies)) {
                    continue;
                }
                /**
                 * if plugin is being removed and is still a dependency
                 * of another plugin, throw error
                 */
                if (isset($PLUGINS[$dependency]) && !isset($NEWPLUGINS[$dependency])) {
                    error('The "' . $dependency . '" plugin cannot be uninstall as it is a dependency' . 'of the "' . $plugins[$i]['name'] . '" plugin. To uninstall, remove' . 'the "' . $plugins[$i]['name'] . '" plugin first.', 'Plugin Dependency Error');
                }
                /**
                 * if plugin is unavailable then throw an error
                 */
                if (!plugin_exists($dependency)) {
                    error('The plugin "' . $plugins[$i]['name'] . '" requires the "' . $dependency . '"' . ' plugin to be installed, however it is not available. In order to use' . ' this plugin you will have to download and install the dependency', 'Plugin Dependency Unavailable');
                }
                $plugin = $Plugins->plugins($p_name);
                if (!$plugin) {
                    require HOME . '_plugins/' . $p_name . '/plugin.php';
                }
                /**
                 * add dependency to list of plugins
                 */
                $NEWPLUGINS[$dependency] = $plugin['version'];
            }
        }
        $NEWPLUGINS[$plugins[$i]['sys_name']] = $plugins[$i]['version'];
    }
    return $NEWPLUGINS;
}