Merged in bugfix/PMC-377 (pull request #6780)

PMC-377

Approved-by: David Callizaya <david.callizaya@processmaker.com>
Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
Roly
2019-02-13 20:59:29 +00:00
committed by Paula Quispe
8 changed files with 182 additions and 49 deletions

View File

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

View File

@@ -1,5 +1,16 @@
<?php
/**
* @see workflow/engine/bin/cron.php
* @see workflow/engine/bin/messageeventcron.php
* @see workflow/engine/bin/timereventcron.php
* @see workflow/engine/bin/ldapcron.php
* @see workflow/engine/bin/sendnotificationscron.php
* @see workflow/engine/methods/setup/cron.php
*
* @link https://wiki.processmaker.com/3.2/Executing_cron.php
*/
use Illuminate\Foundation\Http\Kernel;
require_once __DIR__ . '/../../../gulliver/system/class.g.php';
@@ -202,6 +213,22 @@ try {
if (!defined('DB_ADAPTER')) {
define('DB_ADAPTER', $DB_ADAPTER);
}
if (!defined('DB_HOST')) {
define('DB_HOST', $DB_HOST);
}
if (!defined('DB_NAME')) {
define('DB_NAME', $DB_NAME);
}
if (!defined('DB_USER')) {
define('DB_USER', $DB_USER);
}
if (!defined('DB_PASS')) {
define('DB_PASS', $DB_PASS);
}
if (!defined('SYS_SKIN')) {
$conf = new Configurations();
define('SYS_SKIN', $conf->getConfiguration('SKIN_CRON', ''));
}
//Set Time Zone
$systemUtcTimeZone = false;

View File

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

View File

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

View File

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

View File

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

View File

@@ -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
*
* @return string $message
* @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;
}

View File

@@ -1202,9 +1202,12 @@ 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
* @param bool $frontEnd Flag to represent the terminal front-end
* @throws \Exception
*
* return void
* @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;