Merged in victorsl/processmaker (pull request #558)

ProcessMaker-BE "DynaForm small fix (DYN_CONTENT)"
This commit is contained in:
Erik Amaru Ortiz
2014-06-27 16:13:21 -04:00
3 changed files with 92 additions and 6 deletions

View File

@@ -170,6 +170,10 @@ class Dynaform extends BaseDynaform
$this->setDynType( isset( $aData['DYN_TYPE'] ) ? $aData['DYN_TYPE'] : 'xmlform' );
$this->setDynFilename( $aData['PRO_UID'] . PATH_SEP . $dynUid );
if (isset($aData["DYN_CONTENT"])) {
$this->setDynContent($aData["DYN_CONTENT"]);
}
if ($this->validate()) {
$con->begin();
$res = $this->save();

View File

@@ -8,7 +8,8 @@ class DynaForm
"DYN_TITLE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormTitle"),
"DYN_DESCRIPTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormDescription"),
"DYN_TYPE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("xmlform", "grid"), "fieldNameAux" => "dynaFormType")
"DYN_TYPE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("xmlform", "grid"), "fieldNameAux" => "dynaFormType"),
"DYN_CONTENT" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormContent")
);
private $formatFieldNameInUppercase = true;
@@ -367,10 +368,6 @@ class DynaForm
$dynaFormUid = $dynaForm->create($arrayData);
$oDynaform = \DynaformPeer::retrieveByPK( $dynaFormUid );
$oDynaform->setDynContent( $arrayData['DYN_CONTENT'] );
$oDynaform->save();
//Return
unset($arrayData["PRO_UID"]);
@@ -959,7 +956,7 @@ class DynaForm
$this->getFieldNameByFormatFieldName("DYN_TITLE") => $record["DYN_TITLE"],
$this->getFieldNameByFormatFieldName("DYN_DESCRIPTION") => $record["DYN_DESCRIPTION"] . "",
$this->getFieldNameByFormatFieldName("DYN_TYPE") => $record["DYN_TYPE"] . "",
$this->getFieldNameByFormatFieldName("DYN_CONTENT") => $record["DYN_CONTENT"] . ""
$this->getFieldNameByFormatFieldName("DYN_CONTENT") => $record["DYN_CONTENT"] . ""
);
} catch (\Exception $e) {
throw $e;

View File

@@ -136,6 +136,68 @@ class InputDocument
}
}
/**
* Verify if the InputDocument it's assigned in other objects
*
* @param string $inputDocumentUid Unique id of InputDocument
*
* return array Return array (true if it's assigned or false otherwise and data)
*/
public function itsAssignedInOtherObjects($inputDocumentUid)
{
try {
$flagAssigned = false;
$arrayData = array();
//Step
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\StepPeer::STEP_UID);
$criteria->add(\StepPeer::STEP_TYPE_OBJ, "INPUT_DOCUMENT", \Criteria::EQUAL);
$criteria->add(\StepPeer::STEP_UID_OBJ, $inputDocumentUid, \Criteria::EQUAL);
$rsCriteria = \StepPeer::doSelectRS($criteria);
if ($rsCriteria->next()) {
$flagAssigned = true;
$arrayData[] = \G::LoadTranslation("ID_STEPS");
}
//StepSupervisor
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\StepSupervisorPeer::STEP_UID);
$criteria->add(\StepSupervisorPeer::STEP_TYPE_OBJ, "INPUT_DOCUMENT", \Criteria::EQUAL);
$criteria->add(\StepSupervisorPeer::STEP_UID_OBJ, $inputDocumentUid, \Criteria::EQUAL);
$rsCriteria = \StepSupervisorPeer::doSelectRS($criteria);
if ($rsCriteria->next()) {
$flagAssigned = true;
$arrayData[] = \G::LoadTranslation("ID_CASES_MENU_ADMIN");
}
//ObjectPermission
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\ObjectPermissionPeer::OP_UID);
$criteria->add(\ObjectPermissionPeer::OP_OBJ_TYPE, "INPUT", \Criteria::EQUAL);
$criteria->add(\ObjectPermissionPeer::OP_OBJ_UID, $inputDocumentUid, \Criteria::EQUAL);
$rsCriteria = \ObjectPermissionPeer::doSelectRS($criteria);
if ($rsCriteria->next()) {
$flagAssigned = true;
$arrayData[] = \G::LoadTranslation("ID_PROCESS_PERMISSIONS");
}
//Return
return array($flagAssigned, $arrayData);
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if doesn't exists the InputDocument in table INPUT_DOCUMENT
*
@@ -189,6 +251,27 @@ class InputDocument
}
}
/**
* Verify if the InputDocument it's assigned in other objects
*
* @param string $inputDocumentUid Unique id of InputDocument
* @param string $fieldNameForException Field name for the exception
*
* return void Throw exception if the InputDocument it's assigned in other objects
*/
public function throwExceptionIfItsAssignedInOtherObjects($inputDocumentUid, $fieldNameForException)
{
try {
list($flagAssigned, $arrayData) = $this->itsAssignedInOtherObjects($inputDocumentUid);
if ($flagAssigned) {
throw new \Exception(\G::LoadTranslation("ID_INPUT_DOCUMENT_ITS_ASSIGNED", array($fieldNameForException, $inputDocumentUid, implode(", ", $arrayData))));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Create InputDocument for a Process
*
@@ -313,6 +396,8 @@ class InputDocument
//Verify data
$this->throwExceptionIfNotExistsInputDocument($inputDocumentUid, "", $this->arrayFieldNameForException["inputDocumentUid"]);
$this->throwExceptionIfItsAssignedInOtherObjects($inputDocumentUid, $this->arrayFieldNameForException["inputDocumentUid"]);
//Delete
//StepSupervisor
$stepSupervisor = new \StepSupervisor();