Merged in feature/HOR-3214 (pull request #5712)

Feature/HOR-3214

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
David Callizaya
2017-06-03 19:50:20 +00:00
committed by Julio Cesar Laura Avendaño
11 changed files with 705 additions and 6 deletions

View File

@@ -40,7 +40,7 @@ class WorkflowTestCase extends TestCase
/**
* Import a process to the database.
*
*
* @param type $filename ProcessMaker file to be imported
* @return string PRO_UID
*/
@@ -91,7 +91,7 @@ class WorkflowTestCase extends TestCase
/**
* Clear all the translated messages loaded.
*
*
* @global array $translation
*/
protected function clearTranslations()

View File

@@ -27785,6 +27785,18 @@ msgstr "View Response"
msgid "Error Message"
msgstr "Error Message"
# TRANSLATION
# LABEL/ID_CASE_CREATED
#: LABEL/ID_CASE_CREATED
msgid "Case created"
msgstr "Case created"
# TRANSLATION
# LABEL/ID_CASE_ROUTED_TO
#: LABEL/ID_CASE_ROUTED_TO
msgid "Case routed to"
msgstr "Case routed to"
# additionalTables/additionalTablesData.xml?ADD_TAB_NAME
# additionalTables/additionalTablesData.xml
#: text - ADD_TAB_NAME

View File

@@ -6171,7 +6171,9 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_CASE_NUMBER_CAPITALIZED','en','Case Number','2017-02-22') ,
( 'LABEL','ID_ANSWERED','en','Answered','2017-02-22') ,
( 'LABEL','ID_VIEW_RESPONSE','en','View Response','2017-02-22') ,
( 'LABEL','ID_ERROR_MESSAGE','en','Error Message','2017-02-22') ;
( 'LABEL','ID_ERROR_MESSAGE','en','Error Message','2017-02-22') ,
( 'LABEL','ID_CASE_CREATED','en','Case created','2017-06-02') ,
( 'LABEL','ID_CASE_ROUTED_TO','en','Case routed to','2017-06-02');
INSERT INTO ISO_LOCATION (IC_UID,IL_UID,IL_NAME,IL_NORMAL_NAME,IS_UID) VALUES
('AD','','',' ','') ,

View File

@@ -161,6 +161,7 @@ $G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower );
$oCase = new Cases();
$oStep = new Step();
$bmWebEntry = new \ProcessMaker\BusinessModel\WebEntry;
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'] );
$Fields['APP_DATA'] = array_merge( $Fields['APP_DATA'], G::getSystemConstants() );
@@ -295,6 +296,9 @@ try {
if (isset( $oProcessFieds['PRO_SHOW_MESSAGE'] )) {
$noShowTitle = $oProcessFieds['PRO_SHOW_MESSAGE'];
}
if ($bmWebEntry->isTaskAWebEntry($_SESSION['TASK'])) {
$noShowTitle = 1;
}
switch ($_GET['TYPE']) {
case 'DYNAFORM':
@@ -1105,6 +1109,27 @@ try {
$aFields["TASK"][$sKey]["NEXT_TASK"]["TAS_TITLE"] = G::LoadTranslation("ID_ROUTE_TO_TASK_INTERMEDIATE_CATCH_MESSAGE_EVENT");
}
//SKIP ASSIGN SCREEN
if (!empty($aFields['TASK'][1])) {
$currentTask = $aFields['TASK'][1];
$isWebEntry = $bmWebEntry->isTaskAWebEntry($currentTask['TAS_UID']);
if ($isWebEntry) {
$tplFile = 'webentry/cases_ScreenDerivation';
$caseId = $currentTask['APP_UID'];
$delIndex = $currentTask['DEL_INDEX'];
$derivationResponse = PMFDerivateCase($caseId, $delIndex, true);
if ($derivationResponse) {
$webEntryUrl = $bmWebEntry->getCallbackUrlByTask($currentTask['TAS_UID']);
$delegationData = $Fields['APP_DATA'];
$delegationData['_DELEGATION_DATA'] = $aFields['TASK'];
$delegationData['_DELEGATION_MESSAGE'] = $bmWebEntry->getDelegationMessage($delegationData);
$webEntryUrlEvaluated = \G::replaceDataField($webEntryUrl, $delegationData);
}
$aFields['derivationResponse'] = $derivationResponse;
$aFields['webEntryUrlEvaluated'] = $webEntryUrlEvaluated;
}
}
$G_PUBLISH->AddContent( 'smarty', $tplFile, '', '', $aFields );
/*
if (isset( $aFields['TASK'][1]['NEXT_TASK']['USER_ASSIGNED'])){

View File

@@ -0,0 +1,44 @@
<?php
/**
* This service is to start PM with the anonymous user.
*/
/* @var $RBAC RBAC */
global $RBAC;
G::LoadClass('pmFunctions');
try {
if (empty($_REQUEST['we_uid'])) {
throw new \Exception('Missing required field "we_uid"');
}
$weUid = $_REQUEST['we_uid'];
$webEntry = \WebEntryPeer::retrieveByPK($weUid);
if (empty($webEntry)) {
throw new \Exception('Undefined WebEntry');
}
$userUid = $webEntry->getUsrUid();
$userInfo = PMFInformationUser($userUid);
if (empty($userInfo)) {
throw new \Exception('WebEntry User not found');
}
$_SESSION['USER_LOGGED'] = $userUid;
$_SESSION['USR_USERNAME'] = $userInfo['username'];
$result = [
'user_logged' => $userUid,
'userName' => $userInfo['username'],
'firstName' => $userInfo['firstname'],
'lastName' => $userInfo['lastname'],
'mail' => $userInfo['mail'],
'image' => '../users/users_ViewPhoto?t='.microtime(true),
];
} catch (\Exception $e) {
$result = [
'error' => $e->getMessage(),
];
http_response_code(500);
}
echo G::json_encode($result);

View File

@@ -0,0 +1,35 @@
<?php
/**
* This service verify if the provided APP_UID and DEL_INDEX could be used
* for the web entry.
*/
/* @var $RBAC RBAC */
global $RBAC;
G::LoadClass('pmFunctions');
try {
if (empty($_REQUEST['app_uid'])) {
throw new \Exception('Missing required field "app_uid"');
}
if (empty($_REQUEST['del_index'])) {
throw new \Exception('Missing required field "del_index"');
}
if (empty($_SESSION['USER_LOGGED'])) {
throw new \Exception('You are not logged');
}
$appUid = $_REQUEST['app_uid'];
$delIndex = $_REQUEST['del_index'];
$delegation = \AppDelegationPeer::retrieveByPK($appUid, $delIndex);
$check = $delegation->getDelThreadStatus() === 'OPEN' &&
$delegation->getUsrUid() === $_SESSION['USER_LOGGED'];
$result = ["check" => $check];
} catch (\Exception $e) {
$result = [
'error' => $e->getMessage(),
];
http_response_code(500);
}
echo G::json_encode($result);

View File

@@ -0,0 +1,18 @@
<?php
/**
* This page displays a message when completed or if there is an error
* during the execution.
*/
$G_PUBLISH = new Publisher();
$show = "login/showMessage";
$message = [];
if (isset($_GET["message"])) {
$show = "login/showInfo";
$message['MESSAGE'] = nl2br($_GET["message"]);
} elseif (isset($_GET["error"])) {
$show = "login/showMessage";
$message['MESSAGE'] = $_GET["error"];
}
$G_PUBLISH->AddContent("xmlform", "xmlform", $show, "", $message);
G::RenderPage("publish", "blank");

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
<html>
<head>
<script>
<?php
/**
* This page is redirected from the login page.
*/
G::LoadClass('pmFunctions');
$userUid = $_SESSION['USER_LOGGED'];
$userInfo = PMFInformationUser($userUid);
$result = [
'user_logged' => $userUid,
'userName' => $userInfo['username'],
'firstName' => $userInfo['firstname'],
'lastName' => $userInfo['lastname'],
'mail' => $userInfo['mail'],
'image' => '../users/users_ViewPhoto?t='.microtime(true),
];
?>
parent.fullfill(<?= G::json_encode($result) ?>);
</script>
</head>
</html>

View File

@@ -321,9 +321,6 @@ class WebEntry
//Verify if User is assigned to Task
$projectUser = new \ProcessMaker\BusinessModel\ProjectUser();
if (!$projectUser->userIsAssignedToTask($arrayData["USR_UID"], $arrayDataMain["TAS_UID"])) {
throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_HAVE_ACTIVITY_ASSIGNED", array($arrayUserData["USR_USERNAME"], $arrayTaskData["TAS_TITLE"])));
}
}
} catch (\Exception $e) {
throw $e;
@@ -402,6 +399,12 @@ class WebEntry
$fileContent = "<?php\n\n";
$fileContent .= "global \$_DBArray;\n";
$fileContent .= '$webEntry = new ' . WebEntry::class . ";\n";
$fileContent .= "\$processUid = \"" . $processUid . "\";\n";
$fileContent .= "\$weUid = \"" . $arrayWebEntryData['WE_UID'] . "\";\n";
$fileContent .= 'if (!$webEntry->isWebEntryOne($weUid)) {'."\n";
$fileContent .= " return require(PATH_METHODS . 'webentry/access.php');\n";
$fileContent .= "}\n";
$fileContent .= "if (!isset(\$_DBArray)) {\n";
$fileContent .= " \$_DBArray = array();\n";
$fileContent .= "}\n";
@@ -1067,5 +1070,56 @@ class WebEntry
. "\n";
file_put_contents($pathFileName, $code);
}
/**
* Verify if web entry is a single dynaform without login required.
*
* @param type $processUid
* @param type $weUid
* @return boolean
*/
public function isWebEntryOne($weUid)
{
$webEntry = \WebEntryPeer::retrieveByPK($weUid);
return $webEntry->getWeType()==='SINGLE' && $webEntry->getWeAuthentication()==='ANONYMOUS';
}
/**
* Verify if a Task is and Web Entry auxiliar task.
*
* @param type $tasUid
* @return boolean
*/
public function isTaskAWebEntry($tasUid)
{
return substr($tasUid, 0, 4) === 'wee-';
}
public function getCallbackUrlByTask($tasUid)
{
$criteria = new \Criteria;
$criteria->add(\WebEntryPeer::TAS_UID, $tasUid);
$webEntry = \WebEntryPeer::doSelectOne($criteria);
if ($webEntry->getWeCallback()==='CUSTOM' || $webEntry->getWeCallback()==='CUSTOM_CLEAR') {
return $webEntry->getWeCallbackUrl();
} else {
return '../services/webentry/completed?message=@%_DELEGATION_MESSAGE';
}
}
public function getDelegationMessage($data)
{
$appNumber = $data['APP_NUMBER'];
$appUid = $data['APPLICATION'];
$message = "\n".\G::LoadTranslation('ID_CASE_CREATED').
"\n".\G::LoadTranslation('ID_CASE_NUMBER').": $appNumber".
"\n".\G::LoadTranslation('ID_CASESLIST_APP_UID').": $appUid";
foreach($data['_DELEGATION_DATA'] as $task) {
$message.="\n".\G::LoadTranslation('ID_CASE_ROUTED_TO').": ".
$task['NEXT_TASK']['TAS_TITLE'].
"(".htmlentities($task['NEXT_TASK']['USER_ASSIGNED']['USR_USERNAME']).")";
}
return $message;
}
}

View File

@@ -0,0 +1,6 @@
<script>
if({$derivationResponse|@json_encode})
parent.fullfill({$webEntryUrlEvaluated|@json_encode});
else
parent.reject();
</script>