Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
9ee1995b
Commit
9ee1995b
authored
Sep 12, 2018
by
Elias Villiger
Browse files
Merge branch 'B5467-min-max-parameters' into 'master'
B5467 min max parameters See merge request
!84
parents
a18c5cb5
9ca14668
Pipeline
#872
passed with stage
in 1 minute and 40 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extension/qfq/qfq/QuickFormQuery.php
View file @
9ee1995b
...
...
@@ -389,7 +389,8 @@ class QuickFormQuery {
}
if
(
$this
->
store
->
getVar
(
'id'
,
STORE_BEFORE
)
===
false
)
{
$this
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$recordId
,
STORE_BEFORE
);
$this
->
store
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$recordId
,
$this
->
dbArray
[
$this
->
dbIndexData
],
STORE_BEFORE
);
}
// Check (and release) dirtyRecord.
...
...
@@ -474,7 +475,8 @@ class QuickFormQuery {
$formAction
->
elements
(
$recordId
,
$this
->
feSpecAction
,
FE_TYPE_BEFORE_INSERT
.
','
.
FE_TYPE_BEFORE_UPDATE
.
','
.
FE_TYPE_BEFORE_SAVE
);
// If an old record exist: load it. Necessary to delete uploaded files which should be overwritten.
$this
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$recordId
,
STORE_RECORD
);
$this
->
store
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$recordId
,
$this
->
dbArray
[
$this
->
dbIndexData
]);
// SAVE
$save
=
new
Save
(
$this
->
formSpec
,
$this
->
feSpecAction
,
$this
->
feSpecNative
,
$this
->
feSpecNativeRaw
);
...
...
@@ -485,7 +487,7 @@ class QuickFormQuery {
$rc
=
$save
->
process
();
// Reload fresh saved record and fill STORE_RECORD with it.
$this
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$rc
,
STORE_RECORD
);
$this
->
store
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$rc
,
$this
->
dbArray
[
$this
->
dbIndexData
]
);
$save
->
processAllUploads
(
$rc
);
...
...
@@ -493,7 +495,7 @@ class QuickFormQuery {
$status
=
$formAction
->
elements
(
$rc
,
$this
->
feSpecAction
,
FE_TYPE_AFTER_INSERT
.
','
.
FE_TYPE_AFTER_UPDATE
.
','
.
FE_TYPE_AFTER_SAVE
);
if
(
$status
!=
ACTION_ELEMENT_NO_CHANGE
)
{
// Reload fresh saved record and fill STORE_RECORD with it.
$this
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$rc
,
STORE_RECORD
);
$this
->
store
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$rc
,
$this
->
dbArray
[
$this
->
dbIndexData
]
);
}
// Action: Paste
...
...
@@ -856,7 +858,7 @@ class QuickFormQuery {
// This is needed for filling templateGroup records with their default values
// and for evaluating variables in the Form title
$this
->
fillStoreWithRecord
(
$form
[
F_TABLE_NAME
],
$recordId
,
STORE_RECORD
);
$this
->
store
->
fillStoreWithRecord
(
$form
[
F_TABLE_NAME
],
$recordId
,
$this
->
dbArray
[
$this
->
dbIndexData
]
);
$formSpec
=
$this
->
eval
->
parseArray
(
$form
);
...
...
@@ -1311,24 +1313,6 @@ class QuickFormQuery {
return
$sipFound
;
}
/**
* Load record $id from $table and saves them in $store
*
* @param array $table tablename
* @param string $recordId record ID of current record
* @param string $store name of store where to save the record
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
private
function
fillStoreWithRecord
(
$table
,
$recordId
,
$store
=
STORE_RECORD
)
{
if
(
$recordId
!==
false
&&
$recordId
>
0
)
{
$record
=
$this
->
dbArray
[
$this
->
dbIndexData
]
->
sql
(
"SELECT * FROM
$table
WHERE id = ?"
,
ROW_EXPECT_1
,
[
$recordId
]);
$this
->
store
->
setStore
(
$record
,
$store
,
true
);
}
}
/**
* Searches the whole array $dataArray on the second level for API_ELEMENT_UPDATE.
* All found elements collect under $collect[API_ELEMENT_UPDATE]... . Leave the rest unchanged.
...
...
@@ -1518,7 +1502,7 @@ class QuickFormQuery {
// Subrecord DragAndDrop
$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
->
fillStoreWithRecord
(
'Form'
,
$recordId
);
$this
->
store
->
fillStoreWithRecord
(
'Form'
,
$recordId
,
$this
->
dbArray
[
$this
->
dbIndexQfq
]
);
$dndOrderSql
=
$this
->
eval
->
parse
(
$subrecord
[
0
][
FE_SQL1
]);
foreach
(
$dndOrderSql
as
$i
=>
$row
)
{
foreach
(
$row
as
$key
=>
$value
)
{
...
...
extension/qfq/qfq/form/FormAction.php
View file @
9ee1995b
...
...
@@ -149,7 +149,7 @@ class FormAction {
break
;
default
:
// Always work on recent data: previous actions might have modified the data.
$this
->
fillStoreRecord
(
$this
->
primaryTableName
,
$recordId
);
$this
->
store
->
fillStore
With
Record
(
$this
->
primaryTableName
,
$recordId
,
$this
->
db
);
}
if
(
!
$this
->
checkRequiredList
(
$fe
))
{
...
...
@@ -196,28 +196,6 @@ class FormAction {
return
$rc
;
}
/**
* Copy the current primary record to STORE_RECORD
*
* @param $table
* @param $recordId
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
private
function
fillStoreRecord
(
$table
,
$recordId
)
{
if
(
!
is_string
(
$table
)
||
$table
===
''
)
{
throw
new
UserFormException
(
""
);
}
if
(
$recordId
!==
false
&&
$recordId
>
0
)
{
$record
=
$this
->
db
->
sql
(
"SELECT * FROM
$table
WHERE id = ?"
,
ROW_EXPECT_1
,
[
$recordId
]);
$this
->
store
->
setStore
(
$record
,
STORE_RECORD
,
true
);
}
}
/**
* Process all FormElements given in the `requiredList` identified by their name.
* If none is empty in STORE_FORM return true, else false.
...
...
extension/qfq/qfq/store/FillStoreForm.php
View file @
9ee1995b
...
...
@@ -54,6 +54,7 @@ class FillStoreForm {
public
function
__construct
()
{
$this
->
store
=
Store
::
getInstance
();
$this
->
dbIndexData
=
$this
->
store
->
getVar
(
PARAM_DB_INDEX_DATA
,
STORE_SIP
);
if
(
$this
->
dbIndexData
===
false
)
{
$this
->
dbIndexData
=
DB_INDEX_DEFAULT
;
// Fallback for FORMs which are not called via SIP;
...
...
@@ -66,6 +67,13 @@ class FillStoreForm {
}
$this
->
feSpecNative
=
$this
->
loadFormElementsBasedOnSIP
();
$form
=
$this
->
store
->
getVar
(
SIP_FORM
,
STORE_SIP
,
SANITIZE_ALLOW_ALNUMX
);
$recordId
=
$this
->
store
->
getVar
(
SIP_RECORD_ID
,
STORE_SIP
,
SANITIZE_ALLOW_DIGIT
);
$tableFromFormSql
=
"SELECT f.tableName FROM Form AS f WHERE f.name=?"
;
$tableVars
=
$this
->
dbArray
[
$this
->
dbIndexQfq
]
->
sql
(
$tableFromFormSql
,
ROW_EXPECT_1
,
[
$form
]);
$this
->
store
->
fillStoreWithRecord
(
$tableVars
[
F_TABLE_NAME
],
$recordId
,
$this
->
dbArray
[
$this
->
dbIndexData
]);
$this
->
evaluate
=
new
Evaluate
(
$this
->
store
,
$this
->
dbArray
[
$this
->
dbIndexData
]);
}
...
...
extension/qfq/qfq/store/Store.php
View file @
9ee1995b
...
...
@@ -850,6 +850,25 @@ class Store {
self
::
setVar
(
SYSTEM_SHOW_DEBUG_INFO
,
$value
,
STORE_SYSTEM
);
}
/**
* Load $recordId from $tableName using $db and saves it in $store.
*
* @param $tableName
* @param $recordId
* @param $db
* @param string $store
* @throws CodeException
* @throws UserFormException
*/
public
static
function
fillStoreWithRecord
(
$tableName
,
$recordId
,
$db
,
$store
=
STORE_RECORD
)
{
if
(
$recordId
!==
false
&&
$recordId
>
0
&&
is_string
(
$tableName
)
&&
$tableName
!==
''
)
{
$record
=
$db
->
sql
(
"SELECT * FROM
$tableName
WHERE id = ?"
,
ROW_EXPECT_1
,
[
$recordId
]);
self
::
setStore
(
$record
,
$store
,
true
);
}
}
/**
* Read SYSTEM_FILL_STORE_SYSTEM_BY_SQL_1|2|3 from SYSTEM_STORE and if set:
* a) fire the SQL
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment