2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* pluginsChange.php
|
2019-09-06 15:49:07 -04:00
|
|
|
* If the feature is enable and the code_scanner_scope was enable with the argument enable_plugin, will check the code
|
|
|
|
|
* Review when a plugin was enable
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
2019-09-06 15:49:07 -04:00
|
|
|
* @link https://wiki.processmaker.com/3.0/Plugins#Enable_and_Disable_a_Plugin
|
2010-12-02 23:34:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// lets display the items
|
2017-08-04 09:32:25 -04:00
|
|
|
use ProcessMaker\Plugins\PluginRegistry;
|
|
|
|
|
|
2012-10-17 16:23:22 -04:00
|
|
|
$pluginFile = $_GET['id'];
|
|
|
|
|
$pluginStatus = $_GET['status'];
|
|
|
|
|
|
|
|
|
|
$items = array ();
|
|
|
|
|
//here we are enabling or disabling the plugin and all related options registered.
|
2015-03-12 14:51:09 -04:00
|
|
|
$filter = new InputFilter();
|
|
|
|
|
$path = PATH_PLUGINS . $pluginFile;
|
|
|
|
|
$path = $filter->validateInput($path, 'path');
|
2012-10-17 16:23:22 -04:00
|
|
|
|
2017-08-04 09:32:25 -04:00
|
|
|
$oPluginRegistry = PluginRegistry::loadSingleton();
|
2012-10-17 16:23:22 -04:00
|
|
|
|
2017-07-21 16:56:44 -04:00
|
|
|
if ($handle = opendir(PATH_PLUGINS)) {
|
|
|
|
|
while (false !== ($file = readdir($handle))) {
|
|
|
|
|
if (strpos($file, '.php', 1) && $file == $pluginFile) {
|
2017-08-10 22:59:30 -04:00
|
|
|
if ($pluginStatus == '1') {
|
2017-08-01 12:16:06 -04:00
|
|
|
// change to disable
|
2017-07-21 16:56:44 -04:00
|
|
|
$details = $oPluginRegistry->getPluginDetails($pluginFile);
|
2017-08-01 12:16:06 -04:00
|
|
|
$oPluginRegistry->disablePlugin($details->getNamespace());
|
2017-08-10 21:55:18 -04:00
|
|
|
$oPluginRegistry->savePlugin($details->getNamespace());
|
2017-08-01 12:16:06 -04:00
|
|
|
G::auditLog("DisablePlugin", "Plugin Name: " . $details->getNamespace());
|
2012-10-17 16:23:22 -04:00
|
|
|
} else {
|
2014-11-19 16:47:22 -04:00
|
|
|
$pluginName = str_replace(".php", "", $pluginFile);
|
|
|
|
|
|
|
|
|
|
if (is_file(PATH_PLUGINS . $pluginName . ".php") && is_dir(PATH_PLUGINS . $pluginName)) {
|
2017-08-01 12:16:06 -04:00
|
|
|
// change to ENABLED
|
2015-03-12 14:51:09 -04:00
|
|
|
require_once($path);
|
2014-11-19 16:47:22 -04:00
|
|
|
$details = $oPluginRegistry->getPluginDetails($pluginFile);
|
2017-08-01 12:16:06 -04:00
|
|
|
$oPluginRegistry->enablePlugin($details->getNamespace());
|
2014-11-19 16:47:22 -04:00
|
|
|
$oPluginRegistry->setupPlugins(); //get and setup enabled plugins
|
2017-08-01 12:16:06 -04:00
|
|
|
$oPluginRegistry->savePlugin($details->getNamespace());
|
|
|
|
|
G::auditLog("EnablePlugin", "Plugin Name: " . $details->getNamespace());
|
2014-11-19 16:47:22 -04:00
|
|
|
}
|
2012-10-17 16:23:22 -04:00
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2017-07-21 16:56:44 -04:00
|
|
|
closedir($handle);
|
2012-10-17 16:23:22 -04:00
|
|
|
}
|