This commit is contained in:
Marco Antonio Nina Mena
2017-12-04 13:25:35 +00:00
committed by Julio Cesar Laura Avendaño
parent abe71a6ffe
commit 0d533e19d9
363 changed files with 23948 additions and 44623 deletions

View File

@@ -102,11 +102,19 @@ class ChangeLog
}
if ($index < $start) {
$index += $this->updateData(
$data, $row, $this->hasPermission($row['DYN_UID']), false);
$data,
$row,
$this->hasPermission($row['DYN_UID']),
false
);
continue;
}
$a = $this->updateData($data, $row,
$this->hasPermission($row['DYN_UID']), true);
$a = $this->updateData(
$data,
$row,
$this->hasPermission($row['DYN_UID']),
true
);
$limit-= $a;
$index+= $a;
}
@@ -154,12 +162,12 @@ class ChangeLog
$node = new StdClass();
$node->field = $key;
$previousValue = !isset($this->values[$key]) ? null : $this->values[$key];
if(!is_array($previousValue)){
if (!is_array($previousValue)) {
$node->previousValue = (string) $previousValue;
} else {
$node->previousValue = "<br />".nl2br(print_r($previousValue, true));
}
if(!is_array($value)){
if (!is_array($value)) {
$node->currentValue = (string) $value;
} else {
$node->currentValue = "<br />".nl2br(print_r($value, true));
@@ -250,7 +258,7 @@ class ChangeLog
*/
private function hasPermission($uid)
{
if(array_search($uid, $this->reservedSteps)!==false) {
if (array_search($uid, $this->reservedSteps)!==false) {
return false;
}
foreach ($this->permissions as $type => $ids) {
@@ -260,4 +268,4 @@ class ChangeLog
}
return false;
}
}
}

View File

@@ -81,8 +81,10 @@ class OutputDocument
$criteria2->add(\ObjectPermissionPeer::OP_OBJ_TYPE, "OUTPUT", \Criteria::EQUAL);
$criteria2->add(
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, $outputDocumentUid, \Criteria::EQUAL)->addOr(
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "0", \Criteria::EQUAL))->addOr(
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "", \Criteria::EQUAL))
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "0", \Criteria::EQUAL)
)->addOr(
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "", \Criteria::EQUAL)
)
);
$criteria2->add(\ObjectPermissionPeer::OP_ACTION, "DELETE", \Criteria::EQUAL);
@@ -203,16 +205,16 @@ class OutputDocument
{
try {
$oCase = new \Cases();
$fields = $oCase->loadCase( $applicationUid );
$fields = $oCase->loadCase($applicationUid);
$sProcessUID = $fields['PRO_UID'];
$sTaskUID = '';
$oCriteria = new \ProcessMaker\BusinessModel\Cases();
$oCriteria->getAllGeneratedDocumentsCriteria( $sProcessUID, $applicationUid, $sTaskUID, $userUid);
$result = array ();
$oCriteria->getAllGeneratedDocumentsCriteria($sProcessUID, $applicationUid, $sTaskUID, $userUid);
$result = array();
global $_DBArray;
foreach ($_DBArray['outputDocuments'] as $key => $row) {
if (isset( $row['DOC_VERSION'] )) {
$docrow = array ();
if (isset($row['DOC_VERSION'])) {
$docrow = array();
$docrow['app_doc_uid'] = $row['APP_DOC_UID'];
$docrow['app_doc_filename'] = $row['DOWNLOAD_FILE'];
$docrow['doc_uid'] = $row['DOC_UID'];
@@ -246,16 +248,16 @@ class OutputDocument
$sApplicationUID = $applicationUid;
$sUserUID = $userUid;
$oCase = new \Cases();
$fields = $oCase->loadCase( $sApplicationUID );
$fields = $oCase->loadCase($sApplicationUID);
$sProcessUID = $fields['PRO_UID'];
$sTaskUID = '';
$oCaseRest = new \ProcessMaker\BusinessModel\Cases();
$oCaseRest->getAllGeneratedDocumentsCriteria( $sProcessUID, $sApplicationUID, $sTaskUID, $sUserUID );
$result = array ();
$oCaseRest->getAllGeneratedDocumentsCriteria($sProcessUID, $sApplicationUID, $sTaskUID, $sUserUID);
$result = array();
global $_DBArray;
foreach ($_DBArray['outputDocuments'] as $key => $row) {
if (isset( $row['DOC_VERSION'] )) {
$docrow = array ();
if (isset($row['DOC_VERSION'])) {
$docrow = array();
$docrow['app_doc_uid'] = $row['APP_DOC_UID'];
$docrow['app_doc_filename'] = $row['DOWNLOAD_FILE'];
$docrow['doc_uid'] = $row['DOC_UID'];
@@ -266,8 +268,8 @@ class OutputDocument
$docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
$docrow['app_doc_link'] = $row['DOWNLOAD_LINK'];
if ($docrow['app_doc_uid'] == $applicationDocumentUid) {
$oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, $row['DOC_VERSION'] );
if (is_null( $oAppDocument )) {
$oAppDocument = \AppDocumentPeer::retrieveByPK($applicationDocumentUid, $row['DOC_VERSION']);
if (is_null($oAppDocument)) {
throw new \Exception(\G::LoadTranslation("ID_CASES_OUTPUT_DOES_NOT_EXIST", array($applicationDocumentUid)));
}
$result = $docrow;
@@ -413,12 +415,12 @@ class OutputDocument
try {
$oAppDocumentVersion = new \AppDocument();
$lastDocVersion = $oAppDocumentVersion->getLastAppDocVersion($applicationDocumentUid);
$oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, $lastDocVersion);
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
$oAppDocument = \AppDocumentPeer::retrieveByPK($applicationDocumentUid, $lastDocVersion);
if (is_null($oAppDocument) || $oAppDocument->getAppDocStatus() == 'DELETED') {
throw new \Exception(\G::LoadTranslation("ID_CASES_OUTPUT_DOES_NOT_EXIST", array($applicationDocumentUid)));
}
$aFields = array ('APP_DOC_UID' => $applicationDocumentUid,'DOC_VERSION' => $lastDocVersion,'APP_DOC_STATUS' => 'DELETED');
$oAppDocument->update( $aFields );
$aFields = array('APP_DOC_UID' => $applicationDocumentUid,'DOC_VERSION' => $lastDocVersion,'APP_DOC_STATUS' => 'DELETED');
$oAppDocument->update($aFields);
} catch (\Exception $e) {
throw $e;
}
@@ -443,47 +445,47 @@ class OutputDocument
$g = new \G();
$g->sessionVarSave();
$oCase = new \Cases();
$oCase->thisIsTheCurrentUser( $sApplication, $index, $sUserLogged, '', 'casesListExtJs' );
$oCase->thisIsTheCurrentUser($sApplication, $index, $sUserLogged, '', 'casesListExtJs');
//require_once 'classes/model/OutputDocument.php';
$oOutputDocument = new \OutputDocument();
$aOD = $oOutputDocument->load( $outputID );
$Fields = $oCase->loadCase( $sApplication );
$sFilename = preg_replace( '[^A-Za-z0-9_]', '_', \G::replaceDataField( $aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'] ) );
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppFolder.php");
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppDocument.php");
$aOD = $oOutputDocument->load($outputID);
$Fields = $oCase->loadCase($sApplication);
$sFilename = preg_replace('[^A-Za-z0-9_]', '_', \G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppFolder.php");
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppDocument.php");
//Get the Custom Folder ID (create if necessary)
$oFolder = new \AppFolder();
$folderId = $oFolder->createFromPath( $aOD['OUT_DOC_DESTINATION_PATH'], $sApplication );
$folderId = $oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH'], $sApplication);
//Tags
$fileTags = $oFolder->parseTags( $aOD['OUT_DOC_TAGS'], $sApplication );
$fileTags = $oFolder->parseTags($aOD['OUT_DOC_TAGS'], $sApplication);
//Get last Document Version and apply versioning if is enabled
$oAppDocument = new \AppDocument();
$lastDocVersion = $oAppDocument->getLastDocVersion( $outputID, $sApplication );
$oCriteria = new \Criteria( 'workflow' );
$oCriteria->add( \AppDocumentPeer::APP_UID, $sApplication );
$oCriteria->add( \AppDocumentPeer::DOC_UID, $outputID );
$oCriteria->add( \AppDocumentPeer::DOC_VERSION, $lastDocVersion );
$oCriteria->add( \AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT' );
$oDataset = \AppDocumentPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
$lastDocVersion = $oAppDocument->getLastDocVersion($outputID, $sApplication);
$oCriteria = new \Criteria('workflow');
$oCriteria->add(\AppDocumentPeer::APP_UID, $sApplication);
$oCriteria->add(\AppDocumentPeer::DOC_UID, $outputID);
$oCriteria->add(\AppDocumentPeer::DOC_VERSION, $lastDocVersion);
$oCriteria->add(\AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT');
$oDataset = \AppDocumentPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
if (($aOD['OUT_DOC_VERSIONING']) && ($lastDocVersion != 0)) {
//Create new Version of current output
$lastDocVersion ++;
if ($aRow = $oDataset->getRow()) {
$aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion + 1,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags);
$aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion + 1,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags);
$oAppDocument = new \AppDocument();
$oAppDocument->create( $aFields );
$oAppDocument->create($aFields);
$sDocUID = $aRow['APP_DOC_UID'];
}
} else {
////No versioning so Update a current Output or Create new if no exist
if ($aRow = $oDataset->getRow()) {
//Update
$aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags
$aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags
);
$oAppDocument = new \AppDocument();
$oAppDocument->update( $aFields );
$oAppDocument->update($aFields);
$sDocUID = $aRow['APP_DOC_UID'];
} else {
//we are creating the appdocument row
@@ -491,92 +493,92 @@ class OutputDocument
if ($lastDocVersion == 0) {
$lastDocVersion ++;
}
$aFields = array ('APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags
$aFields = array('APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags
);
$oAppDocument = new \AppDocument();
$aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create( $aFields );
$aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create($aFields);
}
}
$sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion;
$pathOutput = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP; //G::pr($sFilename);die;
\G::mk_dir( $pathOutput );
$aProperties = array ();
if (! isset( $aOD['OUT_DOC_MEDIA'] )) {
\G::mk_dir($pathOutput);
$aProperties = array();
if (! isset($aOD['OUT_DOC_MEDIA'])) {
$aOD['OUT_DOC_MEDIA'] = 'Letter';
}
if (! isset( $aOD['OUT_DOC_LEFT_MARGIN'] )) {
if (! isset($aOD['OUT_DOC_LEFT_MARGIN'])) {
$aOD['OUT_DOC_LEFT_MARGIN'] = '15';
}
if (! isset( $aOD['OUT_DOC_RIGHT_MARGIN'] )) {
if (! isset($aOD['OUT_DOC_RIGHT_MARGIN'])) {
$aOD['OUT_DOC_RIGHT_MARGIN'] = '15';
}
if (! isset( $aOD['OUT_DOC_TOP_MARGIN'] )) {
if (! isset($aOD['OUT_DOC_TOP_MARGIN'])) {
$aOD['OUT_DOC_TOP_MARGIN'] = '15';
}
if (! isset( $aOD['OUT_DOC_BOTTOM_MARGIN'] )) {
if (! isset($aOD['OUT_DOC_BOTTOM_MARGIN'])) {
$aOD['OUT_DOC_BOTTOM_MARGIN'] = '15';
}
$aProperties['media'] = $aOD['OUT_DOC_MEDIA'];
$aProperties['margins'] = array ('left' => $aOD['OUT_DOC_LEFT_MARGIN'],'right' => $aOD['OUT_DOC_RIGHT_MARGIN'],'top' => $aOD['OUT_DOC_TOP_MARGIN'],'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN']
$aProperties['margins'] = array('left' => $aOD['OUT_DOC_LEFT_MARGIN'],'right' => $aOD['OUT_DOC_RIGHT_MARGIN'],'top' => $aOD['OUT_DOC_TOP_MARGIN'],'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN']
);
if (isset($aOD['OUT_DOC_REPORT_GENERATOR'])) {
$aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR'];
}
$this->generate( $outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties , $applicationUid);
$this->generate($outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties, $applicationUid);
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
$oPluginRegistry = PluginRegistry::loadSingleton();
if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( 'uploadDocumentData' )) {
$triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) {
$triggerDetail = $oPluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT);
$aFields['APP_DOC_PLUGIN'] = $triggerDetail->getNamespace();
$oAppDocument1 = new \AppDocument();
$oAppDocument1->update( $aFields );
$oAppDocument1->update($aFields);
$sPathName = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP;
$oData['APP_UID'] = $sApplication;
$oData['ATTACHMENT_FOLDER'] = true;
switch ($aOD['OUT_DOC_GENERATE']) {
case "BOTH":
$documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() );
$documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion());
$documentData->sFileType = "PDF";
$documentData->bUseOutputFolder = true;
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
$uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
if ($uploadReturn) {
//Only delete if the file was saved correctly
unlink( $pathOutput . $sFilename . '.pdf' );
unlink($pathOutput . $sFilename . '.pdf');
}
$documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() );
$documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion());
$documentData->sFileType = "DOC";
$documentData->bUseOutputFolder = true;
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
$uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
if ($uploadReturn) {
//Only delete if the file was saved correctly
unlink( $pathOutput . $sFilename . '.doc' );
unlink($pathOutput . $sFilename . '.doc');
}
break;
case "PDF":
$documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() );
$documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion());
$documentData->sFileType = "PDF";
$documentData->bUseOutputFolder = true;
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
$uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
if ($uploadReturn) {
//Only delete if the file was saved correctly
unlink( $pathOutput . $sFilename . '.pdf' );
unlink($pathOutput . $sFilename . '.pdf');
}
break;
case "DOC":
$documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() );
$documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion());
$documentData->sFileType = "DOC";
$documentData->bUseOutputFolder = true;
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
$uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
if ($uploadReturn) {
//Only delete if the file was saved correctly
unlink( $pathOutput . $sFilename . '.doc' );
unlink($pathOutput . $sFilename . '.doc');
}
break;
}
}
$g->sessionVarRestore();
$oAppDocument = \AppDocumentPeer::retrieveByPK( $aFields['APP_DOC_UID'], $lastDocVersion);
$oAppDocument = \AppDocumentPeer::retrieveByPK($aFields['APP_DOC_UID'], $lastDocVersion);
if ($oAppDocument->getAppDocStatus() == 'DELETED') {
$oAppDocument->setAppDocStatus('ACTIVE');
$oAppDocument->save();
@@ -746,7 +748,13 @@ class OutputDocument
/* End - Create .pdf */
} else {
return \PEAR::raiseError(
null, G_ERROR_USER_UID, null, null, 'You tried to call to a generate method without send the Output Document UID, fields to use and the file path!', 'G_Error', true
null,
G_ERROR_USER_UID,
null,
null,
'You tried to call to a generate method without send the Output Document UID, fields to use and the file path!',
'G_Error',
true
);
}
}
@@ -764,8 +772,8 @@ class OutputDocument
define("MAX_FREE_FRACTION", 1);
define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $sApplication . '/outdocs/');
\G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true);
require_once (PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php');
require_once (PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php');
require_once(PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php');
require_once(PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php');
parse_config_file(PATH_THIRDPARTY . 'html2ps_pdf/html2ps.config');
$GLOBALS['g_config'] = array(
'cssmedia' => 'screen',
@@ -803,14 +811,16 @@ class OutputDocument
$GLOBALS['g_config']['pdfSecurity']['openPassword'] != ""
) {
$GLOBALS['g_config']['pdfSecurity']['openPassword'] = G::decrypt(
$GLOBALS['g_config']['pdfSecurity']['openPassword'], $sUID
$GLOBALS['g_config']['pdfSecurity']['openPassword'],
$sUID
);
}
if (isset($GLOBALS['g_config']['pdfSecurity']['ownerPassword']) &&
$GLOBALS['g_config']['pdfSecurity']['ownerPassword'] != ""
) {
$GLOBALS['g_config']['pdfSecurity']['ownerPassword'] = G::decrypt(
$GLOBALS['g_config']['pdfSecurity']['ownerPassword'], $sUID
$GLOBALS['g_config']['pdfSecurity']['ownerPassword'],
$sUID
);
}
$g_media->set_security($GLOBALS['g_config']['pdfSecurity']);
@@ -887,7 +897,7 @@ class OutputDocument
}
$pipeline->output_driver->set_watermark($watermark_text);
if ($watermark_text != '') {
$dispatcher = & $pipeline->getDispatcher();
$dispatcher = $pipeline->getDispatcher();
}
if ($GLOBALS['g_config']['debugbox']) {
$pipeline->output_driver->set_debug_boxes(true);
@@ -964,7 +974,7 @@ class OutputDocument
$arrayAllObjectsFrom = $case->getAllObjectsFrom($processUid, $applicationUid, null, $userUid, $action, $delIndex);
if (array_key_exists('OUTPUT_DOCUMENTS', $arrayAllObjectsFrom) && !empty($arrayAllObjectsFrom['OUTPUT_DOCUMENTS'])) {
foreach($arrayAllObjectsFrom['OUTPUT_DOCUMENTS'] as $value) {
foreach ($arrayAllObjectsFrom['OUTPUT_DOCUMENTS'] as $value) {
if ($value == $appDocumentUid) {
return true;
}

View File

@@ -1,17 +1,19 @@
<?php
namespace ProcessMaker\BusinessModel;
use DynaformHandler;
class DynaForm
{
private $arrayFieldDefinition = array(
"DYN_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormUid"),
"DYN_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormUid"),
"DYN_TITLE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormTitle"),
"DYN_DESCRIPTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormDescription"),
"DYN_TYPE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("xmlform", "grid"), "fieldNameAux" => "dynaFormType"),
"DYN_CONTENT" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormContent"),
"DYN_VERSION" => array("type" => "int", "required" => false, "empty" => true, "defaultValues" => array(1 ,2), "fieldNameAux" => "dynaFormVersion")
"DYN_TITLE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormTitle"),
"DYN_DESCRIPTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormDescription"),
"DYN_TYPE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("xmlform", "grid"), "fieldNameAux" => "dynaFormType"),
"DYN_CONTENT" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormContent"),
"DYN_VERSION" => array("type" => "int", "required" => false, "empty" => true, "defaultValues" => array(1, 2), "fieldNameAux" => "dynaFormVersion")
);
private $formatFieldNameInUppercase = true;
@@ -82,7 +84,7 @@ class DynaForm
public function getFieldNameByFormatFieldName($fieldName)
{
try {
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
return ($this->formatFieldNameInUppercase) ? strtoupper($fieldName) : strtolower($fieldName);
} catch (\Exception $e) {
throw $e;
}
@@ -91,8 +93,8 @@ class DynaForm
/**
* Verify if exists the title of a DynaForm
*
* @param string $processUid Unique id of Process
* @param string $dynaFormTitle Title
* @param string $processUid Unique id of Process
* @param string $dynaFormTitle Title
* @param string $dynaFormUidExclude Unique id of DynaForm to exclude
*
* return bool Return true if exists the title of a DynaForm, false otherwise
@@ -127,18 +129,18 @@ class DynaForm
* Verify if a DynaForm is assigned some Steps
*
* @param string $dynaFormUid Unique id of DynaForm
* @param string $processUid Unique id of Process
* @param string $processUid Unique id of Process
*
* return bool Return true if a DynaForm is assigned some Steps, false otherwise
*/
public function dynaFormDepends($dynUid, $proUid)
{
$oCriteria = new \Criteria();
$oCriteria->addSelectColumn( \DynaformPeer::DYN_TYPE );
$oCriteria->add( \DynaformPeer::DYN_UID, $dynUid );
$oCriteria->add( \DynaformPeer::PRO_UID, $proUid );
$oDataset = \DynaformPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
$oCriteria->addSelectColumn(\DynaformPeer::DYN_TYPE);
$oCriteria->add(\DynaformPeer::DYN_UID, $dynUid);
$oCriteria->add(\DynaformPeer::PRO_UID, $proUid);
$oDataset = \DynaformPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$dataDyna = $oDataset->getRow();
@@ -146,23 +148,23 @@ class DynaForm
$formsDepend = array();
$oCriteria = new \Criteria( 'workflow' );
$oCriteria->addSelectColumn( \DynaformPeer::DYN_UID );
$oCriteria->addSelectColumn( \DynaformPeer::DYN_TITLE );
$oCriteria->add( \DynaformPeer::PRO_UID, $proUid );
$oCriteria->add( \DynaformPeer::DYN_TYPE, "xmlform" );
$oDataset = \DynaformPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
$oCriteria = new \Criteria('workflow');
$oCriteria->addSelectColumn(\DynaformPeer::DYN_UID);
$oCriteria->addSelectColumn(\DynaformPeer::DYN_TITLE);
$oCriteria->add(\DynaformPeer::PRO_UID, $proUid);
$oCriteria->add(\DynaformPeer::DYN_TYPE, "xmlform");
$oDataset = \DynaformPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($oDataset->next()) {
$dataForms = $oDataset->getRow();
$dynHandler = new DynaformHandler(PATH_DYNAFORM . $proUid . PATH_SEP . $dataForms["DYN_UID"] . ".xml");
$dynFields = $dynHandler->getFields();
foreach ($dynFields as $field) {
$sType = \Step::getAttribute( $field, 'type' );
$sType = \Step::getAttribute($field, 'type');
if ($sType == 'grid') {
$sxmlgrid = \Step::getAttribute( $field, 'xmlgrid' );
$aGridInfo = explode( "/", $sxmlgrid );
$sxmlgrid = \Step::getAttribute($field, 'xmlgrid');
$aGridInfo = explode("/", $sxmlgrid);
if ($aGridInfo[0] == $proUid && $aGridInfo[1] == $dynUid) {
$formsDepend[] = $dataForms["DYN_TITLE"];
}
@@ -258,7 +260,7 @@ class DynaForm
/**
* Throw the exception "The DynaForm doesn't exist"
*
* @param string $dynaFormUid Unique id of DynaForm
* @param string $dynaFormUid Unique id of DynaForm
* @param string $fieldNameForException Field name for the exception
*
* @return void
@@ -273,8 +275,8 @@ class DynaForm
/**
* Verify if doesn't exists the DynaForm in table DYNAFORM
*
* @param string $dynaFormUid Unique id of DynaForm
* @param string $processUid Unique id of Process
* @param string $dynaFormUid Unique id of DynaForm
* @param string $processUid Unique id of Process
* @param string $fieldNameForException Field name for the exception
*
* return void Throw exception if doesn't exists the DynaForm in table DYNAFORM
@@ -305,10 +307,10 @@ class DynaForm
/**
* Verify if exists the title of a DynaForm
*
* @param string $processUid Unique id of Process
* @param string $dynaFormTitle Title
* @param string $processUid Unique id of Process
* @param string $dynaFormTitle Title
* @param string $fieldNameForException Field name for the exception
* @param string $dynaFormUidExclude Unique id of DynaForm to exclude
* @param string $dynaFormUidExclude Unique id of DynaForm to exclude
*
* return void Throw exception if exists the title of a DynaForm
*/
@@ -326,7 +328,7 @@ class DynaForm
/**
* Verify if is not grid DynaForm
*
* @param string $dynaFormUid Unique id of DynaForm
* @param string $dynaFormUid Unique id of DynaForm
* @param string $fieldNameForException Field name for the exception
*
* return void Throw exception if is not grid DynaForm
@@ -350,9 +352,9 @@ class DynaForm
/**
* Get DynaForm record
*
* @param string $dynaFormUid Unique id of DynaForm
* @param array $arrayVariableNameForException Variable name for exception
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
* @param string $dynaFormUid Unique id of DynaForm
* @param array $arrayVariableNameForException Variable name for exception
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
* (TRUE: throw the exception; FALSE: returns FALSE)
*
* @return array Returns an array with DynaForm record, ThrowTheException/FALSE otherwise
@@ -383,7 +385,7 @@ class DynaForm
* Create DynaForm for a Process
*
* @param string $processUid Unique id of Process
* @param array $arrayData Data
* @param array $arrayData Data
*
* return array Return data of the new DynaForm created
*/
@@ -431,7 +433,7 @@ class DynaForm
* Update DynaForm
*
* @param string $dynaFormUid Unique id of DynaForm
* @param array $arrayData Data
* @param array $arrayData Data
*
* return array Return data of the DynaForm updated
*/
@@ -532,7 +534,7 @@ class DynaForm
* Copy/Import a DynaForm
*
* @param string $processUid Unique id of Process
* @param array $arrayData Data
* @param array $arrayData Data
*
* return array Return data of the new DynaForm created
*/
@@ -578,7 +580,7 @@ class DynaForm
$this->throwExceptionIfExistsTitle($processUid, $arrayData["DYN_TITLE"], $this->arrayFieldNameForException["dynaFormTitle"]);
//Copy/Import Uids
$processUidCopyImport = $arrayData["COPY_IMPORT"]["PRJ_UID"];
$processUidCopyImport = $arrayData["COPY_IMPORT"]["PRJ_UID"];
$dynaFormUidCopyImport = $arrayData["COPY_IMPORT"]["DYN_UID"];
//Verify data
@@ -633,8 +635,8 @@ class DynaForm
$dynaFormGrid = new \Dynaform();
$arrayDataAux = array(
"PRO_UID" => $processUid,
"DYN_TITLE" => $dynGrdTitleCopyImport . (($this->existsTitle($processUid, $dynGrdTitleCopyImport))? " (" . $arrayData["DYN_TITLE"] . ")" : ""),
"PRO_UID" => $processUid,
"DYN_TITLE" => $dynGrdTitleCopyImport . (($this->existsTitle($processUid, $dynGrdTitleCopyImport)) ? " (" . $arrayData["DYN_TITLE"] . ")" : ""),
"DYN_DESCRIPTION" => $dynGrdDescriptionCopyImport,
"DYN_TYPE" => "grid"
);
@@ -720,7 +722,7 @@ class DynaForm
* Create a Dynaform based on a PMTable
*
* @param string $processUid Unique id of Process
* @param array $arrayData Data
* @param array $arrayData Data
*
* return array Return data of the new DynaForm created
*/
@@ -830,7 +832,7 @@ class DynaForm
}
//Set data
$tableUid = $arrayData["PMTABLE"]["TAB_UID"];
$tableUid = $arrayData["PMTABLE"]["TAB_UID"];
$arrayFields = $arrayData["PMTABLE"]["FIELDS"];
unset($arrayData["PMTABLE"]);
@@ -866,7 +868,7 @@ class DynaForm
* Defines the method for create a DynaForm
*
* @param string $processUid Unique id of Process
* @param array $arrayData Data
* @param array $arrayData Data
*
* return array Return data of the new DynaForm created
*/
@@ -883,14 +885,14 @@ class DynaForm
if (isset($arrayData["COPY_IMPORT"])) {
$count = $count + 1;
$msgMethod = $msgMethod . (($msgMethod != "")? ", " : "") . "COPY_IMPORT";
$msgMethod = $msgMethod . (($msgMethod != "") ? ", " : "") . "COPY_IMPORT";
$option = "COPY_IMPORT";
}
if (isset($arrayData["PMTABLE"])) {
$count = $count + 1;
$msgMethod = $msgMethod . (($msgMethod != "")? ", " : "") . "PMTABLE";
$msgMethod = $msgMethod . (($msgMethod != "") ? ", " : "") . "PMTABLE";
$option = "PMTABLE";
}
@@ -953,20 +955,22 @@ class DynaForm
public function getDynaFormDataFromRecord($record)
{
try {
if ($record["DYN_VERSION"] == 0) {
$record["DYN_VERSION"] = 1;
if ($record['DYN_VERSION'] === 0) {
$record['DYN_VERSION'] = 1;
}
$record["DYN_CONTENT"] = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", $record["DYN_CONTENT"]);
$record['DYN_CONTENT'] = preg_replace_callback("/\\\\u([a-f0-9]{4})/", function ($m) {
return "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$m[1]')))";
}, $record['DYN_CONTENT']);
return array(
$this->getFieldNameByFormatFieldName("DYN_UID") => $record["DYN_UID"],
$this->getFieldNameByFormatFieldName("DYN_TITLE") => $record["DYN_TITLE"],
$this->getFieldNameByFormatFieldName("DYN_DESCRIPTION") => $record["DYN_DESCRIPTION"] . "",
$this->getFieldNameByFormatFieldName("DYN_TYPE") => $record["DYN_TYPE"] . "",
$this->getFieldNameByFormatFieldName("DYN_CONTENT") => $record["DYN_CONTENT"] . "",
$this->getFieldNameByFormatFieldName("DYN_VERSION") => (int)($record["DYN_VERSION"]),
$this->getFieldNameByFormatFieldName("DYN_UPDATE_DATE") => $record["DYN_UPDATE_DATE"]
$this->getFieldNameByFormatFieldName('DYN_UID') => $record['DYN_UID'],
$this->getFieldNameByFormatFieldName('DYN_TITLE') => $record['DYN_TITLE'],
$this->getFieldNameByFormatFieldName('DYN_DESCRIPTION') => $record['DYN_DESCRIPTION'] . '',
$this->getFieldNameByFormatFieldName('DYN_TYPE') => $record['DYN_TYPE'] . '',
$this->getFieldNameByFormatFieldName('DYN_CONTENT') => $record['DYN_CONTENT'] . '',
$this->getFieldNameByFormatFieldName('DYN_VERSION') => (int)$record['DYN_VERSION'],
$this->getFieldNameByFormatFieldName('DYN_UPDATE_DATE') => $record['DYN_UPDATE_DATE']
);
} catch (\Exception $e) {
throw $e;
@@ -1030,20 +1034,20 @@ class DynaForm
$rsCriteria->next();
$aRow = $rsCriteria->getRow();
$contentDecode = json_decode($aRow['DYN_CONTENT'],true);
$contentDecode = json_decode($aRow['DYN_CONTENT'], true);
$content = $contentDecode['items'][0]['items'];
foreach ($content as $key => $value) {
$valueType = (isset($value[0]["valueType"])) ? $value[0]["valueType"]:null;
$maxLength = (isset($value[0]["maxLength"])) ? $value[0]["maxLength"]:null;
$label = (isset($value[0]["label"])) ? $value[0]["label"]:null;
$defaultValue = (isset($value[0]["defaultValue"])) ? $value[0]["defaultValue"]:null;
$required = (isset($value[0]["required"])) ? $value[0]["required"]:null;
$dbConnection = (isset($value[0]["dbConnection"])) ? $value[0]["dbConnection"]:null;
$sql = (isset($value[0]["sql"])) ? $value[0]["sql"]:null;
$options = (isset($value[0]["options"])) ? $value[0]["options"]:null;
$valueType = (isset($value[0]["valueType"])) ? $value[0]["valueType"] : null;
$maxLength = (isset($value[0]["maxLength"])) ? $value[0]["maxLength"] : null;
$label = (isset($value[0]["label"])) ? $value[0]["label"] : null;
$defaultValue = (isset($value[0]["defaultValue"])) ? $value[0]["defaultValue"] : null;
$required = (isset($value[0]["required"])) ? $value[0]["required"] : null;
$dbConnection = (isset($value[0]["dbConnection"])) ? $value[0]["dbConnection"] : null;
$sql = (isset($value[0]["sql"])) ? $value[0]["sql"] : null;
$options = (isset($value[0]["options"])) ? $value[0]["options"] : null;
if (isset($value[0]["variable"])) {
$variable = $value[0]["variable"];
@@ -1070,19 +1074,19 @@ class DynaForm
$maxLengthMerged = ($maxLength == null && $maxLength == '') ? (int)$aRow['VAR_FIELD_SIZE'] : $maxLength;
$labelMerged = ($label == null && $label == '') ? $aRow['VAR_LABEL'] : $label;
$defaultValueMerged = ($defaultValue == null && $defaultValue == '') ? $aRow['VAR_DEFAULT'] : $defaultValue;
$requiredMerged = ($required == null && $required == '') ? ($aRow['VAR_NULL']==1) ? false: true : $required;
$requiredMerged = ($required == null && $required == '') ? ($aRow['VAR_NULL'] == 1) ? false : true : $required;
$dbConnectionMerged = ($dbConnection == null && $dbConnection == '') ? $aRow['VAR_DBCONNECTION'] : $dbConnection;
$sqlMerged = ($sql == null && $sql == '') ? $aRow['VAR_SQL'] : $sql;
$optionsMerged = ($options == null && $options == '') ? $aRow['VAR_ACCEPTED_VALUES'] : $options;
$aVariables = array('valueType' => $valueTypeMerged,
'maxLength' => $maxLengthMerged,
'label' => $labelMerged,
'defaultValue' => $defaultValueMerged,
'required' => $requiredMerged,
'dbConnection' => $dbConnectionMerged,
'sql' => $sqlMerged,
'options' => $optionsMerged);
'maxLength' => $maxLengthMerged,
'label' => $labelMerged,
'defaultValue' => $defaultValueMerged,
'required' => $requiredMerged,
'dbConnection' => $dbConnectionMerged,
'sql' => $sqlMerged,
'options' => $optionsMerged);
//fields properties
if (isset($value[0]["pickType"])) {

View File

@@ -44,6 +44,7 @@ class Light
* Method get list start case
*
* @param $userId User id
*
* @return array
* @throws Exception
*/
@@ -105,8 +106,11 @@ class Light
$tempTreeChild['text'] = $keyChild; //ellipsis ( $keyChild, 50 );
$tempTreeChild['processId'] = $processInfoChild['pro_uid'];
$tempTreeChild['taskId'] = $processInfoChild['uid'];
list($tempTreeChild['offlineEnabled'], $tempTreeChild['autoRoot']) = $task->getColumnValues($processInfoChild['pro_uid'],
$processInfoChild['uid'], array('TAS_OFFLINE', 'TAS_AUTO_ROOT'));
list($tempTreeChild['offlineEnabled'], $tempTreeChild['autoRoot']) = $task->getColumnValues(
$processInfoChild['pro_uid'],
$processInfoChild['uid'],
array('TAS_OFFLINE', 'TAS_AUTO_ROOT')
);
//Add process category
$tempTreeChild['categoryName'] = $processInfoChild['catname'];
$tempTreeChild['categoryId'] = $processInfoChild['cat'];
@@ -127,8 +131,11 @@ class Light
$newForm[$c]['stepMode'] = $form['step_mode'];
$newForm[$c]['stepCondition'] = $form['step_condition'];
$newForm[$c]['stepPosition'] = $form['step_position'];
$trigger = $this->statusTriggers($step->doGetActivityStepTriggers($form["step_uid"],
$tempTreeChild['taskId'], $tempTreeChild['processId']));
$trigger = $this->statusTriggers($step->doGetActivityStepTriggers(
$form["step_uid"],
$tempTreeChild['taskId'],
$tempTreeChild['processId']
));
$newForm[$c]["triggers"] = $trigger;
$c++;
}
@@ -150,7 +157,9 @@ class Light
/**
* Get status trigger case
*
* @param $triggers
*
* @return array
*/
public function statusTriggers($triggers)
@@ -170,7 +179,9 @@ class Light
/**
* Get counters each type of list
*
* @param $userId
*
* @return array
* @throws Exception
*/
@@ -180,7 +191,7 @@ class Light
$userUid = (isset($userId) && $userId != '') ? $userId : null;
$oAppCache = new AppCacheView();
$aTypes = Array();
$aTypes = array();
$aTypes['to_do'] = 'toDo';
$aTypes['draft'] = 'draft';
$aTypes['cancelled'] = 'cancelled';
@@ -191,7 +202,7 @@ class Light
$aCount = $oAppCache->getAllCounters(array_keys($aTypes), $userUid);
$response = Array();
$response = array();
foreach ($aCount as $type => $count) {
$response[$aTypes[$type]] = $count;
}
@@ -204,6 +215,7 @@ class Light
/**
* @param $sAppUid
*
* @return Criteria
*/
public function getTransferHistoryCriteria($sAppUid)
@@ -219,7 +231,6 @@ class Light
///-- $c->addAsColumn('USR_NAME', "CONCAT(USR_LASTNAME, ' ', USR_FIRSTNAME)");
$sDataBase = 'database_' . strtolower(DB_ADAPTER);
if (G::LoadSystemExist($sDataBase)) {
$oDataBase = new database();
$c->addAsColumn('USR_NAME', $oDataBase->concatString("USR_LASTNAME", "' '", "USR_FIRSTNAME"));
$c->addAsColumn(
@@ -227,7 +238,8 @@ class Light
$oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'-'", AppDelegationPeer::DEL_FINISH_DATE)
);
$c->addAsColumn(
'APP_TYPE', $oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'IN_PROGRESS'", AppDelayPeer::APP_TYPE)
'APP_TYPE',
$oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'IN_PROGRESS'", AppDelayPeer::APP_TYPE)
);
}
$c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
@@ -260,6 +272,7 @@ class Light
* GET history of case
*
* @param $app_uid
*
* @return array
* @throws Exception
*/
@@ -268,7 +281,7 @@ class Light
//global $G_PUBLISH;
$c = $this->getTransferHistoryCriteria($app_uid);
$aProcesses = Array();
$aProcesses = array();
$rs = GulliverBasePeer::doSelectRs($c);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
@@ -298,6 +311,7 @@ class Light
* @param string $userId
* @param string $proUid
* @param string $taskUid
*
* @return array
* @throws Exception
*/
@@ -328,7 +342,8 @@ class Light
//Log
Bootstrap::registerMonolog('MobileCreateCase', 200, "Create case",
['application_uid' => $aData['APPLICATION'], 'usr_uid' => $userId], config("system.workspace"), 'processmaker.log');
['application_uid' => $aData['APPLICATION'], 'usr_uid' => $userId], config("system.workspace"),
'processmaker.log');
} catch (Exception $e) {
$response['status'] = 'failure';
$response['message'] = $e->getMessage();
@@ -370,7 +385,6 @@ class Light
}
return 1;
}
/**
@@ -404,8 +418,13 @@ class Light
$Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants());
$triggers = $oCase->loadTriggers($act_uid, 'DYNAFORM', $step_uid_obj, strtoupper($type));
if ($triggers) {
$Fields['APP_DATA'] = $oCase->ExecuteTriggers($act_uid, 'DYNAFORM', $step_uid_obj, strtoupper($type),
$Fields['APP_DATA']);
$Fields['APP_DATA'] = $oCase->ExecuteTriggers(
$act_uid,
'DYNAFORM',
$step_uid_obj,
strtoupper($type),
$Fields['APP_DATA']
);
}
$Fields['TAS_UID'] = $act_uid;
$Fields['CURRENT_DYNAFORM'] = $step_uid_obj;
@@ -438,8 +457,13 @@ class Light
$triggers = $oCase->loadTriggers($tas_uid, 'ASSIGN_TASK', '-1', 'BEFORE');
if (isset($triggers)) {
$Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants());
$Fields['APP_DATA'] = $oCase->ExecuteTriggers($tas_uid, 'DYNAFORM', '-1', 'BEFORE',
$Fields['APP_DATA']);
$Fields['APP_DATA'] = $oCase->ExecuteTriggers(
$tas_uid,
'DYNAFORM',
'-1',
'BEFORE',
$Fields['APP_DATA']
);
$oCase->updateCase($app_uid, $Fields);
}
$oDerivation = new \Derivation();
@@ -454,10 +478,16 @@ class Light
$sPriority = ''; //set priority value
if ($derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] != '') {
//TO DO: review this type of assignment
if (isset($aData['APP_DATA'][str_replace('@@', '',
$derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])])) {
$sPriority = $aData['APP_DATA'][str_replace('@@', '',
$derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])];
if (isset($aData['APP_DATA'][str_replace(
'@@',
'',
$derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE']
)])) {
$sPriority = $aData['APP_DATA'][str_replace(
'@@',
'',
$derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE']
)];
}
} //set priority value
@@ -545,10 +575,10 @@ class Light
* Route Case
*
* @param string $applicationUid Unique id of Case
* @param string $userUid Unique id of User
* @param string $userUid Unique id of User
* @param string $delIndex
* @param string $tasks
* @param boolean $executeTriggersBeforeAssignment
* @param array $tasks
* @param string $bExecuteTriggersBeforeAssignment
*
* return array Return an array with Task Case
*/
@@ -581,7 +611,8 @@ class Light
//Log
Bootstrap::registerMonolog('MobileRouteCase', 200, 'Route case',
['application_uid' => $applicationUid, 'usr_uid' => $userUid], config("system.workspace"), 'processmaker.log');
['application_uid' => $applicationUid, 'usr_uid' => $userUid], config("system.workspace"),
'processmaker.log');
} catch (Exception $e) {
throw $e;
}
@@ -593,7 +624,7 @@ class Light
* Get user Data
*
* @param string $applicationUid Unique id of Case
* @param string $userUid Unique id of User
* @param string $userUid Unique id of User
* @param string $delIndex
* @param string $bExecuteTriggersBeforeAssignment
*
@@ -668,8 +699,12 @@ class Light
case 'gif':
case 'png':
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
$arrayFiles[$key]['fileContent'] = base64_encode($this->imagesThumbnails($realPath, $ext,
$width, $height));
$arrayFiles[$key]['fileContent'] = base64_encode($this->imagesThumbnails(
$realPath,
$ext,
$width,
$height
));
break;
default:
$fileTmp = fopen($realPath, "r");
@@ -686,8 +721,12 @@ class Light
case 'gif':
case 'png':
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
$arrayFiles[$key]['fileContent'] = $this->imagesThumbnails($realPath1, $ext, $width,
$height);
$arrayFiles[$key]['fileContent'] = $this->imagesThumbnails(
$realPath1,
$ext,
$width,
$height
);
break;
default:
$fileTmp = fopen($realPath, "r");
@@ -709,10 +748,11 @@ class Light
/**
* resize image if send width or height
*
* @param $path
* @param $extensions
* @param $path
* @param $extensions
* @param null $newWidth
* @param null $newHeight
*
* @return string
*/
public function imagesThumbnails($path, $extensions, $newWidth = null, $newHeight = null)
@@ -814,7 +854,8 @@ class Light
session_start();
session_regenerate_id();
setcookie("workspaceSkin", SYS_SKIN, time() + (24 * 60 * 60), "/sys" . config("system.workspace"), null, false, true);
setcookie("workspaceSkin", SYS_SKIN, time() + (24 * 60 * 60), "/sys" . config("system.workspace"), null, false,
true);
if (strlen($msg) > 0) {
$_SESSION['G_MESSAGE'] = $msg;
@@ -829,9 +870,11 @@ class Light
/*----------------------------------********---------------------------------*/
$licenseManager =& PmLicenseManager::getSingleton();
if (in_array(md5($licenseManager->result),
array('38afd7ae34bd5e3e6fc170d8b09178a3', 'ba2b45bdc11e2a4a6e86aab2ac693cbb'))) {
$licenseManager = PmLicenseManager::getSingleton();
if (in_array(
md5($licenseManager->result),
array('38afd7ae34bd5e3e6fc170d8b09178a3', 'ba2b45bdc11e2a4a6e86aab2ac693cbb')
)) {
$G_PUBLISH = new \Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/licenseExpired', '', array(), 'licenseUpdate');
G::RenderPage('publish');
@@ -850,7 +893,6 @@ class Light
}
return $response;
}
/**
@@ -859,6 +901,7 @@ class Light
* @param $userUid
* @param $type
* @param $app_uid
*
* @throws Exception
*/
public function getInformation($userUid, $type, $app_uid)
@@ -894,6 +937,7 @@ class Light
* @param $userUid
* @param $Fields
* @param $type
*
* @throws Exception
*/
public function getInfoResume($userUid, $Fields, $type)
@@ -929,7 +973,8 @@ class Light
*
* @param string $userUid
* @param string $appUid
* @param array $requestData
* @param array $requestData
*
* @return array $response
* @throws Exception
*/
@@ -993,9 +1038,12 @@ class Light
$userInfo = '***';
if ($userUid !== '-1') {
$arrayUserData = $user->load($userUid);
$userInfo = $config->usersNameFormatBySetParameters($confEnvSetting["format"],
$arrayUserData["USR_USERNAME"], $arrayUserData["USR_FIRSTNAME"],
$arrayUserData["USR_LASTNAME"]);
$userInfo = $config->usersNameFormatBySetParameters(
$confEnvSetting["format"],
$arrayUserData["USR_USERNAME"],
$arrayUserData["USR_FIRSTNAME"],
$arrayUserData["USR_LASTNAME"]
);
}
$response[$k]['appDocCreateUser'] = $userInfo;
}
@@ -1011,6 +1059,7 @@ class Light
* @param $userUid
* @param $Fields
* @param $type
*
* @throws Exception
*/
public function documentUploadFiles($userUid, $app_uid, $app_doc_uid, $request_data)
@@ -1081,6 +1130,7 @@ class Light
* @param $userUid
* @param $Fields
* @param $type
*
* @throws Exception
*/
public function claimCaseUser($userUid, $sAppUid)
@@ -1134,6 +1184,7 @@ class Light
* @param $action
* @param $categoryUid
* @param $userUid
*
* @return array
* @throws PropelException
*/
@@ -1242,7 +1293,6 @@ class Light
*/
public function getUsersToReassign($usr_uid, $task_uid)
{
$memcache = PMmemcached::getSingleton(config("system.workspace"));
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
$RBAC->sSystem = 'PROCESSMAKER';
@@ -1326,6 +1376,7 @@ class Light
/**
* Get configuration
*
* @return mixed
*/
public function getConfiguration($params)
@@ -1334,15 +1385,18 @@ class Light
$multiTimeZone = false;
//Set Time Zone
/*----------------------------------********---------------------------------*/
if (\PMLicensedFeatures::getSingleton()->verifyfeature
('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
if (\PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
$multiTimeZone = (int)($sysConf['system_utc_time_zone']) == 1;
}
/*----------------------------------********---------------------------------*/
$tz = isset($_SESSION['USR_TIME_ZONE']) ? $_SESSION['USR_TIME_ZONE'] : $sysConf['time_zone'];
$offset = timezone_offset_get(new \DateTimeZone($tz), new \DateTime());
$response['timeZone'] = sprintf("GMT%s%02d:%02d", ($offset >= 0) ? '+' : '-', abs($offset / 3600),
abs(($offset % 3600) / 60));
$response['timeZone'] = sprintf(
"GMT%s%02d:%02d",
($offset >= 0) ? '+' : '-',
abs($offset / 3600),
abs(($offset % 3600) / 60)
);
$response['multiTimeZone'] = $multiTimeZone;
$fields = System::getSysInfo();
$response['version'] = $fields['PM_VERSION'];
@@ -1435,10 +1489,12 @@ class Light
/**
* This function check if the $data are in the corresponding cases list
*
* @param string $userUid
* @param array $data
* @param array $data
* @param string $listName
* @param string $action
*
* @return array $response
*/
public function getListCheck($userUid, $data, $listName = 'inbox', $action = 'todo')
@@ -1469,14 +1525,13 @@ class Light
foreach ($data as $key => $val) {
$flagRemoved = true;
foreach ($response['data'] as $row) {
$row = array_change_key_case($row,CASE_UPPER);
$row = array_change_key_case($row, CASE_UPPER);
if (isset($row['APP_UID']) && isset($row['DEL_INDEX'])) {
if ($val['caseId'] === $row['APP_UID'] && $val['delIndex'] === $row['DEL_INDEX'] ) {
if ($val['caseId'] === $row['APP_UID'] && $val['delIndex'] === $row['DEL_INDEX']) {
$flagRemoved = false;
continue;
}
}
}
if ($flagRemoved) {
$result[] = [

View File

@@ -1,14 +1,18 @@
<?php
namespace ProcessMaker\BusinessModel;
use \G;
use \Criteria;
use \UsersPeer;
use \PMLicensedFeatures;
/**
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
class Lists {
class Lists
{
/**
* @var array
@@ -82,17 +86,17 @@ class Lists {
* Get list for Cases
*
* @access public
* @param array $dataList, Data for list
* @param array $dataList , Data for list
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
*/
public function getList($listName = 'inbox', $dataList = array(), $total = false)
{
Validator::isArray($dataList, '$dataList');
if (!isset($dataList["userId"])) {
throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('userId',''))));
throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('userId', ''))));
} else {
Validator::usrUid($dataList["userId"], "userId");
}
@@ -156,7 +160,7 @@ class Lists {
$filters["start"] = (int)$filters["start"];
$filters["start"] = abs($filters["start"]);
if ($filters["start"] != 0) {
$filters["start"]+1;
$filters["start"] + 1;
}
$filters["limit"] = (int)$filters["limit"];
@@ -205,25 +209,25 @@ class Lists {
if (!empty($result)) {
foreach ($result as &$value) {
if (isset($value['DEL_PREVIOUS_USR_UID'])) {
$value['PREVIOUS_USR_UID'] = $value['DEL_PREVIOUS_USR_UID'];
$value['PREVIOUS_USR_USERNAME'] = $value['DEL_PREVIOUS_USR_USERNAME'];
$value['PREVIOUS_USR_UID'] = $value['DEL_PREVIOUS_USR_UID'];
$value['PREVIOUS_USR_USERNAME'] = $value['DEL_PREVIOUS_USR_USERNAME'];
$value['PREVIOUS_USR_FIRSTNAME'] = $value['DEL_PREVIOUS_USR_FIRSTNAME'];
$value['PREVIOUS_USR_LASTNAME'] = $value['DEL_PREVIOUS_USR_LASTNAME'];
$value['PREVIOUS_USR_LASTNAME'] = $value['DEL_PREVIOUS_USR_LASTNAME'];
}
if (isset($value['DEL_DUE_DATE'])) {
$value['DEL_TASK_DUE_DATE'] = $value['DEL_DUE_DATE'];
}
if (isset($value['APP_PAUSED_DATE'])) {
$value['APP_UPDATE_DATE'] = $value['APP_PAUSED_DATE'];
$value['APP_UPDATE_DATE'] = $value['APP_PAUSED_DATE'];
}
if (isset($value['DEL_CURRENT_USR_USERNAME'])) {
$value['USR_USERNAME'] = $value['DEL_CURRENT_USR_USERNAME'];
$value['USR_FIRSTNAME'] = $value['DEL_CURRENT_USR_FIRSTNAME'];
$value['USR_LASTNAME'] = $value['DEL_CURRENT_USR_LASTNAME'];
$value['APP_UPDATE_DATE'] = $value['DEL_DELEGATE_DATE'];
$value['USR_USERNAME'] = $value['DEL_CURRENT_USR_USERNAME'];
$value['USR_FIRSTNAME'] = $value['DEL_CURRENT_USR_FIRSTNAME'];
$value['USR_LASTNAME'] = $value['DEL_CURRENT_USR_LASTNAME'];
$value['APP_UPDATE_DATE'] = $value['DEL_DELEGATE_DATE'];
}
if (isset($value['APP_STATUS'])) {
$value['APP_STATUS_LABEL'] = G::LoadTranslation( "ID_{$value['APP_STATUS']}" );
$value['APP_STATUS_LABEL'] = G::LoadTranslation("ID_{$value['APP_STATUS']}");
}
@@ -233,19 +237,19 @@ class Lists {
$response = array();
if ($filters["paged"]) {
$filtersData = array();
$filtersData['start'] = $filters["start"];
$filtersData['limit'] = $filters["limit"];
$filtersData['sort'] = G::toLower($filters["sort"]);
$filtersData['dir'] = G::toLower($filters["dir"]);
$filtersData['cat_uid'] = $filters["category"];
$filtersData['pro_uid'] = $filters["process"];
$filtersData['search'] = $filters["search"];
$filtersData['date_from'] = $filters["dateFrom"];
$filtersData['date_to'] = $filters["dateTo"];
$response['filters'] = $filtersData;
$response['data'] = $result;
$filtersData['action'] = $filters["action"];
$response['totalCount'] = $list->getCountList($userUid, $filtersData);
$filtersData['start'] = $filters["start"];
$filtersData['limit'] = $filters["limit"];
$filtersData['sort'] = G::toLower($filters["sort"]);
$filtersData['dir'] = G::toLower($filters["dir"]);
$filtersData['cat_uid'] = $filters["category"];
$filtersData['pro_uid'] = $filters["process"];
$filtersData['search'] = $filters["search"];
$filtersData['date_from'] = $filters["dateFrom"];
$filtersData['date_to'] = $filters["dateTo"];
$response['filters'] = $filtersData;
$response['data'] = $result;
$filtersData['action'] = $filters["action"];
$response['totalCount'] = $list->getCountList($userUid, $filtersData);
} else {
$response = $result;
}
@@ -264,12 +268,12 @@ class Lists {
foreach ($list as $listObject => $item) {
switch ($listObject) {
case 'ListDraft':
$total = $this->$listObject->getCountList($userId, array('action'=>'draft'));
$total = $this->$listObject->getCountList($userId, array('action' => 'draft'));
array_push($response, (array('count' => $total, 'item' => $item)));
break;
/*----------------------------------********---------------------------------*/
case 'ListConsolidated':
$licensedFeatures = &\PMLicensedFeatures::getSingleton();
$licensedFeatures = PMLicensedFeatures::getSingleton();
if ($licensedFeatures->verifyfeature('7TTeDBQeWRoZTZKYjh4eFpYUlRDUUEyVERPU3FxellWank=')) {
$total = $this->$listObject->getCountList($userId);
array_push($response, (array('count' => $total, 'item' => $item)));
@@ -284,4 +288,4 @@ class Lists {
}
return $response;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
<?php
namespace ProcessMaker\BusinessModel;
use \G;
@@ -17,28 +18,28 @@ class ReportingIndicators
*
* return decimal value
*/
public function getHistoricData($indicatorUid, $initDate, $endDate, $periodicity, $language)
public function getHistoricData($indicatorUid, $initDate, $endDate, $periodicity, $language)
{
$retval = "";
$retval = "";
$calculator = new \IndicatorsCalculator();
$arr = $calculator->indicatorData($indicatorUid);
$indicator = $arr[0];
$processesId = $indicator['DAS_UID_PROCESS'];
$indicatorType = $indicator['DAS_IND_TYPE'];
switch ($indicatorType) {
case \ReportingIndicatorTypeEnum::PEI:
$retval = $calculator->peiHistoric($processesId, $initDate, $endDate, \ReportingPeriodicityEnum::fromValue($periodicity));
break;
case \ReportingIndicatorTypeEnum::UEI:
$retval = $calculator->ueiHistoric($processesId, $initDate, $endDate, \ReportingPeriodicityEnum::fromValue($periodicity));
break;
default:
throw new Exception("Can't retrive historic Data becasuse de indicator type " + $indicator['DAS_IND_TYPE'] + " has no operation associated.");
break;
}
$processesId = $indicator['DAS_UID_PROCESS'];
$indicatorType = $indicator['DAS_IND_TYPE'];
switch ($indicatorType) {
case \ReportingIndicatorTypeEnum::PEI:
$retval = $calculator->peiHistoric($processesId, $initDate, $endDate, \ReportingPeriodicityEnum::fromValue($periodicity));
break;
case \ReportingIndicatorTypeEnum::UEI:
$retval = $calculator->ueiHistoric($processesId, $initDate, $endDate, \ReportingPeriodicityEnum::fromValue($periodicity));
break;
default:
throw new Exception("Can't retrive historic Data becasuse de indicator type " + $indicator['DAS_IND_TYPE'] + " has no operation associated.");
break;
}
return $retval;
}
/**
* Lists tasks of a process and it's statistics (efficiency, average times, etc.)
@@ -50,24 +51,30 @@ class ReportingIndicators
*
* return decimal value
*/
public function getPeiCompleteData($indicatorUid, $compareDate, $measureDate, $language)
public function getPeiCompleteData($indicatorUid, $compareDate, $measureDate, $language)
{
$calculator = new \IndicatorsCalculator();
$processes = $calculator->peiProcesses($indicatorUid, $measureDate, $measureDate, $language);
$arr = $calculator->indicatorData($indicatorUid);
$indicator = $arr[0];
$processesId = $indicator['DAS_UID_PROCESS'];
$peiValue = current(reset($calculator->peiHistoric($processesId, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
$peiCost = current(reset($calculator->peiCostHistoric($processesId, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
$peiCompare = current(reset($calculator->peiHistoric($processesId, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE)));
$processesId = $indicator['DAS_UID_PROCESS'];
$peiValue = $calculator->peiHistoric($processesId, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE);
$peiValue = reset($peiValue);
$peiValue = current($peiValue);
$peiCost = $calculator->peiCostHistoric($processesId, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE);
$peiCost = reset($peiCost);
$peiCost = current($peiCost);
$peiCompare = $calculator->peiHistoric($processesId, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE);
$peiCompare = reset($peiCompare);
$peiCompare = current($peiCompare);
$retval = array(
"id" => $indicatorUid,
"efficiencyIndex" => $peiValue,
"efficiencyIndexToCompare" => $peiCompare,
"efficiencyVariation" => ($peiValue-$peiCompare),
"inefficiencyCost" => $peiCost,
"data"=>$processes);
$retval = array(
"id" => $indicatorUid,
"efficiencyIndex" => $peiValue,
"efficiencyIndexToCompare" => $peiCompare,
"efficiencyVariation" => ($peiValue - $peiCompare),
"inefficiencyCost" => $peiCost,
"data" => $processes);
return $retval;
}
@@ -81,25 +88,31 @@ class ReportingIndicators
*
* return decimal value
*/
public function getUeiCompleteData($indicatorUid, $compareDate, $measureDate,$language)
public function getUeiCompleteData($indicatorUid, $compareDate, $measureDate, $language)
{
$calculator = new \IndicatorsCalculator();
$groups = $calculator->ueiUserGroups($indicatorUid, $measureDate, $measureDate, $language);
//TODO think what if each indicators has a group or user subset assigned. Now are all
$ueiValue = current(reset($calculator->ueiHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
$ueiValue = $calculator->ueiHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE);
$ueiValue = reset($ueiValue);
$ueiValue = current($ueiValue);
$arrCost = $calculator->ueiUserGroups($indicatorUid, $measureDate, $measureDate, $language);
$ueiCost = current(reset($calculator->ueiCostHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
$ueiCompare = current(reset($calculator->ueiHistoric(null, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE)));
$ueiCost = $calculator->ueiCostHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE);
$ueiCost = reset($ueiCost);
$ueiCost = is_array($ueiCost) ? current($ueiCost) : $ueiCost;
$ueiCompare = $calculator->ueiHistoric(null, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE);
$ueiCompare = reset($ueiCompare);
$ueiCompare = current($ueiCompare);
$retval = array(
"id" => $indicatorUid,
"efficiencyIndex" => $ueiValue,
"efficiencyVariation" => ($ueiValue-$ueiCompare),
"inefficiencyCost" => $ueiCost,
"efficiencyIndexToCompare" => $ueiCompare,
"data"=>$groups);
$retval = array(
'id' => $indicatorUid,
'efficiencyIndex' => $ueiValue,
'efficiencyVariation' => $ueiValue - $ueiCompare,
'inefficiencyCost' => $ueiCost,
'efficiencyIndexToCompare' => $ueiCompare,
'data' => $groups);
return $retval;
}
@@ -154,27 +167,33 @@ class ReportingIndicators
$arr = $calculator->generalIndicatorData($indicatorId, $initDate, $endDate, \ReportingPeriodicityEnum::NONE);
$value = $arr[0]['value'];
$dataList1 = $calculator->
generalIndicatorData($indicatorId,
$initDate, $endDate,
\ReportingPeriodicityEnum::fromValue($arr[0]['frequency1Type']));
generalIndicatorData(
$indicatorId,
$initDate,
$endDate,
\ReportingPeriodicityEnum::fromValue($arr[0]['frequency1Type'])
);
$dataList2 = $calculator->
generalIndicatorData($indicatorId,
$initDate, $endDate,
\ReportingPeriodicityEnum::fromValue($arr[0]['frequency2Type']));
generalIndicatorData(
$indicatorId,
$initDate,
$endDate,
\ReportingPeriodicityEnum::fromValue($arr[0]['frequency2Type'])
);
$returnValue = array("index" => $value,
"graph1XLabel"=>$arr[0]['graph1XLabel'],
"graph1YLabel"=>$arr[0]['graph1YLabel'],
"graph2XLabel"=>$arr[0]['graph2XLabel'],
"graph2YLabel"=>$arr[0]['graph2YLabel'],
"graph1Type"=>$arr[0]['graph1Type'],
"graph2Type"=>$arr[0]['graph2Type'],
"frequency1Type"=>$arr[0]['frequency1Type'],
"frequency2Type"=>$arr[0]['frequency2Type'],
"graph1Data"=>$dataList1,
"graph2Data"=>$dataList2
);
"graph1XLabel" => $arr[0]['graph1XLabel'],
"graph1YLabel" => $arr[0]['graph1YLabel'],
"graph2XLabel" => $arr[0]['graph2XLabel'],
"graph2YLabel" => $arr[0]['graph2YLabel'],
"graph1Type" => $arr[0]['graph1Type'],
"graph2Type" => $arr[0]['graph2Type'],
"frequency1Type" => $arr[0]['frequency1Type'],
"frequency2Type" => $arr[0]['frequency2Type'],
"graph1Data" => $dataList1,
"graph2Data" => $dataList2
);
return $returnValue;
}
@@ -182,7 +201,7 @@ class ReportingIndicators
* Get list status indicator
*
* @access public
* @param array $options, Data for list
* @param array $options , Data for list
* @return array
*
* @author Marco Antonio Nina <marco.antonio.nina@colosa.com>
@@ -192,11 +211,10 @@ class ReportingIndicators
{
Validator::isArray($options, '$options');
$usrUid = isset( $options["usrUid"] ) ? $options["usrUid"] : "";
$usrUid = isset($options["usrUid"]) ? $options["usrUid"] : "";
$calculator = new \IndicatorsCalculator();
$result = $calculator->statusIndicator($usrUid);
return $result;
}
}

View File

@@ -45,35 +45,197 @@ use UsersRolesPeer;
class User
{
private $arrayFieldDefinition = array(
"USR_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrUid"),
"USR_FIRSTNAME" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrFirstname"),
"USR_LASTNAME" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrLastname"),
"USR_USERNAME" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrUsername"),
"USR_EMAIL" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrEmail"),
"USR_ADDRESS" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrAddress"),
"USR_ZIP_CODE" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrZipCode"),
"USR_COUNTRY" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrCountry"),
"USR_CITY" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrCity"),
"USR_LOCATION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrLocation"),
"USR_PHONE" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrPhone"),
"USR_POSITION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrPosition"),
"USR_REPLACED_BY" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrReplacedBy"),
"USR_DUE_DATE" => array("type" => "date", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrDueDate"),
"USR_CALENDAR" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrCalendar"),
"USR_STATUS" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("ACTIVE", "INACTIVE", "VACATION"), "fieldNameAux" => "usrStatus"),
"USR_ROLE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrRole"),
"USR_NEW_PASS" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrNewPass"),
"USR_UX" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("NORMAL", "SIMPLIFIED", "SWITCHABLE", "SINGLE"), "fieldNameAux" => "usrUx"),
"DEP_UID" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "depUid"),
"USR_BIRTHDAY" => array("type" => "date", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrBirthday"),
"USR_FAX" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrFax"),
"USR_CELLULAR" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrCellular"),
"USR_UID" => array(
"type" => "string",
"required" => false,
"empty" => false,
"defaultValues" => array(),
"fieldNameAux" => "usrUid"
),
"USR_FIRSTNAME" => array(
"type" => "string",
"required" => true,
"empty" => false,
"defaultValues" => array(),
"fieldNameAux" => "usrFirstname"
),
"USR_LASTNAME" => array(
"type" => "string",
"required" => true,
"empty" => false,
"defaultValues" => array(),
"fieldNameAux" => "usrLastname"
),
"USR_USERNAME" => array(
"type" => "string",
"required" => true,
"empty" => false,
"defaultValues" => array(),
"fieldNameAux" => "usrUsername"
),
"USR_EMAIL" => array(
"type" => "string",
"required" => true,
"empty" => false,
"defaultValues" => array(),
"fieldNameAux" => "usrEmail"
),
"USR_ADDRESS" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrAddress"
),
"USR_ZIP_CODE" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrZipCode"
),
"USR_COUNTRY" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrCountry"
),
"USR_CITY" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrCity"
),
"USR_LOCATION" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrLocation"
),
"USR_PHONE" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrPhone"
),
"USR_POSITION" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrPosition"
),
"USR_REPLACED_BY" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrReplacedBy"
),
"USR_DUE_DATE" => array(
"type" => "date",
"required" => true,
"empty" => false,
"defaultValues" => array(),
"fieldNameAux" => "usrDueDate"
),
"USR_CALENDAR" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrCalendar"
),
"USR_STATUS" => array(
"type" => "string",
"required" => true,
"empty" => false,
"defaultValues" => array("ACTIVE", "INACTIVE", "VACATION"),
"fieldNameAux" => "usrStatus"
),
"USR_ROLE" => array(
"type" => "string",
"required" => true,
"empty" => false,
"defaultValues" => array(),
"fieldNameAux" => "usrRole"
),
"USR_NEW_PASS" => array(
"type" => "string",
"required" => true,
"empty" => false,
"defaultValues" => array(),
"fieldNameAux" => "usrNewPass"
),
"USR_UX" => array(
"type" => "string",
"required" => false,
"empty" => false,
"defaultValues" => array("NORMAL", "SIMPLIFIED", "SWITCHABLE", "SINGLE"),
"fieldNameAux" => "usrUx"
),
"DEP_UID" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "depUid"
),
"USR_BIRTHDAY" => array(
"type" => "date",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrBirthday"
),
"USR_FAX" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrFax"
),
"USR_CELLULAR" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrCellular"
),
/*----------------------------------********---------------------------------*/
"USR_COST_BY_HOUR" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrCostByHour"),
"USR_UNIT_COST" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrUnitCost"),
"USR_COST_BY_HOUR" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrCostByHour"
),
"USR_UNIT_COST" => array(
"type" => "string",
"required" => false,
"empty" => true,
"defaultValues" => array(),
"fieldNameAux" => "usrUnitCost"
),
/*----------------------------------********---------------------------------*/
'USR_LOGGED_NEXT_TIME' => ['type' => 'int', 'required' => false, 'empty' => false, 'defaultValues' => [0, 1], 'fieldNameAux' => 'usrLoggedNextTime'],
'USR_TIME_ZONE' => ['type' => 'string', 'required' => false, 'empty' => true, 'defaultValues' => [], 'fieldNameAux' => 'usrTimeZone']
'USR_LOGGED_NEXT_TIME' => [
'type' => 'int',
'required' => false,
'empty' => false,
'defaultValues' => [0, 1],
'fieldNameAux' => 'usrLoggedNextTime'
],
'USR_TIME_ZONE' => [
'type' => 'string',
'required' => false,
'empty' => true,
'defaultValues' => [],
'fieldNameAux' => 'usrTimeZone'
]
);
private $formatFieldNameInUppercase = true;
@@ -148,7 +310,9 @@ class User
/**
* Set the format of the fields name (uppercase, lowercase)
*
* @param bool $flag Value that set the format
*
* @throws Exception
*/
public function setFormatFieldNameInUppercase($flag)
@@ -164,7 +328,9 @@ class User
/**
* Set exception users for fields
*
* @param array $arrayData Data with the fields
*
* @throws Exception
*/
public function setArrayFieldNameForException(array $arrayData)
@@ -180,7 +346,9 @@ class User
/**
* Get the name of the field according to the format
*
* @param string $fieldName Field name
*
* @return string Return the field name according the format
* @throws Exception
*/
@@ -195,8 +363,10 @@ class User
/**
* Verify if exists the Name of a User
* @param string $userName Name
*
* @param string $userName Name
* @param string $userUidToExclude Unique id of User to exclude
*
* @return bool Return true if exists the Name of a User, false otherwise
* @throws Exception
*/
@@ -223,16 +393,19 @@ class User
/**
* Verify if exists the Name of a User
* @param string $userName Name
*
* @param string $userName Name
* @param string $fieldNameForException Field name for the exception
* @param string $userUidToExclude Unique id of User to exclude
* @param string $userUidToExclude Unique id of User to exclude
*
* @throws Exception if exists the title of a User
*/
public function throwExceptionIfExistsName($userName, $fieldNameForException, $userUidToExclude = "")
{
try {
if ($this->existsName($userName, $userUidToExclude)) {
throw new Exception(G::LoadTranslation("ID_USER_NAME_ALREADY_EXISTS", array($fieldNameForException, $userName)));
throw new Exception(G::LoadTranslation("ID_USER_NAME_ALREADY_EXISTS",
array($fieldNameForException, $userName)));
}
} catch (Exception $e) {
throw $e;
@@ -241,8 +414,10 @@ class User
/**
* Verify password
* @param string $userPassword Password
*
* @param string $userPassword Password
* @param string $fieldNameForException Field name for the exception
*
* @throws Exception if password is invalid
*/
public function throwExceptionIfPasswordIsInvalid($userPassword, $fieldNameForException)
@@ -260,8 +435,10 @@ class User
/**
* Validate the data if they are invalid (INSERT and UPDATE)
* @param string $userUid Unique id of User
* @param array $arrayData Data
*
* @param string $userUid Unique id of User
* @param array $arrayData Data
*
* @throws Exception if data has an invalid value
*/
public function throwExceptionIfDataIsInvalid($userUid, array $arrayData)
@@ -276,11 +453,13 @@ class User
//Verify data - Field definition.
$process = new Process();
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert);
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition,
$this->arrayFieldNameForException, $flagInsert);
//Verify data
if (isset($arrayData["USR_USERNAME"])) {
$this->throwExceptionIfExistsName($arrayData["USR_USERNAME"], $this->arrayFieldNameForException["usrUsername"], $userUid);
$this->throwExceptionIfExistsName($arrayData["USR_USERNAME"],
$this->arrayFieldNameForException["usrUsername"], $userUid);
}
if (isset($arrayData["USR_EMAIL"])) {
@@ -290,14 +469,16 @@ class User
}
if (isset($arrayData["USR_NEW_PASS"])) {
$this->throwExceptionIfPasswordIsInvalid($arrayData["USR_NEW_PASS"], $this->arrayFieldNameForException["usrNewPass"]);
$this->throwExceptionIfPasswordIsInvalid($arrayData["USR_NEW_PASS"],
$this->arrayFieldNameForException["usrNewPass"]);
}
if (isset($arrayData["USR_REPLACED_BY"]) && $arrayData["USR_REPLACED_BY"] != "") {
$obj = UsersPeer::retrieveByPK($arrayData["USR_REPLACED_BY"]);
if (is_null($obj)) {
throw new Exception(G::LoadTranslation("ID_USER_DOES_NOT_EXIST", array($this->arrayFieldNameForException["usrReplacedBy"], $arrayData["USR_REPLACED_BY"])));
throw new Exception(G::LoadTranslation("ID_USER_DOES_NOT_EXIST",
array($this->arrayFieldNameForException["usrReplacedBy"], $arrayData["USR_REPLACED_BY"])));
}
}
@@ -322,7 +503,8 @@ class User
$rsCriteria = RolesPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR", array($this->arrayFieldNameForException["usrRole"])));
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR",
array($this->arrayFieldNameForException["usrRole"])));
}
}
@@ -330,31 +512,36 @@ class User
$obj = IsoCountryPeer::retrieveByPK($arrayData["USR_COUNTRY"]);
if (is_null($obj)) {
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR", array($this->arrayFieldNameForException["usrCountry"])));
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR",
array($this->arrayFieldNameForException["usrCountry"])));
}
}
if (isset($arrayData["USR_CITY"]) && $arrayData["USR_CITY"] != "") {
if (!isset($arrayFinalData["USR_COUNTRY"]) || $arrayFinalData["USR_COUNTRY"] == "") {
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR", array($this->arrayFieldNameForException["usrCountry"])));
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR",
array($this->arrayFieldNameForException["usrCountry"])));
}
$obj = IsoSubdivisionPeer::retrieveByPK($arrayFinalData["USR_COUNTRY"], $arrayData["USR_CITY"]);
if (is_null($obj)) {
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR", array($this->arrayFieldNameForException["usrCity"])));
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR",
array($this->arrayFieldNameForException["usrCity"])));
}
}
if (isset($arrayData["USR_LOCATION"]) && $arrayData["USR_LOCATION"] != "") {
if (!isset($arrayFinalData["USR_COUNTRY"]) || $arrayFinalData["USR_COUNTRY"] == "") {
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR", array($this->arrayFieldNameForException["usrCountry"])));
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR",
array($this->arrayFieldNameForException["usrCountry"])));
}
$obj = IsoLocationPeer::retrieveByPK($arrayFinalData["USR_COUNTRY"], $arrayData["USR_LOCATION"]);
if (is_null($obj)) {
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR", array($this->arrayFieldNameForException["usrLocation"])));
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR",
array($this->arrayFieldNameForException["usrLocation"])));
}
}
@@ -362,7 +549,8 @@ class User
$obj = CalendarDefinitionPeer::retrieveByPK($arrayData["USR_CALENDAR"]);
if (is_null($obj)) {
throw new Exception(G::LoadTranslation("ID_CALENDAR_DOES_NOT_EXIST", array($this->arrayFieldNameForException["usrCalendar"], $arrayData["USR_CALENDAR"])));
throw new Exception(G::LoadTranslation("ID_CALENDAR_DOES_NOT_EXIST",
array($this->arrayFieldNameForException["usrCalendar"], $arrayData["USR_CALENDAR"])));
}
}
@@ -370,13 +558,15 @@ class User
$department = new Department();
if (!$department->existsDepartment($arrayData["DEP_UID"])) {
throw new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array($this->arrayFieldNameForException["depUid"], $arrayData["DEP_UID"])));
throw new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST",
array($this->arrayFieldNameForException["depUid"], $arrayData["DEP_UID"])));
}
}
if (isset($arrayData['USR_TIME_ZONE']) && $arrayData['USR_TIME_ZONE'] != '') {
if (!in_array($arrayData['USR_TIME_ZONE'], DateTimeZone::listIdentifiers())) {
throw new Exception(G::LoadTranslation('ID_TIME_ZONE_DOES_NOT_EXIST', [$this->arrayFieldNameForException['usrTimeZone'], $arrayData['USR_TIME_ZONE']]));
throw new Exception(G::LoadTranslation('ID_TIME_ZONE_DOES_NOT_EXIST',
[$this->arrayFieldNameForException['usrTimeZone'], $arrayData['USR_TIME_ZONE']]));
}
}
} catch (Exception $e) {
@@ -386,8 +576,10 @@ class User
/**
* Verify if does not exist the User in table USERS
* @param string $userUid Unique id of Email Server
*
* @param string $userUid Unique id of Email Server
* @param string $fieldNameForException Field name for the exception
*
* @throws Exception if does not exist the User in table USERS
*/
public function throwExceptionIfNotExistsUser($userUid, $fieldNameForException)
@@ -396,7 +588,8 @@ class User
$obj = UsersPeer::retrieveByPK($userUid);
if (is_null($obj) || $obj->getUsrUsername() == "") {
throw new Exception(G::LoadTranslation("ID_USER_DOES_NOT_EXIST", array($fieldNameForException, $userUid)));
throw new Exception(G::LoadTranslation("ID_USER_DOES_NOT_EXIST",
array($fieldNameForException, $userUid)));
}
} catch (Exception $e) {
throw $e;
@@ -405,10 +598,13 @@ class User
/**
* Get User record
* @param string $userUid Unique id of User
* @param array $arrayVariableNameForException Variable name for exception
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
* (TRUE: throw the exception; FALSE: returns FALSE)
*
* @param string $userUid Unique id of User
* @param array $arrayVariableNameForException Variable name for exception
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or
* do not exist
* (TRUE: throw the exception; FALSE: returns FALSE)
*
* @return array|bool Returns an array with User record, ThrowTheException/FALSE otherwise
* @throws Exception
*/
@@ -437,7 +633,9 @@ class User
/**
* Get custom record
*
* @param array $record Record
*
* @return array Return an array with custom record
* @throws Exception
*/
@@ -504,6 +702,7 @@ class User
/**
* Get criteria for User
*
* @return object
* @throws Exception
*/
@@ -553,7 +752,9 @@ class User
/**
* Create User
*
* @param array $arrayData Data
*
* @return array Return data of the new User created
* @throws Exception
*/
@@ -617,7 +818,8 @@ class User
//User Properties
$userProperty = new UsersProperties();
$aUserProperty = $userProperty->loadOrCreateIfNotExists($arrayData["USR_UID"], array("USR_PASSWORD_HISTORY" => serialize(array(Bootstrap::hashPassword($arrayData["USR_PASSWORD"])))));
$aUserProperty = $userProperty->loadOrCreateIfNotExists($arrayData["USR_UID"],
array("USR_PASSWORD_HISTORY" => serialize(array(Bootstrap::hashPassword($arrayData["USR_PASSWORD"])))));
$aUserProperty["USR_LOGGED_NEXT_TIME"] = $arrayData["USR_LOGGED_NEXT_TIME"];
$userProperty->update($aUserProperty);
@@ -644,9 +846,11 @@ class User
/**
* Update User
* @param string $userUid Unique id of User
* @param array $arrayData Data
*
* @param string $userUid Unique id of User
* @param array $arrayData Data
* @param string $userUidLogged Unique id of User logged
*
* @return array data of the User updated
* @throws Exception
*/
@@ -731,13 +935,13 @@ class User
if (isset($arrayData["USR_PASSWORD"])) {
if ($arrayData["USR_PASSWORD"] != "") {
//require_once 'classes/model/UsersProperties.php';
$userProperty = new UsersProperties();
$aUserProperty = $userProperty->loadOrCreateIfNotExists($userUid, array("USR_PASSWORD_HISTORY" => serialize(array(Bootstrap::hashPassword($arrayData["USR_PASSWORD"])))));
$aUserProperty = $userProperty->loadOrCreateIfNotExists($userUid,
array("USR_PASSWORD_HISTORY" => serialize(array(Bootstrap::hashPassword($arrayData["USR_PASSWORD"])))));
$memKey = "rbacSession" . session_id();
$memcache = &PMmemcached::getSingleton(!empty(config("system.workspace")) ? config("system.workspace") : "");
$memcache = PMmemcached::getSingleton(!empty(config("system.workspace")) ? config("system.workspace") : "");
if (($rbac->aUserInfo = $memcache->get($memKey)) == false) {
$rbac->loadUserRolePermission("PROCESSMAKER", $userUidLogged);
@@ -803,7 +1007,8 @@ class User
$oUser = new Users();
$aUser = $oUser->load($userUid);
$oUserProperty = new UsersProperties();
$aUserProperty = $oUserProperty->loadOrCreateIfNotExists($userUid, array("USR_PASSWORD_HISTORY" => serialize(array($oUser->getUsrPassword()))));
$aUserProperty = $oUserProperty->loadOrCreateIfNotExists($userUid,
array("USR_PASSWORD_HISTORY" => serialize(array($oUser->getUsrPassword()))));
$aUserProperty["USR_LOGGED_NEXT_TIME"] = $arrayData["USR_LOGGED_NEXT_TIME"];
$oUserProperty->update($aUserProperty);
}
@@ -847,8 +1052,10 @@ class User
/**
* Get data of a User
* @param string $userUid Unique id of User
* @param bool $flagGetRecord Value that set the getting
*
* @param string $userUid Unique id of User
* @param bool $flagGetRecord Value that set the getting
*
* @return array Return an array with data of a User
* @throws Exception
*/
@@ -881,7 +1088,9 @@ class User
/**
* Create User Uid
*
* @param array $userData Data
*
* @return int
* @throws Exception
*/
@@ -917,8 +1126,10 @@ class User
* to put role an user
*
* @access public
*
* @param string $sUserUID
* @param string $sRolCode
*
* @return void
*/
public function assignRoleToUser($sUserUID = '', $sRolCode = '')
@@ -933,7 +1144,9 @@ class User
* to test Password
*
* @access public
*
* @param string $sPassword
*
* @return array
*/
public function testPassword($sPassword = '')
@@ -979,7 +1192,9 @@ class User
/**
* change status of an user
*
* @access public
*
* @param string $sUserUID
* @param string $sStatus
*/
@@ -998,7 +1213,9 @@ class User
* remove a role from an user
*
* @access public
*
* @param string $sUserUID
*
* @return void
*/
public function removeRolesFromUser($sUserUID = '')
@@ -1012,8 +1229,10 @@ class User
* updated an user
*
* @access public
* @param array $userData
*
* @param array $userData
* @param string $sRolCode
*
* @return void
*/
public function updateUser($userData = array(), $sRolCode = '')
@@ -1040,7 +1259,8 @@ class User
* @access public
*
* @param string $sSystem the system
* @param string $sUser the user
* @param string $sUser the user
*
* @return $this->aUserInfo[ $sSystem ]
*/
public function loadUserRolePermission($sSystem, $sUser)
@@ -1063,7 +1283,9 @@ class User
/**
* Authenticate User
*
* @param array $arrayUserData Data
*
* @throws Exception
*/
public function authenticate($arrayUserData)
@@ -1076,7 +1298,9 @@ class User
/**
* Delete User
*
* @param string $usrUid Unique id of User
*
* @throws Exception
*/
public function delete($usrUid)
@@ -1134,15 +1358,17 @@ class User
/**
* Get all Users
* @param array $arrayWhere Where (Condition and filters)
* @param string $sortField Field name to sort
* @param string $sortDir Direction of sorting (ASC, DESC)
* @param int $start Start
* @param int $limit Limit
* @param bool $flagRecord Flag that set the "getting" of record
* @param bool $throwException Flag to throw the exception (This only if the parameters are invalid)
*
* @param array $arrayWhere Where (Condition and filters)
* @param string $sortField Field name to sort
* @param string $sortDir Direction of sorting (ASC, DESC)
* @param int $start Start
* @param int $limit Limit
* @param bool $flagRecord Flag that set the "getting" of record
* @param bool $throwException Flag to throw the exception (This only if the parameters are invalid)
* (TRUE: throw the exception; FALSE: returns FALSE)
* @param string $status The user's status, which can be "ACTIVE", "INACTIVE" or "VACATION"
* @param string $status The user's status, which can be "ACTIVE", "INACTIVE" or "VACATION"
*
* @return array Return an array with all Users, ThrowTheException/FALSE otherwise
* @throws Exception
*/
@@ -1299,7 +1525,9 @@ class User
/**
* Upload image User
*
* @param string $userUid Unique id of User
*
* @throws Exception
*/
public function uploadImage($userUid)
@@ -1313,14 +1541,17 @@ class User
}
if (!isset($_FILES["USR_PHOTO"])) {
throw new Exception(G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->arrayFieldNameForException["usrPhoto"])));
throw new Exception(G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED",
array($this->arrayFieldNameForException["usrPhoto"])));
}
if ($_FILES['USR_PHOTO']['error'] != 1) {
if ($_FILES['USR_PHOTO']['tmp_name'] != '') {
$aAux = explode('.', $_FILES['USR_PHOTO']['name']);
G::uploadFile($_FILES['USR_PHOTO']['tmp_name'], PATH_IMAGES_ENVIRONMENT_USERS, $userUid . '.' . $aAux[1]);
G::resizeImage(PATH_IMAGES_ENVIRONMENT_USERS . $userUid . '.' . $aAux[1], 96, 96, PATH_IMAGES_ENVIRONMENT_USERS . $userUid . '.gif');
G::uploadFile($_FILES['USR_PHOTO']['tmp_name'], PATH_IMAGES_ENVIRONMENT_USERS,
$userUid . '.' . $aAux[1]);
G::resizeImage(PATH_IMAGES_ENVIRONMENT_USERS . $userUid . '.' . $aAux[1], 96, 96,
PATH_IMAGES_ENVIRONMENT_USERS . $userUid . '.gif');
}
} else {
throw new Exception(G::LoadTranslation('ID_ERROR') . ' ' . $_FILES['USR_PHOTO']['error']);
@@ -1334,9 +1565,11 @@ class User
* change Bookmarks of an user
*
* @access public
*
* @param $userUID
* @param $tasUid
* @param $type
*
* @return void
*/
public function updateBookmark($userUID, $tasUid, $type)
@@ -1356,8 +1589,9 @@ class User
}
/**
* @param $userUid
* @param $userUid
* @param array $arrayPermission
*
* @return User
* @throws Exception
*/
@@ -1378,6 +1612,7 @@ class User
/**
* @param $aFields
*
* @return array
* @throws Exception
*/
@@ -1395,7 +1630,8 @@ class User
return $resultPermissionsForUser;
} else {
$lang = defined('SYS_LANG') ? SYS_LANG : 'en';
throw (new Exception(G::LoadTranslation("ID_USER_UID_DOESNT_EXIST", $lang, array("USR_UID" => $aFields['USR_UID']))));
throw (new Exception(G::LoadTranslation("ID_USER_UID_DOESNT_EXIST", $lang,
array("USR_UID" => $aFields['USR_UID']))));
}
} catch (Exception $oError) {
throw ($oError);
@@ -1404,8 +1640,10 @@ class User
/**
* Check permission
* @param string $userUid Unique uid of User
*
* @param string $userUid Unique uid of User
* @param string $permissionCode Permission code
*
* @return bool
* @throws Exception
*/
@@ -1432,6 +1670,7 @@ class User
/**
* Get User-Logged Time Zone
*
* @return string Return the User-Logged Time Zone; Time Zone system settings otherwise
* @throws Exception
*/
@@ -1455,9 +1694,11 @@ class User
/**
* Get the User's Manager
* @param string $userUid Unique id of User
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
*
* @param string $userUid Unique id of User
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
* (TRUE: throw the exception; FALSE: returns FALSE)
*
* @return string Returns an string with Unique id of User (Manager), ThrowTheException/FALSE otherwise
* @throws Exception
*/
@@ -1520,25 +1761,34 @@ class User
/**
* AuditLog
* @param string $option Option
* @param array $arrayData Data
*
* @param string $option Option
* @param array $arrayData Data
*
* @throws Exception
*/
public function auditLog($option, array $arrayData)
{
try {
$firstName = (array_key_exists('USR_FIRSTNAME', $arrayData)) ? ' - First Name: ' . $arrayData['USR_FIRSTNAME'] : '';
$lastName = (array_key_exists('USR_LASTNAME', $arrayData)) ? ' - Last Name: ' . $arrayData['USR_LASTNAME'] : '';
$firstName = (array_key_exists('USR_FIRSTNAME',
$arrayData)) ? ' - First Name: ' . $arrayData['USR_FIRSTNAME'] : '';
$lastName = (array_key_exists('USR_LASTNAME',
$arrayData)) ? ' - Last Name: ' . $arrayData['USR_LASTNAME'] : '';
$email = (array_key_exists('USR_EMAIL', $arrayData)) ? ' - Email: ' . $arrayData['USR_EMAIL'] : '';
$dueDate = (array_key_exists('USR_DUE_DATE', $arrayData)) ? ' - Due Date: ' . $arrayData['USR_DUE_DATE'] : '';
$dueDate = (array_key_exists('USR_DUE_DATE',
$arrayData)) ? ' - Due Date: ' . $arrayData['USR_DUE_DATE'] : '';
$status = (array_key_exists('USR_STATUS', $arrayData)) ? ' - Status: ' . $arrayData['USR_STATUS'] : '';
$address = (array_key_exists('USR_ADDRESS', $arrayData)) ? ' - Address: ' . $arrayData['USR_ADDRESS'] : '';
$phone = (array_key_exists('USR_PHONE', $arrayData)) ? ' - Phone: ' . $arrayData['USR_PHONE'] : '';
$zipCode = (array_key_exists('USR_ZIP_CODE', $arrayData)) ? ' - Zip Code: ' . $arrayData['USR_ZIP_CODE'] : '';
$position = (array_key_exists('USR_POSITION', $arrayData)) ? ' - Position: ' . $arrayData['USR_POSITION'] : '';
$zipCode = (array_key_exists('USR_ZIP_CODE',
$arrayData)) ? ' - Zip Code: ' . $arrayData['USR_ZIP_CODE'] : '';
$position = (array_key_exists('USR_POSITION',
$arrayData)) ? ' - Position: ' . $arrayData['USR_POSITION'] : '';
$role = (array_key_exists('USR_ROLE', $arrayData)) ? ' - Role: ' . $arrayData['USR_ROLE'] : '';
$languageDef = (array_key_exists('USR_DEFAULT_LANG', $arrayData)) ? ' - Default Language: ' . $arrayData['USR_DEFAULT_LANG'] : '';
$timeZone = (array_key_exists('USR_TIME_ZONE', $arrayData)) ? ' - Time Zone: ' . $arrayData['USR_TIME_ZONE'] : '';
$languageDef = (array_key_exists('USR_DEFAULT_LANG',
$arrayData)) ? ' - Default Language: ' . $arrayData['USR_DEFAULT_LANG'] : '';
$timeZone = (array_key_exists('USR_TIME_ZONE',
$arrayData)) ? ' - Time Zone: ' . $arrayData['USR_TIME_ZONE'] : '';
$str = 'User Name: ' . $arrayData['USR_USERNAME'] . ' - User ID: (' . $arrayData['USR_UID'] . ')' .
$firstName . $lastName . $email . $dueDate . $status . $address . $phone . $zipCode . $position . $role . $timeZone . $languageDef;
@@ -1551,12 +1801,14 @@ class User
/**
* This function get the list of users
*
* @param string $authSource , authentication source
* @param string $filter
* @param string $sort
* @param int $start
* @param int $limit
* @param string $dir related to order the column
* @param int $start
* @param int $limit
* @param string $dir related to order the column
*
* @return array
* @throws Exception
*/
@@ -1579,7 +1831,8 @@ class User
$cc = $oCriteria->getNewCriterion(UsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE)
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE)
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_LASTNAME, '%' . $filter . '%', Criteria::LIKE)
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_EMAIL, '%' . $filter . '%', Criteria::LIKE))));
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_EMAIL, '%' . $filter . '%',
Criteria::LIKE))));
$oCriteria->add($cc);
}
$oCriteria->add(UsersPeer::USR_STATUS, array('CLOSED'), Criteria::NOT_IN);
@@ -1622,7 +1875,8 @@ class User
$cc = $oCriteria->getNewCriterion(UsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE)
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE)
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_LASTNAME, '%' . $filter . '%', Criteria::LIKE)
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_EMAIL, '%' . $filter . '%', Criteria::LIKE))));
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_EMAIL, '%' . $filter . '%',
Criteria::LIKE))));
$oCriteria->add($cc);
}
if (sizeof($aUsers) > 0) {

View File

@@ -1,4 +1,5 @@
<?php
namespace ProcessMaker\BusinessModel;
use G;
@@ -15,7 +16,7 @@ class Variable
* Create Variable for a Process
*
* @param string $processUid Unique id of Process
* @param array $arrayData Data
* @param array $arrayData Data
*
* @return array, return data of the new Variable created
* @throws Exception
@@ -44,13 +45,13 @@ class Variable
if (isset($arrayData["VAR_NAME"])) {
$variable->setVarName($arrayData["VAR_NAME"]);
} else {
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_name' )));
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_name')));
}
if (isset($arrayData["VAR_FIELD_TYPE"])) {
$arrayData["VAR_FIELD_TYPE"] = $this->validateVarFieldType($arrayData["VAR_FIELD_TYPE"]);
$variable->setVarFieldType($arrayData["VAR_FIELD_TYPE"]);
} else {
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_field_type' )));
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_field_type')));
}
if (isset($arrayData["VAR_FIELD_SIZE"])) {
$variable->setVarFieldSize($arrayData["VAR_FIELD_SIZE"]);
@@ -58,7 +59,7 @@ class Variable
if (isset($arrayData["VAR_LABEL"])) {
$variable->setVarLabel($arrayData["VAR_LABEL"]);
} else {
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_label' )));
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_label')));
}
if (isset($arrayData["VAR_DBCONNECTION"])) {
$variable->setVarDbconnection($arrayData["VAR_DBCONNECTION"]);
@@ -88,16 +89,14 @@ class Variable
$variable->save();
$cnn->commit();
} else {
$msg = "";
foreach ($variable->getValidationFailures() as $validationFailure) {
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
$msg = $msg . (($msg != "") ? "\n" : "") . $validationFailure->getMessage();
}
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . "\n" . $msg);
}
} catch (Exception $e) {
$cnn->rollback();
@@ -108,7 +107,6 @@ class Variable
$variable = $this->getVariable($processUid, $sPkProcessVariables);
return $variable;
} catch (Exception $e) {
throw $e;
}
@@ -119,7 +117,7 @@ class Variable
*
* @param string $processUid Unique id of Process
* @param string $variableUid Unique id of Variable
* @param array $arrayData Data
* @param array $arrayData Data
*
* @return array,return data of the Variable updated
* @throws Exception
@@ -199,16 +197,14 @@ class Variable
$pmDynaform = new PmDynaform();
$pmDynaform->synchronizeVariable($processUid, $newVariable, $oldVariable);
} else {
$msg = "";
foreach ($variable->getValidationFailures() as $validationFailure) {
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
$msg = $msg . (($msg != "") ? "\n" : "") . $validationFailure->getMessage();
}
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . "\n" . $msg);
}
} catch (Exception $e) {
$cnn->rollback();
@@ -241,14 +237,13 @@ class Variable
$pmDynaform = new PmDynaform();
$isUsed = $pmDynaform->isUsed($processUid, $variable);
if ($isUsed !== false) {
$titleDynaform=$pmDynaform->getDynaformTitle($isUsed);
$titleDynaform = $pmDynaform->getDynaformTitle($isUsed);
throw new Exception(G::LoadTranslation("ID_VARIABLE_IN_USE", array($titleDynaform)));
}
//Delete
$criteria = new \Criteria("workflow");
$criteria->add(\ProcessVariablesPeer::VAR_UID, $variableUid);
\ProcessVariablesPeer::doDelete($criteria);
} catch (Exception $e) {
throw $e;
}
@@ -295,10 +290,11 @@ class Variable
$rsCriteria->next();
$arrayVariables = array();
while ($aRow = $rsCriteria->getRow()) {
$VAR_ACCEPTED_VALUES = G::json_decode($aRow['VAR_ACCEPTED_VALUES'], true);
if(sizeof($VAR_ACCEPTED_VALUES)) {
$encodeAcceptedValues = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", G::json_encode($VAR_ACCEPTED_VALUES));
if (count($VAR_ACCEPTED_VALUES)) {
$encodeAcceptedValues = preg_replace_callback("/\\\\u([a-f0-9]{4})/", function ($m) {
return iconv('UCS-4LE', 'UTF-8', pack('V', hexdec('U' . $m[1])));
}, G::json_encode($VAR_ACCEPTED_VALUES));
} else {
$encodeAcceptedValues = $aRow['VAR_ACCEPTED_VALUES'];
}
@@ -320,9 +316,8 @@ class Variable
}
//Return
return $arrayVariables;
} catch (Exception $e) {
throw $e;
throw $e;
}
}
@@ -366,10 +361,11 @@ class Variable
$rsCriteria->next();
$arrayVariables = array();
while ($aRow = $rsCriteria->getRow()) {
$VAR_ACCEPTED_VALUES = G::json_decode($aRow['VAR_ACCEPTED_VALUES'], true);
if(sizeof($VAR_ACCEPTED_VALUES)) {
$encodeAcceptedValues = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", G::json_encode($VAR_ACCEPTED_VALUES));
if (count($VAR_ACCEPTED_VALUES)) {
$encodeAcceptedValues = preg_replace_callback("/\\\\u([a-f0-9]{4})/", function ($m) {
return iconv('UCS-4LE', 'UTF-8', pack('V', hexdec($m[1])));
}, G::json_encode($VAR_ACCEPTED_VALUES));
} else {
$encodeAcceptedValues = $aRow['VAR_ACCEPTED_VALUES'];
}
@@ -391,7 +387,6 @@ class Variable
}
//Return
return $arrayVariables;
} catch (Exception $e) {
throw $e;
}
@@ -430,8 +425,8 @@ class Variable
}
if (isset($aData["VAR_NULL"])) {
Validator::isInteger($aData['VAR_NULL'], '$var_null');
if ($aData["VAR_NULL"] != 0 && $aData["VAR_NULL"] !=1 ) {
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES", array('$var_null','0, 1' )));
if ($aData["VAR_NULL"] != 0 && $aData["VAR_NULL"] != 1) {
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES", array('$var_null', '0, 1')));
}
}
} catch (Exception $e) {
@@ -442,8 +437,8 @@ class Variable
/**
* Verify if exists the name of a variable
*
* @param string $processUid, unique id of Process
* @param string $variableName, name of variable
* @param string $processUid , unique id of Process
* @param string $variableName , name of variable
* @param string $variableUidToExclude
* @throws Exception
*
@@ -502,9 +497,9 @@ class Variable
/**
* Verify if some required variable in the SQL is missing in the variables
*
* @param string $variableName Variable name
* @param string $variableSql SQL
* @param array $arrayVariable The variables
* @param string $variableName Variable name
* @param string $variableSql SQL
* @param array $arrayVariable The variables
*
* @return void Throw exception if some required variable in the SQL is missing in the variables
* @throws Exception
@@ -524,9 +519,9 @@ class Variable
/**
* Get all records by execute SQL
*
* @param string $processUid Unique id of Process
* @param string $variableName Variable name
* @param array $arrayVariable The variables
* @param string $processUid Unique id of Process
* @param string $variableName Variable name
* @param array $arrayVariable The variables
*
* @return array, return an array with all records
* @throws Exception
@@ -543,7 +538,7 @@ class Variable
/**
* Verify if does not exist the variable in table PROCESS_VARIABLES
*
* @param string $variableUid Unique id of variable
* @param string $variableUid Unique id of variable
*
* @return void
* @throws Exception, throw exception if does not exist the variable in table PROCESS_VARIABLES
@@ -554,7 +549,7 @@ class Variable
$obj = \ProcessVariablesPeer::retrieveByPK($variableUid);
if (is_null($obj)) {
throw new Exception('var_uid: '.$variableUid. ' '.G::LoadTranslation("ID_DOES_NOT_EXIST"));
throw new Exception('var_uid: ' . $variableUid . ' ' . G::LoadTranslation("ID_DOES_NOT_EXIST"));
}
} catch (Exception $e) {
throw $e;
@@ -593,8 +588,8 @@ class Variable
/**
* Verify if the variable is being used in a Dynaform
*
* @param string $processUid, Unique id of Process
* @param string $variableUid, Unique id of Variable
* @param string $processUid , Unique id of Process
* @param string $variableUid , Unique id of Variable
* @return void
* @throws Exception
*
@@ -602,7 +597,6 @@ class Variable
public function verifyUse($processUid, $variableUid)
{
try {
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\DynaformPeer::DYN_CONTENT);
$criteria->addSelectColumn(\DynaformPeer::DYN_UID);
@@ -633,7 +627,6 @@ class Variable
}
}
}
} catch (Exception $e) {
throw $e;
}
@@ -642,9 +635,9 @@ class Variable
/**
* Get all records by execute SQL suggest
*
* @param string $processUid Unique id of Process
* @param string $variableName Variable name
* @param array $arrayVariable The variables
* @param string $processUid Unique id of Process
* @param string $variableName Variable name
* @param array $arrayVariable The variables
*
* @return array, return an array with all records
* @throws Exception
@@ -674,7 +667,7 @@ class Variable
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
if ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
return sizeof($row) ? $row : false;
return count($row) ? $row : false;
}
return false;
} catch (Exception $e) {
@@ -685,10 +678,10 @@ class Variable
/**
* Get Variable record by name
*
* @param string $projectUid Unique id of Project
* @param string $variableName Variable name
* @param array $arrayVariableNameForException Variable name for exception
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
* @param string $projectUid Unique id of Project
* @param string $variableName Variable name
* @param array $arrayVariableNameForException Variable name for exception
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
* (TRUE: throw the exception; FALSE: returns FALSE)
*
* @return array, returns an array with Variable record
@@ -699,7 +692,8 @@ class Variable
$variableName,
array $arrayVariableNameForException,
$throwException = true
) {
)
{
try {
$criteria = new \Criteria('workflow');
$criteria->add(\ProcessVariablesPeer::PRJ_UID, $projectUid, \Criteria::EQUAL);
@@ -711,7 +705,7 @@ class Variable
} else {
if ($throwException) {
throw new Exception(
$arrayVariableNameForException['$variableName'] . ': ' . $variableName. ' ' .
$arrayVariableNameForException['$variableName'] . ': ' . $variableName . ' ' .
G::LoadTranslation('ID_DOES_NOT_EXIST')
);
} else {
@@ -729,23 +723,23 @@ class Variable
public function validateVarFieldType($type)
{
$vType = strtolower($type);
if(!in_array($vType, $this->variableTypes)) {
if (!in_array($vType, $this->variableTypes)) {
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED"));
}
return $vType;
}
/**
* Executes the sql string of a control and returns the data in the queryOutputData
* property of the control. The control returned by the pmDynaform :: searchField
* function is the php representation of the json definition, which can be
* Executes the sql string of a control and returns the data in the queryOutputData
* property of the control. The control returned by the pmDynaform :: searchField
* function is the php representation of the json definition, which can be
* supported by the pmDynaform :: jsonr function.
* The params parameter must contain: dyn_uid, field_id and optionally
* app_uid, del_index, filter, start, limit, and so many related control variables
* to be sent and their corresponding value.
* The parameters: filter, start and limit, are only necessary for the suggest
* The params parameter must contain: dyn_uid, field_id and optionally
* app_uid, del_index, filter, start, limit, and so many related control variables
* to be sent and their corresponding value.
* The parameters: filter, start and limit, are only necessary for the suggest
* control.
* If app_uid is not sent you can not get the appData in an environment where
* If app_uid is not sent you can not get the appData in an environment where
* only endPoint is used, it is always advisable to send the app_uid and _index.
* Note: You do not get triguer execution values where only endPoint is used.
* @param type $proUid
@@ -756,7 +750,7 @@ class Variable
public function executeSqlControl($proUid, array $params = array())
{
try {
//Get and clear vector data that does not correspond to variables
//Get and clear vector data that does not correspond to variables
//related to a control.
$dynUid = $params["dyn_uid"];
$fieldId = $params["field_id"];
@@ -764,7 +758,7 @@ class Variable
$start = isset($params["start"]) ? $params["start"] : 0;
$limit = isset($params["limit"]) ? $params["limit"] : 10;
$appUid = empty($params["app_uid"]) ? null : $params["app_uid"];
$delIndex = (int) isset($params["del_index"]) ? $params["del_index"] : 0;
$delIndex = (int)isset($params["del_index"]) ? $params["del_index"] : 0;
unset($params["dyn_uid"]);
unset($params["field_id"]);
unset($params["app_uid"]);
@@ -791,7 +785,7 @@ class Variable
$pmDynaform = new PmDynaform(array("APP_DATA" => $params));
//Get control from dynaform.
//The parameters: queryFilter, queryStart, queryLimit, are only necessary
//The parameters: queryFilter, queryStart, queryLimit, are only necessary
//for the suggest control, the rest of the controls are ignored.
$field = $pmDynaform->searchField($dynUid, $fieldId, $proUid);
$field->queryField = true;
@@ -800,8 +794,8 @@ class Variable
$field->queryStart = $start;
$field->queryLimit = $limit;
//Grids only access the global variables of 'ProcessMaker', other variables are removed.
//The property 'columnWidth' is only present in the controls of a grid,
//in the current change there is no specific property that indicates
//The property 'columnWidth' is only present in the controls of a grid,
//in the current change there is no specific property that indicates
//if the control is in the grid.
if (isset($field->columnWidth)) {
$pmDynaform->fields["APP_DATA"] = $globalVariables;
@@ -821,5 +815,4 @@ class Variable
throw $e;
}
}
}

View File

@@ -10,11 +10,10 @@ use G;
class Installer
{
public $options = Array();
public $result = Array();
public $error = Array();
public $report = Array();
public $options = [];
public $result = [];
public $error = [];
public $report = [];
private $connection_database;
/**
@@ -34,14 +33,14 @@ class Installer
* @param boolean $confirmed
* @return void
*/
public function create_site($config = Array(), $confirmed = false)
public function create_site($config = array(), $confirmed = false)
{
$this->options = G::array_concat(Array('isset' => false, 'password' => G::generate_password(15), 'path_data' => @PATH_DATA, 'path_compiled' => @PATH_C, 'name' => $config['name'], 'database' => Array(), 'admin' => Array('username' => 'admin', 'password' => 'admin'
), 'advanced' => Array('ao_db_wf' => 'wf_' . $config['name'], 'ao_db_rb' => 'rb_' . $config['name'], 'ao_db_rp' => 'rp_' . $config['name'], 'ao_db_drop' => false
$this->options = G::array_concat(array('isset' => false, 'password' => G::generate_password(15), 'path_data' => @PATH_DATA, 'path_compiled' => @PATH_C, 'name' => $config['name'], 'database' => array(), 'admin' => array('username' => 'admin', 'password' => 'admin'
), 'advanced' => array('ao_db_wf' => 'wf_' . $config['name'], 'ao_db_rb' => 'rb_' . $config['name'], 'ao_db_rp' => 'rp_' . $config['name'], 'ao_db_drop' => false
)
), $config);
$a = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH));
$this->options['database'] = G::array_concat(Array('username' => @$a[1], 'password' => @$a[2], 'hostname' => @$a[0]
$this->options['database'] = G::array_concat(array('username' => @$a[1], 'password' => @$a[2], 'hostname' => @$a[0]
), $this->options['database']);
return ($confirmed === true) ? $this->make_site() : $this->create_site_test();
}
@@ -73,14 +72,14 @@ class Installer
private function create_site_test()
{
$name = (preg_match('/^[\w]+$/i', trim($this->options['name']))) ? true : false;
$result = Array('path_data' => $this->is_dir_writable($this->options['path_data']), 'path_compiled' => $this->is_dir_writable($this->options['path_compiled']), 'database' => $this->check_connection(), 'access_level' => $this->cc_status, 'isset' => ($this->options['isset'] == true) ? $this->isset_site($this->options['name']) : false, 'microtime' => microtime(), 'workspace' => $this->options['name'], 'name' => array('status' => $name, 'message' => ($name) ? 'PASSED' : 'Workspace name invalid'
$result = array('path_data' => $this->is_dir_writable($this->options['path_data']), 'path_compiled' => $this->is_dir_writable($this->options['path_compiled']), 'database' => $this->check_connection(), 'access_level' => $this->cc_status, 'isset' => ($this->options['isset'] == true) ? $this->isset_site($this->options['name']) : false, 'microtime' => microtime(), 'workspace' => $this->options['name'], 'name' => array('status' => $name, 'message' => ($name) ? 'PASSED' : 'Workspace name invalid'
), 'admin' => array('username' => (preg_match('/^[\w@\.-]+$/i', trim($this->options['admin']['username']))) ? true : false, 'password' => ((trim($this->options['admin']['password']) == '') ? false : true)
)
);
$result['name']['message'] = ($result['isset']) ? 'Workspace already exist' : $result['name']['message'];
$result['name']['status'] = ($result['isset']) ? false : $result['name']['status'];
//print_r($result);
return Array('created' => G::var_compare(true,
return array('created' => G::var_compare(
true,
$result['path_data'],
$result['database']['connection'],
$result['name']['status'],
@@ -88,7 +87,8 @@ class Installer
$result['database']['ao']['ao_db_wf']['status'],
$result['admin']['username'],
(($result['isset']) ? false : true),
$result['admin']['password']),
$result['admin']['password']
),
'result' => $result
);
}
@@ -138,7 +138,7 @@ class Installer
$myPort = $myPortA[1];
$this->options['database']['hostname'] = $myPortA[0];
mysql_select_db($wf, $this->connection_database);
mysqli_select_db($this->connection_database, $wf);
$pws = PATH_WORKFLOW_MYSQL_DATA . $schema;
$qws = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $schema, $this->connection_database);
$this->log($qws, isset($qws['errors']));
@@ -166,13 +166,13 @@ class Installer
/* Dump schema rbac && data */
$pws = PATH_RBAC_MYSQL_DATA . $schema;
mysql_select_db($rb, $this->connection_database);
mysqli_select_db($this->connection_database, $rb);
$qrs = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $schema, $this->connection_database);
$this->log($qrs, isset($qrs['errors']));
$qrv = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $values, $this->connection_database);
$this->log($qrv, isset($qrv['errors']));
mysql_select_db($wf, $this->connection_database);
mysqli_select_db($this->connection_database, $wf);
require_once("propel/Propel.php");
require_once('classes/model/AppCacheView.php');
@@ -246,7 +246,7 @@ class Installer
// Execute sql for partner
$pathMysqlPartner = PATH_CORE . 'data' . PATH_SEP . 'partner' . PATH_SEP . 'mysql' . PATH_SEP;
if (G::verifyPath($pathMysqlPartner)) {
$res = array();
$res = [];
$filesSlq = glob($pathMysqlPartner . '*.sql');
foreach ($filesSlq as $value) {
$this->query_sql_file($value, $this->connection_database);
@@ -256,7 +256,7 @@ class Installer
// Execute to change of skin
$pathSkinPartner = PATH_CORE . 'data' . PATH_SEP . 'partner' . PATH_SEP . 'skin' . PATH_SEP;
if (G::verifyPath($pathSkinPartner)) {
$res = array();
$res = [];
$fileTar = glob($pathSkinPartner . '*.tar');
foreach ($fileTar as $value) {
$dataFile = pathinfo($value);
@@ -331,7 +331,7 @@ class Installer
curl_close($ch);
$ch = curl_init();
$postData = array();
$postData = [];
// resolv the plugin name
$plugins = glob(PATH_CORE . "plugins/*.tar");
if (count($plugins) > 0) {
@@ -356,10 +356,10 @@ class Installer
}
}
function copyFile($fromDir, $toDir, $chmod = 0777)
public function copyFile($fromDir, $toDir, $chmod = 0777)
{
$errors = array();
$messages = array();
$errors = [];
$messages = [];
if (!is_writable($toDir)) {
$errors[] = 'target ' . $toDir . ' is not writable';
@@ -419,7 +419,7 @@ class Installer
$value['PRO_UID'] . "', '" .
$value['USR_UID'] . "', '" .
$value['APP_UID'] . "')";
mysql_select_db($this->wf_site_name, $this->connection_database);
mysqli_select_db($this->connection_database, $this->wf_site_name);
$this->run_query($query, "Copy configuracion environment");
break;
}
@@ -434,16 +434,16 @@ class Installer
*/
public function setAdmin()
{
mysql_select_db($this->wf_site_name, $this->connection_database);
mysqli_select_db($this->connection_database, $this->wf_site_name);
// The mysql_escape_string function has been DEPRECATED as of PHP 5.3.0.
// $this->run_query('UPDATE USERS SET USR_USERNAME = \''.mysql_escape_string($this->options['admin']['username']).'\', `USR_PASSWORD` = \''.md5($this->options['admin']['password']).'\' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1',
// $this->run_query('UPDATE USERS SET USR_USERNAME = \''.mysqli_escape_string($this->options['admin']['username']).'\', `USR_PASSWORD` = \''.md5($this->options['admin']['password']).'\' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1',
// "Add 'admin' user in ProcessMaker (wf)");
$this->run_query('UPDATE USERS SET USR_USERNAME = \'' . mysql_real_escape_string($this->options['admin']['username']) . '\', ' . ' `USR_PASSWORD` = \'' . G::encryptHash($this->options['admin']['password']) . '\' ' . ' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1', "Add 'admin' user in ProcessMaker (wf)");
mysql_select_db($this->rbac_site_name, $this->connection_database);
$this->run_query('UPDATE USERS SET USR_USERNAME = \'' . mysqli_real_escape_string($this->connection_database, $this->options['admin']['username']) . '\', ' . ' `USR_PASSWORD` = \'' . G::encryptHash($this->options['admin']['password']) . '\' ' . ' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1', "Add 'admin' user in ProcessMaker (wf)");
mysqli_select_db($this->connection_database, $this->rbac_site_name);
// The mysql_escape_string function has been DEPRECATED as of PHP 5.3.0.
// $this->run_query('UPDATE USERS SET USR_USERNAME = \''.mysql_escape_string($this->options['admin']['username']).'\', `USR_PASSWORD` = \''.md5($this->options['admin']['password']).'\' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1',
// $this->run_query('UPDATE USERS SET USR_USERNAME = \''.mysqli_escape_string($this->options['admin']['username']).'\', `USR_PASSWORD` = \''.md5($this->options['admin']['password']).'\' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1',
// "Add 'admin' user in ProcessMaker (rb)");
$this->run_query('UPDATE RBAC_USERS SET USR_USERNAME = \'' . mysql_real_escape_string($this->options['admin']['username']) . '\', ' . ' `USR_PASSWORD` = \'' . G::encryptHash($this->options['admin']['password']) . '\' ' . ' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1', "Add 'admin' user in ProcessMaker (rb)");
$this->run_query('UPDATE RBAC_USERS SET USR_USERNAME = \'' . mysqli_real_escape_string($this->connection_database, $this->options['admin']['username']) . '\', ' . ' `USR_PASSWORD` = \'' . G::encryptHash($this->options['admin']['password']) . '\' ' . ' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1', "Add 'admin' user in ProcessMaker (rb)");
}
/**
@@ -455,8 +455,8 @@ class Installer
*/
private function run_query($query, $description = null)
{
$result = @mysql_query($query, $this->connection_database);
$error = ($result) ? false : mysql_error();
$result = mysqli_query($this->connection_database, $query);
$error = $result ? false : mysqli_error($this->connection_database);
$this->log(($description ? $description : $query) . " => " . (($error) ? $error : "OK") . "\n", $error);
}
@@ -472,7 +472,7 @@ class Installer
$lines = file($file);
$previous = null;
$errors = '';
@mysql_query("SET NAMES 'utf8';");
mysqli_query($connection, "SET NAMES 'utf8';");
foreach ($lines as $j => $line) {
$line = trim($line); // Remove comments from the script
@@ -507,7 +507,7 @@ class Installer
}
$line = substr($line, 0, strrpos($line, ";"));
@mysql_query($line, $connection);
mysqli_query($connection, $line);
}
}
@@ -577,7 +577,7 @@ class Installer
*/
public function getDirectoryFiles($dir, $extension)
{
$filesArray = array();
$filesArray = [];
if (file_exists($dir)) {
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
@@ -600,50 +600,41 @@ class Installer
*/
public function check_db_empty($dbName)
{
$a = @mysql_select_db($dbName, $this->connection_database);
$a = mysqli_select_db($this->connection_database, $dbName);
if (!$a) {
return true;
}
$q = @mysql_query('SHOW TABLES', $this->connection_database);
return (@mysql_num_rows($q) > 0) ? false : true;
$q = mysqli_query($this->connection_database, 'SHOW TABLES');
return !(mysqli_num_rows($q) > 0);
}
/**
* check_db
*
* @param string $dbName
* @return Array Array('status' => true or false,'message' => string)
* @return array Array('status' => true or false,'message' => string)
*/
public function check_db($dbName)
{
$response = [];
$response['status'] = false;
$response['message'] = '';
if (!$this->connection_database) {
//erik: new verification if the mysql extension is enabled
$error = class_exists('mysql_error') ? mysql_error() : 'Mysql Module for PHP is not enabled!';
return Array('status' => false, 'message' => $error
);
//new verification if the mysql extension is enabled
$response['message'] = class_exists('mysql_error') ? mysqli_error() : 'Mysql Module for PHP is not enabled!';
} else {
if (!mysql_select_db($dbName, $this->connection_database) && $this->cc_status != 1) {
return Array('status' => false, 'message' => mysql_error()
);
if (!mysqli_select_db($this->connection_database, $dbName) && $this->cc_status != 1) {
$response['message'] = mysqli_error($this->connection_database);
} else {
/* var_dump($this->options['advanced']['ao_db_drop'],$this->cc_status,$this->check_db_empty($dbName));
if(($this->options['advanced']['ao_db_drop']===false && $this->cc_status!=1 && !$this->check_db_empty($dbName)) )
{
return Array('status'=>false,'message'=>'Database is not empty');
}
else
{
return Array('status'=>true,'message'=>'OK');
} */
if ($this->options['advanced']['ao_db_drop'] === true || $this->check_db_empty($dbName)) {
return Array('status' => true, 'message' => 'PASSED'
);
$response['status'] = true;
$response['message'] = 'PASSED';
} else {
return Array('status' => false, 'message' => 'Database is not empty'
);
$response['message'] = 'Database is not empty';
}
}
}
return $response;
}
/**
@@ -653,58 +644,51 @@ class Installer
*/
private function check_connection()
{
if (!function_exists("mysql_connect")) {
if (!function_exists('mysqli_connect')) {
$this->cc_status = 0;
$rt = Array('connection' => false, 'grant' => 0, 'version' => false, 'message' => "ERROR: Mysql Module for PHP is not enabled, try install <b>php-mysql</b> package.", 'ao' => Array('ao_db_wf' => false, 'ao_db_rb' => false, 'ao_db_rp' => false
$rt = array('connection' => false, 'grant' => 0, 'version' => false, 'message' => "ERROR: Mysql Module for PHP is not enabled, try install <b>php-mysql</b> package.", 'ao' => array('ao_db_wf' => false, 'ao_db_rb' => false, 'ao_db_rp' => false
)
);
} else {
$this->connection_database = @mysql_connect($this->options['database']['hostname'], $this->options['database']['username'], $this->options['database']['password']);
$rt = Array('version' => false, 'ao' => Array('ao_db_wf' => false, 'ao_db_rb' => false, 'ao_db_rp' => false
$this->connection_database = mysqli_connect($this->options['database']['hostname'], $this->options['database']['username'], $this->options['database']['password']);
$rt = array('version' => false, 'ao' => array('ao_db_wf' => false, 'ao_db_rb' => false, 'ao_db_rp' => false
)
);
if (!$this->connection_database) {
$this->cc_status = 0;
$rt['connection'] = false;
$rt['grant'] = 0;
$rt['message'] = "Mysql error: " . mysql_error();
$rt['message'] = 'Mysql error: ' . mysqli_error($this->connection_database);
} else {
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', mysql_get_server_info($this->connection_database), $version);
$rt['version'] = version_compare(@$version[0], "4.1.0", ">=");
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', mysqli_get_server_info($this->connection_database), $version);
$rt['version'] = version_compare(@$version[0], '4.1.0', '>=');
$rt['connection'] = true;
$dbNameTest = "PROCESSMAKERTESTDC";
$db = @mysql_query("CREATE DATABASE " . $dbNameTest, $this->connection_database);
$dbNameTest = 'PROCESSMAKERTESTDC';
$db = mysqli_query($this->connection_database, 'CREATE DATABASE ' . $dbNameTest);
if (!$db) {
$this->cc_status = 3;
$rt['grant'] = 3;
//$rt['message'] = "Db GRANTS error: ".mysql_error();
$rt['message'] = "Successful connection";
$rt['message'] = 'Successful connection';
} else {
//@mysql_drop_db("processmaker_testGA");
$usrTest = "wfrbtest";
$chkG = "GRANT ALL PRIVILEGES ON `" . $dbNameTest . "`.* TO " . $usrTest . "@'%' IDENTIFIED BY 'sample' WITH GRANT OPTION";
$ch = @mysql_query($chkG, $this->connection_database);
$ch = mysqli_query($this->connection_database, $chkG);
if (!$ch) {
$this->cc_status = 2;
$rt['grant'] = 2;
//$rt['message'] = "USER PRIVILEGES ERROR";
$rt['message'] = "Successful connection";
$rt['message'] = 'Successful connection';
} else {
$this->cc_status = 1;
@mysql_query("DROP USER " . $usrTest . "@'%'", $this->connection_database);
mysqli_query($this->connection_database, "DROP USER " . $usrTest . "@'%'");
$rt['grant'] = 1;
$rt['message'] = "Successful connection";
$rt['message'] = 'Successful connection';
}
@mysql_query("DROP DATABASE " . $dbNameTest, $this->connection_database);
mysqli_query($this->connection_database, 'DROP DATABASE ' . $dbNameTest);
}
// var_dump($wf,$rb,$rp);
}
}
$rt['ao']['ao_db_wf'] = $this->check_db($this->options['advanced']['ao_db_wf']);
//$rt['ao']['ao_db_rb'] = $this->check_db($this->options['advanced']['ao_db_rb']);
//$rt['ao']['ao_db_rp'] = $this->check_db($this->options['advanced']['ao_db_rp']);
return $rt;
}
@@ -722,4 +706,3 @@ class Installer
}
}
}

View File

@@ -1195,7 +1195,7 @@ class System
* @return string $result
* @throws Exception
*/
public function updateIndexFile($conf)
public static function updateIndexFile($conf)
{
if (!file_exists(PATH_HTML . 'index.html')) {
throw new Exception('The public index file "' . PATH_HTML . 'index.html" does not exist!');

View File

@@ -0,0 +1,10 @@
<?php
/**
* Our own DB Facade that supports loading the database for workspaces as well as
* external database connections.
*/
class DB extends \Illuminate\Support\Facades\DB
{
}

View File

@@ -0,0 +1,20 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
/**
* Class DbSource
* @package ProcessMaker\Model
*
* Represents an external database connection. Each DB Source is related to a owner process.
*/
class DbSource extends Model
{
// Set our table name
protected $table = 'DB_SOURCE';
// We do not store timestamps
public $timestamps = false;
}

View File

@@ -0,0 +1,21 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
/**
* Class Process
* @package ProcessMaker\Model
*
* Represents a business process object in the system.
*/
class Process extends Model
{
// Set our table name
protected $table = 'PROCESS';
// We do have a created at, but we don't store an updated at
const CREATED_AT = 'PRO_CREATE_DATE';
const UPDATED_AT = null;
}

View File

@@ -1,4 +1,5 @@
<?php
namespace ProcessMaker\Project\Adapter;
use ProcessMaker\Plugins\PluginRegistry;
@@ -18,22 +19,22 @@ class BpmnWorkflow extends Project\Bpmn
*/
protected $wp;
const BPMN_GATEWAY_COMPLEX = "COMPLEX";
const BPMN_GATEWAY_PARALLEL = "PARALLEL";
const BPMN_GATEWAY_INCLUSIVE = "INCLUSIVE";
const BPMN_GATEWAY_EXCLUSIVE = "EXCLUSIVE";
const BPMN_GATEWAY_COMPLEX = "COMPLEX";
const BPMN_GATEWAY_PARALLEL = "PARALLEL";
const BPMN_GATEWAY_INCLUSIVE = "INCLUSIVE";
const BPMN_GATEWAY_EXCLUSIVE = "EXCLUSIVE";
const BPMN_GATEWAY_EVENTBASED = "EVENTBASED";
private $arrayTaskAttribute = array(
"gateway-to-gateway" => array("type" => "GATEWAYTOGATEWAY", "prefix" => "gtg-"),
"end-message-event" => array("type" => "END-MESSAGE-EVENT", "prefix" => "eme-"),
"start-message-event" => array("type" => "START-MESSAGE-EVENT", "prefix" => "sme-"),
"gateway-to-gateway" => array("type" => "GATEWAYTOGATEWAY", "prefix" => "gtg-"),
"end-message-event" => array("type" => "END-MESSAGE-EVENT", "prefix" => "eme-"),
"start-message-event" => array("type" => "START-MESSAGE-EVENT", "prefix" => "sme-"),
"intermediate-throw-message-event" => array("type" => "INTERMEDIATE-THROW-MESSAGE-EVENT", "prefix" => "itme-"),
"intermediate-catch-message-event" => array("type" => "INTERMEDIATE-CATCH-MESSAGE-EVENT", "prefix" => "icme-"),
"start-timer-event" => array("type" => "START-TIMER-EVENT", "prefix" => "ste-"),
"intermediate-catch-timer-event" => array("type" => "INTERMEDIATE-CATCH-TIMER-EVENT", "prefix" => "icte-"),
"end-email-event" => array("type" => "END-EMAIL-EVENT", "prefix" => "eee-"),
"intermediate-throw-email-event" => array("type" => "INTERMEDIATE-THROW-EMAIL-EVENT", "prefix" => "itee-")
"start-timer-event" => array("type" => "START-TIMER-EVENT", "prefix" => "ste-"),
"intermediate-catch-timer-event" => array("type" => "INTERMEDIATE-CATCH-TIMER-EVENT", "prefix" => "icte-"),
"end-email-event" => array("type" => "END-EMAIL-EVENT", "prefix" => "eee-"),
"intermediate-throw-email-event" => array("type" => "INTERMEDIATE-THROW-EMAIL-EVENT", "prefix" => "itee-")
);
private $arrayElementTaskRelation = array();
@@ -44,9 +45,7 @@ class BpmnWorkflow extends Project\Bpmn
public static function load($prjUid)
{
$parent = parent::load($prjUid);
//return new BpmnWorkflow();
$me = new BpmnWorkflow();
@@ -104,19 +103,17 @@ class BpmnWorkflow extends Project\Bpmn
//Add Audit Log
$ogetProcess = new \Process();
$getprocess=$ogetProcess->load($this->getUid());
$nameProcess=$getprocess['PRO_TITLE'];
\G::auditLog("ImportProcess", 'PMX File Imported '.$nameProcess. ' ('.$this->getUid().')');
$getprocess = $ogetProcess->load($this->getUid());
$nameProcess = $getprocess['PRO_TITLE'];
\G::auditLog("ImportProcess", 'PMX File Imported ' . $nameProcess . ' (' . $this->getUid() . ')');
} catch (\Exception $e) {
$prjUid = $this->getUid();
//$this->remove();
$bpmnProject = Project\Bpmn::load($prjUid);
$bpmnProject->remove();
throw new \RuntimeException(sprintf(
"Can't create Bpmn Project with prj_uid: %s, workflow creation fails." . PHP_EOL . $e->getMessage()
, $prjUid
"Can't create Bpmn Project with prj_uid: %s, workflow creation fails." . PHP_EOL . $e->getMessage(),
$prjUid
));
}
}
@@ -284,18 +281,18 @@ class BpmnWorkflow extends Project\Bpmn
$taskData = self::__updateServiceTask($activityBefore, $activityCurrent, $taskData);
if($activityCurrent->getActLoopType() == "PARALLEL"){
$task = \TaskPeer::retrieveByPK($actUid);
if($task->getTasAssignType() == "BALANCED" || $task->getTasAssignType() == "MANUAL" || $task->getTasAssignType() == "EVALUATE" || $task->getTasAssignType() == "REPORT_TO" || $task->getTasAssignType() == "SELF_SERVICE"){
$taskData["TAS_ASSIGN_TYPE"] = "MULTIPLE_INSTANCE";
}
if ($activityCurrent->getActLoopType() == "PARALLEL") {
$task = \TaskPeer::retrieveByPK($actUid);
if ($task->getTasAssignType() == "BALANCED" || $task->getTasAssignType() == "MANUAL" || $task->getTasAssignType() == "EVALUATE" || $task->getTasAssignType() == "REPORT_TO" || $task->getTasAssignType() == "SELF_SERVICE") {
$taskData["TAS_ASSIGN_TYPE"] = "MULTIPLE_INSTANCE";
}
}
if($activityCurrent->getActLoopType() == "EMPTY"){
$task = \TaskPeer::retrieveByPK($actUid);
if($task->getTasAssignType() == "MULTIPLE_INSTANCE_VALUE_BASED" || $task->getTasAssignType() == "MULTIPLE_INSTANCE"){
$taskData["TAS_ASSIGN_TYPE"] = "BALANCED";
}
if ($activityCurrent->getActLoopType() == "EMPTY") {
$task = \TaskPeer::retrieveByPK($actUid);
if ($task->getTasAssignType() == "MULTIPLE_INSTANCE_VALUE_BASED" || $task->getTasAssignType() == "MULTIPLE_INSTANCE") {
$taskData["TAS_ASSIGN_TYPE"] = "BALANCED";
}
}
$this->wp->updateTask($actUid, $taskData);
@@ -324,7 +321,7 @@ class BpmnWorkflow extends Project\Bpmn
* @param $taskData
* @return mixed
*/
static function __updateServiceTask($activityBefore, $activityCurrent, $taskData)
public static function __updateServiceTask($activityBefore, $activityCurrent, $taskData)
{
$registry = PluginRegistry::loadSingleton();
if ($activityBefore->getActTaskType() != "SERVICETASK" && $activityCurrent->getActTaskType() == "SERVICETASK") {
@@ -341,7 +338,7 @@ class BpmnWorkflow extends Project\Bpmn
if ($activityBefore->getActTaskType() == "SERVICETASK" && $activityCurrent->getActTaskType() != "SERVICETASK") {
$taskData["TAS_TYPE"] = "NORMAL";
$taskData["TAS_ASSIGN_TYPE"] = "BALANCED";
if($activityCurrent->getActTaskType() == "SCRIPTTASK"){
if ($activityCurrent->getActTaskType() == "SCRIPTTASK") {
$taskData["TAS_TYPE"] = "SCRIPT-TASK";
}
//The plugin pmConnectors will be moved to the core in pm.3.3
@@ -380,8 +377,8 @@ class BpmnWorkflow extends Project\Bpmn
$arrayElementTaskRelationData = $elementTaskRelation->getElementTaskRelationWhere(
array(
\ElementTaskRelationPeer::PRJ_UID => $this->wp->getUid(),
\ElementTaskRelationPeer::ELEMENT_UID => $elementUid,
\ElementTaskRelationPeer::PRJ_UID => $this->wp->getUid(),
\ElementTaskRelationPeer::ELEMENT_UID => $elementUid,
\ElementTaskRelationPeer::ELEMENT_TYPE => $elementType
),
true
@@ -461,7 +458,7 @@ class BpmnWorkflow extends Project\Bpmn
return $floUid;
}
public function updateFlow($floUid, $data, $flows)
public function updateFlow($floUid, $data, $flows = null)
{
$flowBefore = \BpmnFlowPeer::retrieveByPK($floUid);
@@ -538,7 +535,7 @@ class BpmnWorkflow extends Project\Bpmn
$messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation();
$messageEventRelation->deleteWhere(array(
\MessageEventRelationPeer::PRJ_UID => $flowBefore->getPrjUid(),
\MessageEventRelationPeer::PRJ_UID => $flowBefore->getPrjUid(),
\MessageEventRelationPeer::EVN_UID_THROW => $flowBefore->getFloElementOrigin(),
\MessageEventRelationPeer::EVN_UID_CATCH => $flowBefore->getFloElementDest()
));
@@ -563,10 +560,10 @@ class BpmnWorkflow extends Project\Bpmn
$flow->getFloElementDestType() == "bpmnActivity"
) {
$bpmnFlow = \BpmnFlow::findOneBy(array(
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $flow->getFloElementOrigin(),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $flow->getFloElementOrigin(),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnEvent",
\BpmnFlowPeer::FLO_ELEMENT_DEST => $flow->getFloElementDest(),
\BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => "bpmnActivity"
\BpmnFlowPeer::FLO_ELEMENT_DEST => $flow->getFloElementDest(),
\BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => "bpmnActivity"
));
if (is_null($bpmnFlow)) {
@@ -617,7 +614,7 @@ class BpmnWorkflow extends Project\Bpmn
$messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation();
$messageEventRelation->deleteWhere(array(
\MessageEventRelationPeer::PRJ_UID => $flow->getPrjUid(),
\MessageEventRelationPeer::PRJ_UID => $flow->getPrjUid(),
\MessageEventRelationPeer::EVN_UID_THROW => $flow->getFloElementOrigin(),
\MessageEventRelationPeer::EVN_UID_CATCH => $flow->getFloElementDest()
));
@@ -637,8 +634,8 @@ class BpmnWorkflow extends Project\Bpmn
if ($bpmnEvent->getEvnType() == "START") {
//Flows
$arrayFlow = \BpmnFlow::findAllBy(array(
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $bpmnEvent->getEvnUid(),
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $bpmnEvent->getEvnUid(),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnEvent"
));
@@ -679,7 +676,7 @@ class BpmnWorkflow extends Project\Bpmn
}
//Message-Event-Definition - Delete
$arrayEventType = array("START", "END", "INTERMEDIATE");
$arrayEventType = array("START", "END", "INTERMEDIATE");
$arrayEventMarker = array("MESSAGETHROW", "MESSAGECATCH");
if (in_array($bpmnEvent->getEvnType(), $arrayEventType) && in_array($bpmnEvent->getEvnMarker(), $arrayEventMarker)) {
@@ -693,7 +690,7 @@ class BpmnWorkflow extends Project\Bpmn
}
//Timer-Event - Delete
$arrayEventType = array("START", "INTERMEDIATE");
$arrayEventType = array("START", "INTERMEDIATE");
$arrayEventMarker = array("TIMER");
if (in_array($bpmnEvent->getEvnType(), $arrayEventType) && in_array($bpmnEvent->getEvnMarker(), $arrayEventMarker)) {
@@ -706,7 +703,7 @@ class BpmnWorkflow extends Project\Bpmn
}
//Email-Event - Delete
$arrayEventType = array("END", "INTERMEDIATE");
$arrayEventType = array("END", "INTERMEDIATE");
$arrayEventMarker = array("EMAIL");
if (in_array($bpmnEvent->getEvnType(), $arrayEventType) && in_array($bpmnEvent->getEvnMarker(), $arrayEventMarker)) {
@@ -728,7 +725,7 @@ class BpmnWorkflow extends Project\Bpmn
public function addEvent($data)
{
if (! array_key_exists("EVN_TYPE", $data)) {
if (!array_key_exists("EVN_TYPE", $data)) {
throw new \RuntimeException("Required param \"EVN_TYPE\" is missing.");
}
@@ -811,7 +808,7 @@ class BpmnWorkflow extends Project\Bpmn
$taskPosY = 0;
$flow = \BpmnFlow::findOneBy(array(
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $elementUid,
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $elementUid,
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => $elementType
));
@@ -822,7 +819,7 @@ class BpmnWorkflow extends Project\Bpmn
$taskPosY = (int)($arrayFlowData["FLO_Y1"]);
} else {
$flow = \BpmnFlow::findOneBy(array(
\BpmnFlowPeer::FLO_ELEMENT_DEST => $elementUid,
\BpmnFlowPeer::FLO_ELEMENT_DEST => $elementUid,
\BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => $elementType
));
@@ -834,15 +831,15 @@ class BpmnWorkflow extends Project\Bpmn
}
}
$prefix = $this->arrayTaskAttribute[$key]["prefix"];
$prefix = $this->arrayTaskAttribute[$key]["prefix"];
$taskType = $this->arrayTaskAttribute[$key]["type"];
$taskUid = $this->wp->addTask(array(
"TAS_UID" => $prefix . substr(Util\Common::generateUID(), (32 - strlen($prefix)) * -1),
"TAS_TYPE" => $taskType,
"TAS_UID" => $prefix . substr(Util\Common::generateUID(), (32 - strlen($prefix)) * -1),
"TAS_TYPE" => $taskType,
"TAS_TITLE" => $taskType,
"TAS_POSX" => $taskPosX,
"TAS_POSY" => $taskPosY
"TAS_POSX" => $taskPosX,
"TAS_POSY" => $taskPosY
));
//Element-Task-Relation - Create
@@ -851,9 +848,9 @@ class BpmnWorkflow extends Project\Bpmn
$arrayResult = $elementTaskRelation->create(
$this->wp->getUid(),
[
'ELEMENT_UID' => $elementUid,
'ELEMENT_UID' => $elementUid,
'ELEMENT_TYPE' => $elementType,
'TAS_UID' => $taskUid
'TAS_UID' => $taskUid
]
);
@@ -922,16 +919,16 @@ class BpmnWorkflow extends Project\Bpmn
//Flows
$arrayFlow = \BpmnFlow::findAllBy(array(
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $gatewayUid,
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $gatewayUid,
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnGateway"
));
foreach ($arrayFlow as $value) {
$arrayFlowData = $value->toArray();
$routeDefault = (array_key_exists("FLO_TYPE", $arrayFlowData) && $arrayFlowData["FLO_TYPE"] == "DEFAULT")? 1 : 0;
$routeCondition = (array_key_exists("FLO_CONDITION", $arrayFlowData))? $arrayFlowData["FLO_CONDITION"] : "";
$routeDefault = (array_key_exists("FLO_TYPE", $arrayFlowData) && $arrayFlowData["FLO_TYPE"] == "DEFAULT") ? 1 : 0;
$routeCondition = (array_key_exists("FLO_CONDITION", $arrayFlowData)) ? $arrayFlowData["FLO_CONDITION"] : "";
switch ($arrayFlowData["FLO_ELEMENT_DEST_TYPE"]) {
case "bpmnActivity":
@@ -1015,15 +1012,15 @@ class BpmnWorkflow extends Project\Bpmn
$arrayEventData = \BpmnEvent::findOneBy(\BpmnEventPeer::EVN_UID, $eventUid)->toArray();
if (!is_null($arrayEventData)) {
$arrayEventType = array("INTERMEDIATE");
$arrayEventType = array("INTERMEDIATE");
$arrayEventMarker = array("MESSAGETHROW", "MESSAGECATCH", "TIMER", "EMAIL");
if (in_array($arrayEventData["EVN_TYPE"], $arrayEventType) && in_array($arrayEventData["EVN_MARKER"], $arrayEventMarker)) {
$arrayKey = array(
"MESSAGETHROW" => "intermediate-throw-message-event",
"MESSAGECATCH" => "intermediate-catch-message-event",
"TIMER" => "intermediate-catch-timer-event",
"EMAIL" => "intermediate-throw-email-event"
"TIMER" => "intermediate-catch-timer-event",
"EMAIL" => "intermediate-throw-email-event"
);
$taskUid = $this->__createTaskByElement(
@@ -1042,15 +1039,15 @@ class BpmnWorkflow extends Project\Bpmn
// The result value returns zero if the element is already mapped as a route
// we need to add this to fix cases of recursion if an already element has been mapped.
// like a loop for example.
if ($result === 0 ) {
if ($result === 0) {
return;
}
}
//Flows
$arrayFlow = \BpmnFlow::findAllBy(array(
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $eventUid,
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $eventUid,
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnEvent"
));
@@ -1141,8 +1138,8 @@ class BpmnWorkflow extends Project\Bpmn
//Flows
$arrayFlow = \BpmnFlow::findAllBy(array(
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $activity["ACT_UID"],
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $activity["ACT_UID"],
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnActivity"
));
@@ -1266,13 +1263,13 @@ class BpmnWorkflow extends Project\Bpmn
if (\Process::existsByProTitle($projectData["prj_name"])) {
throw new \Exception("Project with name: {$projectData["prj_name"]}, already exists.");
}
$activities = isset($projectData['diagrams']['0']['activities'])?$projectData['diagrams']['0']['activities']:array();
$activities = isset($projectData['diagrams']['0']['activities']) ? $projectData['diagrams']['0']['activities'] : array();
foreach ($activities as $value) {
if (empty($value['act_type'])) {
throw new \Exception("For activity: {$value['act_uid']} `act_type` is required but missing.");
}
}
$events = isset($projectData['diagrams']['0']['events'])?$projectData['diagrams']['0']['events']:array();
$events = isset($projectData['diagrams']['0']['events']) ? $projectData['diagrams']['0']['events'] : array();
foreach ($events as $value) {
if (empty($value['evn_type'])) {
throw new \Exception("For event: {$value['evn_uid']} `evn_type` is required but missing.");
@@ -1388,7 +1385,7 @@ class BpmnWorkflow extends Project\Bpmn
$configList = array("changeCaseTo" => CASE_LOWER);
if (! is_null($diagram)) {
if (!is_null($diagram)) {
$diagram = array_change_key_case($diagram, CASE_LOWER);
$diagram["activities"] = $bwp->getActivities($configList);
$diagram["events"] = $bwp->getEvents($configList);
@@ -1475,20 +1472,22 @@ class BpmnWorkflow extends Project\Bpmn
* @return array
*/
public static function updateFromStruct(
$prjUid, $projectData,
$prjUid,
$projectData,
$generateUid = true,
$forceInsert = false,
$allData = null
) {
)
{
$diagram = isset($projectData["diagrams"]) && isset($projectData["diagrams"][0]) ? $projectData["diagrams"][0] : array();
$diagram["activities"] = isset($diagram["activities"])? $diagram["activities"]: array();
$diagram["artifacts"] = isset($diagram["artifacts"])? $diagram["artifacts"]: array();
$diagram["gateways"] = isset($diagram["gateways"])? $diagram["gateways"]: array();
$diagram["events"] = isset($diagram["events"])? $diagram["events"]: array();
$diagram["data"] = isset($diagram["data"])? $diagram["data"]: array();
$diagram["participants"] = isset($diagram["participants"])? $diagram["participants"]: array();
$diagram["laneset"] = isset($diagram["laneset"])? $diagram["laneset"]: array();
$diagram["lanes"] = isset($diagram["lanes"])? $diagram["lanes"]: array();
$diagram["activities"] = isset($diagram["activities"]) ? $diagram["activities"] : array();
$diagram["artifacts"] = isset($diagram["artifacts"]) ? $diagram["artifacts"] : array();
$diagram["gateways"] = isset($diagram["gateways"]) ? $diagram["gateways"] : array();
$diagram["events"] = isset($diagram["events"]) ? $diagram["events"] : array();
$diagram["data"] = isset($diagram["data"]) ? $diagram["data"] : array();
$diagram["participants"] = isset($diagram["participants"]) ? $diagram["participants"] : array();
$diagram["laneset"] = isset($diagram["laneset"]) ? $diagram["laneset"] : array();
$diagram["lanes"] = isset($diagram["lanes"]) ? $diagram["lanes"] : array();
$result = array();
@@ -1540,13 +1539,13 @@ class BpmnWorkflow extends Project\Bpmn
$diagram = self::refreshElementUid($diagram, $uidOld, $lanesetData["LNS_UID"]);
$result[] = array(
"object" => "laneset",
"object" => "laneset",
"old_uid" => $uidOld,
"new_uid" => $lanesetData["LNS_UID"]
);
}
$bwp->addLaneset($lanesetData);
} elseif (! $bwp->isEquals($dataObject, $lanesetData)) {
} elseif (!$bwp->isEquals($dataObject, $lanesetData)) {
$bwp->updateLaneset($lanesetData["LNS_UID"], $lanesetData);
} else {
Util\Logger::log("Update Laneset ({$lanesetData["LNS_UID"]}) Skipped - No changes required");
@@ -1560,7 +1559,7 @@ class BpmnWorkflow extends Project\Bpmn
// looking for removed elements
foreach ($dataCollection as $lanesetData) {
if (! in_array($lanesetData["LNS_UID"], $whiteList)) {
if (!in_array($lanesetData["LNS_UID"], $whiteList)) {
// If it is not in the white list, then remove them
$bwp->removeLaneset($lanesetData["LNS_UID"]);
}
@@ -1585,13 +1584,13 @@ class BpmnWorkflow extends Project\Bpmn
$diagram = self::refreshElementUid($diagram, $uidOld, $laneData["LAN_UID"]);
$result[] = array(
"object" => "lane",
"object" => "lane",
"old_uid" => $uidOld,
"new_uid" => $laneData["LAN_UID"]
);
}
$bwp->addLane($laneData);
} elseif (! $bwp->isEquals($dataObject, $laneData)) {
} elseif (!$bwp->isEquals($dataObject, $laneData)) {
$bwp->updateLane($laneData["LAN_UID"], $laneData);
} else {
Util\Logger::log("Update Lane ({$laneData["LAN_UID"]}) Skipped - No changes required");
@@ -1605,7 +1604,7 @@ class BpmnWorkflow extends Project\Bpmn
// looking for removed elements
foreach ($dataCollection as $laneData) {
if (! in_array($laneData["LAN_UID"], $whiteList)) {
if (!in_array($laneData["LAN_UID"], $whiteList)) {
// If it is not in the white list, then remove them
$bwp->removeLane($laneData["LAN_UID"]);
}
@@ -1630,7 +1629,7 @@ class BpmnWorkflow extends Project\Bpmn
$activityData["ACT_UID"] = Util\Common::generateUID();
$result[] = array(
"object" => "activity",
"object" => "activity",
"old_uid" => $uidOld,
"new_uid" => $activityData["ACT_UID"]
);
@@ -1644,7 +1643,7 @@ class BpmnWorkflow extends Project\Bpmn
}
$bwp->addActivity($activityData);
} elseif (! $bwp->isEquals($activity, $activityData)) {
} elseif (!$bwp->isEquals($activity, $activityData)) {
$bwp->updateActivity($activityData["ACT_UID"], $activityData);
} else {
Util\Logger::log("Update Activity ({$activityData["ACT_UID"]}) Skipped - No changes required");
@@ -1652,14 +1651,13 @@ class BpmnWorkflow extends Project\Bpmn
$bwp->sincronizeActivityData($activityData["ACT_UID"], $activityData);
$diagram["activities"][$i] = $activityData;
$whiteList[] = $activityData["ACT_UID"];
}
$activities = $bwp->getActivities();
// looking for removed elements
foreach ($activities as $activityData) {
if (! in_array($activityData["ACT_UID"], $whiteList)) {
if (!in_array($activityData["ACT_UID"], $whiteList)) {
$bwp->removeActivity($activityData["ACT_UID"]);
}
}
@@ -1683,14 +1681,14 @@ class BpmnWorkflow extends Project\Bpmn
$artifactData["ART_UID"] = Util\Common::generateUID();
$result[] = array(
"object" => "artifact",
"object" => "artifact",
"old_uid" => $uidOld,
"new_uid" => $artifactData["ART_UID"]
);
}
$bwp->addArtifact($artifactData);
} elseif (! $bwp->isEquals($artifact, $artifactData)) {
} elseif (!$bwp->isEquals($artifact, $artifactData)) {
$bwp->updateArtifact($artifactData["ART_UID"], $artifactData);
} else {
Util\Logger::log("Update Artifact ({$artifactData["ART_UID"]}) Skipped - No changes required");
@@ -1703,7 +1701,7 @@ class BpmnWorkflow extends Project\Bpmn
$artifacts = $bwp->getArtifacts();
// looking for removed elements
foreach ($artifacts as $artifactData) {
if (! in_array($artifactData["ART_UID"], $whiteList)) {
if (!in_array($artifactData["ART_UID"], $whiteList)) {
$bwp->removeArtifact($artifactData["ART_UID"]);
}
}
@@ -1734,7 +1732,7 @@ class BpmnWorkflow extends Project\Bpmn
$gatewayData["GAT_UID"] = Util\Common::generateUID();
$result[] = array(
"object" => "gateway",
"object" => "gateway",
"old_uid" => $uidOld,
"new_uid" => $gatewayData["GAT_UID"]
);
@@ -1743,7 +1741,7 @@ class BpmnWorkflow extends Project\Bpmn
$bwp->addGateway($gatewayData);
$flagAddOrUpdate = true;
} elseif (! $bwp->isEquals($gateway, $gatewayData)) {
} elseif (!$bwp->isEquals($gateway, $gatewayData)) {
$bwp->updateGateway($gatewayData["GAT_UID"], $gatewayData);
$flagAddOrUpdate = true;
@@ -1775,7 +1773,7 @@ class BpmnWorkflow extends Project\Bpmn
// looking for removed elements
foreach ($gateways as $gatewayData) {
if (! in_array($gatewayData["GAT_UID"], $whiteList)) {
if (!in_array($gatewayData["GAT_UID"], $whiteList)) {
$bwp->removeGateway($gatewayData["GAT_UID"]);
}
}
@@ -1808,14 +1806,14 @@ class BpmnWorkflow extends Project\Bpmn
$eventData["EVN_UID"] = Util\Common::generateUID();
$result[] = array(
"object" => "event",
"object" => "event",
"old_uid" => $uidOld,
"new_uid" => $eventData["EVN_UID"]
);
}
$bwp->addEvent($eventData);
} elseif (! $bwp->isEquals($event, $eventData)) {
} elseif (!$bwp->isEquals($event, $eventData)) {
$bwp->updateEvent($eventData["EVN_UID"], $eventData);
} else {
Util\Logger::log("Update Event ({$eventData["EVN_UID"]}) Skipped - No changes required");
@@ -1829,7 +1827,7 @@ class BpmnWorkflow extends Project\Bpmn
// looking for removed elements
foreach ($events as $eventData) {
if (! in_array($eventData["EVN_UID"], $whiteList)) {
if (!in_array($eventData["EVN_UID"], $whiteList)) {
// If it is not in the white list, then remove them
$bwp->removeEvent($eventData["EVN_UID"]);
}
@@ -1854,14 +1852,14 @@ class BpmnWorkflow extends Project\Bpmn
$dataObjectData["DAT_UID"] = Util\Common::generateUID();
$result[] = array(
"object" => "data",
"object" => "data",
"old_uid" => $uidOld,
"new_uid" => $dataObjectData["DAT_UID"]
);
}
$bwp->addData($dataObjectData);
} elseif (! $bwp->isEquals($dataObject, $dataObjectData)) {
} elseif (!$bwp->isEquals($dataObject, $dataObjectData)) {
$bwp->updateData($dataObjectData["DAT_UID"], $dataObjectData);
} else {
Util\Logger::log("Update Data ({$dataObjectData["DAT_UID"]}) Skipped - No changes required");
@@ -1875,7 +1873,7 @@ class BpmnWorkflow extends Project\Bpmn
// looking for removed elements
foreach ($dataCollection as $dataObjectData) {
if (! in_array($dataObjectData["DAT_UID"], $whiteList)) {
if (!in_array($dataObjectData["DAT_UID"], $whiteList)) {
// If it is not in the white list, then remove them
$bwp->removeData($dataObjectData["DAT_UID"]);
}
@@ -1900,14 +1898,14 @@ class BpmnWorkflow extends Project\Bpmn
$participantData["PAR_UID"] = Util\Common::generateUID();
$result[] = array(
"object" => "participant",
"object" => "participant",
"old_uid" => $uidOld,
"new_uid" => $participantData["PAR_UID"]
);
}
$bwp->addParticipant($participantData);
} elseif (! $bwp->isEquals($participant, $participantData)) {
} elseif (!$bwp->isEquals($participant, $participantData)) {
$bwp->updateParticipant($participantData["PAR_UID"], $participantData);
} else {
Util\Logger::log("Update Participant ({$participantData["PAR_UID"]}) Skipped - No changes required");
@@ -1921,7 +1919,7 @@ class BpmnWorkflow extends Project\Bpmn
// looking for removed elements
foreach ($dataCollection as $participantData) {
if (! in_array($participantData["PAR_UID"], $whiteList)) {
if (!in_array($participantData["PAR_UID"], $whiteList)) {
// If it is not in the white list, then remove them
$bwp->removeParticipant($participantData["PAR_UID"]);
}
@@ -1934,7 +1932,7 @@ class BpmnWorkflow extends Project\Bpmn
$whiteList = array();
$diagramFlows = isset($diagram["flows"])?$diagram["flows"]:array();
$diagramFlows = isset($diagram["flows"]) ? $diagram["flows"] : array();
foreach ($diagramFlows as $i => $flowData) {
$flowData = array_change_key_case($flowData, CASE_UPPER);
@@ -1987,12 +1985,12 @@ class BpmnWorkflow extends Project\Bpmn
$whiteList[] = $flowData["FLO_UID"];
}
$diagramFlows = isset($diagram["flows"])?$diagram["flows"]:array();
$diagramFlows = isset($diagram["flows"]) ? $diagram["flows"] : array();
foreach ($diagramFlows as $flowData) {
$flow = $bwp->getFlow($flowData["FLO_UID"]);
if ($forceInsert || is_null($flow)) {
$bwp->addFlow($flowData);
} elseif (! $bwp->isEquals($flow, $flowData)) {
} elseif (!$bwp->isEquals($flow, $flowData)) {
$bwp->updateFlow($flowData["FLO_UID"], $flowData, $diagram["flows"]);
} else {
Util\Logger::log("Update Flow ({$flowData["FLO_UID"]}) Skipped - No changes required");
@@ -2003,7 +2001,7 @@ class BpmnWorkflow extends Project\Bpmn
// looking for removed elements
foreach ($flows as $flowData) {
if (! in_array($flowData["FLO_UID"], $whiteList)) {
if (!in_array($flowData["FLO_UID"], $whiteList)) {
$bwp->removeFlow($flowData["FLO_UID"]);
}
}
@@ -2014,15 +2012,15 @@ class BpmnWorkflow extends Project\Bpmn
if (!is_null($arrayGatewayData)) {
$arrayFlow = \BpmnFlow::findAllBy([
\BpmnFlowPeer::FLO_TYPE => ['MESSAGE', \Criteria::NOT_EQUAL],
\BpmnFlowPeer::FLO_ELEMENT_DEST => $arrayGatewayData['GAT_UID'],
\BpmnFlowPeer::FLO_TYPE => ['MESSAGE', \Criteria::NOT_EQUAL],
\BpmnFlowPeer::FLO_ELEMENT_DEST => $arrayGatewayData['GAT_UID'],
\BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => 'bpmnGateway'
]);
if (count($arrayFlow) > 1) {
$arrayFlow = \BpmnFlow::findAllBy([
\BpmnFlowPeer::FLO_TYPE => ['MESSAGE', \Criteria::NOT_EQUAL],
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $arrayGatewayData['GAT_UID'],
\BpmnFlowPeer::FLO_TYPE => ['MESSAGE', \Criteria::NOT_EQUAL],
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $arrayGatewayData['GAT_UID'],
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => 'bpmnGateway'
]);
@@ -2086,7 +2084,7 @@ class BpmnWorkflow extends Project\Bpmn
$arrayResult = $webEntryEvent->update(
$arrayWebEntryEventData['WEE_UID'],
$bpmnProject->getPrjAuthor(),
(!is_null($arrayData))? $arrayData : $arrayWebEntryEventData,
(!is_null($arrayData)) ? $arrayData : $arrayWebEntryEventData,
false
);
}
@@ -2129,10 +2127,9 @@ class BpmnWorkflow extends Project\Bpmn
{
array_walk_recursive(
$diagram,
function (&$value, $key, $arrayData)
{
function (&$value, $key, $arrayData) {
try {
if (strcmp($arrayData['oldUid'], $value) === 0){
if (strcmp($arrayData['oldUid'], $value) === 0) {
$value = $arrayData['newUid'];
}
} catch (\Exception $e) {
@@ -2166,7 +2163,7 @@ class BpmnWorkflow extends Project\Bpmn
$criteria->addSelectColumn(\TaskPeer::TAS_UID);
$criteria->addAlias('RT', \RoutePeer::TABLE_NAME);
$criteria->addAlias('RT', \RoutePeer::TABLE_NAME);
$criteria->addAlias('RNT', \RoutePeer::TABLE_NAME);
$arrayCondition = [];
@@ -2182,7 +2179,8 @@ class BpmnWorkflow extends Project\Bpmn
$criteria->add(
$criteria->getNewCriterion('RT.ROU_UID', null, \Criteria::ISNULL)->addAnd(
$criteria->getNewCriterion('RNT.ROU_UID', null, \Criteria::ISNULL))
$criteria->getNewCriterion('RNT.ROU_UID', null, \Criteria::ISNULL)
)
);
$rsCriteria = \TaskPeer::doSelectRS($criteria);
@@ -2207,7 +2205,7 @@ class BpmnWorkflow extends Project\Bpmn
//Update Process
$process = \ProcessPeer::retrieveByPk($this->wp->getUid());
$arrayActionDone = (!is_null($process->getProActionDone()) && (string)($process->getProActionDone()) != '')? unserialize($process->getProActionDone()) : [];
$arrayActionDone = (!is_null($process->getProActionDone()) && (string)($process->getProActionDone()) != '') ? unserialize($process->getProActionDone()) : [];
$arrayActionDone[] = $actionDone;
$this->wp->update(['PRO_ACTION_DONE' => serialize($arrayActionDone)]);

View File

@@ -1,4 +1,5 @@
<?php
namespace ProcessMaker\Project\Adapter;
use ProcessMaker\Project;
@@ -67,17 +68,16 @@ class WorkflowBpmn extends Project\Workflow
//Add Audit Log
$ogetProcess = new \Process();
$getprocess=$ogetProcess->load($this->getUid());
$nameProcess=$getprocess['PRO_TITLE'];
\G::auditLog("ImportProcess", 'BPMN Imported '.$nameProcess. ' ('.$this->getUid().')');
$getprocess = $ogetProcess->load($this->getUid());
$nameProcess = $getprocess['PRO_TITLE'];
\G::auditLog("ImportProcess", 'BPMN Imported ' . $nameProcess . ' (' . $this->getUid() . ')');
} catch (\Exception $e) {
$prjUid = $this->getUid();
$this->remove();
throw new \RuntimeException(sprintf(
"Can't create Project with prj_uid: %s, workflow creation fails." . PHP_EOL . $e->getMessage()
, $prjUid
"Can't create Project with prj_uid: %s, workflow creation fails." . PHP_EOL . $e->getMessage(),
$prjUid
));
}
}
@@ -103,12 +103,13 @@ class WorkflowBpmn extends Project\Workflow
$eventName,
$eventType,
$condition = ""
) {
)
{
try {
$eventBouWidth = 35;
$eventBouWidth = 35;
$eventBouHeight = $eventBouWidth;
$eventBouWidth2 = (int)($eventBouWidth / 2);
$eventBouWidth2 = (int)($eventBouWidth / 2);
$eventBouHeight2 = (int)($eventBouHeight / 2);
$eventBouHeight12 = (int)($eventBouWidth / 12);
@@ -125,16 +126,16 @@ class WorkflowBpmn extends Project\Workflow
} else {
//Activity
$eventBouX = $objectBouX + $objectBouWidth2 - $eventBouWidth2;
$eventBouY = ($eventType == "START")? $objectBouY - $eventBouHeight - $eventBouHeight2 : $objectBouY + $objectBouHeight + $eventBouHeight2 + $eventBouHeight12;
$eventBouY = ($eventType == "START") ? $objectBouY - $eventBouHeight - $eventBouHeight2 : $objectBouY + $objectBouHeight + $eventBouHeight2 + $eventBouHeight12;
}
$arrayData = array(
"EVN_NAME" => $eventName,
"EVN_TYPE" => $eventType,
"EVN_NAME" => $eventName,
"EVN_TYPE" => $eventType,
"EVN_MARKER" => "EMPTY",
"BOU_X" => $eventBouX,
"BOU_Y" => $eventBouY,
"BOU_WIDTH" => $eventBouWidth,
"BOU_X" => $eventBouX,
"BOU_Y" => $eventBouY,
"BOU_WIDTH" => $eventBouWidth,
"BOU_HEIGHT" => $eventBouHeight
);
@@ -150,24 +151,24 @@ class WorkflowBpmn extends Project\Workflow
} else {
//Activity
$flowX1 = $objectBouX + $objectBouWidth2;
$flowY1 = ($eventType == "START")? $objectBouY - $eventBouHeight + $eventBouHeight2 : $objectBouY + $objectBouHeight;
$flowY1 = ($eventType == "START") ? $objectBouY - $eventBouHeight + $eventBouHeight2 : $objectBouY + $objectBouHeight;
$flowX2 = $flowX1;
$flowY2 = ($eventType == "START")? $objectBouY : $objectBouY + $objectBouHeight + $eventBouHeight2 + $eventBouHeight12;
$flowY2 = ($eventType == "START") ? $objectBouY : $objectBouY + $objectBouHeight + $eventBouHeight2 + $eventBouHeight12;
}
$arrayData = array(
"FLO_TYPE" => "SEQUENCE",
"FLO_ELEMENT_ORIGIN" => ($eventType == "START")? $eventUid : $objectUid,
"FLO_ELEMENT_ORIGIN_TYPE" => ($eventType == "START")? "bpmnEvent" : $objectBpmnType,
"FLO_ELEMENT_DEST" => ($eventType == "START")? $objectUid : $eventUid,
"FLO_ELEMENT_DEST_TYPE" => ($eventType == "START")? $objectBpmnType : "bpmnEvent",
"FLO_IS_INMEDIATE" => 1,
"FLO_CONDITION" => $condition,
"FLO_X1" => $flowX1,
"FLO_Y1" => $flowY1,
"FLO_X2" => $flowX2,
"FLO_Y2" => $flowY2,
"FLO_STATE" => json_encode(
"FLO_TYPE" => "SEQUENCE",
"FLO_ELEMENT_ORIGIN" => ($eventType == "START") ? $eventUid : $objectUid,
"FLO_ELEMENT_ORIGIN_TYPE" => ($eventType == "START") ? "bpmnEvent" : $objectBpmnType,
"FLO_ELEMENT_DEST" => ($eventType == "START") ? $objectUid : $eventUid,
"FLO_ELEMENT_DEST_TYPE" => ($eventType == "START") ? $objectBpmnType : "bpmnEvent",
"FLO_IS_INMEDIATE" => 1,
"FLO_CONDITION" => $condition,
"FLO_X1" => $flowX1,
"FLO_Y1" => $flowY1,
"FLO_X2" => $flowX2,
"FLO_Y2" => $flowY2,
"FLO_STATE" => json_encode(
array(
array("x" => $flowX1, "y" => $flowY1),
array("x" => $flowX1, "y" => $flowY2 - 5),
@@ -195,23 +196,23 @@ class WorkflowBpmn extends Project\Workflow
//BPMN
//Activity
$arrayActivityType = array(
"NORMAL" => "TASK",
"ADHOC" => "TASK",
"NORMAL" => "TASK",
"ADHOC" => "TASK",
"SUBPROCESS" => "SUB_PROCESS"
);
$activityBouX = (int)($arrayTaskData["TAS_POSX"]);
$activityBouY = (int)($arrayTaskData["TAS_POSY"]);
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
$activityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);
$arrayData = array(
"ACT_UID" => $taskUid,
"ACT_NAME" => $arrayTaskData["TAS_TITLE"],
"ACT_TYPE" => $arrayActivityType[$arrayTaskData["TAS_TYPE"]],
"BOU_X" => $activityBouX,
"BOU_Y" => $activityBouY,
"BOU_WIDTH" => $activityBouWidth,
"ACT_UID" => $taskUid,
"ACT_NAME" => $arrayTaskData["TAS_TITLE"],
"ACT_TYPE" => $arrayActivityType[$arrayTaskData["TAS_TYPE"]],
"BOU_X" => $activityBouX,
"BOU_Y" => $activityBouY,
"BOU_WIDTH" => $activityBouWidth,
"BOU_HEIGHT" => $activityBouHeight
);
@@ -247,12 +248,13 @@ class WorkflowBpmn extends Project\Workflow
$gatewayName,
$gatewayType,
$gatewayDirection
) {
)
{
try {
$gatewayBouWidth = 45;
$gatewayBouWidth = 45;
$gatewayBouHeight = $gatewayBouWidth;
$gatewayBouWidth2 = (int)($gatewayBouWidth / 2);
$gatewayBouWidth2 = (int)($gatewayBouWidth / 2);
$gatewayBouHeight2 = (int)($gatewayBouHeight / 2);
//
@@ -261,17 +263,17 @@ class WorkflowBpmn extends Project\Workflow
//Gateway
$gatewayBouX = $objectBouX + $objectBouWidth2 - $gatewayBouWidth2;
$gatewayBouY = ($gatewayDirection == "DIVERGING")? $objectBouY + $objectBouHeight + $gatewayBouHeight2 : $objectBouY - $gatewayBouHeight - $gatewayBouHeight2;
$gatewayBouY = ($gatewayDirection == "DIVERGING") ? $objectBouY + $objectBouHeight + $gatewayBouHeight2 : $objectBouY - $gatewayBouHeight - $gatewayBouHeight2;
$arrayData = array(
"GAT_NAME" => $gatewayName,
"GAT_TYPE" => $gatewayType,
"GAT_DIRECTION" => $gatewayDirection,
"GAT_NAME" => $gatewayName,
"GAT_TYPE" => $gatewayType,
"GAT_DIRECTION" => $gatewayDirection,
"GAT_DEFAULT_FLOW" => "0",
"BOU_X" => $gatewayBouX,
"BOU_Y" => $gatewayBouY,
"BOU_WIDTH" => $gatewayBouWidth,
"BOU_HEIGHT" => $gatewayBouHeight
"BOU_X" => $gatewayBouX,
"BOU_Y" => $gatewayBouY,
"BOU_WIDTH" => $gatewayBouWidth,
"BOU_HEIGHT" => $gatewayBouHeight
);
$gatewayUid = $this->bp->addGateway($arrayData);
@@ -290,18 +292,18 @@ class WorkflowBpmn extends Project\Workflow
}
$arrayData = array(
"FLO_TYPE" => "SEQUENCE",
"FLO_ELEMENT_ORIGIN" => ($gatewayDirection == "DIVERGING")? $objectUid : $gatewayUid,
"FLO_ELEMENT_ORIGIN_TYPE" => ($gatewayDirection == "DIVERGING")? $objectBpmnType : "bpmnGateway",
"FLO_ELEMENT_DEST" => ($gatewayDirection == "DIVERGING")? $gatewayUid : $objectUid,
"FLO_ELEMENT_DEST_TYPE" => ($gatewayDirection == "DIVERGING")? "bpmnGateway" : $objectBpmnType,
"FLO_IS_INMEDIATE" => 1,
"FLO_CONDITION" => "",
"FLO_X1" => $flowX1,
"FLO_Y1" => $flowY1,
"FLO_X2" => $flowX2,
"FLO_Y2" => $flowY2,
"FLO_STATE" => json_encode(
"FLO_TYPE" => "SEQUENCE",
"FLO_ELEMENT_ORIGIN" => ($gatewayDirection == "DIVERGING") ? $objectUid : $gatewayUid,
"FLO_ELEMENT_ORIGIN_TYPE" => ($gatewayDirection == "DIVERGING") ? $objectBpmnType : "bpmnGateway",
"FLO_ELEMENT_DEST" => ($gatewayDirection == "DIVERGING") ? $gatewayUid : $objectUid,
"FLO_ELEMENT_DEST_TYPE" => ($gatewayDirection == "DIVERGING") ? "bpmnGateway" : $objectBpmnType,
"FLO_IS_INMEDIATE" => 1,
"FLO_CONDITION" => "",
"FLO_X1" => $flowX1,
"FLO_Y1" => $flowY1,
"FLO_X2" => $flowX2,
"FLO_Y2" => $flowY2,
"FLO_STATE" => json_encode(
array(
array("x" => $flowX1, "y" => $flowY1),
array("x" => $flowX1, "y" => $flowY2 - 5),
@@ -334,10 +336,11 @@ class WorkflowBpmn extends Project\Workflow
$objectDestBouWidth,
$objectDestBouHeight,
$condition = ""
) {
)
{
try {
$objectOriginBouWidth2 = (int)($objectOriginBouWidth / 2);
$objectDestBouWidth2 = (int)($objectDestBouWidth / 2);
$objectOriginBouWidth2 = (int)($objectOriginBouWidth / 2);
$objectDestBouWidth2 = (int)($objectDestBouWidth / 2);
$flowX1 = $objectOriginBouX + $objectOriginBouWidth2;
$flowY1 = $objectOriginBouY + $objectOriginBouHeight;
@@ -346,18 +349,18 @@ class WorkflowBpmn extends Project\Workflow
//Flow
$arrayData = array(
"FLO_TYPE" => "SEQUENCE",
"FLO_ELEMENT_ORIGIN" => $objectOriginUid,
"FLO_TYPE" => "SEQUENCE",
"FLO_ELEMENT_ORIGIN" => $objectOriginUid,
"FLO_ELEMENT_ORIGIN_TYPE" => $objectOriginBpmnType,
"FLO_ELEMENT_DEST" => $objectDestUid,
"FLO_ELEMENT_DEST_TYPE" => $objectDestBpmnType,
"FLO_IS_INMEDIATE" => 1,
"FLO_CONDITION" => $condition,
"FLO_X1" => $flowX1,
"FLO_Y1" => $flowY1,
"FLO_X2" => $flowX2,
"FLO_Y2" => $flowY2,
"FLO_STATE" => json_encode(array())
"FLO_ELEMENT_DEST" => $objectDestUid,
"FLO_ELEMENT_DEST_TYPE" => $objectDestBpmnType,
"FLO_IS_INMEDIATE" => 1,
"FLO_CONDITION" => $condition,
"FLO_X1" => $flowX1,
"FLO_Y1" => $flowY1,
"FLO_X2" => $flowX2,
"FLO_Y2" => $flowY2,
"FLO_STATE" => json_encode(array())
);
$flowUid = $this->bp->addFlow($arrayData);
@@ -381,7 +384,7 @@ class WorkflowBpmn extends Project\Workflow
$activityUid = $arrayTaskData["TAS_UID"];
$activityBouX = (int)($arrayTaskData["TAS_POSX"]);
$activityBouY = (int)($arrayTaskData["TAS_POSY"]);
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
$activityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);
$arrayTaskData = $this->getTask($nextTaskUid);
@@ -389,7 +392,7 @@ class WorkflowBpmn extends Project\Workflow
$nextActivityUid = $arrayTaskData["TAS_UID"];
$nextActivityBouX = (int)($arrayTaskData["TAS_POSX"]);
$nextActivityBouY = (int)($arrayTaskData["TAS_POSY"]);
$nextActivityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
$nextActivityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
$nextActivityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);
$result = $this->bp->getGatewayByDirectionActivityAndFlow("CONVERGING", $nextActivityUid);
@@ -439,11 +442,11 @@ class WorkflowBpmn extends Project\Workflow
$arrayGatewayData = $result;
}
$gatewayUid = $arrayGatewayData["GAT_UID"];
$gatewayUid = $arrayGatewayData["GAT_UID"];
$gatewayType = $arrayGatewayData["GAT_TYPE"];
$gatewayBouX = $arrayGatewayData["BOU_X"];
$gatewayBouY = $arrayGatewayData["BOU_Y"];
$gatewayBouWidth = $arrayGatewayData["BOU_WIDTH"];
$gatewayBouWidth = $arrayGatewayData["BOU_WIDTH"];
$gatewayBouHeight = $arrayGatewayData["BOU_HEIGHT"];
$flowUid = $this->routeToBpmnFlow(
@@ -470,7 +473,7 @@ class WorkflowBpmn extends Project\Workflow
}
}
public function addRoute($taskUid, $nextTaskUid, $type, $condition = "")
public function addRoute($taskUid, $nextTaskUid, $type, $condition = "", $default = 0)
{
try {
//Verify data
@@ -483,9 +486,9 @@ class WorkflowBpmn extends Project\Workflow
//BPMN
$arrayBpmnGatewayType = array(
"EVALUATE" => "EXCLUSIVE",
"SELECT" => "COMPLEX",
"PARALLEL" => "PARALLEL",
"EVALUATE" => "EXCLUSIVE",
"SELECT" => "COMPLEX",
"PARALLEL" => "PARALLEL",
"PARALLEL-BY-EVALUATION" => "INCLUSIVE"
);
@@ -494,7 +497,7 @@ class WorkflowBpmn extends Project\Workflow
$activityUid = $arrayTaskData["TAS_UID"];
$activityBouX = (int)($arrayTaskData["TAS_POSX"]);
$activityBouY = (int)($arrayTaskData["TAS_POSY"]);
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
$activityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);
switch ($type) {
@@ -522,11 +525,11 @@ class WorkflowBpmn extends Project\Workflow
$arrayGatewayData = $result;
}
$gatewayUid = $arrayGatewayData["GAT_UID"];
$gatewayUid = $arrayGatewayData["GAT_UID"];
$gatewayType = $arrayGatewayData["GAT_TYPE"];
$gatewayBouX = $arrayGatewayData["BOU_X"];
$gatewayBouY = $arrayGatewayData["BOU_Y"];
$gatewayBouWidth = $arrayGatewayData["BOU_WIDTH"];
$gatewayBouWidth = $arrayGatewayData["BOU_WIDTH"];
$gatewayBouHeight = $arrayGatewayData["BOU_HEIGHT"];
if ($nextTaskUid != "-1") {
@@ -610,12 +613,12 @@ class WorkflowBpmn extends Project\Workflow
//BPMN
//Artifact
$arrayData = array(
"ART_UID" => $swiUid,
"ART_TYPE" => ($direction == "HORIZONTAL")? "HORIZONTAL_LINE" : "VERTICAL_LINE",
"ART_NAME" => "",
"BOU_X" => ($direction == "HORIZONTAL")? -6666 : $position,
"BOU_Y" => ($direction == "HORIZONTAL")? $position : -6666,
"BOU_WIDTH" => 0,
"ART_UID" => $swiUid,
"ART_TYPE" => ($direction == "HORIZONTAL") ? "HORIZONTAL_LINE" : "VERTICAL_LINE",
"ART_NAME" => "",
"BOU_X" => ($direction == "HORIZONTAL") ? -6666 : $position,
"BOU_Y" => ($direction == "HORIZONTAL") ? $position : -6666,
"BOU_WIDTH" => 0,
"BOU_HEIGHT" => 0
);
@@ -637,12 +640,12 @@ class WorkflowBpmn extends Project\Workflow
//BPMN
//Artifact
$arrayData = array(
"ART_UID" => $swiUid,
"ART_TYPE" => "TEXT_ANNOTATION",
"ART_NAME" => $text,
"BOU_X" => $x,
"BOU_Y" => $y,
"BOU_WIDTH" => 100,
"ART_UID" => $swiUid,
"ART_TYPE" => "TEXT_ANNOTATION",
"ART_NAME" => $text,
"BOU_X" => $x,
"BOU_Y" => $y,
"BOU_WIDTH" => 100,
"BOU_HEIGHT" => 30
);
@@ -689,7 +692,7 @@ class WorkflowBpmn extends Project\Workflow
$arrayWorkflowData["groupwfs"] = array();
//Create WorkflowBpmn
$arrayUid = array();
$arrayUid = array();
$arrayUid2 = array();
//Process
@@ -701,8 +704,8 @@ class WorkflowBpmn extends Project\Workflow
);
$arrayProcessData["PRO_PARENT"] = $processUidBk;
$arrayProcessData["PRO_TITLE"] = $arrayProcessData["PRO_TITLE"] . " - New version - " . date("M d, H:i:s");
$arrayProcessData["PRO_CREATE_USER"] = ($userUid != "")? $userUid : "00000000000000000000000000000001";
$arrayProcessData["PRO_TITLE"] = $arrayProcessData["PRO_TITLE"] . " - New version - " . date("M d, H:i:s");
$arrayProcessData["PRO_CREATE_USER"] = ($userUid != "") ? $userUid : "00000000000000000000000000000001";
$this->create($arrayProcessData);
@@ -739,7 +742,7 @@ class WorkflowBpmn extends Project\Workflow
$arrayRouteData = $value;
$arrayRouteData["TAS_UID"] = $arrayUid["task"][$arrayRouteData["TAS_UID"]];
$arrayRouteData["ROU_NEXT_TASK"] = ($arrayRouteData["ROU_NEXT_TASK"] != "-1")? $arrayUid["task"][$arrayRouteData["ROU_NEXT_TASK"]] : $arrayRouteData["ROU_NEXT_TASK"];
$arrayRouteData["ROU_NEXT_TASK"] = ($arrayRouteData["ROU_NEXT_TASK"] != "-1") ? $arrayUid["task"][$arrayRouteData["ROU_NEXT_TASK"]] : $arrayRouteData["ROU_NEXT_TASK"];
if ($arrayRouteData["ROU_TYPE"] != "SEC-JOIN") {
//Add
@@ -770,9 +773,9 @@ class WorkflowBpmn extends Project\Workflow
$swiUid = $this->addText($arrayLaneData["SWI_TEXT"], $swiX, $swiY);
break;
case "LINE":
$direction = (($swiX == 0)? "HORIZONTAL" : "VERTICAL");
$direction = (($swiX == 0) ? "HORIZONTAL" : "VERTICAL");
$swiUid = $this->addLine(($direction == "HORIZONTAL")? $swiY : $swiX, $direction);
$swiUid = $this->addLine(($direction == "HORIZONTAL") ? $swiY : $swiX, $direction);
break;
}
}
@@ -808,4 +811,3 @@ class WorkflowBpmn extends Project\Workflow
}
}
}

View File

@@ -225,7 +225,7 @@ class Bpmn extends Handler
$response = array();
foreach ($data as $key => $val) {
//Review if the type is "prj_uid"
if (isset($val['prj_uid']) && !empty($val['prj_uid']) ) {
if (isset($val['prj_uid']) && !empty($val['prj_uid'])) {
//The project exist?
if (!Bpmn::exists($val['prj_uid'])) {
$response[] = array(
@@ -514,7 +514,8 @@ class Bpmn extends Handler
}
// setting defaults
$data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Common::generateUID();;
$data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Common::generateUID();
;
$data['PRO_NAME'] = array_key_exists('PRO_NAME', $data) ? $data['PRO_NAME'] : $this->diagram->getDiaName();
$this->process = new Process();
@@ -696,7 +697,7 @@ class Bpmn extends Handler
);
}
public function updateEvent($evnUid, $data)
public function updateEvent($evnUid, array $data)
{
/*if (array_key_exists("EVN_CANCEL_ACTIVITY", $data)) {
$data["EVN_CANCEL_ACTIVITY"] = $data["EVN_CANCEL_ACTIVITY"] ? 1 : 0;
@@ -913,15 +914,22 @@ class Bpmn extends Handler
case "bpmnLaneset": $class = "BpmnLaneset"; break;
case "bpmnLane": $class = "BpmnLane"; break;
default:
throw new \RuntimeException(sprintf("Invalid Object type, accepted types: [%s|%s|%s|%s], given %s.",
"BpmnActivity", "BpmnBpmnGateway", "BpmnEvent", "bpmnArtifact", $data["FLO_ELEMENT_ORIGIN_TYPE"]
throw new \RuntimeException(sprintf(
"Invalid Object type, accepted types: [%s|%s|%s|%s], given %s.",
"BpmnActivity",
"BpmnBpmnGateway",
"BpmnEvent",
"bpmnArtifact",
$data["FLO_ELEMENT_ORIGIN_TYPE"]
));
}
// Validate origin object exists
if (! $class::exists($data["FLO_ELEMENT_ORIGIN"])) {
throw new \RuntimeException(sprintf("Reference not found, the %s with UID: %s, does not exist!",
ucfirst($data["FLO_ELEMENT_ORIGIN_TYPE"]), $data["FLO_ELEMENT_ORIGIN"]
throw new \RuntimeException(sprintf(
"Reference not found, the %s with UID: %s, does not exist!",
ucfirst($data["FLO_ELEMENT_ORIGIN_TYPE"]),
$data["FLO_ELEMENT_ORIGIN"]
));
}
@@ -935,15 +943,22 @@ class Bpmn extends Handler
case "bpmnLaneset": $class = "BpmnLaneset"; break;
case "bpmnLane": $class = "BpmnLane"; break;
default:
throw new \RuntimeException(sprintf("Invalid Object type, accepted types: [%s|%s|%s|%s], given %s.",
"BpmnActivity", "BpmnBpmnGateway", "BpmnEvent", "bpmnArtifact", $data["FLO_ELEMENT_DEST_TYPE"]
throw new \RuntimeException(sprintf(
"Invalid Object type, accepted types: [%s|%s|%s|%s], given %s.",
"BpmnActivity",
"BpmnBpmnGateway",
"BpmnEvent",
"bpmnArtifact",
$data["FLO_ELEMENT_DEST_TYPE"]
));
}
// Validate origin object exists
if (! $class::exists($data["FLO_ELEMENT_DEST"])) {
throw new \RuntimeException(sprintf("Reference not found, the %s with UID: %s, does not exist!",
ucfirst($data["FLO_ELEMENT_DEST_TYPE"]), $data["FLO_ELEMENT_DEST"]
throw new \RuntimeException(sprintf(
"Reference not found, the %s with UID: %s, does not exist!",
ucfirst($data["FLO_ELEMENT_DEST_TYPE"]),
$data["FLO_ELEMENT_DEST"]
));
}
@@ -1536,12 +1551,11 @@ class Bpmn extends Handler
}
}
public function getFlowNextPosition ($sFloUid, $sFloType, $sFloElementOrigin)
public function getFlowNextPosition($sFloUid, $sFloType, $sFloElementOrigin)
{
try {
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn( '(COUNT(*) + 1) AS FLOW_POS' );
$oCriteria->addSelectColumn('(COUNT(*) + 1) AS FLOW_POS');
$oCriteria->add(\BpmnFlowPeer::PRJ_UID, $this->getUid());
$oCriteria->add(\BpmnFlowPeer::DIA_UID, $this->getDiagram("object")->getDiaUid());
$oCriteria->add(\BpmnFlowPeer::FLO_UID, $sFloUid, \Criteria::NOT_EQUAL);
@@ -1552,26 +1566,25 @@ class Bpmn extends Handler
$oDataset->next();
$aRow = $oDataset->getRow();
return (int)($aRow["FLOW_POS"]);
} catch (Exception $oException) {
throw $oException;
}
}
public function reOrderFlowPosition ($sFloOrigin, $iPosition)
public function reOrderFlowPosition($sFloOrigin, $iPosition)
{
try {
$con = \Propel::getConnection('workflow');
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( \BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $sFloOrigin );
$oCriteria->add( \BpmnFlowPeer::FLO_POSITION, $iPosition, '>' );
$oDataset = \BpmnFlowPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oCriteria = new Criteria('workflow');
$oCriteria->add(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $sFloOrigin);
$oCriteria->add(\BpmnFlowPeer::FLO_POSITION, $iPosition, '>');
$oDataset = \BpmnFlowPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($oDataset->next()) {
$aRow = $oDataset->getRow();
$newPosition = ((int)$aRow['FLO_POSITION'])-1;
$oCriteriaTemp = new Criteria( 'workflow' );
$oCriteriaTemp->add( \BpmnFlowPeer::FLO_UID, $aRow['FLO_UID'] );
$oCriteriaTemp = new Criteria('workflow');
$oCriteriaTemp->add(\BpmnFlowPeer::FLO_UID, $aRow['FLO_UID']);
$oCriteria2 = new Criteria('workflow');
$oCriteria2->add(\BpmnFlowPeer::FLO_POSITION, $newPosition);
BasePeer::doUpdate($oCriteriaTemp, $oCriteria2, $con);
@@ -1680,8 +1693,7 @@ class Bpmn extends Handler
$level,
$message,
$context = array()
)
{
) {
try {
Bootstrap::registerMonolog($channel, $level, $message, $context, $context['workspace'], 'processmaker.log');
} catch (Exception $e) {
@@ -1689,4 +1701,3 @@ class Bpmn extends Handler
}
}
}

View File

@@ -15,6 +15,7 @@ use ProcessMaker\Util\Common;
use ProcessMaker\Exception;
use ProcessMaker\Util;
use ReportTables;
/**
* Class Workflow
*
@@ -68,7 +69,7 @@ class Workflow extends Handler
$testTitle = htmlspecialchars($data['PRO_TITLE']);
if($testTitle != $data['PRO_TITLE']) {
if ($testTitle != $data['PRO_TITLE']) {
$data['PRO_TITLE'] = $testTitle;
}
@@ -174,7 +175,7 @@ class Workflow extends Handler
* Projects elements handlers
*/
public function addTask($taskData)
public function addTask(array $taskData)
{
// Setting defaults
$taskData['TAS_UID'] = array_key_exists('TAS_UID', $taskData) ? $taskData['TAS_UID'] : Common::generateUID();
@@ -190,7 +191,6 @@ class Workflow extends Handler
if ($task->getTasType() == "SUBPROCESS") {
$this->addSubProcess($this->proUid, $tasUid);
}
} catch (\Exception $e) {
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
throw $e;
@@ -242,7 +242,6 @@ class Workflow extends Handler
}
}
}
} catch (\Exception $e) {
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
throw $e;
@@ -254,7 +253,7 @@ class Workflow extends Handler
try {
$task = new ClassesTask();
$taskData = $task->load($tasUid);
} catch (\Exception $e){
} catch (\Exception $e) {
$taskData = null;
}
@@ -320,7 +319,6 @@ class Workflow extends Handler
public function updateSubProcess()
{
}
/**
@@ -398,8 +396,8 @@ class Workflow extends Handler
}
//if ($type == 'SEQUENTIAL' || $type == 'SEC-JOIN' || $type == 'DISCRIMINATOR') {
//$oTasks = new Tasks();
//$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid);
//$oTasks = new Tasks();
//$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid);
//}
$route = \Route::findOneBy([
@@ -547,7 +545,7 @@ class Workflow extends Handler
$aFields["ROU_TYPE"] = $sType;
$aFields["ROU_DEFAULT"] = $default;
if(! empty($condition)) {
if (! empty($condition)) {
$aFields['ROU_CONDITION'] = $condition;
}
@@ -894,7 +892,7 @@ class Workflow extends Handler
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$emailEvent->delete($sProcessUID,$row["EMAIL_EVENT_UID"],false);
$emailEvent->delete($sProcessUID, $row["EMAIL_EVENT_UID"], false);
}
if (!$onlyDiagram) {
@@ -945,7 +943,7 @@ class Workflow extends Handler
'PRO_UID'=>$this->proUid,
'TAS_UID'=>'',
'SCH_TIME_NEXT_RUN'=>date('Y-m-d H:i:s'),
'SCH_LAST_RUN_TIME'=>NULL,
'SCH_LAST_RUN_TIME'=>null,
'SCH_STATE'=>'',
'SCH_LAST_STATE'=>'',
'USR_UID'=>'',
@@ -953,7 +951,7 @@ class Workflow extends Handler
'SCH_START_TIME'=>date('Y-m-d H:i:s'),
'SCH_START_DATE'=>date('Y-m-d H:i:s'),
'SCH_DAYS_PERFORM_TASK'=>'',
'SCH_EVERY_DAYS'=>NULL,
'SCH_EVERY_DAYS'=>null,
'SCH_WEEK_DAYS'=>'',
'SCH_START_DAY'=>'',
'SCH_START_DAY_OPT_1'=>'',
@@ -962,7 +960,7 @@ class Workflow extends Handler
'SCH_END_DATE'=>date('Y-m-d H:i:s'),
'SCH_REPEAT_EVERY'=>'',
'SCH_REPEAT_STOP_IF_RUNNING'=>'',
'CASE_SH_PLUGIN_UID'=>NULL,
'CASE_SH_PLUGIN_UID'=>null,
'SCH_DEL_USER_PASS'=>'',
'SCH_UID'=>$schUid,
'SCH_REPEAT_UNTIL'=>''
@@ -1047,7 +1045,6 @@ class Workflow extends Handler
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
throw $e;
}
}
public function addLine($position, $direction = "HORIZONTAL")
@@ -1323,8 +1320,8 @@ class Workflow extends Handler
isset($arrayWorkflowData["uid"][$value["CTO_TYPE_OBJ"]]) &&
isset($arrayWorkflowData["uid"][$value["CTO_TYPE_OBJ"]][$value["CTO_UID_OBJ"]])) {
$arrayWorkflowData["caseTrackerObject"][$key]["CTO_UID_OBJ"] = $arrayWorkflowData["uid"][$value["CTO_TYPE_OBJ"]][$value["CTO_UID_OBJ"]];
}
}
}
}
//Synchronize variables with process variables.
foreach ($arrayWorkflowData["processVariables"] as $key => $value) {
@@ -1378,4 +1375,3 @@ class Workflow extends Handler
}
}
}

View File

@@ -2,27 +2,29 @@
namespace ProcessMaker\Services\OAuth2;
use PDO;
/**
* Simple PmPDO storage for all storage types
* based on \OAuth2\Storage\Pdo
*
* @author Erik Amaru Ortiz <aortiz.erik at gmail dot com>
*/
class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
class PmPdo implements
\OAuth2\Storage\AuthorizationCodeInterface,
\OAuth2\Storage\AccessTokenInterface,
\OAuth2\Storage\ClientCredentialsInterface,
\OAuth2\Storage\UserCredentialsInterface,
\OAuth2\Storage\RefreshTokenInterface,
\OAuth2\Storage\JwtBearerInterface
{
protected $db;
protected $dbRBAC;
protected $config;
public function __construct($connection, $config = array(), $connectionRBAC = null)
{
if (!$connection instanceof \PDO) {
if (!$connection instanceof PDO) {
if (!is_array($connection)) {
throw new \InvalidArgumentException('First argument to OAuth2\Storage\Pdo must be an instance of PDO or a configuration array');
}
@@ -34,12 +36,12 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
'username' => null,
'password' => null,
), $connection);
$connection = new \PDO($connection['dsn'], $connection['username'], $connection['password']);
$connection = new PDO($connection['dsn'], $connection['username'], $connection['password']);
}
$this->db = $connection;
// it's for Pm < 3
if (!is_null($connectionRBAC) &&(!$connectionRBAC instanceof \PDO)) {
if (!is_null($connectionRBAC) &&(!$connectionRBAC instanceof PDO)) {
if (!is_array($connectionRBAC)) {
throw new \InvalidArgumentException('First argument to OAuth2\Storage\Pdo must be an instance of PDO or a configuration array');
}
@@ -51,12 +53,12 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
'username' => null,
'password' => null,
), $connectionRBAC);
$connectionRBAC = new \PDO($connectionRBAC['dsn'], $connectionRBAC['username'], $connectionRBAC['password']);
$connectionRBAC = new PDO($connectionRBAC['dsn'], $connectionRBAC['username'], $connectionRBAC['password']);
}
$this->dbRBAC = $connectionRBAC;
// debugging
$connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->config = array_merge(array(
'client_table' => 'OAUTH_CLIENTS',
@@ -173,7 +175,7 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
{
$access_token = new \OauthAccessTokens();
$access_token->load($token);
$stmt = $this->db->prepare(sprintf('UPDATE %s SET EXPIRES=%s WHERE ACCESS_TOKEN=:token', $this->config['access_token_table'], "'".Date('Y-m-d H:i:s',strtotime("-1 minute"))."'"));
$stmt = $this->db->prepare(sprintf('UPDATE %s SET EXPIRES=%s WHERE ACCESS_TOKEN=:token', $this->config['access_token_table'], "'".Date('Y-m-d H:i:s', strtotime("-1 minute"))."'"));
return $stmt->execute(compact('token'));
}
@@ -192,12 +194,12 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
{
$RBAC = \RBAC::getSingleton();
$RBAC->initRBAC();
$uid = $RBAC->VerifyLogin($username , $password);
if($uid < 0){
return false;
$uid = $RBAC->VerifyLogin($username, $password);
if ($uid < 0) {
return false;
}
if($uid != ''){
return true;
if ($uid != '') {
return true;
}
return false;
}
@@ -295,6 +297,4 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
return array_merge($a, array_change_key_case($a, $case));
}
}