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

QuickFormQuery.php: for modeForm='Form Delete' the 'required param' are not...

QuickFormQuery.php: for modeForm='Form Delete' the 'required param' are not respected - this makes sense, cause these parameters typically filled in newly created records.
parent c3afadfe
...@@ -207,30 +207,30 @@ class QuickFormQuery { ...@@ -207,30 +207,30 @@ class QuickFormQuery {
* FORM_SAVE: The submitted form will be saved. Return Failure or Success as JSON. * FORM_SAVE: The submitted form will be saved. Return Failure or Success as JSON.
* FORM_DELETE: * FORM_DELETE:
* *
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE | FORM_DELETE * @param string $formMode FORM_LOAD | FORM_UPDATE | FORM_SAVE | FORM_DELETE
* @return array|string * @return array|string
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
*/ */
private function doForm($mode) { private function doForm($formMode) {
$data = ''; $data = '';
$foundInStore = ''; $foundInStore = '';
// Fill STORE_FORM // Fill STORE_FORM
if ($mode === FORM_UPDATE || $mode === FORM_SAVE) { if ($formMode === FORM_UPDATE || $formMode === FORM_SAVE) {
$fillStoreForm = new FillStoreForm(); $fillStoreForm = new FillStoreForm();
$fillStoreForm->process(); $fillStoreForm->process();
} }
$formName = $this->loadFormSpecification($mode, $foundInStore); $formName = $this->loadFormSpecification($formMode, $foundInStore);
if ($formName === false && $mode !== FORM_DELETE) { if ($formName === false && $formMode !== FORM_DELETE) {
// No form found: do nothing // No form found: do nothing
return ''; return '';
} }
if ($formName !== false) { if ($formName !== false) {
// Validate only if there is a 'real' form (not a FORM_DELETE with only a tablename). // Validate only if there is a 'real' form (not a FORM_DELETE with only a tablename).
$sipFound = $this->validateForm($foundInStore); $sipFound = $this->validateForm($foundInStore, $formMode);
} else { } else {
// FORM_DELETE without a form definition: Fake the form wiht only a tableName. // FORM_DELETE without a form definition: Fake the form wiht only a tableName.
...@@ -246,11 +246,11 @@ class QuickFormQuery { ...@@ -246,11 +246,11 @@ class QuickFormQuery {
$recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_TYPO3 . STORE_CLIENT); $recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_TYPO3 . STORE_CLIENT);
// For 'new' record always create a new TAB-uniq (for this current form, nowhere else used) SIP. // For 'new' record always create a new TAB-uniq (for this current form, nowhere else used) SIP.
// With such a TAB-uniq SIP, multiple TABs and following repeated NEWs are easily implemented. // With such a TAB-uniq SIP, multiple TABs and following repeated NEWs are easily implemented.
if (!$sipFound || ($mode == FORM_LOAD && $recordId == 0)) { if (!$sipFound || ($formMode == FORM_LOAD && $recordId == 0)) {
$this->store->createSipAfterFormLoad($formName); $this->store->createSipAfterFormLoad($formName);
} }
if ($mode === FORM_DELETE) { if ($formMode === FORM_DELETE) {
$build = new Delete(); $build = new Delete();
...@@ -273,12 +273,12 @@ class QuickFormQuery { ...@@ -273,12 +273,12 @@ class QuickFormQuery {
} }
$formAction = new FormAction($this->formSpec, $this->db, $this->phpUnit); $formAction = new FormAction($this->formSpec, $this->db, $this->phpUnit);
switch ($mode) { switch ($formMode) {
case FORM_LOAD: case FORM_LOAD:
case FORM_UPDATE: case FORM_UPDATE:
$formAction->elements($recordId, $this->feSpecAction, FE_TYPE_BEFORE_LOAD); $formAction->elements($recordId, $this->feSpecAction, FE_TYPE_BEFORE_LOAD);
$data = $build->process($mode); $data = $build->process($formMode);
$formAction->elements($recordId, $this->feSpecAction, FE_TYPE_AFTER_LOAD); $formAction->elements($recordId, $this->feSpecAction, FE_TYPE_AFTER_LOAD);
break; break;
...@@ -328,7 +328,7 @@ class QuickFormQuery { ...@@ -328,7 +328,7 @@ class QuickFormQuery {
$formAction->elements($rc, $this->feSpecAction, FE_TYPE_SENDMAIL); $formAction->elements($rc, $this->feSpecAction, FE_TYPE_SENDMAIL);
// Retrieve FE Values as JSON // Retrieve FE Values as JSON
$data = $build->process($mode, $htmlElementNameIdZero); $data = $build->process($formMode, $htmlElementNameIdZero);
break; break;
default: default:
...@@ -500,7 +500,7 @@ class QuickFormQuery { ...@@ -500,7 +500,7 @@ class QuickFormQuery {
* @throws UserFormException * @throws UserFormException
* @internal param $foundInStore * @internal param $foundInStore
*/ */
private function validateForm($formNameFoundInStore) { private function validateForm($formNameFoundInStore, $formMode) {
// Retrieve record_id either from SIP (prefered) or via URL // Retrieve record_id either from SIP (prefered) or via URL
$r = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_TYPO3 . STORE_CLIENT, '', $recordIdFoundInStore); $r = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_TYPO3 . STORE_CLIENT, '', $recordIdFoundInStore);
...@@ -554,20 +554,22 @@ class QuickFormQuery { ...@@ -554,20 +554,22 @@ class QuickFormQuery {
throw new UserFormException("MultiMode selected, but MultiSQL missing", ERROR_MULTI_SQL_MISSING); throw new UserFormException("MultiMode selected, but MultiSQL missing", ERROR_MULTI_SQL_MISSING);
} }
$sipArray = $this->store->getStore(STORE_SIP); if ($formMode !== FORM_DELETE) {
// Check: requiredParameter: '' or 'form' or 'form,grId' or 'form #formname for form,grId' $sipArray = $this->store->getStore(STORE_SIP);
$param = explode(',', $this->formSpec[F_REQUIRED_PARAMETER]); // Check: requiredParameter: '' or 'form' or 'form,grId' or 'form #formname for form,grId'
foreach ($param AS $name) { $param = explode(',', $this->formSpec[F_REQUIRED_PARAMETER]);
foreach ($param AS $name) {
$name = explode('#', $name, 2); $name = explode('#', $name, 2);
$name = trim($name[0]); $name = trim($name[0]);
if ($name === '') { if ($name === '') {
continue; continue;
} }
if (!isset($sipArray[$name])) { if (!isset($sipArray[$name])) {
throw new UserFormException("Missing required SIP parameter: $name", ERROR_MISSING_REQUIRED_PARAMETER); throw new UserFormException("Missing required SIP parameter: $name", ERROR_MISSING_REQUIRED_PARAMETER);
}
} }
} }
......
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