This commit is contained in:
Roly Rudy Gutierrez Pinto
2017-05-15 14:49:15 -04:00
parent f879964e92
commit c235f15a29
5 changed files with 114 additions and 179 deletions

View File

@@ -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");
}

View File

@@ -48,6 +48,22 @@ function run_flush_cache($args, $opts)
die("ERROR: seems processmaker is not properly installed (System constants are missing)." . PHP_EOL);
}
//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);

View File

@@ -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:
* <?php
* G::LoadClass("plugin");
* class myPlugin extends PMPlugin {
*
* public function myPlugin($sNamespace, $sFilename = null) {
* $res = parent::PMPlugin($sNamespace, $sFilename);
* $this->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';
}
}
if ($itWasFound === false) {
$workspaces = [];
throw new Exception('Error: The workspace "' . $workspaceName . '" does not exist');
$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;
}
}
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);
$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
];
}
}
} 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;
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* pluginsList.php
*
@@ -21,97 +22,8 @@
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
$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", "<br>", G::LoadTranslation( 'ID_MSG_REMOVE_PLUGIN' ) );
$linkRemove = 'javascript:showMessage(\'' . $removePluginMsg . '<br>' . $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);
$items = \PMPlugin::getlist(SYS_SYS);
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' );

1
workflow/public_html/ee Normal file
View File

@@ -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";}}