From da2ea4c865e73559d1aca5efea4cc600bb5b9ef2 Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Wed, 13 Feb 2019 15:53:21 -0400 Subject: [PATCH] PMC-377 --- gulliver/system/class.bootstrap.php | 54 ++++++++++---- workflow/engine/bin/cron_single.php | 27 +++++++ .../classes/ActionsByEmailCoreClass.php | 23 +++++- workflow/engine/classes/PmDynaform.php | 13 +++- .../engine/classes/model/AbeConfiguration.php | 16 ++++ workflow/engine/classes/model/AppNotes.php | 11 ++- .../BusinessModel/ActionsByEmail.php | 74 +++++++++++++------ .../ProcessMaker/BusinessModel/TimerEvent.php | 13 +++- 8 files changed, 182 insertions(+), 49 deletions(-) diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php index 058c4c835..a5874a76b 100644 --- a/gulliver/system/class.bootstrap.php +++ b/gulliver/system/class.bootstrap.php @@ -2683,30 +2683,54 @@ class Bootstrap * Get the default information from the context * * @return array + * + * @see AdditionalTables->populateReportTable + * @see AppAssignSelfServiceValueGroup->createRow + * @see Bootstrap->registerMonologPhpUploadExecution() + * @see Cases->loadDataSendEmail() + * @see Cases->removeCase() + * @see Cases->reportTableDeleteRecord() + * @see Derivation->derivate + * @see G->logTriggerExecution() + * @see LdapAdvanced->VerifyLogin + * @see ldapadvancedClassCron->executeCron + * @see PmDynaform->__construct + * @see pmTablesProxy->genDataReport + * @see Processes->createFiles + * @see ProcessMaker\AuditLog\AuditLog->register + * @see ProcessMaker\Util\ParseSoapVariableName->buildVariableName + * @see RBAC->checkAutomaticRegister() + * @see workflow/engine/classes/class.pmFunctions.php::executeQuery + + * @link https://wiki.processmaker.com/3.3/Actions_by_Email + * @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions + * @link https://wiki.processmaker.com/3.1/Report_Tables + * @link https://wiki.processmaker.com/3.2/Cases/Running_Cases + * @link https://wiki.processmaker.com/3.3/login + * @link https://wiki.processmaker.com/3.2/Executing_cron.php + * @link https://wiki.processmaker.com/3.2/HTML5_Responsive_DynaForm_Designer + * @link https://wiki.processmaker.com/3.2/Audit_Log + * @link https://wiki.processmaker.com/3.0/ProcessMaker_WSDL_Web_Services */ public static function getDefaultContextLog() { - - global $RBAC; $info = [ 'ip' => G::getIpAddress(), 'workspace' => !empty(config('system.workspace')) ? config('system.workspace') : 'Undefined Workspace', - 'timeZone' => DateTime::convertUtcToTimeZone(date('Y-m-d H:m:s')) + 'timeZone' => DateTime::convertUtcToTimeZone(date('Y-m-d H:m:s')), + 'usrUid' => G::LoadTranslation('UID_UNDEFINED_USER') ]; - if ($RBAC !== null) { - $userInfo = [ - 'usrUid' => $RBAC->aUserInfo['USER_INFO']['USR_UID'] - ]; - $info = array_merge($info, $userInfo); + global $RBAC; + if (!empty($RBAC) && !empty($RBAC->aUserInfo['USER_INFO']) && !empty($RBAC->aUserInfo['USER_INFO']['USR_UID'])) { + $info['usrUid'] = $RBAC->aUserInfo['USER_INFO']['USR_UID']; + return $info; } - //Some endpoints can defined the USER_LOGGED - if (empty($info['usrUid'])) { - $user = !empty($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : G::LoadTranslation('UID_UNDEFINED_USER'); - $userInfo = [ - 'usrUid' => $user - ]; - $info = array_merge($info, $userInfo); + + //if default session exists + if (!empty($_SESSION['USER_LOGGED'])) { + $info['usrUid'] = $_SESSION['USER_LOGGED']; + return $info; } return $info; diff --git a/workflow/engine/bin/cron_single.php b/workflow/engine/bin/cron_single.php index 31b17228d..7324ddb97 100644 --- a/workflow/engine/bin/cron_single.php +++ b/workflow/engine/bin/cron_single.php @@ -1,5 +1,16 @@ getConfiguration('SKIN_CRON', '')); + } //Set Time Zone $systemUtcTimeZone = false; diff --git a/workflow/engine/classes/ActionsByEmailCoreClass.php b/workflow/engine/classes/ActionsByEmailCoreClass.php index 87eac721e..4228bf13e 100644 --- a/workflow/engine/classes/ActionsByEmailCoreClass.php +++ b/workflow/engine/classes/ActionsByEmailCoreClass.php @@ -23,9 +23,16 @@ class ActionsByEmailCoreClass extends PMPlugin } /** - * @param $data - * @param $dataAbe + * Send Actions By Email. + * + * @global object $RBAC + * @param object $data + * @param array $dataAbe + * @return type * @throws Exception + * + * @see AppDelegation->createAppDelegation() + * @link https://wiki.processmaker.com/3.3/Actions_by_Email */ public function sendActionsByEmail($data, $dataAbe) { @@ -246,14 +253,22 @@ class ActionsByEmailCoreClass extends PMPlugin $user = new Users(); + $emailFrom = ''; if (!$configuration['ABE_MAILSERVER_OR_MAILCURRENT'] && $configuration['ABE_TYPE'] !== '') { if ($data->PREVIOUS_USR_UID !== '') { $userDetails = $user->loadDetails($data->PREVIOUS_USR_UID); $emailFrom = ($userDetails["USR_FULLNAME"] . ' <' . $userDetails["USR_EMAIL"] . '>'); } else { global $RBAC; - $currentUser = $RBAC->aUserInfo['USER_INFO']; - $emailFrom = ($currentUser["USR_FIRSTNAME"] . ' ' . $currentUser["USR_LASTNAME"] . ' <' . $currentUser["USR_EMAIL"] . '>'); + if ($RBAC != null && is_array($RBAC->aUserInfo['USER_INFO'])) { + $currentUser = $RBAC->aUserInfo['USER_INFO']; + $emailFrom = ($currentUser["USR_FIRSTNAME"] . ' ' . $currentUser["USR_LASTNAME"] . ' <' . $currentUser["USR_EMAIL"] . '>'); + } else { + $usersPeer = UsersPeer::retrieveByPK($data->USR_UID); + if (!empty($usersPeer)) { + $emailFrom = ($usersPeer->getUsrFirstname() . ' ' . $usersPeer->getUsrLastname() . ' <' . $usersPeer->getUsrEmail() . '>'); + } + } } } else { if (isset($emailSetup["MESS_FROM_NAME"]) && isset($emailSetup["MESS_FROM_MAIL"])) { diff --git a/workflow/engine/classes/PmDynaform.php b/workflow/engine/classes/PmDynaform.php index b85c92107..4169c3a10 100644 --- a/workflow/engine/classes/PmDynaform.php +++ b/workflow/engine/classes/PmDynaform.php @@ -1359,9 +1359,20 @@ class PmDynaform exit(); } + /** + * Print PmDynaform for Action by Email. + * + * @param array $record + * @return string + * + * @see ActionsByEmailCoreClass->sendActionsByEmail() + * @link https://wiki.processmaker.com/3.3/Actions_by_Email + */ public function printPmDynaformAbe($record) { - ob_clean(); + if (ob_get_length() > 0) { + ob_clean(); + } $this->record = $record; $json = G::json_decode($this->record["DYN_CONTENT"]); $this->jsonr($json); diff --git a/workflow/engine/classes/model/AbeConfiguration.php b/workflow/engine/classes/model/AbeConfiguration.php index 6b740d85a..66b6cf0d0 100644 --- a/workflow/engine/classes/model/AbeConfiguration.php +++ b/workflow/engine/classes/model/AbeConfiguration.php @@ -48,6 +48,17 @@ class AbeConfiguration extends BaseAbeConfiguration } } + /** + * Create or update. + * + * @param array $data + * @throws Exception + * + * @see Processes->createActionsByEmail() + * @see ProcessMaker\BusinessModel\ActionsByEmail->saveConfiguration() + * @see ProcessMaker\BusinessModel\ActionsByEmail->saveConfiguration2() + * @link https://wiki.processmaker.com/3.3/Actions_by_Email#Configuration + */ public function createOrUpdate($data) { foreach ($data as $field => $value) { @@ -70,6 +81,11 @@ class AbeConfiguration extends BaseAbeConfiguration } else { $abeConfigurationInstance = AbeConfigurationPeer::retrieveByPK($data['ABE_UID']); } + //Only the 'FIELD' and 'LINK' types have a DYN_UID, + //the DYN_UID field is empty when the type is 'CUSTOM'. + if ($data['ABE_TYPE'] === 'CUSTOM') { + $data['DYN_UID'] = ''; + } if (isset($data['ABE_CUSTOM_GRID'])) { $data['ABE_CUSTOM_GRID'] = serialize($data['ABE_CUSTOM_GRID']); diff --git a/workflow/engine/classes/model/AppNotes.php b/workflow/engine/classes/model/AppNotes.php index 57db63a23..e40a75068 100644 --- a/workflow/engine/classes/model/AppNotes.php +++ b/workflow/engine/classes/model/AppNotes.php @@ -169,9 +169,14 @@ class AppNotes extends BaseAppNotes $configuration['MESS_ENGINE'] = ''; } - $users = new Users(); - $userInfo = $users->load($usrUid); - $authorName = ((($userInfo['USR_FIRSTNAME'] != '') || ($userInfo['USR_LASTNAME'] != '')) ? $userInfo['USR_FIRSTNAME'] . ' ' . $userInfo['USR_LASTNAME'] . ' ' : '') . '<' . $userInfo['USR_EMAIL'] . '>'; + //This value can be empty when the previous task is: 'Script Task', 'Timer Event' or other without user. + if (!empty($usrUid)) { + $users = new Users(); + $userInfo = $users->load($usrUid); + $authorName = ((($userInfo['USR_FIRSTNAME'] != '') || ($userInfo['USR_LASTNAME'] != '')) ? $userInfo['USR_FIRSTNAME'] . ' ' . $userInfo['USR_LASTNAME'] . ' ' : '') . '<' . $userInfo['USR_EMAIL'] . '>'; + } else { + $authorName = G::LoadTranslation('UID_UNDEFINED_USER'); + } $cases = new Cases(); $fieldCase = $cases->loadCase($appUid, $delIndex); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ActionsByEmail.php b/workflow/engine/src/ProcessMaker/BusinessModel/ActionsByEmail.php index 7764ad001..77f1581f9 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/ActionsByEmail.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ActionsByEmail.php @@ -265,12 +265,15 @@ class ActionsByEmail } /** - * Get the information for the log - * + * Get the information for the log. + * * @param array $arrayData - * * @return array - */ + * + * @see ProcessMaker\Services\Api\ActionsByEmail->loadActionByEmail() + * @see workflow/engine/methods/actionsByEmail/actionsByEmailAjax.php + * @link https://wiki.processmaker.com/3.3/Actions_by_Email + */ public function loadActionByEmail(array $arrayData) { //Get the total @@ -331,10 +334,15 @@ class ActionsByEmail //Get the previous user $appDelegation = new AppDelegation(); $usrUid = $appDelegation->getUserAssignedInThread($data[$index]['APP_UID'], $data[$index]['DEL_PREVIOUS']); - $users = new ClassUsers(); - $dataRes = $users->load($usrUid); - if (!empty($dataRes)) { - $data[$index]['USER'] = $dataRes['USR_FIRSTNAME'] . ' ' . $dataRes['USR_LASTNAME']; + //This value can be empty when the previous task is: 'Script Task', 'Timer Event' or other without user. + if (!empty($usrUid)) { + $users = new ClassUsers(); + $dataRes = $users->load($usrUid); + if (!empty($dataRes)) { + $data[$index]['USER'] = $dataRes['USR_FIRSTNAME'] . ' ' . $dataRes['USR_LASTNAME']; + } else { + $data[$index]['USER'] = ''; + } } else { $data[$index]['USER'] = ''; } @@ -435,10 +443,14 @@ class ActionsByEmail } /** - * Get the decision from Actions By Email and check if is Bpmn Process + * Get the decision from Actions By Email and check if is Bpmn Process. * @param array $arrayData * * @return string $message + * + * @see workflow/engine/methods/actionsByEmail/actionsByEmailAjax.php + * @see ProcessMaker\Services\Api\ActionsByEmail->viewForm() + * @link https://wiki.processmaker.com/3.3/Actions_by_Email#Actions_by_Email_Log */ public function viewForm(array $arrayData) { @@ -453,6 +465,7 @@ class ActionsByEmail $criteria->addSelectColumn(AbeConfigurationPeer::TAS_UID); $criteria->addSelectColumn(AbeConfigurationPeer::DYN_UID); $criteria->addSelectColumn(AbeConfigurationPeer::ABE_ACTION_FIELD); + $criteria->addSelectColumn(AbeConfigurationPeer::ABE_TYPE); $criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_UID); $criteria->addSelectColumn(AbeRequestsPeer::APP_UID); @@ -468,17 +481,21 @@ class ActionsByEmail $resultRes->setFetchmode(ResultSet::FETCHMODE_ASSOC); $resultRes->next(); - $dataRes = Array(); + $dataRes = []; $message = G::LoadTranslation('ID_USER_NOT_RESPONDED_REQUEST'); if ($dataRes = $resultRes->getRow()) { $_SESSION['CURRENT_DYN_UID'] = trim($dataRes['DYN_UID']); $process = new \Process(); $isBpmn = $process->isBpmnProcess($dataRes['PRO_UID']); - if($isBpmn) { - $message = $this->viewFormBpmn($dataRes); + if ($isBpmn) { + if ($dataRes['ABE_TYPE'] === 'FIELD') { + $message = $this->viewFormBpmn($dataRes); + } else { + $message = G::LoadTranslation('ID_CASE_RESPONSE_NOT_AVAILABLE'); + } } else { - $message = $this->viewFormClassic($dataRes); + $message = $this->viewFormClassic($dataRes); //to do, review this function } } @@ -538,11 +555,13 @@ class ActionsByEmail } /** - * Get the decision from Actions By Email by BPMN dynaform - * + * Get the decision from Actions By Email by BPMN dynaform. + * * @param array $dataRes - * - * @return string $message + * @return string + * + * @see ActionsByEmail->viewForm() + * @link https://wiki.processmaker.com/3.3/Actions_by_Email */ public function viewFormBpmn(array $dataRes) { @@ -599,9 +618,15 @@ class ActionsByEmail case 'dropdown': case 'radiogroup': case 'radio': - $message = $field->label . ': '; - $message .= $field->options[$value]; + if (!empty($field->options[$value])) { + $message = $field->label . ': '; + $message .= $field->options[$value]; + } break; + /** + * 'yesno' is deprecated in version ProcessMaker 3.x.x. + * @deprecated + */ case 'yesno': $message = $field->label . ': '; $message .= $value == 1 ? G::LoadTranslation('ID_YES') : G::LoadTranslation('ID_NO'); @@ -609,13 +634,18 @@ class ActionsByEmail case 'checkgroup': case 'checkbox': $message = $field->label . ': '; - $message .= $value == 'On' ? G::LoadTranslation('ID_CHECK') : G::LoadTranslation('ID_UNCHECK'); + if (!empty($value)) { + /** + * Value 'On' is deprecated in version ProcessMaker 3.x.x. + * now return '1'. + * @deprecated + */ + $message .= ($value == 'On' || $value == '1') ? G::LoadTranslation('ID_CHECK') : G::LoadTranslation('ID_UNCHECK'); + } break; } } } - - //Return return $message; } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/TimerEvent.php b/workflow/engine/src/ProcessMaker/BusinessModel/TimerEvent.php index 3496b1268..c997f2508 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/TimerEvent.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/TimerEvent.php @@ -1200,11 +1200,14 @@ class TimerEvent /** * Start/Continue case by Timer-Event - * + * * @param string $datetime Datetime (yyyy-mm-dd hh:ii:ss) - * @param bool $frontEnd Flag to represent the terminal front-end - * - * return void + * @param bool $frontEnd Flag to represent the terminal front-end + * @throws \Exception + * + * @see workflow/engine/bin/cron_single.php + * @link https://wiki.processmaker.com/3.3/Actions_by_Email + * @link https://wiki.processmaker.com/3.2/Executing_cron.php */ public function startContinueCaseByTimerEvent($datetime, $frontEnd = false) { @@ -1622,6 +1625,8 @@ class TimerEvent $delIndex = $row["DEL_INDEX"]; $delDelegateDate = $row["DEL_DELEGATE_DATE"]; $bpmnEventName = $row["EVN_NAME"]; + $taskUid = !empty($arrayApplicationData['APP_DATA']) && !empty($arrayApplicationData['APP_DATA']['TASK']) ? + $arrayApplicationData['APP_DATA']['TASK'] : ''; //Continue the case $continueCaseDate = $delDelegateDate;