ProcessMaker-MA "Web Entry (endpoints)"
- Se han implementado los siguientes Endpoints:
POST /api/1.0/{workspace}/project/{prj_uid}/web-entry
This commit is contained in:
@@ -31,7 +31,7 @@ class ProjectUser
|
|||||||
$oCriteria->addSelectColumn(\TaskUserPeer::TU_RELATION);
|
$oCriteria->addSelectColumn(\TaskUserPeer::TU_RELATION);
|
||||||
$oCriteria->addJoin(\TaskUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN);
|
$oCriteria->addJoin(\TaskUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN);
|
||||||
$oCriteria->addJoin(\TaskUserPeer::TAS_UID, \TaskPeer::TAS_UID, \Criteria::LEFT_JOIN);
|
$oCriteria->addJoin(\TaskUserPeer::TAS_UID, \TaskPeer::TAS_UID, \Criteria::LEFT_JOIN);
|
||||||
$oCriteria->add(\TaskPeer::PRO_UID, $sProcessUID);
|
$oCriteria->add(\TaskPeer::PRO_UID, $sProcessUID);
|
||||||
$oCriteria->add(\TaskUserPeer::TU_TYPE, 1);
|
$oCriteria->add(\TaskUserPeer::TU_TYPE, 1);
|
||||||
$oCriteria->add(\TaskUserPeer::TU_RELATION, 1);
|
$oCriteria->add(\TaskUserPeer::TU_RELATION, 1);
|
||||||
$oCriteria->addGroupByColumn(USR_UID);
|
$oCriteria->addGroupByColumn(USR_UID);
|
||||||
@@ -73,7 +73,7 @@ class ProjectUser
|
|||||||
$oCriteria->addSelectColumn(\UsersPeer::USR_USERNAME);
|
$oCriteria->addSelectColumn(\UsersPeer::USR_USERNAME);
|
||||||
$oCriteria->addJoin(\TaskUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN);
|
$oCriteria->addJoin(\TaskUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN);
|
||||||
$oCriteria->addJoin(\TaskUserPeer::TAS_UID, \TaskPeer::TAS_UID, \Criteria::LEFT_JOIN);
|
$oCriteria->addJoin(\TaskUserPeer::TAS_UID, \TaskPeer::TAS_UID, \Criteria::LEFT_JOIN);
|
||||||
$oCriteria->add(\TaskPeer::PRO_UID, $sProcessUID);
|
$oCriteria->add(\TaskPeer::PRO_UID, $sProcessUID);
|
||||||
$oCriteria->add(\TaskUserPeer::TU_TYPE, 1);
|
$oCriteria->add(\TaskUserPeer::TU_TYPE, 1);
|
||||||
$oCriteria->add(\TaskUserPeer::TU_RELATION, 1);
|
$oCriteria->add(\TaskUserPeer::TU_RELATION, 1);
|
||||||
$oCriteria->addGroupByColumn(USR_UID);
|
$oCriteria->addGroupByColumn(USR_UID);
|
||||||
@@ -245,5 +245,76 @@ class ProjectUser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User Login
|
||||||
|
*
|
||||||
|
* @param string $username Username
|
||||||
|
* @param string $password Password
|
||||||
|
*
|
||||||
|
* return object Return object $response
|
||||||
|
* $response->status_code, 0 when User has been authenticated, any number otherwise
|
||||||
|
* $response->message, message
|
||||||
|
*/
|
||||||
|
public function userLogin($username, $password)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$http = (\G::is_https())? "https://" : "http://";
|
||||||
|
|
||||||
|
$client = new \SoapClient($http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/wsdl2");
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
"userid" => $username,
|
||||||
|
"password" => "md5:" . md5($password)
|
||||||
|
);
|
||||||
|
|
||||||
|
$response = $client->login($params);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify if the User is assigned to Task
|
||||||
|
*
|
||||||
|
* @param string $userUid Unique id of User
|
||||||
|
* @param string $taskUid Unique id of Task
|
||||||
|
*
|
||||||
|
* return bool Return true if the User is assigned to Task, false otherwise
|
||||||
|
*/
|
||||||
|
public function userIsAssignedToTask($userUid, $taskUid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$criteria = new \Criteria("workflow");
|
||||||
|
|
||||||
|
$criteria->addSelectColumn(\TaskUserPeer::TAS_UID);
|
||||||
|
$criteria->add(\TaskUserPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
|
||||||
|
$criteria->add(\TaskUserPeer::USR_UID, $userUid, \Criteria::EQUAL);
|
||||||
|
|
||||||
|
$rsCriteria = \TaskUserPeer::doSelectRS($criteria);
|
||||||
|
|
||||||
|
//If the User is not assigned directly, maybe a have the Task a Group with the User
|
||||||
|
if (!$rsCriteria->next()) {
|
||||||
|
$criteria = new \Criteria("workflow");
|
||||||
|
|
||||||
|
$criteria->addSelectColumn(\UsersPeer::USR_UID);
|
||||||
|
$criteria->addJoin(\UsersPeer::USR_UID, \GroupUserPeer::USR_UID, \Criteria::LEFT_JOIN);
|
||||||
|
$criteria->addJoin(\GroupUserPeer::GRP_UID, \TaskUserPeer::USR_UID, \Criteria::LEFT_JOIN);
|
||||||
|
$criteria->add(\TaskUserPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
|
||||||
|
$criteria->add(\UsersPeer::USR_UID, $userUid, \Criteria::EQUAL);
|
||||||
|
|
||||||
|
$rsCriteria = \UsersPeer::doSelectRS($criteria);
|
||||||
|
|
||||||
|
if (!$rsCriteria->next()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,46 @@ namespace BusinessModel;
|
|||||||
|
|
||||||
class WebEntry
|
class WebEntry
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Sanitizes a filename
|
||||||
|
*
|
||||||
|
* @param string $name Filename
|
||||||
|
*
|
||||||
|
* return string Return the filename sanitizes
|
||||||
|
*/
|
||||||
|
public function sanitizeFilename($name)
|
||||||
|
{
|
||||||
|
$name = trim($name);
|
||||||
|
|
||||||
|
$arraySpecialCharSearch = array(
|
||||||
|
"ñ", "Ñ",
|
||||||
|
"á", "é", "í", "ó", "ú", "Á", "É", "Í", "Ó", "Ú",
|
||||||
|
"à", "è", "ì", "ò", "ù", "À", "È", "Ì", "Ò", "Ù",
|
||||||
|
"â", "ê", "î", "ô", "û", "Â", "Ê", "Î", "Ô", "Û",
|
||||||
|
"ä", "ë", "ï", "ö", "ü", "Ä", "Ë", "Ï", "Ö", "Ü",
|
||||||
|
"/", "\\",
|
||||||
|
" "
|
||||||
|
);
|
||||||
|
$arraySpecialCharReplace = array(
|
||||||
|
"n", "N",
|
||||||
|
"a", "e", "i", "o", "u", "A", "E", "I", "O", "U",
|
||||||
|
"a", "e", "i", "o", "u", "A", "E", "I", "O", "U",
|
||||||
|
"a", "e", "i", "o", "u", "A", "E", "I", "O", "U",
|
||||||
|
"a", "e", "i", "o", "u", "A", "E", "I", "O", "U",
|
||||||
|
"_", "_",
|
||||||
|
"_"
|
||||||
|
);
|
||||||
|
|
||||||
|
$newName = str_replace($arraySpecialCharSearch, $arraySpecialCharReplace, $name);
|
||||||
|
|
||||||
|
$arraySpecialCharSearch = array("/[^a-zA-Z0-9\_\-\.]/");
|
||||||
|
$arraySpecialCharReplace = array("");
|
||||||
|
|
||||||
|
$newName = preg_replace($arraySpecialCharSearch, $arraySpecialCharReplace, $newName);
|
||||||
|
|
||||||
|
return $newName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all Web Entries data of a Process
|
* Get all Web Entries data of a Process
|
||||||
*
|
*
|
||||||
@@ -127,7 +167,280 @@ class WebEntry
|
|||||||
public function create($processUid, $arrayData)
|
public function create($processUid, $arrayData)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
//
|
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
$process = new \Process();
|
||||||
|
|
||||||
|
if (!$process->exists($processUid)) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}", "{1}"), array($processUid, "PROCESS"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($arrayData["TAS_UID"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array(strtolower("TAS_UID")), "The \"{0}\" attribute is not defined")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($arrayData["DYN_UID"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array(strtolower("DYN_UID")), "The \"{0}\" attribute is not defined")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($arrayData["METHOD"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array(strtolower("METHOD")), "The \"{0}\" attribute is not defined")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($arrayData["INPUT_DOCUMENT_ACCESS"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array(strtolower("INPUT_DOCUMENT_ACCESS")), "The \"{0}\" attribute is not defined")));
|
||||||
|
}
|
||||||
|
|
||||||
|
$projectUser = new \BusinessModel\ProjectUser();
|
||||||
|
|
||||||
|
if ($arrayData["METHOD"] == "WS") {
|
||||||
|
if (!isset($arrayData["USR_USERNAME"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array(strtolower("USR_USERNAME")), "The \"{0}\" attribute is not defined")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($arrayData["USR_PASSWORD"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array(strtolower("USR_PASSWORD")), "The \"{0}\" attribute is not defined")));
|
||||||
|
}
|
||||||
|
|
||||||
|
$loginData = $projectUser->userLogin($arrayData["USR_USERNAME"], $arrayData["USR_PASSWORD"]);
|
||||||
|
|
||||||
|
if ($loginData->status_code != 0) {
|
||||||
|
throw (new \Exception($loginData->message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$task = new \Task();
|
||||||
|
|
||||||
|
if (!$task->taskExists($arrayData["TAS_UID"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}", "{1}"), array($arrayData["TAS_UID"], "TASK"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrayTaskData = $task->load($arrayData["TAS_UID"]);
|
||||||
|
|
||||||
|
if ($arrayTaskData["TAS_START"] == "FALSE") {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array($arrayTaskData["TAS_TITLE"]), "The task \"{0}\" isn't initial task")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($arrayTaskData["TAS_ASSIGN_TYPE"] != "BALANCED") {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array($arrayTaskData["TAS_TITLE"]), "Web Entry only works with tasks which have \"Cyclical Assignment\", the task \"{0}\" doesn't have a valid assignment type. Please change the Assignment Rules")));
|
||||||
|
}
|
||||||
|
|
||||||
|
$task = new \Tasks();
|
||||||
|
|
||||||
|
if ($task->assignUsertoTask($arrayData["TAS_UID"]) == 0) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array($arrayTaskData["TAS_TITLE"]), "The task \"{0}\" doesn't have users")));
|
||||||
|
}
|
||||||
|
|
||||||
|
$dynaForm = new \Dynaform();
|
||||||
|
|
||||||
|
if (!$dynaForm->dynaformExists($arrayData["DYN_UID"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}", "{1}"), array($arrayData["DYN_UID"], "DYNAFORM"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrayDynaFormData = $dynaForm->Load($arrayData["DYN_UID"]);
|
||||||
|
|
||||||
|
$step = new \BusinessModel\Step();
|
||||||
|
|
||||||
|
if (!$step->existsRecord($arrayData["TAS_UID"], "DYNAFORM", $arrayData["DYN_UID"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}", "{1}"), array($arrayDynaFormData["DYN_TITLE"], $arrayTaskData["TAS_TITLE"]), "The DynaForm \"{0}\" isn't assigned to the task \"{1}\"")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($arrayData["METHOD"] == "WS") {
|
||||||
|
//Verify if the Web Entry exist
|
||||||
|
$arrayWebEntryData = $this->getData($processUid, "UID", $arrayData["TAS_UID"], $arrayData["DYN_UID"]);
|
||||||
|
|
||||||
|
if (count($arrayWebEntryData) > 0) {
|
||||||
|
throw (new \Exception("The Web Entry exist"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Verify if User is assigned to Task
|
||||||
|
$criteria = new \Criteria("workflow");
|
||||||
|
|
||||||
|
$criteria->addSelectColumn(\UsersPeer::USR_UID);
|
||||||
|
$criteria->add(\UsersPeer::USR_USERNAME, $arrayData["USR_USERNAME"], \Criteria::EQUAL);
|
||||||
|
|
||||||
|
$rsCriteria = \UsersPeer::doSelectRS($criteria);
|
||||||
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
$rsCriteria->next();
|
||||||
|
|
||||||
|
$row = $rsCriteria->getRow();
|
||||||
|
|
||||||
|
if (!$projectUser->userIsAssignedToTask($row["USR_UID"], $arrayData["TAS_UID"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}", "{1}"), array($arrayData["USR_USERNAME"], $arrayTaskData["TAS_TITLE"]), "The user \"{0}\" doesn't have the task \"{1}\" assigned")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create
|
||||||
|
$taskUid = $arrayData["TAS_UID"];
|
||||||
|
$dynaFormUid = $arrayData["DYN_UID"];
|
||||||
|
$method = $arrayData["METHOD"];
|
||||||
|
$inputDocumentAccess = $arrayData["INPUT_DOCUMENT_ACCESS"];
|
||||||
|
$wsRoundRobin = 0; //0, 1 //0 - Cyclical Assignment
|
||||||
|
|
||||||
|
$pathProcess = PATH_DATA_SITE . "public" . PATH_SEP . $processUid;
|
||||||
|
|
||||||
|
\G::mk_dir($pathProcess, 0777);
|
||||||
|
|
||||||
|
$http = (\G::is_https())? "https://" : "http://";
|
||||||
|
|
||||||
|
$arrayDataAux = array();
|
||||||
|
|
||||||
|
switch ($method) {
|
||||||
|
case "WS":
|
||||||
|
$usrUsername = $arrayData["USR_USERNAME"];
|
||||||
|
$usrPassword = $arrayData["USR_PASSWORD"];
|
||||||
|
|
||||||
|
$task = new \Task();
|
||||||
|
|
||||||
|
$weEventUid = $task->getStartingEvent($taskUid);
|
||||||
|
|
||||||
|
//Creating sys.info;
|
||||||
|
$site_public_path = "";
|
||||||
|
|
||||||
|
if (file_exists($site_public_path . "")) {
|
||||||
|
}
|
||||||
|
|
||||||
|
//Creating the first file
|
||||||
|
$dynTitle = $this->sanitizeFilename($arrayDynaFormData["DYN_TITLE"]);
|
||||||
|
$fileName = $dynTitle;
|
||||||
|
|
||||||
|
$fileContent = "<?php\n";
|
||||||
|
$fileContent .= "global \$_DBArray;\n";
|
||||||
|
$fileContent .= "if (!isset(\$_DBArray)) {\n";
|
||||||
|
$fileContent .= " \$_DBArray = array();\n";
|
||||||
|
$fileContent .= "}\n";
|
||||||
|
$fileContent .= "\$_SESSION['PROCESS'] = '" . $processUid . "';\n";
|
||||||
|
$fileContent .= "\$_SESSION['CURRENT_DYN_UID'] = '" . $dynaFormUid . "';\n";
|
||||||
|
$fileContent .= "\$G_PUBLISH = new Publisher;\n";
|
||||||
|
$fileContent .= "\$G_PUBLISH->AddContent('dynaform', 'xmlform', '" . $processUid . '/' . $dynaFormUid . "', '', array(), '" . $fileName . 'Post.php' . "');\n";
|
||||||
|
$fileContent .= "G::RenderPage('publish', 'blank');";
|
||||||
|
|
||||||
|
file_put_contents($pathProcess . PATH_SEP . $fileName . ".php", $fileContent);
|
||||||
|
|
||||||
|
//Creating the second file, the post file who receive the post form.
|
||||||
|
$pluginTpl = PATH_CORE . "templates" . PATH_SEP . "processes" . PATH_SEP . "webentryPost.tpl";
|
||||||
|
|
||||||
|
$template = new \TemplatePower($pluginTpl);
|
||||||
|
$template->prepare();
|
||||||
|
|
||||||
|
$template->assign("wsdlUrl", $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/wsdl2");
|
||||||
|
$template->assign("wsUploadUrl", $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/upload");
|
||||||
|
$template->assign("processUid", $processUid);
|
||||||
|
$template->assign("dynaformUid", $dynaFormUid);
|
||||||
|
$template->assign("taskUid", $taskUid);
|
||||||
|
$template->assign("wsUser", $usrUsername);
|
||||||
|
$template->assign("wsPass", "md5:" . md5($usrPassword));
|
||||||
|
$template->assign("wsRoundRobin", $wsRoundRobin);
|
||||||
|
|
||||||
|
if ($inputDocumentAccess == 0) {
|
||||||
|
//Restricted to process permissions
|
||||||
|
$template->assign("USR_VAR", "\$cInfo = ws_getCaseInfo(\$caseId);\n\t \$USR_UID = \$cInfo->currentUsers->userId;");
|
||||||
|
} else {
|
||||||
|
//No Restriction
|
||||||
|
$template->assign("USR_VAR", "\$USR_UID = -1;");
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign("dynaform", $dynTitle);
|
||||||
|
$template->assign("timestamp", date("l jS \of F Y h:i:s A"));
|
||||||
|
$template->assign("ws", SYS_SYS);
|
||||||
|
$template->assign("version", \System::getVersion());
|
||||||
|
|
||||||
|
$fileName = $pathProcess . PATH_SEP . $dynTitle . "Post.php";
|
||||||
|
|
||||||
|
file_put_contents($fileName, $template->getOutputContent());
|
||||||
|
|
||||||
|
//Creating the third file, only if this wsClient.php file doesn't exist.
|
||||||
|
$fileName = $pathProcess . PATH_SEP . "wsClient.php";
|
||||||
|
$pluginTpl = PATH_CORE . "test" . PATH_SEP . "unit" . PATH_SEP . "ws" . PATH_SEP . "wsClient.php";
|
||||||
|
|
||||||
|
if (file_exists($fileName)) {
|
||||||
|
if (filesize($fileName) != filesize($pluginTpl)) {
|
||||||
|
@copy($fileName, $pathProcess . PATH_SEP . "wsClient.php.bck");
|
||||||
|
@unlink($fileName);
|
||||||
|
|
||||||
|
$template = new \TemplatePower($pluginTpl);
|
||||||
|
$template->prepare();
|
||||||
|
|
||||||
|
file_put_contents($fileName, $template->getOutputContent());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$template = new \TemplatePower($pluginTpl);
|
||||||
|
$template->prepare();
|
||||||
|
|
||||||
|
file_put_contents($fileName, $template->getOutputContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
//Event
|
||||||
|
$event = new \Event();
|
||||||
|
|
||||||
|
$arrayEventData = array();
|
||||||
|
|
||||||
|
$arrayEventData["EVN_UID"] = $weEventUid;
|
||||||
|
$arrayEventData["EVN_RELATED_TO"] = "MULTIPLE";
|
||||||
|
$arrayEventData["EVN_ACTION"] = $dynaFormUid;
|
||||||
|
$arrayEventData["EVN_CONDITIONS"] = $usrUsername;
|
||||||
|
|
||||||
|
$result = $event->update($arrayEventData);
|
||||||
|
|
||||||
|
//Data
|
||||||
|
$url = $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $processUid . "/" . $dynTitle . ".php";
|
||||||
|
|
||||||
|
$arrayDataAux = array("url" => $url);
|
||||||
|
break;
|
||||||
|
case "HTML":
|
||||||
|
global $G_FORM;
|
||||||
|
|
||||||
|
$G_FORM = new \Form($processUid . "/" . $dynaFormUid, PATH_DYNAFORM, SYS_LANG, false);
|
||||||
|
$G_FORM->action = $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/cases_StartExternal.php";
|
||||||
|
|
||||||
|
$scriptCode = "";
|
||||||
|
$scriptCode = $G_FORM->render(PATH_CORE . "templates/" . "xmlform" . ".html", $scriptCode);
|
||||||
|
$scriptCode = str_replace("/controls/", $http . $_SERVER["HTTP_HOST"] . "/controls/", $scriptCode);
|
||||||
|
$scriptCode = str_replace("/js/maborak/core/images/", $http . $_SERVER["HTTP_HOST"] . "/js/maborak/core/images/", $scriptCode);
|
||||||
|
|
||||||
|
//Render the template
|
||||||
|
$pluginTpl = PATH_CORE . "templates" . PATH_SEP . "processes" . PATH_SEP . "webentry.tpl";
|
||||||
|
|
||||||
|
$template = new \TemplatePower($pluginTpl);
|
||||||
|
$template->prepare();
|
||||||
|
|
||||||
|
$step = new \Step();
|
||||||
|
$sUidGrids = $step->lookingforUidGrids($processUid, $dynaFormUid);
|
||||||
|
|
||||||
|
$template->assign("URL_MABORAK_JS", \G::browserCacheFilesUrl("/js/maborak/core/maborak.js"));
|
||||||
|
$template->assign("URL_TRANSLATION_ENV_JS", \G::browserCacheFilesUrl("/jscore/labels/" . SYS_LANG . ".js"));
|
||||||
|
$template->assign("siteUrl", $http . $_SERVER["HTTP_HOST"]);
|
||||||
|
$template->assign("sysSys", SYS_SYS);
|
||||||
|
$template->assign("sysLang", SYS_LANG);
|
||||||
|
$template->assign("sysSkin", SYS_SKIN);
|
||||||
|
$template->assign("processUid", $processUid);
|
||||||
|
$template->assign("dynaformUid", $dynaFormUid);
|
||||||
|
$template->assign("taskUid", $taskUid);
|
||||||
|
$template->assign("dynFileName", $processUid . "/" . $dynaFormUid);
|
||||||
|
$template->assign("formId", $G_FORM->id);
|
||||||
|
$template->assign("scriptCode", $scriptCode);
|
||||||
|
|
||||||
|
if (sizeof($sUidGrids) > 0) {
|
||||||
|
foreach ($sUidGrids as $k => $v) {
|
||||||
|
$template->newBlock("grid_uids");
|
||||||
|
$template->assign("siteUrl", $http . $_SERVER["HTTP_HOST"]);
|
||||||
|
$template->assign("gridFileName", $processUid . "/" . $v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Data
|
||||||
|
$html = str_replace("</body>", "</form></body>", str_replace("</form>", "", $template->getOutputContent()));
|
||||||
|
|
||||||
|
$arrayDataAux = array("html" => $html);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return
|
||||||
|
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||||
|
|
||||||
|
return array_merge($arrayData, $arrayDataAux);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,38 +31,42 @@ class WebEntry extends Api
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///**
|
/**
|
||||||
// * @url POST /:projectUid/case-tracker/object
|
* @url POST /:projectUid/web-entry
|
||||||
// *
|
*
|
||||||
// * @param string $projectUid {@min 32}{@max 32}
|
* @param string $projectUid {@min 32}{@max 32}
|
||||||
// * @param array $request_data
|
* @param array $request_data
|
||||||
// * @param string $cto_type_obj {@from body}{@choice DYNAFORM,INPUT_DOCUMENT,OUTPUT_DOCUMENT}{@required true}
|
* @param string $tas_uid {@from body}{@min 32}{@max 32}{@required true}
|
||||||
// * @param string $cto_uid_obj {@from body}{@min 32}{@max 32}{@required true}
|
* @param string $dyn_uid {@from body}{@min 32}{@max 32}{@required true}
|
||||||
// * @param string $cto_condition
|
* @param string $method {@from body}{@choice WS,HTML}{@required true}
|
||||||
// * @param int $cto_position {@from body}{@min 1}
|
* @param int $input_document_access {@from body}{@choice 0,1}{@required true}
|
||||||
// *
|
* @param string $usr_username {@from body}
|
||||||
// * @status 201
|
* @param string $usr_password {@from body}
|
||||||
// */
|
*
|
||||||
//public function doPostWebEntry(
|
* @status 201
|
||||||
// $projectUid,
|
*/
|
||||||
// $request_data,
|
public function doPostWebEntry(
|
||||||
// $cto_type_obj = "DYNAFORM",
|
$projectUid,
|
||||||
// $cto_uid_obj = "00000000000000000000000000000000",
|
$request_data,
|
||||||
// $cto_condition = "",
|
$tas_uid = "00000000000000000000000000000000",
|
||||||
// $cto_position = 1
|
$dyn_uid = "00000000000000000000000000000000",
|
||||||
//) {
|
$method = "WS",
|
||||||
// try {
|
$input_document_access = 0,
|
||||||
// $caseTrackerObject = new \BusinessModel\WebEntry();
|
$usr_username = "",
|
||||||
//
|
$usr_password = ""
|
||||||
// $arrayData = $caseTrackerObject->create($projectUid, $request_data);
|
) {
|
||||||
//
|
try {
|
||||||
// $response = $arrayData;
|
$webEntry = new \BusinessModel\WebEntry();
|
||||||
//
|
|
||||||
// return $response;
|
$arrayData = $webEntry->create($projectUid, $request_data);
|
||||||
// } catch (\Exception $e) {
|
|
||||||
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
$response = $arrayData;
|
||||||
// }
|
|
||||||
//}
|
return $response;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @url DELETE /:projectUid/web-entry/:activityUid/:dynaFormUid
|
* @url DELETE /:projectUid/web-entry/:activityUid/:dynaFormUid
|
||||||
|
|||||||
Reference in New Issue
Block a user