From 94a2db1e2303894be2bb5b1a98267316308595bf Mon Sep 17 00:00:00 2001 From: Ronald Quenta Date: Thu, 10 Aug 2017 12:10:42 -0400 Subject: [PATCH] HOR-3629 --- gulliver/system/class.g.php | 10 +-- gulliver/system/class.headPublisher.php | 8 ++- rbac/engine/classes/model/RbacUsers.php | 4 +- .../creole/drivers/mysql/MySQLConnection.php | 4 -- thirdparty/propel/Propel.php | 2 - workflow/engine/bin/cron_single.php | 6 -- workflow/engine/bin/tasks/cliFlushCache.php | 2 +- workflow/engine/classes/PmInstaller.php | 2 +- workflow/engine/classes/ProcessMap.php | 63 ++++++++++++------- workflow/engine/classes/class.plugin.php | 25 ++++---- .../engine/classes/class.pmLicenseManager.php | 2 +- .../engine/classes/class.triggerLibrary.php | 2 +- workflow/engine/classes/class.wsTools.php | 2 +- workflow/engine/controllers/main.php | 2 +- workflow/engine/menus/cases.php | 18 +++--- workflow/engine/methods/setup/pluginsMain.php | 6 +- workflow/engine/skinEngine/skinEngine.php | 4 +- .../src/ProcessMaker/BusinessModel/User.php | 4 +- .../ProcessMaker/Plugins/PluginRegistry.php | 4 +- .../engine/src/ProcessMaker/Util/System.php | 59 +++++++++-------- 20 files changed, 125 insertions(+), 104 deletions(-) diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index 435eca3e4..18f77a204 100644 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -24,6 +24,8 @@ * */ +use ProcessMaker\Plugins\PluginRegistry; + /** * @package gulliver.system */ @@ -502,7 +504,7 @@ class G * * @return void */ - public function rm_dir ($dirName) + public static function rm_dir ($dirName) { if (! is_writable( $dirName )) { return false; @@ -5042,9 +5044,9 @@ class G $restClasses = array_merge( $restClasses, $pluginRestClasses ); } // hook to get rest api classes from plugins - if (class_exists( 'PMPluginRegistry' )) { - $pluginRegistry = & PMPluginRegistry::getSingleton(); - $pluginClasses = $pluginRegistry->getRegisteredRestClassFiles(); + if (class_exists( 'ProcessMaker\Plugins\PluginRegistry' )) { + $pluginRegistry = PluginRegistry::loadSingleton(); + $pluginClasses = $pluginRegistry->getRegisteredRestServices(); $restClasses = array_merge( $restClasses, $pluginClasses ); } foreach ($restClasses as $key => $classFile) { diff --git a/gulliver/system/class.headPublisher.php b/gulliver/system/class.headPublisher.php index a402825b6..95deb79ed 100644 --- a/gulliver/system/class.headPublisher.php +++ b/gulliver/system/class.headPublisher.php @@ -25,6 +25,8 @@ * */ +use ProcessMaker\Plugins\PluginRegistry; + /** * Class headPublisher * @@ -387,7 +389,7 @@ class headPublisher // Load external/plugin css // NOTE is necesary to move this to decorator server if (class_exists('PMPluginRegistry') && defined('SYS_SYS')) { - $oPluginRegistry = & PMPluginRegistry::getSingleton(); + $oPluginRegistry = PluginRegistry::loadSingleton(); $registeredCss = $oPluginRegistry->getRegisteredCss(); /** @var \ProcessMaker\Plugins\Interfaces\CssFile $cssFile */ foreach ($registeredCss as $cssFile) { @@ -505,7 +507,7 @@ class headPublisher $flagPlugin = false; $keyPlugin = count($aux)-2; - $oPluginRegistry = & PMPluginRegistry::getSingleton(); + $oPluginRegistry = PluginRegistry::loadSingleton(); if ($oPluginRegistry->isRegisteredFolder($aux[$keyPlugin])) { $flagPlugin = true; } else { @@ -682,7 +684,7 @@ class headPublisher $aux = explode(PATH_SEP, $file); //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) { - $oPluginRegistry = & PMPluginRegistry::getSingleton(); + $oPluginRegistry = PluginRegistry::loadSingleton(); if ($oPluginRegistry->isRegisteredFolder($aux[0])) { $sPath = PATH_PLUGINS; } diff --git a/rbac/engine/classes/model/RbacUsers.php b/rbac/engine/classes/model/RbacUsers.php index 07abdecc1..fe25c14e3 100644 --- a/rbac/engine/classes/model/RbacUsers.php +++ b/rbac/engine/classes/model/RbacUsers.php @@ -197,12 +197,12 @@ class RbacUsers extends BaseRbacUsers public function create($aData) { - if (class_exists('PMPluginRegistry')) { + if (class_exists('ProcessMaker\Plugins\PluginRegistry')) { $pluginRegistry = PluginRegistry::loadSingleton(); if ($pluginRegistry->existsTrigger(PM_BEFORE_CREATE_USER)) { try { $pluginRegistry->executeTriggers(PM_BEFORE_CREATE_USER, null); - } catch(Exception $error) { + } catch (Exception $error) { throw new Exception($error->getMessage()); } } diff --git a/thirdparty/creole/drivers/mysql/MySQLConnection.php b/thirdparty/creole/drivers/mysql/MySQLConnection.php index d3c8a05ee..b41c69faa 100644 --- a/thirdparty/creole/drivers/mysql/MySQLConnection.php +++ b/thirdparty/creole/drivers/mysql/MySQLConnection.php @@ -126,7 +126,6 @@ class MySQLConnection extends ConnectionCommon implements Connection { */ public function getDatabaseInfo() { - require_once 'creole/drivers/mysql/metadata/MySQLDatabaseInfo.php'; return new MySQLDatabaseInfo($this); } @@ -135,7 +134,6 @@ class MySQLConnection extends ConnectionCommon implements Connection { */ public function getIdGenerator() { - require_once 'creole/drivers/mysql/MySQLIdGenerator.php'; return new MySQLIdGenerator($this); } @@ -144,7 +142,6 @@ class MySQLConnection extends ConnectionCommon implements Connection { */ public function prepareStatement($sql) { - require_once 'creole/drivers/mysql/MySQLPreparedStatement.php'; return new MySQLPreparedStatement($this, $sql); } @@ -160,7 +157,6 @@ class MySQLConnection extends ConnectionCommon implements Connection { */ public function createStatement() { - require_once 'creole/drivers/mysql/MySQLStatement.php'; return new MySQLStatement($this); } diff --git a/thirdparty/propel/Propel.php b/thirdparty/propel/Propel.php index 842f6f086..5d8e5dde2 100644 --- a/thirdparty/propel/Propel.php +++ b/thirdparty/propel/Propel.php @@ -495,8 +495,6 @@ class Propel { throw new PropelException("No connection params set for " . $name); } } - - include_once 'creole/Creole.php'; // if specified, use custom driver if (isset(self::$configuration['datasources'][$name]['driver'])) { Creole::registerDriver($dsn['phptype'], self::$configuration['datasources'][$name]['driver']); diff --git a/workflow/engine/bin/cron_single.php b/workflow/engine/bin/cron_single.php index 802968870..81c572969 100644 --- a/workflow/engine/bin/cron_single.php +++ b/workflow/engine/bin/cron_single.php @@ -179,12 +179,6 @@ try { eprintln('WARNING! No server info found!', 'red'); } - $sSerializedFile = PATH_DATA_SITE . 'plugin.singleton'; - - if (file_exists($sSerializedFile)) { - $pluginRegistry = PMPluginRegistry::loadSingleton($sSerializedFile); - } - //DB $phpCode = ''; diff --git a/workflow/engine/bin/tasks/cliFlushCache.php b/workflow/engine/bin/tasks/cliFlushCache.php index 3934d096a..6a4a8f28a 100644 --- a/workflow/engine/bin/tasks/cliFlushCache.php +++ b/workflow/engine/bin/tasks/cliFlushCache.php @@ -72,7 +72,7 @@ function flush_cache($workspace) echo " Update singleton in workspace " . $workspace->name . " ... "; echo PHP_EOL; echo " Flush workspace " . pakeColor::colorize($workspace->name, "INFO") . " cache ... " . PHP_EOL; - $status = \ProcessMaker\Util\System::flushCache($workspace); + \ProcessMaker\Util\System::flushCache($workspace); echo "DONE" . PHP_EOL; } catch (Exception $e) { echo $e->getMessage() . PHP_EOL; diff --git a/workflow/engine/classes/PmInstaller.php b/workflow/engine/classes/PmInstaller.php index c7bc743d6..23b9b082c 100644 --- a/workflow/engine/classes/PmInstaller.php +++ b/workflow/engine/classes/PmInstaller.php @@ -84,7 +84,7 @@ class PmInstaller * @param string $name Default value "workflow" * @return string file_exists(PATH_DATA."sites/".$name); */ - public function isset_site($name = "workflow") + public static function isset_site($name = "workflow") { $pathSites = PATH_DATA . 'sites/'. '*'; $directories = glob($pathSites, GLOB_ONLYDIR); diff --git a/workflow/engine/classes/ProcessMap.php b/workflow/engine/classes/ProcessMap.php index d93ae3d10..798e7e893 100644 --- a/workflow/engine/classes/ProcessMap.php +++ b/workflow/engine/classes/ProcessMap.php @@ -24,6 +24,9 @@ * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. */ + +use ProcessMaker\Plugins\PluginRegistry; + /** * * @package workflow.engine.ProcessMaker @@ -368,12 +371,13 @@ class ProcessMap $oPM->derivation = array('Sequential', 'Evaluate (manual)', 'Evaluate (auto)', 'Parallel (fork)', 'Parallel by evaluation (fork)', 'Parallel (sequential join)', 'Parallel (sequential main join)' ); //Load extended task properties from plugin. By JHL Jan 18, 2011 - $oPluginRegistry = & PMPluginRegistry::getSingleton(); + $oPluginRegistry = PluginRegistry::loadSingleton(); + /** @var \ProcessMaker\Plugins\Interfaces\TaskExtendedProperty[] $activePluginsForTaskProperties */ $activePluginsForTaskProperties = $oPluginRegistry->getTaskExtendedProperties(); $oPM->taskOptions = array(); - foreach ($activePluginsForTaskProperties as $key => $taskPropertiesInfo) { - $taskOption['title'] = $taskPropertiesInfo->sName; - $taskOption['id'] = $taskPropertiesInfo->sNamespace . "--" . $taskPropertiesInfo->sName; + foreach ($activePluginsForTaskProperties as $taskPropertiesInfo) { + $taskOption['title'] = $taskPropertiesInfo->getName(); + $taskOption['id'] = $taskPropertiesInfo->getNamespace() . "--" . $taskPropertiesInfo->getName(); $oPM->taskOptions[] = $taskOption; } @@ -745,7 +749,8 @@ class ProcessMap { try { //call plugin - $oPluginRegistry = &PMPluginRegistry::getSingleton(); + $oPluginRegistry = PluginRegistry::loadSingleton(); + /** @var \ProcessMaker\Plugins\Interfaces\StepDetail[] $externalSteps */ $externalSteps = $oPluginRegistry->getSteps(); $aSteps = array(); @@ -795,9 +800,9 @@ class ProcessMap case 'EXTERNAL': $sTitle = 'unknown ' . $aRow['STEP_UID']; foreach ($externalSteps as $key => $val) { - if ($val->sStepId == $aRow['STEP_UID_OBJ']) { - $sTitle = $val->sStepTitle; - if (trim($val->sSetupStepPage) != '') { + if ($val->equalStepIdTo($aRow['STEP_UID_OBJ'])) { + $sTitle = $val->getStepTitle(); + if (trim($val->getSetupStepPage()) != '') { $urlEdit = "externalStepEdit('" . $aRow['STEP_UID'] . "', '" . $val->sSetupStepPage . "');"; $linkEditValue = 'Edit'; } else { @@ -929,11 +934,17 @@ class ProcessMap } //call plugin - $oPluginRegistry = &PMPluginRegistry::getSingleton(); + $oPluginRegistry = PluginRegistry::loadSingleton(); + /** @var \ProcessMaker\Plugins\Interfaces\StepDetail[] $externalSteps */ $externalSteps = $oPluginRegistry->getSteps(); if (is_array($externalSteps) && count($externalSteps) > 0) { foreach ($externalSteps as $key => $stepVar) { - $aBB[] = array('STEP_UID' => $stepVar->sStepId, 'STEP_TITLE' => $stepVar->sStepTitle, 'STEP_TYPE_OBJ' => 'EXTERNAL', 'STEP_MODE' => '' ); + $aBB[] = array( + 'STEP_UID' => $stepVar->getStepId(), + 'STEP_TITLE' => $stepVar->getStepTitle(), + 'STEP_TYPE_OBJ' => 'EXTERNAL', + 'STEP_MODE' => '' + ); } } global $_DBArray; @@ -1363,12 +1374,13 @@ class ProcessMap break; default: //if the $iForm is not one of the defaults then search under Plugins for an extended property. By JHL Jan 18, 2011 - $oPluginRegistry = & PMPluginRegistry::getSingleton(); + $oPluginRegistry = PluginRegistry::loadSingleton(); + /** @var \ProcessMaker\Plugins\Interfaces\TaskExtendedProperty[] $activePluginsForTaskProperties */ $activePluginsForTaskProperties = $oPluginRegistry->getTaskExtendedProperties(); foreach ($activePluginsForTaskProperties as $key => $taskPropertiesInfo) { - $id = $taskPropertiesInfo->sNamespace . "--" . $taskPropertiesInfo->sName; + $id = $taskPropertiesInfo->getNamespace() . "--" . $taskPropertiesInfo->getName(); if ($id == $iForm) { - $sFilename = $taskPropertiesInfo->sPage; + $sFilename = $taskPropertiesInfo->getPage(); $sw_template = true; } } @@ -4697,10 +4709,6 @@ class ProcessMap public function getDynaformList($sTaskUID = '') { try { - //call plugin - $oPluginRegistry = &PMPluginRegistry::getSingleton(); - $externalSteps = $oPluginRegistry->getSteps(); - $aSteps = array(); //$aSteps [] = array ('STEP_TITLE' => 'char', 'STEP_UID' => 'char', 'STEP_TYPE_OBJ' => 'char', 'STEP_CONDITION' => 'char', 'STEP_POSITION' => 'integer' ); $oCriteria = new Criteria('workflow'); @@ -5131,11 +5139,17 @@ class ProcessMap } //call plugin - $oPluginRegistry = &PMPluginRegistry::getSingleton(); + $oPluginRegistry = PluginRegistry::loadSingleton(); + /** @var \ProcessMaker\Plugins\Interfaces\StepDetail[] $externalSteps */ $externalSteps = $oPluginRegistry->getSteps(); if (is_array($externalSteps) && count($externalSteps) > 0) { foreach ($externalSteps as $key => $stepVar) { - $aBB[] = array('STEP_UID' => $stepVar->sStepId, 'STEP_TITLE' => $stepVar->sStepTitle, 'STEP_TYPE_OBJ' => 'EXTERNAL', 'STEP_MODE' => '' ); + $aBB[] = array( + 'STEP_UID' => $stepVar->getStepId(), + 'STEP_TITLE' => $stepVar->getStepTitle(), + 'STEP_TYPE_OBJ' => 'EXTERNAL', + 'STEP_MODE' => '' + ); } } @@ -5180,7 +5194,8 @@ class ProcessMap { try { //call plugin - $oPluginRegistry = &PMPluginRegistry::getSingleton(); + $oPluginRegistry = PluginRegistry::loadSingleton(); + /** @var \ProcessMaker\Plugins\Interfaces\StepDetail[] $externalSteps */ $externalSteps = $oPluginRegistry->getSteps(); $aSteps = array(); @@ -5239,10 +5254,10 @@ class ProcessMap case 'EXTERNAL': $sTitle = 'unknown ' . $aRow['STEP_UID']; foreach ($externalSteps as $key => $val) { - if ($val->sStepId == $aRow['STEP_UID_OBJ']) { - $sTitle = $val->sStepTitle; - if (trim($val->sSetupStepPage) != '') { - $urlEdit = "externalStepEdit('" . $aRow['STEP_UID'] . "', '" . $val->sSetupStepPage . "');"; + if ($val->equalStepIdTo($aRow['STEP_UID_OBJ'])) { + $sTitle = $val->getStepTitle(); + if (trim($val->getSetupStepPage()) != '') { + $urlEdit = "externalStepEdit('" . $aRow['STEP_UID'] . "', '" . $val->getSetupStepPage() . "');"; $linkEditValue = 'Edit'; } else { $urlEdit = ""; diff --git a/workflow/engine/classes/class.plugin.php b/workflow/engine/classes/class.plugin.php index 16d4ed8d6..8a1eb0e6d 100644 --- a/workflow/engine/classes/class.plugin.php +++ b/workflow/engine/classes/class.plugin.php @@ -504,7 +504,7 @@ class PMPlugin $aPluginsPP[] = substr($aPlugin['sFilename'], 0, strpos($aPlugin['sFilename'], '-')) . '.php'; } } - $oPluginRegistry = PMPluginRegistry::getSingleton(); + $oPluginRegistry = PluginRegistry::loadSingleton(); if ($handle = opendir(PATH_PLUGINS)) { while (false !== ($file = readdir($handle))) { if (in_array($file, $aPluginsPP)) { @@ -512,23 +512,24 @@ class PMPlugin } if (strpos($file, '.php', 1) && is_file(PATH_PLUGINS . $file)) { include_once (PATH_PLUGINS . $file); + /** @var \ProcessMaker\Plugins\Interfaces\PluginDetail $pluginDetail */ $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(); + $status_label = $pluginDetail->isEnabled() ? G::LoadTranslation('ID_ENABLED') : G::LoadTranslation('ID_DISABLED'); + $status = $pluginDetail->isEnabled(); + if ($pluginDetail->getWorkspaces()) { + if (!is_array($pluginDetail->getWorkspaces())) { + $pluginDetail->setWorkspaces(array()); } - if (!in_array($workspace, $pluginDetail->aWorkspaces)) { + if (!in_array($workspace, $pluginDetail->getWorkspaces())) { continue; } } - $setup = $pluginDetail->sSetupPage != '' && $pluginDetail->enabled ? '1' : '0'; + $setup = $pluginDetail->getSetupPage() != '' && $pluginDetail->isEnabled() ? '1' : '0'; - if (isset($pluginDetail) && !$pluginDetail->bPrivate) { + if (isset($pluginDetail) && !$pluginDetail->isPrivate()) { $items[] = [ 'id' => (count($items) + 1), 'namespace' => $pluginDetail->sNamespace, @@ -559,14 +560,13 @@ class PMPlugin */ public static function getListAllPlugins($workspace) { - PMPluginRegistry::saveState(); - $pathSingleton = PATH_DATA . "sites" . PATH_SEP . $workspace . PATH_SEP . "plugin.singleton"; - $oPluginRegistry = PMPluginRegistry::loadSingleton($pathSingleton); + $oPluginRegistry = PluginRegistry::loadSingleton(); $items = []; if ($handle = opendir(PATH_PLUGINS)) { while (false !== ($file = readdir($handle))) { if (strpos($file, '.php', 1) && is_file(PATH_PLUGINS . $file)) { include_once (PATH_PLUGINS . $file); + /** @var \ProcessMaker\Plugins\Interfaces\PluginDetail $detail */ $detail = $oPluginRegistry->getPluginDetails($file); if ($detail !== null) { $items[] = $detail; @@ -575,7 +575,6 @@ class PMPlugin } closedir($handle); } - PMPluginRegistry::restoreState(); return $items; } diff --git a/workflow/engine/classes/class.pmLicenseManager.php b/workflow/engine/classes/class.pmLicenseManager.php index 3e8b4cade..63c40ee8d 100644 --- a/workflow/engine/classes/class.pmLicenseManager.php +++ b/workflow/engine/classes/class.pmLicenseManager.php @@ -269,7 +269,7 @@ class pmLicenseManager public function unSerializeInstance($serialized) { if (self::$instance == null) { - self::$instance = new PMPluginRegistry (); + self::$instance = new PluginRegistry(); } $instance = unserialize ( $serialized ); self::$instance = $instance; diff --git a/workflow/engine/classes/class.triggerLibrary.php b/workflow/engine/classes/class.triggerLibrary.php index 506b906be..b054b6ee4 100644 --- a/workflow/engine/classes/class.triggerLibrary.php +++ b/workflow/engine/classes/class.triggerLibrary.php @@ -93,7 +93,7 @@ class triggerLibrary function unSerializeInstance ($serialized) { if (self::$instance == NULL) { - self::$instance = new PMPluginRegistry(); + self::$instance = new PluginRegistry(); } $instance = unserialize( $serialized ); diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index 9f0b29892..d12b41394 100644 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -1654,7 +1654,7 @@ class workspaceTools if (count($metaFiles) > 1 && (!isset($srcWorkspace))) { throw new Exception("Multiple workspaces in backup but no workspace specified to restore"); } - if (isset($srcWorkspace) && !in_array("$srcWorkspace.meta", array_map(BASENAME, $metaFiles))) { + if (isset($srcWorkspace) && !in_array("$srcWorkspace.meta", array_map('basename', $metaFiles))) { throw new Exception("Workspace $srcWorkspace not found in backup"); } diff --git a/workflow/engine/controllers/main.php b/workflow/engine/controllers/main.php index 4c5041ffe..c80b740fe 100644 --- a/workflow/engine/controllers/main.php +++ b/workflow/engine/controllers/main.php @@ -474,7 +474,7 @@ class Main extends Controller $sWspaceSelect = trim( $aFotoSelect['WORKSPACE_LOGO_NAME'] ); } } - if (class_exists( 'PMPluginRegistry' )) { + if (class_exists( 'ProcessMaker\Plugins\PluginRegistry' )) { $oPluginRegistry = PluginRegistry::loadSingleton(); $logoPlugin = $oPluginRegistry->getCompanyLogo( $sCompanyLogo ); if ($logoPlugin != '/images/processmaker2.logo2.png') { diff --git a/workflow/engine/menus/cases.php b/workflow/engine/menus/cases.php index 098b1619b..a5d7d8eff 100644 --- a/workflow/engine/menus/cases.php +++ b/workflow/engine/menus/cases.php @@ -22,7 +22,12 @@ * Coral Gables, FL, 33134, USA, or email info@colosa.com. * */ + +use ProcessMaker\Plugins\PluginRegistry; + +/** @var RBAC $RBAC */ global $RBAC; +/** @var Menu $G_TMP_MENU */ global $G_TMP_MENU; $G_TMP_MENU->AddIdRawOption('FOLDERS', '', G::LoadTranslation('ID_CASES_MENU_FOLDERS'), '', '', 'blockHeader'); @@ -48,10 +53,6 @@ $G_TMP_MENU->AddIdRawOption('CASES_SELFSERVICE', 'casesListExtJs?action=selfserv $G_TMP_MENU->AddIdRawOption('CASES_PAUSED', 'casesListExtJs?action=paused', G::LoadTranslation('ID_PAUSED'), 'mail-queue.png'); -if ($RBAC->userCanAccess('PM_ALLCASES') == 1) { - //$G_TMP_MENU->AddIdRawOption('CASES_GRAL', 'casesListExtJs?action=gral', G::LoadTranslation('ID_GENERAL')); -} - $G_TMP_MENU->AddIdRawOption('SEARCHS', '', G::LoadTranslation('ID_CASES_MENU_SEARCH'), '', '', 'blockHeader'); if ($RBAC->userCanAccess('PM_ALLCASES') == 1) { @@ -77,14 +78,15 @@ if ($RBAC->userCanAccess('PM_FOLDERS_VIEW') == 1) { //Load Other registered Dashboards (From plugins) -$oPluginRegistry = & PMPluginRegistry::getSingleton (); +$oPluginRegistry = PluginRegistry::loadSingleton(); +/** @var \ProcessMaker\Plugins\Interfaces\DashboardPage[] $dashBoardPages */ $dashBoardPages = $oPluginRegistry->getDashboardPages (); if (count($dashBoardPages)>0) { $G_TMP_MENU->AddIdRawOption('PLUGINS', '', G::LoadTranslation('ID_PLUGINS'), '', '', 'blockHeader'); foreach ($dashBoardPages as $key => $tabInfo) { - $tabNameSpace=$tabInfo->sNamespace; - $tabName=$tabInfo->sName; - $tabIcon=str_replace("ICON_","",$tabInfo->sIcon); + $tabNameSpace=$tabInfo->getNamespace(); + $tabName=$tabInfo->getName(); + $tabIcon=str_replace("ICON_","",$tabInfo->getIcon()); if ($tabName!= "") { $G_TMP_MENU->AddIdRawOption($tabIcon, 'casesStartPage?action='.$tabNameSpace.'-'.$tabName, ucwords(strtolower($tabName)), ''); diff --git a/workflow/engine/methods/setup/pluginsMain.php b/workflow/engine/methods/setup/pluginsMain.php index 666b68c85..8848fb917 100644 --- a/workflow/engine/methods/setup/pluginsMain.php +++ b/workflow/engine/methods/setup/pluginsMain.php @@ -21,6 +21,10 @@ * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. */ + +use ProcessMaker\Plugins\PluginRegistry; + +/** @var RBAC $RBAC */ global $RBAC; $RBAC->requirePermissions( 'PM_SETUP' ); @@ -29,7 +33,7 @@ $headPublisher->addExtJsScript( 'setup/pluginsMain', false ); $headPublisher->assign( "PROCESSMAKER_URL", "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN ); $headPublisher->assign( "SYS_SKIN", SYS_SKIN ); -$oPluginRegistry = &PMPluginRegistry::getSingleton(); +$oPluginRegistry = PluginRegistry::loadSingleton(); if ($oPluginRegistry->getStatusPlugin('pmWorkspaceManagement') && $oPluginRegistry->getStatusPlugin('pmWorkspaceManagement') == "enabled") { $headPublisher = $oPluginRegistry->executeMethod('pmWorkspaceManagement', 'disableButtonsPluginMain', $headPublisher); } diff --git a/workflow/engine/skinEngine/skinEngine.php b/workflow/engine/skinEngine/skinEngine.php index bde49c832..a6f40fc90 100644 --- a/workflow/engine/skinEngine/skinEngine.php +++ b/workflow/engine/skinEngine/skinEngine.php @@ -451,7 +451,7 @@ class SkinEngine $smarty->assign('tpl_menu', PATH_TEMPLATE . 'menu.html'); $smarty->assign('tpl_submenu', PATH_TEMPLATE . 'submenu.html'); - if (class_exists('PMPluginRegistry')) { + if (class_exists('ProcessMaker\Plugins\PluginRegistry')) { $oPluginRegistry = PluginRegistry::loadSingleton(); $sCompanyLogo = $oPluginRegistry->getCompanyLogo('/images/processmaker.logo.jpg'); } @@ -535,7 +535,7 @@ class SkinEngine $smarty->assign('tpl_menu', PATH_TEMPLATE . 'menu.html' ); $smarty->assign('tpl_submenu', PATH_TEMPLATE . 'submenu.html' ); - if (class_exists('PMPluginRegistry')) { + if (class_exists('ProcessMaker\Plugins\PluginRegistry')) { $oPluginRegistry = PluginRegistry::loadSingleton(); $sCompanyLogo = $oPluginRegistry->getCompanyLogo ( '/images/processmaker.logo.jpg' ); } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/User.php b/workflow/engine/src/ProcessMaker/BusinessModel/User.php index 2da9eb6a3..39fc53dec 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/User.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/User.php @@ -22,7 +22,7 @@ use IsoLocationPeer; use IsoSubdivisionPeer; use ListParticipatedLast; use PMmemcached; -use PMPluginRegistry; +use ProcessMaker\Plugins\PluginRegistry; use ProcessMaker\Util\DateTime; use ProcessMaker\Util\System; use Propel; @@ -869,7 +869,7 @@ class User public function createUser($userData) { $this->userObj = new RbacUsers(); - if (class_exists('PMPluginRegistry')) { + if (class_exists('ProcessMaker\Plugins\PluginRegistry')) { $pluginRegistry = PluginRegistry::loadSingleton(); if ($pluginRegistry->existsTrigger(PM_BEFORE_CREATE_USER)) { try { diff --git a/workflow/engine/src/ProcessMaker/Plugins/PluginRegistry.php b/workflow/engine/src/ProcessMaker/Plugins/PluginRegistry.php index 2fe6ceaca..cce3f2cd7 100644 --- a/workflow/engine/src/ProcessMaker/Plugins/PluginRegistry.php +++ b/workflow/engine/src/ProcessMaker/Plugins/PluginRegistry.php @@ -826,8 +826,8 @@ class PluginRegistry require_once($classFile); $sClassName = substr($this->_aPluginDetails[$trigger->getNamespace()]->getClassName(), 0, 1) . str_replace( - 'Plugin', - 'Class', + 'plugin', + 'class', substr($this->_aPluginDetails[$trigger->getNamespace()]->getClassName(), 1) ); $obj = new $sClassName(); diff --git a/workflow/engine/src/ProcessMaker/Util/System.php b/workflow/engine/src/ProcessMaker/Util/System.php index c01a86b89..f9863f741 100644 --- a/workflow/engine/src/ProcessMaker/Util/System.php +++ b/workflow/engine/src/ProcessMaker/Util/System.php @@ -2,9 +2,16 @@ namespace ProcessMaker\Util; -use \ProcessMaker\Services\OAuth2\PmPdo; -use \ProcessMaker\Services\OAuth2\Server; -use \OAuth2\Request; +use Bootstrap; +use Exception; +use Maveriks\Util\ClassLoader; +use PMPlugin; +use ProcessMaker\Plugins\Interfaces\PluginDetail; +use ProcessMaker\Plugins\PluginRegistry; +use ProcessMaker\Services\OAuth2\PmPdo; +use ProcessMaker\Services\OAuth2\Server; +use OAuth2\Request; +use Propel; class System { @@ -14,7 +21,7 @@ class System * Get Time Zone * * @return string Return Time Zone - * @throws \Exception + * @throws Exception */ public static function getTimeZone() { @@ -23,7 +30,7 @@ class System //Return return $arraySystemConfiguration['time_zone']; - } catch (\Exception $e) { + } catch (Exception $e) { throw $e; } } @@ -37,26 +44,28 @@ class System { try { //Update singleton file by workspace - \Bootstrap::setConstantsRelatedWs($workspace->name); - $pathSingleton = PATH_DATA . "sites" . PATH_SEP . $workspace->name . PATH_SEP . "plugin.singleton"; - $oPluginRegistry = \PMPluginRegistry::loadSingleton($pathSingleton); - $items = \PMPlugin::getListAllPlugins($workspace->name); + Bootstrap::setConstantsRelatedWs($workspace->name); + Propel::init(PATH_CORE . "config/databases.php"); + $oPluginRegistry = PluginRegistry::loadSingleton(); + $items = PMPlugin::getListAllPlugins($workspace->name); + /** @var PluginDetail $item */ foreach ($items as $item) { - if ($item->enabled === true) { - require_once($item->sFilename); - $details = $oPluginRegistry->getPluginDetails(basename($item->sFilename)); + if ($item->isEnabled()) { + require_once($item->getFile()); + /** @var PluginDetail $details */ + $details = $oPluginRegistry->getPluginDetails(basename($item->getFile())); //Only if the API directory structure is defined - $pathApiDirectory = PATH_PLUGINS . $details->sPluginFolder . PATH_SEP . "src" . PATH_SEP . "Services" . PATH_SEP . "Api"; + $pathApiDirectory = PATH_PLUGINS . $details->getFolder() . PATH_SEP . "src" . PATH_SEP . "Services" . PATH_SEP . "Api"; if (is_dir($pathApiDirectory)) { - $pluginSrcDir = PATH_PLUGINS . $details->sNamespace . PATH_SEP . 'src'; - $loader = \Maveriks\Util\ClassLoader::getInstance(); + $pluginSrcDir = PATH_PLUGINS . $details->getNamespace() . PATH_SEP . 'src'; + $loader = ClassLoader::getInstance(); $loader->add($pluginSrcDir); - $oPluginRegistry->registerRestService($details->sNamespace); - if (class_exists($details->sClassName)) { - $oPlugin = new $details->sClassName($details->sNamespace, $details->sFilename); + $oPluginRegistry->registerRestService($details->getNamespace()); + $className = $details->getClassName(); + if (class_exists($className)) { + $oPlugin = new $className($details->getNamespace(), $details->getFile()); $oPlugin->setup(); } - file_put_contents($pathSingleton, $oPluginRegistry->serializeInstance()); } } } @@ -71,8 +80,8 @@ class System if (file_exists($workspace->path . '/routes.php')) { unlink($workspace->path . '/routes.php'); } - } catch (\Exception $e) { - throw new \Exception("Error: cannot perform this task. " . $e->getMessage()); + } catch (Exception $e) { + throw new Exception("Error: cannot perform this task. " . $e->getMessage()); } } @@ -87,7 +96,7 @@ class System $authCode = self::getAuthorizationCodeUserLogged($client); - $loader = \Maveriks\Util\ClassLoader::getInstance(); + $loader = ClassLoader::getInstance(); $loader->add(PATH_TRUNK . 'vendor/bshaffer/oauth2-server-php/src/', "OAuth2"); $request = array( @@ -117,7 +126,7 @@ class System * Get client credentials * @return array */ - protected function getClientCredentials() + protected static function getClientCredentials() { $oauthQuery = new PmPdo(self::getDsn()); return $oauthQuery->getClientDetails(self::CLIENT_ID); @@ -127,7 +136,7 @@ class System * Get DNS of workspace * @return array */ - protected function getDsn() + protected static function getDsn() { list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, ''); $port = empty($port) ? '' : ";port=$port"; @@ -141,7 +150,7 @@ class System * @param $client * @return bool|string */ - protected function getAuthorizationCodeUserLogged($client) + protected static function getAuthorizationCodeUserLogged($client) { Server::setDatabaseSource(self::getDsn()); Server::setPmClientId($client['CLIENT_ID']);