Commit ffd8ea7c authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fixes #7553. If a pill is hidden, FE on that one should not be processed during save/update

parent 617386b6
Pipeline #1272 passed with stage
in 1 minute and 51 seconds
......@@ -696,6 +696,11 @@ EOF;
*/
public function buildPill(array $formElement, $htmlFormElementName, $value, array &$json) {
$html = '';
if($formElement[FE_MODE]==FE_MODE_HIDDEN){
return '';
}
// save parent processed FE's
$tmpStore = $this->feSpecNative;
......
......@@ -1170,6 +1170,7 @@ const FE_TYPE_SENDMAIL = 'sendMail';
const FE_TYPE_PASTE = 'paste';
const FE_TYPE_TEMPLATE_GROUP = 'templateGroup';
const FE_TYPE_FIELDSET = 'fieldset';
const FE_TYPE_PILL = 'pill';
const FE_HTML_ID = 'htmlId'; // Will be dynamically computed during runtime.
......
......@@ -78,7 +78,8 @@ class QuickFormQuery {
/**
* @var Evaluate instantiated class
*/
protected $eval = null;
protected $evaluate = null;
protected $formSpec = array();
protected $feSpecAction = array(); // Form Definition: copy of the loaded form
protected $feSpecNative = array(); // FormEelement Definition: all formElement.class='action' of the loaded form
......@@ -182,7 +183,7 @@ class QuickFormQuery {
$this->dbArray[$this->dbIndexQfq] = new Database($this->dbIndexQfq);
}
$this->eval = new Evaluate($this->store, $this->dbArray[$this->dbIndexData]);
$this->evaluate = new Evaluate($this->store, $this->dbArray[$this->dbIndexData]);
$dbUpdate = $this->store->getVar(SYSTEM_DB_UPDATE, STORE_SYSTEM);
$updateDb = new DatabaseUpdate($this->dbArray[$this->dbIndexQfq]);
......@@ -192,7 +193,7 @@ class QuickFormQuery {
// Set dbIndex, evaluate any
$dbIndex = $this->store->getVar(TOKEN_DB_INDEX, STORE_TYPO3 . STORE_EMPTY);
$dbIndex = $this->eval->parse($dbIndex);
$dbIndex = $this->evaluate->parse($dbIndex);
$dbIndex = ($dbIndex == '') ? DB_INDEX_DEFAULT : $dbIndex;
$this->store->setVar(TOKEN_DB_INDEX, $dbIndex, STORE_TYPO3);
}
......@@ -492,6 +493,8 @@ class QuickFormQuery {
$this->store->fillStoreWithRecord($this->formSpec[F_TABLE_NAME], $recordId,
$this->dbArray[$this->dbIndexData], $this->formSpec[F_PRIMARY_KEY]);
$this->ifPillIsHiddenSetChildFeToHidden();
// SAVE
$save = new Save($this->formSpec, $this->feSpecAction, $this->feSpecNative, $this->feSpecNativeRaw);
......@@ -573,6 +576,45 @@ class QuickFormQuery {
return $data;
}
/**
* Copies state 'hidden' from a FE pill to all FE child elements of that pill.
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
private function ifPillIsHiddenSetChildFeToHidden() {
$feFilter = OnArray::filter($this->feSpecNative, FE_TYPE, FE_TYPE_PILL);
if (!empty($feFilter)) {
foreach ($feFilter AS $feParent) {
if($feParent[FE_MODE_SQL]){
$mode = $this->evaluate->parse($feParent[FE_MODE_SQL]);
if($mode!=''){
$feParent[FE_MODE]=$mode;
}
}
if ($feParent[FE_MODE] == FE_MODE_HIDDEN) {
$feChild = OnArray::filter($this->feSpecNative, FE_ID_CONTAINER, $feParent[FE_ID]);
foreach ($feChild AS $fe) {
# Search for origin
foreach($this->feSpecNative as $key => $value){
if($value[FE_ID]==$fe[FE_ID]){
$this->feSpecNative[$key][FE_MODE] = FE_MODE_HIDDEN;
break;
}
}
}
}
}
}
}
/**
* @throws CodeException
* @throws DbException
......@@ -631,7 +673,7 @@ class QuickFormQuery {
return false;
}
$forwardPageTmp = $this->eval->parse($this->formSpec[F_FORWARD_PAGE]);
$forwardPageTmp = $this->evaluate->parse($this->formSpec[F_FORWARD_PAGE]);
// Format: [mode/url][|url]
$forwardArray = explode('|', $forwardPageTmp, 2);
......@@ -830,7 +872,7 @@ class QuickFormQuery {
// Check if there is a recordId specified in Bodytext - as variable or query.
$rTmp = $this->store->getVar(CLIENT_RECORD_ID, STORE_TYPO3, SANITIZE_ALLOW_ALL);
if (false !== $rTmp && !is_int($rTmp)) {
$rTmp = $this->eval->parse($rTmp);
$rTmp = $this->evaluate->parse($rTmp);
$this->store->setVar(CLIENT_RECORD_ID, $rTmp, STORE_TYPO3);
}
......@@ -857,7 +899,7 @@ class QuickFormQuery {
if (empty($form[F_DB_INDEX])) {
$form[F_DB_INDEX] = $this->dbIndexData;
} else {
$form[F_DB_INDEX] = $this->eval->parse($form[F_DB_INDEX]);
$form[F_DB_INDEX] = $this->evaluate->parse($form[F_DB_INDEX]);
}
if (empty($form[F_PRIMARY_KEY])) {
$form[F_PRIMARY_KEY] = F_PRIMARY_KEY_DEFAULT;
......@@ -870,15 +912,15 @@ class QuickFormQuery {
}
$this->dbIndexData = $form[F_DB_INDEX];
unset($this->eval);
$this->eval = new Evaluate($this->store, $this->dbArray[$this->dbIndexData]);
unset($this->evaluate);
$this->evaluate = new Evaluate($this->store, $this->dbArray[$this->dbIndexData]);
}
// This is needed for filling templateGroup records with their default values
// and for evaluating variables in the Form title
$this->store->fillStoreWithRecord($form[F_TABLE_NAME], $recordId, $this->dbArray[$this->dbIndexData], $form[F_PRIMARY_KEY]);
$formSpec = $this->eval->parseArray($form);
$formSpec = $this->evaluate->parseArray($form);
$parameterLanguageFieldName = $this->store->getVar(SYSTEM_PARAMETER_LANGUAGE_FIELD_NAME, STORE_SYSTEM);
$formSpec = HelperFormElement::setLanguage($formSpec, $parameterLanguageFieldName);
......@@ -903,11 +945,11 @@ class QuickFormQuery {
// Fire FE_FILL_STORE_VAR after the primary form record has been loaded
if (!empty($fillStoreVar)) {
$rows = $this->eval->parse($fillStoreVar, ROW_EXPECT_0_1);
$rows = $this->evaluate->parse($fillStoreVar, ROW_EXPECT_0_1);
if (is_array($rows)) {
$this->store->appendToStore($rows, STORE_VAR);
// LOG
if(!empty($form[FORM_LOG_ACTIVE])) {
if (!empty($form[FORM_LOG_ACTIVE])) {
Logger::logFormLine($form, "F:add to STORE_VAR", $rows);
}
} else {
......@@ -1023,7 +1065,7 @@ class QuickFormQuery {
// Iterate over all
foreach ($elements as $row) {
if (isset($row[NAME_TG_COPIES]) && $row[NAME_TG_COPIES] > 0) {
$row[FE_VALUE] = $this->eval->parse($row[FE_VALUE]);
$row[FE_VALUE] = $this->evaluate->parse($row[FE_VALUE]);
for ($ii = 1; $ii <= $row[NAME_TG_COPIES]; $ii++) {
$tmpRow = $row;
if (is_array($row[FE_VALUE])) {
......@@ -1086,7 +1128,7 @@ class QuickFormQuery {
}
$storeFormName = $this->store->getVar(SIP_FORM, $store, '', $foundInStore);
$formName = $this->eval->parse($storeFormName, ROW_IMPLODE_ALL, 0, $dummy, $foundInStore);
$formName = $this->evaluate->parse($storeFormName, ROW_IMPLODE_ALL, 0, $dummy, $foundInStore);
// If the formname is empty or if 'form' has not been found in any store: no form.
if ($formName === '' || $foundInStore === '') {
......@@ -1386,7 +1428,7 @@ class QuickFormQuery {
Session::checkSessionExpired($this->store->getVar(SYSTEM_SESSION_TIMEOUT_SECONDS, STORE_SYSTEM));
$report = new Report($this->t3data, $this->eval, $this->phpUnit);
$report = new Report($this->t3data, $this->evaluate, $this->phpUnit);
$html = '';
$beUserLoggedIn = $this->store->getVar(TYPO3_BE_USER, STORE_TYPO3, SANITIZE_ALLOW_ALNUMX);
......@@ -1543,7 +1585,7 @@ class QuickFormQuery {
$subrecord = $this->dbArray[$this->dbIndexQfq]->sql(SQL_FORM_ELEMENT_BY_ID, ROW_REGULAR, [$dndSubrecordId]);
$recordId = $this->store->getVar(DND_SUBRECORD_FORM_ID, STORE_SIP . STORE_ZERO);
$this->store->fillStoreWithRecord('Form', $recordId, $this->dbArray[$this->dbIndexQfq]);
$dndOrderSql = $this->eval->parse($subrecord[0][FE_SQL1]);
$dndOrderSql = $this->evaluate->parse($subrecord[0][FE_SQL1]);
foreach ($dndOrderSql as $i => $row) {
foreach ($row as $key => $value) {
if (substr($key, 0, 1) === '_') {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment