This commit is contained in:
Roly Rudy Gutierrez Pinto
2016-03-07 08:56:49 -04:00
parent f57c8fe7d5
commit 75b4fd8913
2 changed files with 97 additions and 14 deletions

View File

@@ -202,18 +202,16 @@ class pmDynaform
$cnn = Propel::getConnection($json->dbConnection);
$stmt = $cnn->createStatement();
$sql = G::replaceDataField($json->sql, $this->getValuesDependentFields($json));
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_NUM);
$rs = $stmt->executeQuery($sql, \ResultSet::FETCHMODE_NUM);
while ($rs->next()) {
$row = $rs->getRow();
$option = new stdClass();
$option->value = $row[0];
$option->label = (isset($row[1]))? $row[1] : $row[0];
$option->label = isset($row[1]) ? $row[1] : $row[0];
$json->optionsSql[] = $option;
}
} catch (Exception $e) {
}
}
break;
@@ -1389,6 +1387,80 @@ class pmDynaform
$con->commit();
}
/**
* Remove the posted values that are not in the definition of Dynaform.
* @param array $post
* @return array
*/
public function validatePost($post = array())
{
$aux = $post;
$json = G::json_decode($this->record["DYN_CONTENT"]);
$modeForm = $json->items[0]->mode;
foreach ($aux as $key => $value) {
if (substr($key, -6, 6) === "_label") {
continue;
}
$modeField = null;
$protectedValue = null;
$field = $this->jsonsf($json, $key, "variable");
if ($field !== null) {
if (isset($field->mode)) {
$modeField = $field->mode;
}
if ($modeField === "parent") {
$modeField = $modeForm;
}
if (isset($field->protectedValue)) {
$protectedValue = $field->protectedValue;
}
}
//insert for strict validation: || $modeField === "view" || $this->fields["STEP_MODE"] === "VIEW"
if ($field === null || $protectedValue === true) {
if (isset($post[$key])) {
unset($post[$key]);
}
if (isset($post[$key . "_label"])) {
unset($post[$key . "_label"]);
}
}
//columns
if (is_array($value)) {
foreach ($value as $keyRow => $valueRow) {
foreach ($valueRow as $keyCell => $valueCell) {
if (substr($keyCell, -6, 6) === "_label") {
continue;
}
$modeField = null;
$protectedValue = null;
$field = $this->jsonsf($json, $keyCell, "id");
if ($field !== null) {
if (isset($field->mode)) {
$modeField = $field->mode;
}
if ($modeField === "parent") {
$modeField = $modeForm;
}
if (isset($field->protectedValue)) {
$protectedValue = $field->protectedValue;
}
}
//insert for strict validation: || $modeField === "view" || $this->fields["STEP_MODE"] === "VIEW"
if ($field === null || $protectedValue === true) {
if (isset($post[$key][$keyRow][$keyCell])) {
unset($post[$key][$keyRow][$keyCell]);
}
if (isset($post[$key][$keyRow][$keyCell . "_label"])) {
unset($post[$key][$keyRow][$keyCell . "_label"]);
}
}
}
}
}
}
return $post;
}
private function clientToken()
{
$client = $this->getClientCredentials();

View File

@@ -90,6 +90,17 @@ try {
$Fields = $oCase->loadCase( $_SESSION["APPLICATION"] );
if ($swpmdynaform) {
$oStep = new Step();
$oStep = $oStep->loadByProcessTaskPosition($_SESSION['PROCESS'], $_SESSION['TASK'], $_SESSION['STEP_POSITION']);
$dataFields = $Fields["APP_DATA"];
$dataFields["CURRENT_DYNAFORM"] = $_GET['UID'];
$dataFields["STEP_MODE"] = $oStep->getStepMode();
G::LoadClass('pmDynaform');
$oPmDynaform = new pmDynaform($dataFields);
$pmdynaform = $oPmDynaform->validatePost($pmdynaform);
$Fields["APP_DATA"] = array_merge( $Fields["APP_DATA"], $pmdynaform );
}