Merge remote-tracking branch 'origin/feature/HOR-3274' into feature/HOR-3559

This commit is contained in:
davidcallizaya
2017-08-10 21:38:58 -04:00
44 changed files with 60980 additions and 710 deletions

View File

@@ -7,8 +7,8 @@ class WebEntry
"WE_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "webEntryUid"),
"TAS_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "taskUid"),
"DYN_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormUid"),
"USR_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUid"),
"DYN_UID" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormUid"),
"USR_UID" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "userUid"),
"WE_TITLE" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "webEntryTitle"),
"WE_DESCRIPTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "webEntryDescription"),
"WE_METHOD" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("WS", "HTML"), "fieldNameAux" => "webEntryMethod"),
@@ -16,7 +16,7 @@ class WebEntry
);
private $arrayUserFieldDefinition = array(
"USR_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUid")
"USR_UID" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "userUid")
);
private $formatFieldNameInUppercase = true;
@@ -269,13 +269,13 @@ class WebEntry
$task->throwExceptionIfNotExistsTask($processUid, $arrayData["TAS_UID"], $this->arrayFieldNameForException["taskUid"]);
}
if (isset($arrayData["DYN_UID"])) {
if (!empty($arrayData["DYN_UID"])) {
$dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
$dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["DYN_UID"], $processUid, $this->arrayFieldNameForException["dynaFormUid"]);
}
if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["USR_UID"])) {
if ($arrayDataMain["WE_METHOD"] == "WS" && !empty($arrayData["USR_UID"])) {
$process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
}
@@ -293,7 +293,7 @@ class WebEntry
}
}
if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["TAS_UID"])) {
if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["TAS_UID"]) && (!isset($arrayData["WE_AUTHENTICATION"]) || $arrayData["WE_AUTHENTICATION"]!='LOGIN_REQUIRED')) {
$task = new \Tasks();
if ($task->assignUsertoTask($arrayData["TAS_UID"]) == 0) {
@@ -301,7 +301,7 @@ class WebEntry
}
}
if (isset($arrayData["DYN_UID"])) {
if (isset($arrayData["DYN_UID"]) && (!isset($arrayData["WE_TYPE"]) || $arrayData["WE_TYPE"]==='SINGLE')) {
$dynaForm = new \Dynaform();
$arrayDynaFormData = $dynaForm->Load($arrayData["DYN_UID"]);
@@ -313,7 +313,7 @@ class WebEntry
}
}
if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["USR_UID"])) {
if ($arrayDataMain["WE_METHOD"] == "WS" && !empty($arrayData["USR_UID"])) {
$user = new \Users();
$arrayUserData = $user->load($arrayData["USR_UID"]);
@@ -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;
@@ -337,7 +334,7 @@ class WebEntry
*
* return void
*/
public function setWeData($webEntryUid)
protected function setWeData($webEntryUid, $arrayData)
{
try {
//Verify data
@@ -386,7 +383,9 @@ class WebEntry
$dynaForm = new \Dynaform();
$arrayDynaFormData = $dynaForm->Load($arrayWebEntryData["DYN_UID"]);
if (!empty($arrayWebEntryData["DYN_UID"])) {
$arrayDynaFormData = $dynaForm->Load($arrayWebEntryData["DYN_UID"]);
}
//Creating sys.info;
$sitePublicPath = "";
@@ -400,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";
@@ -407,7 +412,8 @@ class WebEntry
$fileContent .= "\$_SESSION[\"CURRENT_DYN_UID\"] = \"" . $dynaFormUid . "\";\n";
$fileContent .= "\$G_PUBLISH = new Publisher();\n";
$fileContent .= "\$a = new pmDynaform(array(\"CURRENT_DYNAFORM\" => \"" . $arrayWebEntryData["DYN_UID"] . "\"));\n";
$fileContent .= "G::LoadClass(\"pmDynaform\");\n";
$fileContent .= "\$a = new pmDynaform(array(\"CURRENT_DYNAFORM\" => \"" . $dynaFormUid . "\"));\n";
$fileContent .= "if (\$a->isResponsive()) {\n";
$fileContent .= " \$a->printWebEntry(\"" . $fileName . "Post.php\");\n";
$fileContent .= "} else {\n";
@@ -444,7 +450,7 @@ class WebEntry
$template->assign("USR_VAR", "\$USR_UID = -1;");
}
$template->assign("dynaform", $arrayDynaFormData["DYN_TITLE"]);
$template->assign("dynaform", empty($arrayDynaFormData) ? '' : $arrayDynaFormData["DYN_TITLE"]);
$template->assign("timestamp", date("l jS \of F Y h:i:s A"));
$template->assign("ws", $this->sysSys);
$template->assign("version", \PmSystem::getVersion());
@@ -551,15 +557,17 @@ class WebEntry
}
//Update
//Update where
$criteriaWhere = new \Criteria("workflow");
$criteriaWhere->add(\WebEntryPeer::WE_UID, $webEntryUid);
if (!isset($arrayData['WE_LINK_GENERATION']) || $arrayData['WE_LINK_GENERATION']==='DEFAULT') {
//Update where
$criteriaWhere = new \Criteria("workflow");
$criteriaWhere->add(\WebEntryPeer::WE_UID, $webEntryUid);
//Update set
$criteriaSet = new \Criteria("workflow");
$criteriaSet->add(\WebEntryPeer::WE_DATA, $webEntryData);
//Update set
$criteriaSet = new \Criteria("workflow");
$criteriaSet->add(\WebEntryPeer::WE_DATA, $webEntryData);
\BasePeer::doUpdate($criteriaWhere, $criteriaSet, \Propel::getConnection("workflow"));
\BasePeer::doUpdate($criteriaWhere, $criteriaSet, \Propel::getConnection("workflow"));
}
} catch (\Exception $e) {
throw $e;
}
@@ -629,7 +637,7 @@ class WebEntry
}
//Set WE_DATA
$this->setWeData($webEntryUid);
$this->setWeData($webEntryUid, $arrayData);
//Return
return $this->getWebEntry($webEntryUid);
@@ -710,7 +718,7 @@ class WebEntry
}
//Set WE_DATA
$this->setWeData($webEntryUid);
$this->setWeData($webEntryUid, $arrayData);
//Return
if (!$this->formatFieldNameInUppercase) {
@@ -839,7 +847,7 @@ class WebEntry
public function getWebEntryDataFromRecord(array $record)
{
try {
if ($record["WE_METHOD"] == "WS") {
if ((!isset($record['WE_LINK_GENERATION']) || $record['WE_LINK_GENERATION']==='DEFAULT') && $record["WE_METHOD"] == "WS") {
$http = (\G::is_https())? "https://" : "http://";
$url = $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $record["PRO_UID"];
@@ -1061,5 +1069,55 @@ class WebEntry
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;
}
}