diff --git a/workflow/engine/bin/cli.php b/workflow/engine/bin/cli.php index 5407f9786..c6e568654 100644 --- a/workflow/engine/bin/cli.php +++ b/workflow/engine/bin/cli.php @@ -41,8 +41,10 @@ if (!defined('TIME_ZONE')) { $cliName = array_shift($args); $taskName = array_shift($args); $workspace = array_shift($args); - while ($workspace[0] == '-') { - $workspace = array_shift($args); + if (isset($workspace[0])) { + while ($workspace[0] == '-') { + $workspace = array_shift($args); + } } // Get time zone (global or by workspace) diff --git a/workflow/engine/classes/ActionsByEmailCoreClass.php b/workflow/engine/classes/ActionsByEmailCoreClass.php index d9cb9a8e0..38515fd73 100644 --- a/workflow/engine/classes/ActionsByEmailCoreClass.php +++ b/workflow/engine/classes/ActionsByEmailCoreClass.php @@ -7,6 +7,7 @@ use ProcessMaker\Services\Api\Project\Variable; class ActionsByEmailCoreClass extends PMPlugin { + //The %0d and %0a are URL-encoded forms of CR and LF const BODY_REPLY_LF = '%0D%0A'; private $abeRequest = []; private $appNumber = null; @@ -716,38 +717,60 @@ class ActionsByEmailCoreClass extends PMPlugin $customGrid = unserialize($this->getItemAbeProperties('ABE_CUSTOM_GRID')); $field = new stdClass(); $field->label = ''; - $html = '
' . $field->label . ''; - $html .= '\n" + . "\n" + . "
'; + + $html = '' + . "
\n" + . "{$field->label}\n" + . "
\n" + . "\n" + . "\n" + . "
\n" + . "\n" + . "\n"; + $index = 1; foreach ($customGrid as $key => $value) { - // Get the subject $emailSubject = $this->getSubjectByResponse($value['abe_custom_label']); $emailBody = $this->getBodyByResponse($value['abe_custom_value']); - // Define the html for the actions - $html .= '' . (($index % 5 == 0) ? '' : ' '); + + $emailSubject = rawurlencode($emailSubject); + $emailBody = rawurlencode($emailBody); + + $href = "mailto:{$noReply}?subject={$emailSubject}&body={$emailBody}"; + + $html = $html + . "\n"; + //this is left for compatibility with template customizations + if ($index % 5 === 0) { + $html = $html + . "\n" + . "\n"; + } $index++; } - $html .= '
'; - $html .= $value['abe_custom_label']; - $html .= '
\n" + . "{$value['abe_custom_label']}\n" + . "
'; + $html = $html + . "
\n" + . "
\n" + . "\n"; return $html; } /** - * Get the subject for response the action by email - * + * Get the subject for response the action by email. + * * @param string $fieldLabel - * * @return string */ - private function getSubjectByResponse($fieldLabel) + private function getSubjectByResponse(string $fieldLabel): string { $subject = G::LoadTranslation('ID_CASE') . ' ' . $this->getCasePropertiesKey('APP_TITLE'); $subject .= $this->delimiter . ' ' . $fieldLabel; - - return urlencode($subject); + return $subject; } /** @@ -769,10 +792,11 @@ class ActionsByEmailCoreClass extends PMPlugin ]; $bodyToCrypt = G::json_encode($bodyToCrypt); - $body = str_repeat(self::BODY_REPLY_LF, 4); - $body .= '/' . str_repeat("=", 24) . self::BODY_REPLY_LF; - $body .= G::LoadTranslation('ID_ABE_EMAIL_RESPONSE_BODY_NOTE') . self::BODY_REPLY_LF; - $body .= '{' . Crypt::encryptString($bodyToCrypt) . '}' . self::BODY_REPLY_LF; + $CR_LF = "\r\n"; + $body = str_repeat($CR_LF, 4); + $body .= '/' . str_repeat("=", 24) . $CR_LF; + $body .= G::LoadTranslation('ID_ABE_EMAIL_RESPONSE_BODY_NOTE') . $CR_LF; + $body .= '{' . Crypt::encryptString($bodyToCrypt) . '}' . $CR_LF; $body .= str_repeat("=", 24) . '/'; return $body; } diff --git a/workflow/engine/classes/CLI.php b/workflow/engine/classes/CLI.php index c98053df0..9963ce5fc 100644 --- a/workflow/engine/classes/CLI.php +++ b/workflow/engine/classes/CLI.php @@ -206,8 +206,10 @@ EOT; $args = $argv; $cliname = array_shift( $args ); $taskName = array_shift( $args ); - while ($taskName[0] == '-') { - $taskName = array_shift( $args ); + if (isset($taskName[0])) { + while ($taskName[0] == '-') { + $taskName = array_shift( $args ); + } } if (! $taskName) { echo self::error( "Specify a task from the list below." ) . "\n\n"; diff --git a/workflow/engine/classes/model/AppDocument.php b/workflow/engine/classes/model/AppDocument.php index 115aecf33..35bc30d28 100644 --- a/workflow/engine/classes/model/AppDocument.php +++ b/workflow/engine/classes/model/AppDocument.php @@ -162,7 +162,7 @@ class AppDocument extends BaseAppDocument try { $oAppDocument = new AppDocument(); - if (! isset( $aData['APP_DOC_UID'] )) { + if (empty($aData['APP_DOC_UID'])) { $sUID = G::generateUniqueID(); $docVersion = 1; } else { diff --git a/workflow/engine/methods/cases/open.php b/workflow/engine/methods/cases/open.php index c30ea1c4b..8cbab67af 100644 --- a/workflow/engine/methods/cases/open.php +++ b/workflow/engine/methods/cases/open.php @@ -16,6 +16,7 @@ use ProcessMaker\BusinessModel\Cases as BmCases; use ProcessMaker\BusinessModel\ProcessSupervisor; +use ProcessMaker\Core\System; $tBarGmail = false; if (isset($_GET['gmail']) && $_GET['gmail'] == 1) { @@ -157,6 +158,7 @@ if ($isBpmn && $viewSummaryForm && $isNoEmpty) { } /*----------------------------------********---------------------------------*/ +$pmDynaform = new PmDynaform(); $step = new Step(); $step = $step->loadByProcessTaskPosition($case['PRO_UID'], $case['TAS_UID'], 1); $headPublisher->assign('uri', $script . $uri); @@ -171,6 +173,11 @@ $headPublisher->assign('appStatus', $case['APP_STATUS']); $headPublisher->assign('tbarGmail', $tBarGmail); $headPublisher->assign('showCustomForm', $showCustomForm); $headPublisher->assign('canClaimCase', $canClaimCase); +$headPublisher->assign('_CREDENTIALS', G::json_encode($pmDynaform->getCredentials())); +$headPublisher->assign('_SERVER', System::getHttpServerHostnameRequestsFrontEnd()); +$headPublisher->assign('_WORKSPACE', config("system.workspace")); +$headPublisher->assign('_DEL_INDEX_DELEGATE', $delIndex); +$headPublisher->assign('_USR_DELEGATE', $case['CURRENT_USER_UID']); if (!isset($_SESSION['APPLICATION']) || !isset($_SESSION['TASK']) || !isset($_SESSION['INDEX'])) { $_SESSION['PROCESS'] = $case['PRO_UID']; diff --git a/workflow/engine/methods/userPersonalInformation/src/components/personalInformation.vue b/workflow/engine/methods/userPersonalInformation/src/components/personalInformation.vue index a1c1c05c1..533c14188 100644 --- a/workflow/engine/methods/userPersonalInformation/src/components/personalInformation.vue +++ b/workflow/engine/methods/userPersonalInformation/src/components/personalInformation.vue @@ -467,11 +467,11 @@ mounted() { this.$nextTick(function () { let promise = null; + this.getTimeZoneList(); if ("USR_UID" in window && window.USR_UID !== "") { this.editing = true; promise = this.load(); - promise.then(response => { - response; + promise.then(() => { this.loadServices(); }); } else { @@ -851,7 +851,6 @@ loadServices() { this.getCountryList(); this.getAvailableCalendars(); - this.getTimeZoneList(); this.getLanguagesList(); this.getDefaultMainMenuOptionList(); this.getDefaultCasesMenuOptionList(); diff --git a/workflow/engine/templates/cases/open.js b/workflow/engine/templates/cases/open.js index 1e4a91057..d4c09e5b5 100644 --- a/workflow/engine/templates/cases/open.js +++ b/workflow/engine/templates/cases/open.js @@ -1368,7 +1368,8 @@ Ext.onReady(function(){ Actions.reassignCase = function() { var rowSelected = Ext.getCmp("grdpnlUsersToReassign").getSelectionModel().getSelected(); - + var msg = ""; + var credentials = JSON.parse(_CREDENTIALS); if( rowSelected ) { if (Ext.getCmp('idTextareaReason').getValue() === '') { Ext.Msg.alert(_('ID_ALERT'), _('ID_THE_REASON_REASSIGN_USER_EMPTY')); @@ -1376,11 +1377,17 @@ Ext.onReady(function(){ } PMExt.confirm(_('ID_CONFIRM'), _('ID_REASSIGN_CONFIRM'), function(){ Ext.Ajax.request({ - url : 'ajaxListener' , - params : {action : 'reassignCase', USR_UID: rowSelected.data.USR_UID, NOTE_REASON: Ext.getCmp('idTextareaReason').getValue(), NOTIFY_REASSIGN: Ext.getCmp('idCheckboxReason').getValue()}, - success: function ( result, request ) { - var data = Ext.util.JSON.decode(result.responseText); - if( data.status == 0 ) { + method:"PUT", + url: _SERVER + "/api/1.0/" + _WORKSPACE + `/cases/${_APP_UID}/reassign-case`, + headers: { + "Accept": "application/json", + "Content-Type": "application/json", + "Authorization": `Bearer ` + credentials.accessToken, + }, + jsonData : {del_index : _DEL_INDEX_DELEGATE, usr_uid_target: rowSelected.data.USR_UID,usr_uid_source: _USR_DELEGATE, reason: Ext.getCmp('idTextareaReason').getValue()}, + success: function (result, request) { + var data = result; + if( data.status == 0 || data.status == 200) { try { if (typeof parent.notify !== "undefined") { parent.notify('', data.msg); @@ -1402,8 +1409,9 @@ Ext.onReady(function(){ alert(data.msg); } }, - failure: function ( result, request) { - Ext.MessageBox.alert( _('ID_FAILED') , result.responseText); + failure: function (result, request) { + msg = JSON.parse(result.responseText); + Ext.MessageBox.alert( _('ID_FAILED') , msg.error? msg.error.message: ""); } }); });