This commit is contained in:
Roly Rudy Gutierrez Pinto
2019-03-08 09:56:08 -04:00
parent 099d056cd0
commit 2e79581a30
6 changed files with 89 additions and 75 deletions

View File

@@ -2,13 +2,14 @@
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Process as BmProcess;
/*----------------------------------********---------------------------------*/
use ProcessMaker\ChangeLog\ChangeLog;
/*----------------------------------********---------------------------------*/
use ProcessMaker\BusinessModel\Process as BmProcess;
use ProcessMaker\Core\Installer;
use ProcessMaker\Core\System;
use ProcessMaker\Plugins\Adapters\PluginAdapter;
use ProcessMaker\Project\Adapter\BpmnWorkflow;
use ProcessMaker\Util\FixReferencePath;
/**
@@ -3739,53 +3740,62 @@ class WorkspaceTools
CLI::logging("|--> Clean data in table " . OauthRefreshTokensPeer::TABLE_NAME . " rows " . $refreshToken . "\n");
}
/**
* Migrate the Intermediate throw Email Event to Dummy task, specify the workspaces.
* The processes in this workspace will be updated.
*
* @param string $workspaceName
* @see workflow/engine/bin/tasks/cliWorkspaces.php::run_migrate_itee_to_dummytask()
* @see workflow/engine/classes/WorkspaceTools.php->upgradeDatabase()
* @link https://wiki.processmaker.com/3.3/processmaker_command#migrate-itee-to-dummytask
*/
public function migrateIteeToDummytask($workspaceName)
{
$this->initPropel(true);
$arraySystemConfiguration = System::getSystemConfiguration('', '', $workspaceName);
$conf = new Configurations();
\G::$sysSys = $workspaceName;
\G::$pathDataSite = PATH_DATA . "sites" . PATH_SEP . \G::$sysSys . PATH_SEP;
\G::$pathDocument = PATH_DATA . 'sites' . DIRECTORY_SEPARATOR . $workspaceName . DIRECTORY_SEPARATOR . 'files';
\G::$memcachedEnabled = $arraySystemConfiguration['memcached'];
\G::$pathDataPublic = \G::$pathDataSite . "public" . PATH_SEP;
\G::$sysSkin = $conf->getConfiguration('SKIN_CRON', '');
if (is_file(\G::$pathDataSite . PATH_SEP . ".server_info")) {
$serverInfo = file_get_contents(\G::$pathDataSite . PATH_SEP . ".server_info");
$config = System::getSystemConfiguration('', '', $workspaceName);
G::$sysSys = $workspaceName;
G::$pathDataSite = PATH_DATA . "sites" . PATH_SEP . G::$sysSys . PATH_SEP;
G::$pathDocument = PATH_DATA . 'sites' . DIRECTORY_SEPARATOR . $workspaceName . DIRECTORY_SEPARATOR . 'files';
G::$memcachedEnabled = $config['memcached'];
G::$pathDataPublic = G::$pathDataSite . "public" . PATH_SEP;
G::$sysSkin = $config['default_skin'];
if (is_file(G::$pathDataSite . PATH_SEP . ".server_info")) {
$serverInfo = file_get_contents(G::$pathDataSite . PATH_SEP . ".server_info");
$serverInfo = unserialize($serverInfo);
$envHost = $serverInfo["SERVER_NAME"];
$envPort = ($serverInfo["SERVER_PORT"] . "" != "80") ? ":" . $serverInfo["SERVER_PORT"] : "";
if (!empty($envPort) && strpos($envHost, $envPort) === false) {
$envHost = $envHost . $envPort;
}
\G::$httpHost = $envHost;
G::$httpHost = $envHost;
}
//Search All process
$oCriteria = new Criteria("workflow");
$oCriteria->addSelectColumn(ProcessPeer::PRO_UID);
$oCriteria->addSelectColumn(ProcessPeer::PRO_ITEE);
$oCriteria->add(ProcessPeer::PRO_ITEE, '0', Criteria::EQUAL);
$rsCriteria = ProcessPeer::doSelectRS($oCriteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$criteria = new Criteria("workflow");
$criteria->addSelectColumn(ProcessPeer::PRO_UID);
$criteria->addSelectColumn(ProcessPeer::PRO_ITEE);
$criteria->add(ProcessPeer::PRO_ITEE, '0', Criteria::EQUAL);
$resultSet = ProcessPeer::doSelectRS($criteria);
$resultSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$message = "-> Migrating the Intermediate Email Event \n";
CLI::logging($message);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$prj_uid = $row['PRO_UID'];
$bpmnProcess = new Process();
if ($bpmnProcess->isBpmnProcess($prj_uid)) {
$project = new \ProcessMaker\Project\Adapter\BpmnWorkflow();
$diagram = $project->getStruct($prj_uid);
$res = $project->updateFromStruct($prj_uid, $diagram);
$bpmnProcess->setProUid($prj_uid);
$oProcess = new Process();
$aProcess['PRO_UID'] = $prj_uid;
$aProcess['PRO_ITEE'] = '1';
if ($oProcess->processExists($prj_uid)) {
$oProcess->update($aProcess);
while ($resultSet->next()) {
$row = $resultSet->getRow();
$prjUid = $row['PRO_UID'];
$process = new Process();
if ($process->isBpmnProcess($prjUid)) {
$project = new BpmnWorkflow();
$diagram = $project->getStruct($prjUid);
$project->updateFromStruct($prjUid, $diagram);
$process->setProUid($prjUid);
$updateProcess = new Process();
$updateProcessData = [];
$updateProcessData['PRO_UID'] = $prjUid;
$updateProcessData['PRO_ITEE'] = '1';
if ($updateProcess->processExists($prjUid)) {
$updateProcess->update($updateProcessData);
}
$message = " Process updated " . $bpmnProcess->getProTitle() . "\n";
$message = " Process updated " . $process->getProTitle() . "\n";
CLI::logging($message);
}
}

View File

@@ -28,11 +28,11 @@
//
// License: LGPL, see LICENSE
////////////////////////////////////////////////////
use ProcessMaker\BusinessModel\Cases as BusinessModelCases;
use ProcessMaker\Core\System;
use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Util\ElementTranslation;
/**
* ProcessMaker has made a number of its PHP functions available be used in triggers and conditions.
* Most of these functions are wrappers for internal functions used in Gulliver, which is the development framework
@@ -3470,38 +3470,26 @@ function PMFGetNextDerivationInfo($caseUid, $delIndex)
* @param string | $skin = null | Skin | The skin
*
* @return string | $url | Direct case link | Returns the direct case link, FALSE otherwise
* @link https://wiki.processmaker.com/3.2/Direct_Case_Link
*/
function PMFCaseLink($caseUid, $workspace = null, $language = null, $skin = null)
{
try {
$case = new \ProcessMaker\BusinessModel\Cases();
$case = new BusinessModelCases();
$arrayApplicationData = $case->getApplicationRecordByPk($caseUid, [], false);
if ($arrayApplicationData === false) {
return false;
}
$conf = new Configurations();
$envSkin = defined("SYS_SKIN") ? SYS_SKIN : $conf->getConfiguration('SKIN_CRON', '');
$workspace = (!empty($workspace)) ? $workspace : config("system.workspace");
$language = (!empty($language)) ? $language : SYS_LANG;
$skin = (!empty($skin)) ? $skin : $envSkin;
$workspace = !empty($workspace) ? $workspace : config("system.workspace");
$language = !empty($language) ? $language : SYS_LANG;
if (empty($skin)) {
$config = System::getSystemConfiguration();
$skin = defined("SYS_SKIN") ? SYS_SKIN : $config['default_skin'];
}
$uri = '/sys' . $workspace . '/' . $language . '/' . $skin . '/cases/opencase/' . $caseUid;
$envHost = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : SERVER_NAME;
$envProtocol = defined("REQUEST_SCHEME") && REQUEST_SCHEME === "https";
if (isset($_SERVER['SERVER_PORT'])) {
$envPort = ($_SERVER['SERVER_PORT'] != "80") ? ":" . $_SERVER['SERVER_PORT'] : "";
} else if (defined('SERVER_PORT')) {
$envPort = (SERVER_PORT . "" != "80") ? ":" . SERVER_PORT : "";
} else {
$envPort = "";
}
if (!empty($envPort) && strpos($envHost, $envPort) === false) {
$envHost = $envHost . $envPort;
}
$link = (G::is_https() || $envProtocol ? 'https://' : 'http://') . $envHost . $uri;
$link = System::getServerProtocolHost() . $uri;
return $link;
} catch (Exception $e) {
throw $e;