diff --git a/workflow/engine/bin/cron_single.php b/workflow/engine/bin/cron_single.php
index 83c25f284..fe420ca23 100644
--- a/workflow/engine/bin/cron_single.php
+++ b/workflow/engine/bin/cron_single.php
@@ -324,6 +324,9 @@ try {
case 'sendnotificationscron':
sendNotifications();
break;
+ case 'updateSingleton':
+ updateSingleton($workspace);
+ break;
}
} catch (Exception $e) {
$token = strtotime("now");
@@ -1132,3 +1135,33 @@ function sendNotifications()
saveLog("ExecuteSendNotifications", "error", "Error when sending notifications " . $e->getMessage());
}
}
+
+/**
+ * Update singleton file in workspace.
+ *
+ * @param string $workspace
+ */
+function updateSingleton($workspace)
+{
+ eprint("* Update singleton ... ");
+ G::LoadClass('case');
+ $pathSingleton = PATH_DATA . "sites" . PATH_SEP . $workspace . PATH_SEP . "plugin.singleton";
+ $oPluginRegistry = PMPluginRegistry::loadSingleton($pathSingleton);
+ $items = \PMPlugin::getlist($workspace);
+ foreach ($items as $item) {
+ if ($item["sStatusFile"] === true) {
+ $path = PATH_PLUGINS . $item["sFile"];
+ require_once($path);
+ $details = $oPluginRegistry->getPluginDetails($item["sFile"]);
+ //Only if the API directory structure is defined
+ $pathApiDirectory = PATH_PLUGINS . $details->sPluginFolder . PATH_SEP . "src" . PATH_SEP . "Services" . PATH_SEP . "Api";
+ if (is_dir($pathApiDirectory)) {
+ $oPluginRegistry->enablePlugin($details->sNamespace);
+ $oPluginRegistry->setupPlugins();
+ file_put_contents($pathSingleton, $oPluginRegistry->serializeInstance());
+ G::auditLog("EnablePlugin", "Plugin Name: " . $details->sNamespace);
+ }
+ }
+ }
+ eprint("DONE");
+}
diff --git a/workflow/engine/bin/tasks/cliFlushCache.php b/workflow/engine/bin/tasks/cliFlushCache.php
index 2b427e1d5..e9cbb27bf 100644
--- a/workflow/engine/bin/tasks/cliFlushCache.php
+++ b/workflow/engine/bin/tasks/cliFlushCache.php
@@ -38,17 +38,33 @@ CLI::taskRun('run_flush_cache');
function run_flush_cache($args, $opts)
{
- $rootDir = realpath(__DIR__."/../../../../");
+ $rootDir = realpath(__DIR__ . "/../../../../");
$app = new Maveriks\WebApplication();
$app->setRootDir($rootDir);
$loadConstants = false;
$workspaces = get_workspaces_from_args($args);
- if (! defined("PATH_C")) {
- die("ERROR: seems processmaker is not properly installed (System constants are missing).".PHP_EOL);
+ if (!defined("PATH_C")) {
+ die("ERROR: seems processmaker is not properly installed (System constants are missing)." . PHP_EOL);
}
- CLI::logging("Flush ".pakeColor::colorize("system", "INFO")." cache ... ");
+ //Update singleton file by workspace
+ $dateSystem = date('Y-m-d H:i:s');
+ $date = $dateSystem;
+ foreach ($workspaces as $workspace) {
+ $cmd = 'php -f '
+ . '"' . PATH_CORE . 'bin' . PATH_SEP . 'cron_single.php' . '" '
+ . '"' . base64_encode(PATH_HOME) . '" '
+ . '"' . base64_encode(PATH_TRUNK) . '" '
+ . '"' . base64_encode(PATH_OUTTRUNK) . '" '
+ . '"updateSingleton" '
+ . '"' . $workspace->name . '" '
+ . '"' . $dateSystem . '" '
+ . '"' . $date . '" ';
+ passthru($cmd);
+ }
+
+ CLI::logging("Flush " . pakeColor::colorize("system", "INFO") . " cache ... ");
G::rm_dir(PATH_C);
G::mk_dir(PATH_C, 0777);
echo "DONE" . PHP_EOL;
@@ -60,8 +76,8 @@ function run_flush_cache($args, $opts)
G::mk_dir($workspace->path . "/cache", 0777);
G::rm_dir($workspace->path . "/cachefiles");
G::mk_dir($workspace->path . "/cachefiles", 0777);
- if (file_exists($workspace->path.'/routes.php')) {
- unlink($workspace->path.'/routes.php');
+ if (file_exists($workspace->path . '/routes.php')) {
+ unlink($workspace->path . '/routes.php');
}
echo "DONE" . PHP_EOL;
}
diff --git a/workflow/engine/classes/class.plugin.php b/workflow/engine/classes/class.plugin.php
index c34016d05..5888222aa 100644
--- a/workflow/engine/classes/class.plugin.php
+++ b/workflow/engine/classes/class.plugin.php
@@ -516,92 +516,65 @@ class PMPlugin
}
/**
- * This function is an analog of the command: '$ ./processmaker flush-cache',
- * only its use is recommended only when enabling the plugin (inside the
- * enable function).
- * IMPORTANT! Inappropriate use may render the 'API/REST' unusable.
- * Example:
- * sFriendlyName = "myPlugin Plugin";
- * $this->sDescription = "Autogenerated plugin for class myPlugin";
- * $this->sPluginFolder = "myPlugin";
- * $this->sSetupPage = "setup";
- * $this->iVersion = 1;
- * $this->aWorkspaces = null;
- * return $res;
- * }
- * public function setup() {
- *
- * }
- *
- * public function install() {
- *
- * }
- *
- * public function enable() {
- * $this->enableRestService(true);
- * $this->flushCache();
- * }
- *
- * public function disable() {
- *
- * }
- *
- * }
- *
- * $oPluginRegistry = &PMPluginRegistry::getSingleton();
- * $oPluginRegistry->registerPlugin("ejemplo3", __FILE__);
- *
- * @param string $workspaceName
- * @throws Exception
+ * Gets an array of plugins that are in the processmaker plugin directory.
+ * @param string $workspace
+ * @return array
*/
- public function flushCache($workspaceName = "")
+ public static function getList($workspace)
{
- try {
- $workspaces = System::listWorkspaces();
- if (!empty($workspaceName)) {
- $itWasFound = false;
- foreach ($workspaces as $workspace) {
- if ($workspace->name === $workspaceName) {
- $itWasFound = true;
- $workspaces = [$workspace];
- break;
+ $items = Array();
+ $aPluginsPP = array();
+ if (is_file(PATH_PLUGINS . 'enterprise/data/data')) {
+ $aPlugins = unserialize(trim(file_get_contents(PATH_PLUGINS . 'enterprise/data/data')));
+ foreach ($aPlugins as $aPlugin) {
+ $aPluginsPP[] = substr($aPlugin['sFilename'], 0, strpos($aPlugin['sFilename'], '-')) . '.php';
+ }
+ }
+ $oPluginRegistry = PMPluginRegistry::getSingleton();
+ if ($handle = opendir(PATH_PLUGINS)) {
+ while (false !== ($file = readdir($handle))) {
+ if (in_array($file, $aPluginsPP)) {
+ continue;
+ }
+ if (strpos($file, '.php', 1) && is_file(PATH_PLUGINS . $file)) {
+ include_once (PATH_PLUGINS . $file);
+ $pluginDetail = $oPluginRegistry->getPluginDetails($file);
+ if ($pluginDetail === null) {
+ continue;
+ }
+ $status_label = $pluginDetail->enabled ? G::LoadTranslation('ID_ENABLED') : G::LoadTranslation('ID_DISABLED');
+ $status = $pluginDetail->enabled ? 1 : 0;
+ if (isset($pluginDetail->aWorkspaces)) {
+ if (!is_array($pluginDetail->aWorkspaces)) {
+ $pluginDetail->aWorkspaces = array();
+ }
+ if (!in_array($workspace, $pluginDetail->aWorkspaces)) {
+ continue;
+ }
+ }
+ $setup = $pluginDetail->sSetupPage != '' && $pluginDetail->enabled ? '1' : '0';
+
+ if (isset($pluginDetail) && !$pluginDetail->bPrivate) {
+ $items[] = [
+ 'id' => (count($items) + 1),
+ 'namespace' => $pluginDetail->sNamespace,
+ 'title' => $pluginDetail->sFriendlyName . "\n(" . $pluginDetail->sNamespace . '.php)',
+ 'className' => $pluginDetail->sNamespace,
+ 'description' => $pluginDetail->sDescription,
+ 'version' => $pluginDetail->iVersion,
+ 'setupPage' => $pluginDetail->sSetupPage,
+ 'status_label' => $status_label,
+ 'status' => $status,
+ 'setup' => $setup,
+ 'sFile' => $file,
+ 'sStatusFile' => $pluginDetail->enabled
+ ];
}
}
- if ($itWasFound === false) {
- $workspaces = [];
- throw new Exception('Error: The workspace "' . $workspaceName . '" does not exist');
- }
}
- foreach ($workspaces as $workspace) {
- $path = $workspace->path . "/cache";
- if (file_exists($path)) {
- G::rm_dir($path);
- }
- G::mk_dir($path, 0777);
- $path = $workspace->path . "/cachefiles";
- if (file_exists($path)) {
- G::rm_dir($path);
- }
- G::mk_dir($path, 0777);
- $path = $workspace->path . "/routes.php";
- if (file_exists($path)) {
- unlink($path);
- }
- }
- } catch (Exception $exception) {
- $sysSys = (defined("SYS_SYS")) ? SYS_SYS : "Undefined";
- $context = \Bootstrap::getDefaultContextLog();
- $context["exception"] = (array) $exception;
- \Bootstrap::initVendors();
- \Bootstrap::LoadSystem('monologProvider');
- \Bootstrap::registerMonolog("flush-cache", 400, "flush-cache", $context, $sysSys, "processmaker.log");
+ closedir($handle);
}
+ return $items;
}
}
diff --git a/workflow/engine/methods/setup/pluginsList.php b/workflow/engine/methods/setup/pluginsList.php
index 663256c06..edfa49a2b 100644
--- a/workflow/engine/methods/setup/pluginsList.php
+++ b/workflow/engine/methods/setup/pluginsList.php
@@ -1,4 +1,5 @@
requirePermissions('PM_SETUP_ADVANCE');
-$RBAC->requirePermissions( 'PM_SETUP_ADVANCE' );
-
-// lets display the items
-//$items = array ( 'id' => 'char', 'title' => 'char', 'type' => 'char', 'creator' => 'char' , 'modifiedBy' => 'char', 'filename' => 'char', 'size' => 'char', 'mime' => 'char');
-
-
-$items = Array ();
-//***************** Plugins **************************
-G::LoadClass( 'plugin' );
-//here we are loading all plugins registered
-//krumo ($items); die;
-$aPluginsPP = array ();
-if (is_file( PATH_PLUGINS . 'enterprise/data/data' )) {
- $aPlugins = unserialize( trim( file_get_contents( PATH_PLUGINS . 'enterprise/data/data' ) ) );
- foreach ($aPlugins as $aPlugin) {
- $aPluginsPP[] = substr( $aPlugin['sFilename'], 0, strpos( $aPlugin['sFilename'], '-' ) ) . '.php';
- }
-}
-$oPluginRegistry = & PMPluginRegistry::getSingleton();
-if ($handle = opendir( PATH_PLUGINS )) {
- while (false !== ($file = readdir( $handle ))) {
-
- if (in_array( $file, $aPluginsPP )) {
- continue;
- }
- if (strpos( $file, '.php', 1 ) && is_file( PATH_PLUGINS . $file )) {
- include_once (PATH_PLUGINS . $file);
- $pluginDetail = $oPluginRegistry->getPluginDetails( $file );
- //print_R ($pluginDetail );
- //die;
- //$status = $pluginDetail->enabled ? 'Enabled' : 'Disabled';
- if ($pluginDetail == null)
- continue; //When for some reason we gen NULL plugin
- $status_label = $pluginDetail->enabled ? G::LoadTranslation( 'ID_ENABLED' ) : G::LoadTranslation( 'ID_DISABLED' );
- $status = $pluginDetail->enabled ? 1 : 0;
- if (isset( $pluginDetail->aWorkspaces )) {
- if (!is_array($pluginDetail->aWorkspaces)) {
- $pluginDetail->aWorkspaces = array();
- }
- if (! in_array( SYS_SYS, $pluginDetail->aWorkspaces ))
- continue;
- }
- $linkEditValue = $pluginDetail->sSetupPage != '' && $pluginDetail->enabled ? G::LoadTranslation( 'ID_SETUP' ) : ' ';
- //g::pr($pluginDetail->sSetupPage);
- $setup = $pluginDetail->sSetupPage != '' && $pluginDetail->enabled ? '1' : '0';
-
- $link = 'pluginsChange?id=' . $file . '&status=' . $pluginDetail->enabled;
- $linkEdit = 'pluginsSetup?id=' . $file;
- $pluginName = $pluginDetail->sFriendlyName;
- $pluginId = $pluginDetail->sNamespace;
- $removePluginMsg = str_replace( "\r\n", "
", G::LoadTranslation( 'ID_MSG_REMOVE_PLUGIN' ) );
- $linkRemove = 'javascript:showMessage(\'' . $removePluginMsg . '
' . $pluginName . ' \',\'' . $pluginId . '\')';
- // $linkRemove = 'pluginsRemove?id='.$pluginId.'.php&status=1';
- if (isset( $pluginDetail )) {
- if (! $pluginDetail->bPrivate) {
- $items[] = array ('id' => (count( $items ) + 1),'namespace' => $pluginDetail->sNamespace,'title' => $pluginDetail->sFriendlyName . "\n(" . $pluginDetail->sNamespace . '.php)','className' => $pluginDetail->sNamespace,'description' => $pluginDetail->sDescription,'version' => $pluginDetail->iVersion,'setupPage' => $pluginDetail->sSetupPage,'status_label' => $status_label,'status' => $status,'setup' => $setup,
-
- 'sFile' => $file,'sStatusFile' => $pluginDetail->enabled
- );
- }
- }
-
- }
- }
- closedir( $handle );
-}
-
-$folders['items'] = $items;
-//g::pr($items);
-echo G::json_encode( $items );
-die();
-$_DBArray['plugins'] = $items;
-$_SESSION['_DBArray'] = $_DBArray;
-
-G::LoadClass( 'ArrayPeer' );
-$c = new Criteria( 'dbarray' );
-$c->setDBArrayTable( 'plugins' );
-//$c->addAscendingOrderByColumn ('id');
-
-
-$G_MAIN_MENU = 'processmaker';
-$G_ID_MENU_SELECTED = 'SETUP';
-$G_SUB_MENU = 'setup';
-$G_ID_SUB_MENU_SELECTED = 'PLUGINS';
-
-$G_PUBLISH = new Publisher();
-
-$oHeadPublisher = & headPublisher::getSingleton();
-$oHeadPublisher->addScriptFile( '/jscore/setup/pluginList.js' );
-
-$G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/pluginList', $c );
-G::RenderPage( 'publishBlank', 'blank' );
-
+G::LoadClass('plugin');
+$items = \PMPlugin::getlist(SYS_SYS);
+echo G::json_encode($items);
diff --git a/workflow/public_html/ee b/workflow/public_html/ee
new file mode 100644
index 000000000..aac5b4494
--- /dev/null
+++ b/workflow/public_html/ee
@@ -0,0 +1 @@
+a:11:{s:14:"actionsByEmail";a:1:{s:9:"sFilename";s:33:"actionsByEmail-PLUGIN_VERSION.tar";}s:16:"EnterpriseSearch";a:1:{s:9:"sFilename";s:35:"EnterpriseSearch-PLUGIN_VERSION.tar";}s:9:"pmReports";a:1:{s:9:"sFilename";s:28:"pmReports-PLUGIN_VERSION.tar";}s:10:"windowsSSO";a:1:{s:9:"sFilename";s:23:"windowsSSO-HOR-1976.tar";}s:9:"pmPowerUp";a:1:{s:9:"sFilename";s:28:"pmPowerUp-PLUGIN_VERSION.tar";}s:12:"pmConnectors";a:1:{s:9:"sFilename";s:31:"pmConnectors-PLUGIN_VERSION.tar";}s:16:"pmConsolidatedCL";a:1:{s:9:"sFilename";s:35:"pmConsolidatedCL-PLUGIN_VERSION.tar";}s:18:"dataReportingTools";a:1:{s:9:"sFilename";s:30:"dataReportingTools-1.1.0.6.tar";}s:21:"pmWorkspaceManagement";a:1:{s:9:"sFilename";s:40:"pmWorkspaceManagement-PLUGIN_VERSION.tar";}s:5:"pmSLA";a:1:{s:9:"sFilename";s:24:"pmSLA-PLUGIN_VERSION.tar";}s:20:"externalRegistration";a:1:{s:9:"sFilename";s:39:"externalRegistration-PLUGIN_VERSION.tar";}}
\ No newline at end of file