This commit is contained in:
Ronald Quenta
2017-08-10 12:10:42 -04:00
parent dc7abaae6b
commit 94a2db1e23
20 changed files with 125 additions and 104 deletions

View File

@@ -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) {

View File

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

View File

@@ -197,7 +197,7 @@ 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 {

View File

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

View File

@@ -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']);

View File

@@ -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 = '';

View File

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

View File

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

View File

@@ -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' => '<input type="hidden" id="STEP_MODE_' . $stepVar->sStepId . '">' );
$aBB[] = array(
'STEP_UID' => $stepVar->getStepId(),
'STEP_TITLE' => $stepVar->getStepTitle(),
'STEP_TYPE_OBJ' => 'EXTERNAL',
'STEP_MODE' => '<input type="hidden" id="STEP_MODE_' . $stepVar->getStepId() . '">'
);
}
}
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' => '<input type="hidden" id="STEP_MODE_' . $stepVar->sStepId . '">' );
$aBB[] = array(
'STEP_UID' => $stepVar->getStepId(),
'STEP_TITLE' => $stepVar->getStepTitle(),
'STEP_TYPE_OBJ' => 'EXTERNAL',
'STEP_MODE' => '<input type="hidden" id="STEP_MODE_' . $stepVar->getStepId() . '">'
);
}
}
@@ -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 = "";

View File

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

View File

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

View File

@@ -93,7 +93,7 @@ class triggerLibrary
function unSerializeInstance ($serialized)
{
if (self::$instance == NULL) {
self::$instance = new PMPluginRegistry();
self::$instance = new PluginRegistry();
}
$instance = unserialize( $serialized );

View File

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

View File

@@ -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') {

View File

@@ -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)), '');

View File

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

View File

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

View File

@@ -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 {

View File

@@ -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();

View File

@@ -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']);