From 937e40d6d1f4fe0ea31cef2904c94e564e43a1c7 Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Mena Date: Thu, 15 Mar 2018 16:35:53 -0400 Subject: [PATCH] HOR-4434 --- workflow/engine/bin/cron_single.php | 10 ++- workflow/engine/classes/PMPluginRegistry.php | 17 +++-- workflow/engine/classes/ProcessMap.php | 2 +- .../model/map/PluginsRegistryMapBuilder.php | 2 + .../classes/model/om/BasePluginsRegistry.php | 76 ++++++++++++++++--- .../model/om/BasePluginsRegistryPeer.php | 23 +++--- workflow/engine/config/schema.xml | 1 + workflow/engine/data/mysql/schema.sql | 1 + workflow/engine/methods/cases/cases_Step.php | 6 +- .../Plugins/Adapters/PluginAdapter.php | 1 + .../Plugins/Interfaces/CronFile.php | 20 +++++ .../ProcessMaker/Plugins/PluginRegistry.php | 15 ++-- .../Plugins/Traits/PluginStructure.php | 19 +++++ 13 files changed, 155 insertions(+), 38 deletions(-) diff --git a/workflow/engine/bin/cron_single.php b/workflow/engine/bin/cron_single.php index ee35c8c5b..068875dc4 100644 --- a/workflow/engine/bin/cron_single.php +++ b/workflow/engine/bin/cron_single.php @@ -439,8 +439,16 @@ function executePlugins() // -> Execute functions if (!empty($cronFiles)) { setExecutionMessage('Executing registered cron files for Workspace: ' . SYS_SYS); + /** + * @var \ProcessMaker\Plugins\Interfaces\CronFile $cronFile + */ foreach($cronFiles as $cronFile) { - executeCustomCronFunction(PATH_PLUGINS . $cronFile->namespace . PATH_SEP . 'bin' . PATH_SEP . $cronFile->cronFile . '.php', $cronFile->cronFile); + $path = PATH_PLUGINS . $cronFile->getNamespace() . PATH_SEP . 'bin' . PATH_SEP . $cronFile->getCronFile() . '.php'; + if (file_exists($path)) { + executeCustomCronFunction($path, $cronFile->getCronFile()); + } else { + setExecutionMessage('File ' . $cronFile->getCronFile() . '.php ' . 'does not exist.'); + } } } diff --git a/workflow/engine/classes/PMPluginRegistry.php b/workflow/engine/classes/PMPluginRegistry.php index 3851910b7..28b96deb4 100644 --- a/workflow/engine/classes/PMPluginRegistry.php +++ b/workflow/engine/classes/PMPluginRegistry.php @@ -1479,21 +1479,22 @@ class PMPluginRegistry /** * Register a cron file in the singleton * - * @param unknown_type $namespace - * @param unknown_type $cronFile + * @param string $pluginName + * @param string $cronFileToRegister */ - public function registerCronFile($namespace, $cronFile) + public function registerCronFile($pluginName, $cronFileToRegister) { $found = false; - foreach ($this->_aCronFiles as $row => $detail) { - if ($cronFile == $detail->cronFile && $namespace == $detail->namespace) { - $detail->cronFile = $cronFile; + foreach ($this->_aCronFiles as $cronFile) { + if ($cronFile instanceof cronFile && + $cronFileToRegister === $cronFile->cronFile && + $pluginName === $cronFile->namespace) { + $cronFile->cronFile = $cronFileToRegister; $found = true; } } if (!$found) { - $cronFile = new cronFile($namespace, $cronFile); - $this->_aCronFiles[] = $cronFile; + $this->_aCronFiles[] = new cronFile($pluginName, $cronFileToRegister); } } diff --git a/workflow/engine/classes/ProcessMap.php b/workflow/engine/classes/ProcessMap.php index 798e7e893..eaf04cc2d 100644 --- a/workflow/engine/classes/ProcessMap.php +++ b/workflow/engine/classes/ProcessMap.php @@ -803,7 +803,7 @@ class ProcessMap if ($val->equalStepIdTo($aRow['STEP_UID_OBJ'])) { $sTitle = $val->getStepTitle(); if (trim($val->getSetupStepPage()) != '') { - $urlEdit = "externalStepEdit('" . $aRow['STEP_UID'] . "', '" . $val->sSetupStepPage . "');"; + $urlEdit = "externalStepEdit('" . $aRow['STEP_UID'] . "', '" . $val->getSetupStepPage() . "');"; $linkEditValue = 'Edit'; } else { $urlEdit = ""; diff --git a/workflow/engine/classes/model/map/PluginsRegistryMapBuilder.php b/workflow/engine/classes/model/map/PluginsRegistryMapBuilder.php index 25cfaf8c6..a76eeaff8 100644 --- a/workflow/engine/classes/model/map/PluginsRegistryMapBuilder.php +++ b/workflow/engine/classes/model/map/PluginsRegistryMapBuilder.php @@ -109,6 +109,8 @@ class PluginsRegistryMapBuilder $tMap->addColumn('PLUGIN_REST_SERVICE', 'PluginRestService', 'string', CreoleTypes::LONGVARCHAR, false, null); + $tMap->addColumn('PLUGIN_CRON_FILES', 'PluginCronFiles', 'string', CreoleTypes::LONGVARCHAR, false, null); + $tMap->addColumn('PLUGIN_TASK_EXTENDED_PROPERTIES', 'PluginTaskExtendedProperties', 'string', CreoleTypes::LONGVARCHAR, false, null); $tMap->addColumn('PLUGIN_ATTRIBUTES', 'PluginAttributes', 'string', CreoleTypes::LONGVARCHAR, false, null); diff --git a/workflow/engine/classes/model/om/BasePluginsRegistry.php b/workflow/engine/classes/model/om/BasePluginsRegistry.php index d6f0be021..61d38d7bc 100644 --- a/workflow/engine/classes/model/om/BasePluginsRegistry.php +++ b/workflow/engine/classes/model/om/BasePluginsRegistry.php @@ -159,6 +159,12 @@ abstract class BasePluginsRegistry extends BaseObject implements Persistent */ protected $plugin_rest_service; + /** + * The value for the plugin_cron_files field. + * @var string + */ + protected $plugin_cron_files; + /** * The value for the plugin_task_extended_properties field. * @var string @@ -427,6 +433,17 @@ abstract class BasePluginsRegistry extends BaseObject implements Persistent return $this->plugin_rest_service; } + /** + * Get the [plugin_cron_files] column value. + * + * @return string + */ + public function getPluginCronFiles() + { + + return $this->plugin_cron_files; + } + /** * Get the [plugin_task_extended_properties] column value. * @@ -933,6 +950,28 @@ abstract class BasePluginsRegistry extends BaseObject implements Persistent } // setPluginRestService() + /** + * Set the value of [plugin_cron_files] column. + * + * @param string $v new value + * @return void + */ + public function setPluginCronFiles($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->plugin_cron_files !== $v) { + $this->plugin_cron_files = $v; + $this->modifiedColumns[] = PluginsRegistryPeer::PLUGIN_CRON_FILES; + } + + } // setPluginCronFiles() + /** * Set the value of [plugin_task_extended_properties] column. * @@ -1038,16 +1077,18 @@ abstract class BasePluginsRegistry extends BaseObject implements Persistent $this->plugin_rest_service = $rs->getString($startcol + 21); - $this->plugin_task_extended_properties = $rs->getString($startcol + 22); + $this->plugin_cron_files = $rs->getString($startcol + 22); - $this->plugin_attributes = $rs->getString($startcol + 23); + $this->plugin_task_extended_properties = $rs->getString($startcol + 23); + + $this->plugin_attributes = $rs->getString($startcol + 24); $this->resetModified(); $this->setNew(false); // FIXME - using NUM_COLUMNS may be clearer. - return $startcol + 24; // 24 = PluginsRegistryPeer::NUM_COLUMNS - PluginsRegistryPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 25; // 25 = PluginsRegistryPeer::NUM_COLUMNS - PluginsRegistryPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating PluginsRegistry object", $e); @@ -1318,9 +1359,12 @@ abstract class BasePluginsRegistry extends BaseObject implements Persistent return $this->getPluginRestService(); break; case 22: - return $this->getPluginTaskExtendedProperties(); + return $this->getPluginCronFiles(); break; case 23: + return $this->getPluginTaskExtendedProperties(); + break; + case 24: return $this->getPluginAttributes(); break; default: @@ -1365,8 +1409,9 @@ abstract class BasePluginsRegistry extends BaseObject implements Persistent $keys[19] => $this->getPluginCss(), $keys[20] => $this->getPluginJs(), $keys[21] => $this->getPluginRestService(), - $keys[22] => $this->getPluginTaskExtendedProperties(), - $keys[23] => $this->getPluginAttributes(), + $keys[22] => $this->getPluginCronFiles(), + $keys[23] => $this->getPluginTaskExtendedProperties(), + $keys[24] => $this->getPluginAttributes(), ); return $result; } @@ -1465,9 +1510,12 @@ abstract class BasePluginsRegistry extends BaseObject implements Persistent $this->setPluginRestService($value); break; case 22: - $this->setPluginTaskExtendedProperties($value); + $this->setPluginCronFiles($value); break; case 23: + $this->setPluginTaskExtendedProperties($value); + break; + case 24: $this->setPluginAttributes($value); break; } // switch() @@ -1582,11 +1630,15 @@ abstract class BasePluginsRegistry extends BaseObject implements Persistent } if (array_key_exists($keys[22], $arr)) { - $this->setPluginTaskExtendedProperties($arr[$keys[22]]); + $this->setPluginCronFiles($arr[$keys[22]]); } if (array_key_exists($keys[23], $arr)) { - $this->setPluginAttributes($arr[$keys[23]]); + $this->setPluginTaskExtendedProperties($arr[$keys[23]]); + } + + if (array_key_exists($keys[24], $arr)) { + $this->setPluginAttributes($arr[$keys[24]]); } } @@ -1688,6 +1740,10 @@ abstract class BasePluginsRegistry extends BaseObject implements Persistent $criteria->add(PluginsRegistryPeer::PLUGIN_REST_SERVICE, $this->plugin_rest_service); } + if ($this->isColumnModified(PluginsRegistryPeer::PLUGIN_CRON_FILES)) { + $criteria->add(PluginsRegistryPeer::PLUGIN_CRON_FILES, $this->plugin_cron_files); + } + if ($this->isColumnModified(PluginsRegistryPeer::PLUGIN_TASK_EXTENDED_PROPERTIES)) { $criteria->add(PluginsRegistryPeer::PLUGIN_TASK_EXTENDED_PROPERTIES, $this->plugin_task_extended_properties); } @@ -1792,6 +1848,8 @@ abstract class BasePluginsRegistry extends BaseObject implements Persistent $copyObj->setPluginRestService($this->plugin_rest_service); + $copyObj->setPluginCronFiles($this->plugin_cron_files); + $copyObj->setPluginTaskExtendedProperties($this->plugin_task_extended_properties); $copyObj->setPluginAttributes($this->plugin_attributes); diff --git a/workflow/engine/classes/model/om/BasePluginsRegistryPeer.php b/workflow/engine/classes/model/om/BasePluginsRegistryPeer.php index f6c8814a7..47f9954dc 100644 --- a/workflow/engine/classes/model/om/BasePluginsRegistryPeer.php +++ b/workflow/engine/classes/model/om/BasePluginsRegistryPeer.php @@ -25,7 +25,7 @@ abstract class BasePluginsRegistryPeer const CLASS_DEFAULT = 'classes.model.PluginsRegistry'; /** The total number of columns. */ - const NUM_COLUMNS = 24; + const NUM_COLUMNS = 25; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -97,6 +97,9 @@ abstract class BasePluginsRegistryPeer /** the column name for the PLUGIN_REST_SERVICE field */ const PLUGIN_REST_SERVICE = 'PLUGINS_REGISTRY.PLUGIN_REST_SERVICE'; + /** the column name for the PLUGIN_CRON_FILES field */ + const PLUGIN_CRON_FILES = 'PLUGINS_REGISTRY.PLUGIN_CRON_FILES'; + /** the column name for the PLUGIN_TASK_EXTENDED_PROPERTIES field */ const PLUGIN_TASK_EXTENDED_PROPERTIES = 'PLUGINS_REGISTRY.PLUGIN_TASK_EXTENDED_PROPERTIES'; @@ -114,10 +117,10 @@ abstract class BasePluginsRegistryPeer * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('PrUid', 'PluginNamespace', 'PluginDescription', 'PluginClassName', 'PluginFriendlyName', 'PluginFile', 'PluginFolder', 'PluginSetupPage', 'PluginCompanyLogo', 'PluginWorkspaces', 'PluginVersion', 'PluginEnable', 'PluginPrivate', 'PluginMenus', 'PluginFolders', 'PluginTriggers', 'PluginPmFunctions', 'PluginRedirectLogin', 'PluginSteps', 'PluginCss', 'PluginJs', 'PluginRestService', 'PluginTaskExtendedProperties', 'PluginAttributes', ), - BasePeer::TYPE_COLNAME => array (PluginsRegistryPeer::PR_UID, PluginsRegistryPeer::PLUGIN_NAMESPACE, PluginsRegistryPeer::PLUGIN_DESCRIPTION, PluginsRegistryPeer::PLUGIN_CLASS_NAME, PluginsRegistryPeer::PLUGIN_FRIENDLY_NAME, PluginsRegistryPeer::PLUGIN_FILE, PluginsRegistryPeer::PLUGIN_FOLDER, PluginsRegistryPeer::PLUGIN_SETUP_PAGE, PluginsRegistryPeer::PLUGIN_COMPANY_LOGO, PluginsRegistryPeer::PLUGIN_WORKSPACES, PluginsRegistryPeer::PLUGIN_VERSION, PluginsRegistryPeer::PLUGIN_ENABLE, PluginsRegistryPeer::PLUGIN_PRIVATE, PluginsRegistryPeer::PLUGIN_MENUS, PluginsRegistryPeer::PLUGIN_FOLDERS, PluginsRegistryPeer::PLUGIN_TRIGGERS, PluginsRegistryPeer::PLUGIN_PM_FUNCTIONS, PluginsRegistryPeer::PLUGIN_REDIRECT_LOGIN, PluginsRegistryPeer::PLUGIN_STEPS, PluginsRegistryPeer::PLUGIN_CSS, PluginsRegistryPeer::PLUGIN_JS, PluginsRegistryPeer::PLUGIN_REST_SERVICE, PluginsRegistryPeer::PLUGIN_TASK_EXTENDED_PROPERTIES, PluginsRegistryPeer::PLUGIN_ATTRIBUTES, ), - BasePeer::TYPE_FIELDNAME => array ('PR_UID', 'PLUGIN_NAMESPACE', 'PLUGIN_DESCRIPTION', 'PLUGIN_CLASS_NAME', 'PLUGIN_FRIENDLY_NAME', 'PLUGIN_FILE', 'PLUGIN_FOLDER', 'PLUGIN_SETUP_PAGE', 'PLUGIN_COMPANY_LOGO', 'PLUGIN_WORKSPACES', 'PLUGIN_VERSION', 'PLUGIN_ENABLE', 'PLUGIN_PRIVATE', 'PLUGIN_MENUS', 'PLUGIN_FOLDERS', 'PLUGIN_TRIGGERS', 'PLUGIN_PM_FUNCTIONS', 'PLUGIN_REDIRECT_LOGIN', 'PLUGIN_STEPS', 'PLUGIN_CSS', 'PLUGIN_JS', 'PLUGIN_REST_SERVICE', 'PLUGIN_TASK_EXTENDED_PROPERTIES', 'PLUGIN_ATTRIBUTES', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, ) + BasePeer::TYPE_PHPNAME => array ('PrUid', 'PluginNamespace', 'PluginDescription', 'PluginClassName', 'PluginFriendlyName', 'PluginFile', 'PluginFolder', 'PluginSetupPage', 'PluginCompanyLogo', 'PluginWorkspaces', 'PluginVersion', 'PluginEnable', 'PluginPrivate', 'PluginMenus', 'PluginFolders', 'PluginTriggers', 'PluginPmFunctions', 'PluginRedirectLogin', 'PluginSteps', 'PluginCss', 'PluginJs', 'PluginRestService', 'PluginCronFiles', 'PluginTaskExtendedProperties', 'PluginAttributes', ), + BasePeer::TYPE_COLNAME => array (PluginsRegistryPeer::PR_UID, PluginsRegistryPeer::PLUGIN_NAMESPACE, PluginsRegistryPeer::PLUGIN_DESCRIPTION, PluginsRegistryPeer::PLUGIN_CLASS_NAME, PluginsRegistryPeer::PLUGIN_FRIENDLY_NAME, PluginsRegistryPeer::PLUGIN_FILE, PluginsRegistryPeer::PLUGIN_FOLDER, PluginsRegistryPeer::PLUGIN_SETUP_PAGE, PluginsRegistryPeer::PLUGIN_COMPANY_LOGO, PluginsRegistryPeer::PLUGIN_WORKSPACES, PluginsRegistryPeer::PLUGIN_VERSION, PluginsRegistryPeer::PLUGIN_ENABLE, PluginsRegistryPeer::PLUGIN_PRIVATE, PluginsRegistryPeer::PLUGIN_MENUS, PluginsRegistryPeer::PLUGIN_FOLDERS, PluginsRegistryPeer::PLUGIN_TRIGGERS, PluginsRegistryPeer::PLUGIN_PM_FUNCTIONS, PluginsRegistryPeer::PLUGIN_REDIRECT_LOGIN, PluginsRegistryPeer::PLUGIN_STEPS, PluginsRegistryPeer::PLUGIN_CSS, PluginsRegistryPeer::PLUGIN_JS, PluginsRegistryPeer::PLUGIN_REST_SERVICE, PluginsRegistryPeer::PLUGIN_CRON_FILES, PluginsRegistryPeer::PLUGIN_TASK_EXTENDED_PROPERTIES, PluginsRegistryPeer::PLUGIN_ATTRIBUTES, ), + BasePeer::TYPE_FIELDNAME => array ('PR_UID', 'PLUGIN_NAMESPACE', 'PLUGIN_DESCRIPTION', 'PLUGIN_CLASS_NAME', 'PLUGIN_FRIENDLY_NAME', 'PLUGIN_FILE', 'PLUGIN_FOLDER', 'PLUGIN_SETUP_PAGE', 'PLUGIN_COMPANY_LOGO', 'PLUGIN_WORKSPACES', 'PLUGIN_VERSION', 'PLUGIN_ENABLE', 'PLUGIN_PRIVATE', 'PLUGIN_MENUS', 'PLUGIN_FOLDERS', 'PLUGIN_TRIGGERS', 'PLUGIN_PM_FUNCTIONS', 'PLUGIN_REDIRECT_LOGIN', 'PLUGIN_STEPS', 'PLUGIN_CSS', 'PLUGIN_JS', 'PLUGIN_REST_SERVICE', 'PLUGIN_CRON_FILES', 'PLUGIN_TASK_EXTENDED_PROPERTIES', 'PLUGIN_ATTRIBUTES', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, ) ); /** @@ -127,10 +130,10 @@ abstract class BasePluginsRegistryPeer * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('PrUid' => 0, 'PluginNamespace' => 1, 'PluginDescription' => 2, 'PluginClassName' => 3, 'PluginFriendlyName' => 4, 'PluginFile' => 5, 'PluginFolder' => 6, 'PluginSetupPage' => 7, 'PluginCompanyLogo' => 8, 'PluginWorkspaces' => 9, 'PluginVersion' => 10, 'PluginEnable' => 11, 'PluginPrivate' => 12, 'PluginMenus' => 13, 'PluginFolders' => 14, 'PluginTriggers' => 15, 'PluginPmFunctions' => 16, 'PluginRedirectLogin' => 17, 'PluginSteps' => 18, 'PluginCss' => 19, 'PluginJs' => 20, 'PluginRestService' => 21, 'PluginTaskExtendedProperties' => 22, 'PluginAttributes' => 23, ), - BasePeer::TYPE_COLNAME => array (PluginsRegistryPeer::PR_UID => 0, PluginsRegistryPeer::PLUGIN_NAMESPACE => 1, PluginsRegistryPeer::PLUGIN_DESCRIPTION => 2, PluginsRegistryPeer::PLUGIN_CLASS_NAME => 3, PluginsRegistryPeer::PLUGIN_FRIENDLY_NAME => 4, PluginsRegistryPeer::PLUGIN_FILE => 5, PluginsRegistryPeer::PLUGIN_FOLDER => 6, PluginsRegistryPeer::PLUGIN_SETUP_PAGE => 7, PluginsRegistryPeer::PLUGIN_COMPANY_LOGO => 8, PluginsRegistryPeer::PLUGIN_WORKSPACES => 9, PluginsRegistryPeer::PLUGIN_VERSION => 10, PluginsRegistryPeer::PLUGIN_ENABLE => 11, PluginsRegistryPeer::PLUGIN_PRIVATE => 12, PluginsRegistryPeer::PLUGIN_MENUS => 13, PluginsRegistryPeer::PLUGIN_FOLDERS => 14, PluginsRegistryPeer::PLUGIN_TRIGGERS => 15, PluginsRegistryPeer::PLUGIN_PM_FUNCTIONS => 16, PluginsRegistryPeer::PLUGIN_REDIRECT_LOGIN => 17, PluginsRegistryPeer::PLUGIN_STEPS => 18, PluginsRegistryPeer::PLUGIN_CSS => 19, PluginsRegistryPeer::PLUGIN_JS => 20, PluginsRegistryPeer::PLUGIN_REST_SERVICE => 21, PluginsRegistryPeer::PLUGIN_TASK_EXTENDED_PROPERTIES => 22, PluginsRegistryPeer::PLUGIN_ATTRIBUTES => 23, ), - BasePeer::TYPE_FIELDNAME => array ('PR_UID' => 0, 'PLUGIN_NAMESPACE' => 1, 'PLUGIN_DESCRIPTION' => 2, 'PLUGIN_CLASS_NAME' => 3, 'PLUGIN_FRIENDLY_NAME' => 4, 'PLUGIN_FILE' => 5, 'PLUGIN_FOLDER' => 6, 'PLUGIN_SETUP_PAGE' => 7, 'PLUGIN_COMPANY_LOGO' => 8, 'PLUGIN_WORKSPACES' => 9, 'PLUGIN_VERSION' => 10, 'PLUGIN_ENABLE' => 11, 'PLUGIN_PRIVATE' => 12, 'PLUGIN_MENUS' => 13, 'PLUGIN_FOLDERS' => 14, 'PLUGIN_TRIGGERS' => 15, 'PLUGIN_PM_FUNCTIONS' => 16, 'PLUGIN_REDIRECT_LOGIN' => 17, 'PLUGIN_STEPS' => 18, 'PLUGIN_CSS' => 19, 'PLUGIN_JS' => 20, 'PLUGIN_REST_SERVICE' => 21, 'PLUGIN_TASK_EXTENDED_PROPERTIES' => 22, 'PLUGIN_ATTRIBUTES' => 23, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, ) + BasePeer::TYPE_PHPNAME => array ('PrUid' => 0, 'PluginNamespace' => 1, 'PluginDescription' => 2, 'PluginClassName' => 3, 'PluginFriendlyName' => 4, 'PluginFile' => 5, 'PluginFolder' => 6, 'PluginSetupPage' => 7, 'PluginCompanyLogo' => 8, 'PluginWorkspaces' => 9, 'PluginVersion' => 10, 'PluginEnable' => 11, 'PluginPrivate' => 12, 'PluginMenus' => 13, 'PluginFolders' => 14, 'PluginTriggers' => 15, 'PluginPmFunctions' => 16, 'PluginRedirectLogin' => 17, 'PluginSteps' => 18, 'PluginCss' => 19, 'PluginJs' => 20, 'PluginRestService' => 21, 'PluginCronFiles' => 22, 'PluginTaskExtendedProperties' => 23, 'PluginAttributes' => 24, ), + BasePeer::TYPE_COLNAME => array (PluginsRegistryPeer::PR_UID => 0, PluginsRegistryPeer::PLUGIN_NAMESPACE => 1, PluginsRegistryPeer::PLUGIN_DESCRIPTION => 2, PluginsRegistryPeer::PLUGIN_CLASS_NAME => 3, PluginsRegistryPeer::PLUGIN_FRIENDLY_NAME => 4, PluginsRegistryPeer::PLUGIN_FILE => 5, PluginsRegistryPeer::PLUGIN_FOLDER => 6, PluginsRegistryPeer::PLUGIN_SETUP_PAGE => 7, PluginsRegistryPeer::PLUGIN_COMPANY_LOGO => 8, PluginsRegistryPeer::PLUGIN_WORKSPACES => 9, PluginsRegistryPeer::PLUGIN_VERSION => 10, PluginsRegistryPeer::PLUGIN_ENABLE => 11, PluginsRegistryPeer::PLUGIN_PRIVATE => 12, PluginsRegistryPeer::PLUGIN_MENUS => 13, PluginsRegistryPeer::PLUGIN_FOLDERS => 14, PluginsRegistryPeer::PLUGIN_TRIGGERS => 15, PluginsRegistryPeer::PLUGIN_PM_FUNCTIONS => 16, PluginsRegistryPeer::PLUGIN_REDIRECT_LOGIN => 17, PluginsRegistryPeer::PLUGIN_STEPS => 18, PluginsRegistryPeer::PLUGIN_CSS => 19, PluginsRegistryPeer::PLUGIN_JS => 20, PluginsRegistryPeer::PLUGIN_REST_SERVICE => 21, PluginsRegistryPeer::PLUGIN_CRON_FILES => 22, PluginsRegistryPeer::PLUGIN_TASK_EXTENDED_PROPERTIES => 23, PluginsRegistryPeer::PLUGIN_ATTRIBUTES => 24, ), + BasePeer::TYPE_FIELDNAME => array ('PR_UID' => 0, 'PLUGIN_NAMESPACE' => 1, 'PLUGIN_DESCRIPTION' => 2, 'PLUGIN_CLASS_NAME' => 3, 'PLUGIN_FRIENDLY_NAME' => 4, 'PLUGIN_FILE' => 5, 'PLUGIN_FOLDER' => 6, 'PLUGIN_SETUP_PAGE' => 7, 'PLUGIN_COMPANY_LOGO' => 8, 'PLUGIN_WORKSPACES' => 9, 'PLUGIN_VERSION' => 10, 'PLUGIN_ENABLE' => 11, 'PLUGIN_PRIVATE' => 12, 'PLUGIN_MENUS' => 13, 'PLUGIN_FOLDERS' => 14, 'PLUGIN_TRIGGERS' => 15, 'PLUGIN_PM_FUNCTIONS' => 16, 'PLUGIN_REDIRECT_LOGIN' => 17, 'PLUGIN_STEPS' => 18, 'PLUGIN_CSS' => 19, 'PLUGIN_JS' => 20, 'PLUGIN_REST_SERVICE' => 21, 'PLUGIN_CRON_FILES' => 22, 'PLUGIN_TASK_EXTENDED_PROPERTIES' => 23, 'PLUGIN_ATTRIBUTES' => 24, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, ) ); /** @@ -275,6 +278,8 @@ abstract class BasePluginsRegistryPeer $criteria->addSelectColumn(PluginsRegistryPeer::PLUGIN_REST_SERVICE); + $criteria->addSelectColumn(PluginsRegistryPeer::PLUGIN_CRON_FILES); + $criteria->addSelectColumn(PluginsRegistryPeer::PLUGIN_TASK_EXTENDED_PROPERTIES); $criteria->addSelectColumn(PluginsRegistryPeer::PLUGIN_ATTRIBUTES); diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml index 07b1000b8..c9c7d7963 100644 --- a/workflow/engine/config/schema.xml +++ b/workflow/engine/config/schema.xml @@ -5673,6 +5673,7 @@ + diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index 57b0e5a8b..6fbd09a3b 100644 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -3177,6 +3177,7 @@ CREATE TABLE `PLUGINS_REGISTRY` `PLUGIN_CSS` MEDIUMTEXT, `PLUGIN_JS` MEDIUMTEXT, `PLUGIN_REST_SERVICE` MEDIUMTEXT, + `PLUGIN_CRON_FILES` MEDIUMTEXT, `PLUGIN_TASK_EXTENDED_PROPERTIES` MEDIUMTEXT, `PLUGIN_ATTRIBUTES` MEDIUMTEXT, PRIMARY KEY (`PR_UID`) diff --git a/workflow/engine/methods/cases/cases_Step.php b/workflow/engine/methods/cases/cases_Step.php index 6cbda3d5d..c5cfe2e42 100644 --- a/workflow/engine/methods/cases/cases_Step.php +++ b/workflow/engine/methods/cases/cases_Step.php @@ -1124,9 +1124,9 @@ try { $sNamespace = ''; $sStepName = ''; foreach ($externalSteps as $key => $val) { - if ($val->sStepId == $_GET['UID']) { - $sNamespace = $val->sNamespace; - $sStepName = $val->sStepName; + if ($val->getStepId() == $_GET['UID']) { + $sNamespace = $val->getNamespace(); + $sStepName = $val->getStepName(); } } diff --git a/workflow/engine/src/ProcessMaker/Plugins/Adapters/PluginAdapter.php b/workflow/engine/src/ProcessMaker/Plugins/Adapters/PluginAdapter.php index 9d95a1786..f02a66b25 100644 --- a/workflow/engine/src/ProcessMaker/Plugins/Adapters/PluginAdapter.php +++ b/workflow/engine/src/ProcessMaker/Plugins/Adapters/PluginAdapter.php @@ -90,6 +90,7 @@ class PluginAdapter '_aJavascripts' => ['name' => 'PLUGIN_JS', 'type' => 'array'], '_aJs' => ['name' => 'PLUGIN_JS', 'type' => 'array'], '_restServices' => ['name' => 'PLUGIN_REST_SERVICE', 'type' => 'array'], + '_aCronFiles' => ['name' => 'PLUGIN_CRON_FILES', 'type' => 'array'], '_aTaskExtendedProperties' => ['name' => 'PLUGIN_TASK_EXTENDED_PROPERTIES', 'type' => 'array'], ]; diff --git a/workflow/engine/src/ProcessMaker/Plugins/Interfaces/CronFile.php b/workflow/engine/src/ProcessMaker/Plugins/Interfaces/CronFile.php index bce110c6d..ca4db7a57 100644 --- a/workflow/engine/src/ProcessMaker/Plugins/Interfaces/CronFile.php +++ b/workflow/engine/src/ProcessMaker/Plugins/Interfaces/CronFile.php @@ -53,4 +53,24 @@ class CronFile { return $CronFile == $this->CronFile; } + + /** + * Get plugin name + * + * @return string + */ + public function getNamespace() + { + return $this->Namespace; + } + + /** + * Get Cron file + * + * @return string + */ + public function getCronFile() + { + return $this->CronFile; + } } diff --git a/workflow/engine/src/ProcessMaker/Plugins/PluginRegistry.php b/workflow/engine/src/ProcessMaker/Plugins/PluginRegistry.php index dc3cce7f2..be7ca2911 100644 --- a/workflow/engine/src/ProcessMaker/Plugins/PluginRegistry.php +++ b/workflow/engine/src/ProcessMaker/Plugins/PluginRegistry.php @@ -1355,22 +1355,23 @@ class PluginRegistry /** * Register a cron file - * @param string $Namespace Name of Plugin - * @param string $CronFile + * @param string $pluginName Name of Plugin + * @param string $cronFileToRegister */ - public function registerCronFile($Namespace, $CronFile) + public function registerCronFile($pluginName, $cronFileToRegister) { $found = false; /** @var CronFile $cronFile */ foreach ($this->_aCronFiles as $cronFile) { - if ($cronFile->equalCronFileTo($CronFile) && $cronFile->equalNamespaceTo($Namespace)) { - $cronFile->setCronFile($CronFile); + if ($cronFile instanceof CronFile && + $cronFile->equalNamespaceTo($pluginName) && + $cronFile->equalCronFileTo($cronFileToRegister)) { + $cronFile->setCronFile($cronFileToRegister); $found = true; } } if (!$found) { - $CronFile = new CronFile($Namespace, $CronFile); - $this->_aCronFiles[] = $CronFile; + $this->_aCronFiles[] = new CronFile($pluginName, $cronFileToRegister); } } diff --git a/workflow/engine/src/ProcessMaker/Plugins/Traits/PluginStructure.php b/workflow/engine/src/ProcessMaker/Plugins/Traits/PluginStructure.php index bfd03254c..1d6c5cd38 100644 --- a/workflow/engine/src/ProcessMaker/Plugins/Traits/PluginStructure.php +++ b/workflow/engine/src/ProcessMaker/Plugins/Traits/PluginStructure.php @@ -5,6 +5,7 @@ namespace ProcessMaker\Plugins\Traits; use BasePeer; use G; use PluginsRegistry; +use ProcessMaker\Plugins\Interfaces\CronFile; use ProcessMaker\Plugins\Interfaces\CssFile; use ProcessMaker\Plugins\Interfaces\FolderDetail; use ProcessMaker\Plugins\Interfaces\JsFile; @@ -116,6 +117,7 @@ trait PluginStructure $this->buildCss(G::json_decode($plugin['PluginCss'], true)); $this->buildJs(G::json_decode($plugin['PluginJs'], true)); $this->buildRestService(G::json_decode($plugin['PluginRestService'], true)); + $this->buildCronFiles($plugin['PluginNamespace'], G::json_decode($plugin['PluginCronFiles'], true)); $this->buildAttributes($plugin['PluginNamespace'], G::json_decode($plugin['PluginAttributes'])); } } @@ -261,6 +263,23 @@ trait PluginStructure $this->_restServices = array_merge($this->_restServices, $restServices); } + /** + * Builds an array with the Cron Files configurations and set to the respective attribute + * + * @param string $pluginName + * @param array $cronFilesToAdd + */ + private function buildCronFiles($pluginName, $cronFilesToAdd) + { + $cronFiles = []; + if ($cronFilesToAdd) { + foreach ($cronFilesToAdd as $cronFile) { + $cronFiles[] = new CronFile($pluginName, $cronFile['CronFile']); + } + } + $this->_aCronFiles = array_merge($this->_aCronFiles, $cronFiles); + } + /** * Build other properties that are not considered in the schema of the table * @param string $namespace