2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* pluginsChange.php
|
|
|
|
|
*
|
|
|
|
|
* ProcessMaker Open Source Edition
|
|
|
|
|
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-10-17 16:23:22 -04:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2010-12-02 23:34:41 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2012-10-17 16:23:22 -04:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
|
|
|
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
|
|
|
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// 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)) {
|
2014-12-23 17:22:42 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2016-07-14 12:16:12 -04:00
|
|
|
if (!$oPluginRegistry->isEnterprisePlugin($pluginName) &&
|
2017-07-21 16:56:44 -04:00
|
|
|
PMLicensedFeatures::getSingleton()
|
|
|
|
|
->verifyfeature('B0oWlBLY3hHdWY0YUNpZEtFQm5CeTJhQlIwN3IxMEkwaG4=')
|
2016-07-14 12:16:12 -04:00
|
|
|
) {
|
2015-06-01 14:15:53 -04:00
|
|
|
//Check disabled code
|
2014-11-19 16:47:22 -04:00
|
|
|
|
2017-10-10 12:33:25 -04:00
|
|
|
$cs = new CodeScanner(config("system.workspace"));
|
2014-11-19 16:47:22 -04:00
|
|
|
|
2017-07-21 16:56:44 -04:00
|
|
|
$arrayFoundDisabledCode = array_merge(
|
|
|
|
|
$cs->checkDisabledCode("FILE", PATH_PLUGINS . $pluginName . ".php"),
|
|
|
|
|
$cs->checkDisabledCode("PATH", PATH_PLUGINS . $pluginName)
|
|
|
|
|
);
|
2014-11-19 16:47:22 -04:00
|
|
|
|
2015-06-01 14:15:53 -04:00
|
|
|
if (!empty($arrayFoundDisabledCode)) {
|
|
|
|
|
$response = array();
|
2017-07-21 16:56:44 -04:00
|
|
|
$response["status"] = "DISABLED-CODE";
|
2015-06-01 14:15:53 -04:00
|
|
|
$response["message"] = G::LoadTranslation("ID_DISABLED_CODE_PLUGIN");
|
|
|
|
|
|
|
|
|
|
echo G::json_encode($response);
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
2014-11-19 16:47:22 -04:00
|
|
|
}
|
2014-12-23 17:22:42 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2015-06-01 14:15:53 -04:00
|
|
|
|
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
|
|
|
}
|