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

Implemented form.requiredParameter - comma sepated list of SIP parameter. If...

Implemented form.requiredParameter - comma sepated list of SIP parameter. If at least one of them is missing in the SIP store, the form won't be loaded.
Sip.php: set param 'r'=0 if missing.
QuickFormQuery.php: if SIP param 'r' or any of defined in form.requiredParameter is missing, throws an exception.
parent 3331e631
...@@ -22,7 +22,6 @@ Features not implemented yet ...@@ -22,7 +22,6 @@ Features not implemented yet
* FormElement: * FormElement:
* type=action (especially not *addNupdate*) * type=action (especially not *addNupdate*)
* Checkbox: some combinations not tested.
QFQ content element QFQ content element
------------------- -------------------
...@@ -371,10 +370,12 @@ Form: basic setup ...@@ -371,10 +370,12 @@ Form: basic setup
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+ +------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|permitEdit | enum('sip', 'logged_in', 'logged_out', 'always', 'never')| Default: sip | |permitEdit | enum('sip', 'logged_in', 'logged_out', 'always', 'never')| Default: sip |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+ +------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|showButton | set('new', 'delete') | Default 'new,delete'. Displays button 'new' and 'delete'. |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|render | enum('plain','table', 'bootstrap') | Default bootstrap | |render | enum('plain','table', 'bootstrap') | Default bootstrap |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+ +------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|requiredParameter | string | Name of required SIP parameter, seperated by comma. '#' as comment delimiter |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|showButton | set('new', 'delete', 'close', 'save') | Default 'new,delete,close,save'. Shown buttons in the upper right corner of the form. |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|multiMode | enum('none','horizontal','vertical') | Default 'none' | |multiMode | enum('none','horizontal','vertical') | Default 'none' |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+ +------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|multiSql | text | Optional. SQL Query which selects all records to edit. | |multiSql | text | Optional. SQL Query which selects all records to edit. |
......
...@@ -91,8 +91,9 @@ const ERROR_UNKNOW_SANITIZE_CLASS = 1001; ...@@ -91,8 +91,9 @@ const ERROR_UNKNOW_SANITIZE_CLASS = 1001;
const ERROR_CODE_SHOULD_NOT_HAPPEN = 1003; const ERROR_CODE_SHOULD_NOT_HAPPEN = 1003;
const ERROR_SIP_MALFORMED = 1005; const ERROR_SIP_MALFORMED = 1005;
const ERROR_SIP_INVALID = 1006; const ERROR_SIP_INVALID = 1006;
//const ERROR_MISSING_FORM_NAME = 1007; const ERROR_MISSING_RECORD_ID = 1007;
const ERROR_IN_SQL_STATEMENT = 1008; const ERROR_IN_SQL_STATEMENT = 1008;
const ERROR_MISSING_REQUIRED_PARAMETER = 1009;
const ERROR_MISSING_SESSIONNAME = 1010; const ERROR_MISSING_SESSIONNAME = 1010;
const ERROR_BROKEN_PARAMETER = 1011; const ERROR_BROKEN_PARAMETER = 1011;
const ERROR_FE_USER_UID_CHANGED = 1012; const ERROR_FE_USER_UID_CHANGED = 1012;
...@@ -373,6 +374,9 @@ const GLYPH_ICON_SHOW = 'glyphicon glyphicon-search'; ...@@ -373,6 +374,9 @@ const GLYPH_ICON_SHOW = 'glyphicon glyphicon-search';
const GLYPH_ICON_TOOL = 'glyphicon-wrench'; const GLYPH_ICON_TOOL = 'glyphicon-wrench';
const GLYPH_ICON_CHECK = 'glyphicon glyphicon-ok'; const GLYPH_ICON_CHECK = 'glyphicon glyphicon-ok';
// FORM
const F_REQUIRED_PARAMETER = 'requiredParameter';
// FORM_ELEMENT_STATI // FORM_ELEMENT_STATI
const FE_MODE_SHOW = 'show'; const FE_MODE_SHOW = 'show';
const FE_MODE_READONLY = 'readonly'; const FE_MODE_READONLY = 'readonly';
......
...@@ -408,6 +408,11 @@ class QuickFormQuery { ...@@ -408,6 +408,11 @@ class QuickFormQuery {
// 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);
// Missing 'r' is in general an error
if ($r === false) {
throw new UserFormException("Missing RECORD_ID (broken SIP?).", ERROR_MISSING_RECORD_ID);
}
// If there is a record_id>0: EDIT else NEW: 'sip','logged_in','logged_out','always','never' // If there is a record_id>0: EDIT else NEW: 'sip','logged_in','logged_out','always','never'
$permitMode = ($r > 0) ? $this->formSpec['permitEdit'] : $this->formSpec['permitNew']; $permitMode = ($r > 0) ? $this->formSpec['permitEdit'] : $this->formSpec['permitNew'];
...@@ -450,6 +455,23 @@ class QuickFormQuery { ...@@ -450,6 +455,23 @@ 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);
// Check: requiredParameter: '' or 'form' or 'form,grId' or 'form #formname for form,grId'
$param = explode(',', $this->formSpec[F_REQUIRED_PARAMETER]);
foreach ($param AS $name) {
$name = explode('#', $name, 2);
$name = trim($name[0]);
if ($name === '') {
continue;
}
if (!isset($sipArray[$name])) {
throw new UserFormException("Missing required SIP parameter: $name", ERROR_MISSING_REQUIRED_PARAMETER);
}
}
return $sipFound; return $sipFound;
} }
......
...@@ -83,6 +83,11 @@ class Sip { ...@@ -83,6 +83,11 @@ class Sip {
// Split URL parameter: // Split URL parameter:
$paramArray = KeyValueStringParser::parse($queryString, "=", "&"); $paramArray = KeyValueStringParser::parse($queryString, "=", "&");
// If no 'r' is specified: define r=0
if (!isset($paramArray[SIP_RECORD_ID])) {
$paramArray[SIP_RECORD_ID] = 0;
}
// Split parameter between Script, Client and SIP // Split parameter between Script, Client and SIP
$script = $this->splitParamClientSip($paramArray, $clientArray, $sipArray); $script = $this->splitParamClientSip($paramArray, $clientArray, $sipArray);
......
...@@ -10,6 +10,7 @@ CREATE TABLE IF NOT EXISTS `Form` ( ...@@ -10,6 +10,7 @@ CREATE TABLE IF NOT EXISTS `Form` (
`permitNew` ENUM('sip', 'logged_in', 'logged_out', 'always', 'never') NOT NULL DEFAULT 'sip', `permitNew` ENUM('sip', 'logged_in', 'logged_out', 'always', 'never') NOT NULL DEFAULT 'sip',
`permitEdit` ENUM('sip', 'logged_in', 'logged_out', 'always', 'never') NOT NULL DEFAULT 'sip', `permitEdit` ENUM('sip', 'logged_in', 'logged_out', 'always', 'never') NOT NULL DEFAULT 'sip',
`render` ENUM('plain', 'table', 'bootstrap') NOT NULL DEFAULT 'plain', `render` ENUM('plain', 'table', 'bootstrap') NOT NULL DEFAULT 'plain',
`requiredParameter` VARCHAR(255) NOT NULL DEFAULT '',
`showButton` SET('new', 'delete', 'close', 'save') NOT NULL DEFAULT 'new,delete,close,save', `showButton` SET('new', 'delete', 'close', 'save') NOT NULL DEFAULT 'new,delete,close,save',
`multiMode` ENUM('none', 'horizontal', 'vertical') NOT NULL DEFAULT 'none', `multiMode` ENUM('none', 'horizontal', 'vertical') NOT NULL DEFAULT 'none',
`multiSql` TEXT NOT NULL, `multiSql` TEXT NOT NULL,
...@@ -130,7 +131,7 @@ INSERT INTO Form (name, title, noteInternal, tableName, permitNew, permitEdit, r ...@@ -130,7 +131,7 @@ INSERT INTO Form (name, title, noteInternal, tableName, permitNew, permitEdit, r
INSERT INTO FormElement (formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, sql1, sql2, parameter, feIdContainer, subrecordOption, modeSql) INSERT INTO FormElement (formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, sql1, sql2, parameter, feIdContainer, subrecordOption, modeSql)
VALUES VALUES
(1, 'basic', 'Basic', 'show', 'pill', 'all', 'container', 10, 0, 0, '', '', '', '', '', '', 0, '', ''), (1, 'basic', 'Basic', 'show', 'pill', 'all', 'container', 10, 0, 0, '', '', '', '', '', '', 0, '', ''),
(1, 'permission', 'Permission', 'show', 'pill', 'all', 'container', 20, 0, 0, '', '', '', '', '', '', 0, '', ''), (1, 'access', 'Access', 'show', 'pill', 'all', 'container', 20, 0, 0, '', '', '', '', '', '', 0, '', ''),
(1, 'various', 'Various', 'show', 'pill', 'all', 'container', 30, 0, 0, '', '', '', '', '', '', 0, '', ''), (1, 'various', 'Various', 'show', 'pill', 'all', 'container', 30, 0, 0, '', '', '', '', '', '', 0, '', ''),
(1, 'multi', 'Multi', 'show', 'pill', 'all', 'container', 40, 0, 0, '', '', '', '', '', '', 0, '', ''), (1, 'multi', 'Multi', 'show', 'pill', 'all', 'container', 40, 0, 0, '', '', '', '', '', '', 0, '', ''),
(1, 'formelement', 'Formelement', 'show', 'pill', 'all', 'container', 50, 0, 0, '', '', '', '', '', '', 0, '', ''), (1, 'formelement', 'Formelement', 'show', 'pill', 'all', 'container', 50, 0, 0, '', '', '', '', '', '', 0, '', ''),
...@@ -141,29 +142,28 @@ VALUES ...@@ -141,29 +142,28 @@ VALUES
(1, 'noteInternal', 'Note', 'show', 'text', 'all', 'native', 140, '40,3', 0, '', '', '', '', '', '', 1, '', ''), (1, 'noteInternal', 'Note', 'show', 'text', 'all', 'native', 140, '40,3', 0, '', '', '', '', '', '', 1, '', ''),
(1, 'tableName', 'Table', 'required', 'select', 'all', 'native', 150, 0, 0, '', '', '', '{{!SHOW tables}}', '', 'emptyItemAtStart', 1, '', ''), (1, 'tableName', 'Table', 'required', 'select', 'all', 'native', 150, 0, 0, '', '', '', '{{!SHOW tables}}', '', 'emptyItemAtStart', 1, '', ''),
(1, 'permitNew', 'Permit New', 'show', 'radio', 'all', 'native', 160, 0, 0, '', '', '', '', '', '', 2, '', ''), (1, 'requiredParameter', 'Required Parameter', 'show', 'text', 'all', 'native', 200, 0, 255, '', '', '', '', '', '', 2, '', ''),
(1, 'permitEdit', 'Permit Edit', 'show', 'radio', 'all', 'native', 170, 0, 0, '', '', '', '', '', '', 2, '', ''), (1, 'permitNew', 'Permit New', 'show', 'radio', 'all', 'native', 210, 0, 3, '', '', '', '', '', '', 2, '', ''),
(1, 'render', 'Render', 'show', 'radio', 'all', 'native', 190, 0, 0, '', '', '', '', '', '', 2, '', ''), (1, 'permitEdit', 'Permit Edit', 'show', 'radio', 'all', 'native', 220, 0, 3, '', '', '', '', '', '', 2, '', ''),
(1, 'showButton', 'Show button', 'show', 'checkbox', 'all', 'native', 200, 0, 0, '', '', '', '', '', 'checkBoxMode = multi\norientation=vertical', 2, '', ''), (1, 'render', 'Render', 'show', 'radio', 'all', 'native', 230, 0, 3, '', '', '', '', '', '', 2, '', ''),
(1, 'showButton', 'Show button', 'show', 'checkbox', 'all', 'native', 240, 0, 5, '', '', '', '', '', 'checkBoxMode = multi\norientation=vertical', 2, '', ''),
(1, 'forwardMode', 'Forward', 'show', 'radio', 'all', 'native', 260, 0, 0, '', '', '', '', '', '', 3, '', ''),
(1, 'forwardPage', 'Forward Page', 'show', 'text', 'all', 'native', 270, 0, 255, '', '', '', '', '', '', 3, '', ''), (1, 'forwardMode', 'Forward', 'show', 'radio', 'all', 'native', 300, 0, 0, '', '', '', '', '', '', 3, '', ''),
(1, 'parameter', 'Parameter', 'show', 'text', 'all', 'native', 275, '40,3', 0, '', '', '', '', '', '', 3, '', ''), (1, 'forwardPage', 'Forward Page', 'show', 'text', 'all', 'native', 310, 0, 255, '', '', '', '', '', '', 3, '', ''),
(1, 'parameter', 'Parameter', 'show', 'text', 'all', 'native', 320, '40,3', 0, '', '', '', '', '', '', 3, '', ''),
(1, 'bsLabelColumns', 'BS Label Columns', 'show', 'text', 'all', 'native', 280, 0, 250, '', '', '', '', '', '', 3, '', ''), (1, 'bsLabelColumns', 'BS Label Columns', 'show', 'text', 'all', 'native', 330, 0, 250, '', '', '', '', '', '', 3, '', ''),
(1, 'bsInputColumns', 'BS Input Columns', 'show', 'text', 'all', 'native', 290, 0, 250, '', '', '', '', '', '', 3, '', ''), (1, 'bsInputColumns', 'BS Input Columns', 'show', 'text', 'all', 'native', 340, 0, 250, '', '', '', '', '', '', 3, '', ''),
(1, 'bsNoteColumns', 'BS Note Columns', 'show', 'text', 'all', 'native', 300, 0, 250, '', '', '', '', '', '', 3, '', ''), (1, 'bsNoteColumns', 'BS Note Columns', 'show', 'text', 'all', 'native', 350, 0, 250, '', '', '', '', '', '', 3, '', ''),
(1, 'deleted', 'Deleted', 'show', 'checkbox', 'all', 'native', 360, 0, 0, '', '', '', '', '', '', 3, '', ''),
(1, 'deleted', 'Deleted', 'show', 'checkbox', 'all', 'native', 405, 0, 0, '', '', '', '', '', '', 3, '', ''), (1, 'modified', 'Modified', 'readonly', 'text', 'all', 'native', 370, 0, 20, '', '', '', '', '', '', 3, '', ''),
(1, 'modified', 'Modified', 'readonly', 'text', 'all', 'native', 410, 0, 20, '', '', '', '', '', '', 3, '', ''), (1, 'created', 'Created', 'readonly', 'text', 'all', 'native', 380, 0, 20, '', '', '', '', '', '', 3, '', ''),
(1, 'created', 'Created', 'readonly', 'text', 'all', 'native', 420, 0, 20, '', '', '', '', '', '', 3, '', ''),
(1, 'multi', 'Multi', 'show', 'fieldset', 'all', 'native', 400, 0, 0, '', '', '', '', '', '', 4, '', ''),
(1, 'multi', 'Multi', 'show', 'fieldset', 'all', 'native', 210, 0, 0, '', '', '', '', '', '', 4, '', ''), (1, 'multiMode', 'Multi Mode', 'show', 'radio', 'all', 'native', 410, 0, 0, '', '', '', '', '', '', 4, '', ''),
(1, 'multiMode', 'Multi Mode', 'show', 'radio', 'all', 'native', 220, 0, 0, '', '', '', '', '', '', 4, '', ''), (1, 'multiSql', 'Multi SQL', 'show', 'text', 'all', 'native', 420, '40,3', 0, '', '', '', '', '', '', 4, '', ''),
(1, 'multiSql', 'Multi SQL', 'show', 'text', 'all', 'native', 230, '40,3', 0, '', '', '', '', '', '', 4, '', ''), (1, 'multiDetailForm', 'Multi Detail Form', 'show', 'text', 'all', 'native', 430, 0, 255, '', '', '', '', '', '', 4,
(1, 'multiDetailForm', 'Multi Detail Form', 'show', 'text', 'all', 'native', 240, 0, 255, '', '', '', '', '', '', 4,
'', ''), '', ''),
(1, 'multiDetailFormParameter', 'Multi Detail Form Parameter', 'show', 'text', 'all', 'native', 250, 0, 255, '', '', (1, 'multiDetailFormParameter', 'Multi Detail Form Parameter', 'show', 'text', 'all', 'native', 440, 0, 255, '', '',
'', '', '', '', 4, '', ''), '', '', '', '', 4, '', ''),
(1, '', 'FormElements', 'show', 'subrecord', 'all', 'native', 500, 0, 0, '', '', '', (1, '', 'FormElements', 'show', 'subrecord', 'all', 'native', 500, 0, 0, '', '', '',
...@@ -172,11 +172,12 @@ VALUES ...@@ -172,11 +172,12 @@ VALUES
# #
# FormEditor: FormElement # FormEditor: FormElement
INSERT INTO Form (name, title, noteInternal, tableName, permitNew, permitEdit, render, multiSql, parameter) VALUES INSERT INTO Form (name, title, noteInternal, tableName, permitNew, permitEdit, render, multiSql, parameter, requiredParameter)
VALUES
('formElement', ('formElement',
'Form Element Editor. Form : {{SELECT f.id, " / ", f.name FROM FormElement AS fe, Form AS f WHERE fe.id = {{r:S0}} AND fe.formId=f.id }}', 'Form Element Editor. Form : {{SELECT f.id, " / ", f.name FROM FormElement AS fe, Form AS f WHERE fe.id = {{r:S0}} AND fe.formId=f.id }}',
'Please secure the form', 'Please secure the form',
'FormElement', 'always', 'always', 'bootstrap', '', 'maxVisiblePill=5'); 'FormElement', 'always', 'always', 'bootstrap', '', 'maxVisiblePill=5', 'formId');
# FormEditor: FormElements for 'formElement' # FormEditor: FormElements for 'formElement'
INSERT INTO FormElement (id, formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, INSERT INTO FormElement (id, formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value,
......
Markdown is supported
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