Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qfq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
typo3
qfq
Commits
b1974b79
Commit
b1974b79
authored
8 years ago
by
Carsten Rose
Browse files
Options
Downloads
Patches
Plain Diff
Save.php: Implemented new Formelement.parameter: fileReplace=always - will replace existing files.
parent
f59b6ca4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
extension/Documentation/UsersManual/Index.rst
+2
-0
2 additions, 0 deletions
extension/Documentation/UsersManual/Index.rst
extension/qfq/qfq/Constants.php
+2
-0
2 additions, 0 deletions
extension/qfq/qfq/Constants.php
extension/qfq/qfq/Save.php
+12
-4
12 additions, 4 deletions
extension/qfq/qfq/Save.php
with
16 additions
and
4 deletions
extension/Documentation/UsersManual/Index.rst
+
2
−
0
View file @
b1974b79
...
...
@@ -1217,6 +1217,8 @@ current record, either to finalize the upload or to delete a previous uploaded f
* Using the current record id in the `fileDestination`: Using {{r}} is problematic for new records: that one is still '0'
at the time of saving. Use `{{id:R0}}` instead.
* *fileReplace*=*always*: If `fileDestination` exist - replace it by the new one.
Deleting a record and the referenced file
'''''''''''''''''''''''''''''''''''''''''
...
...
This diff is collapsed.
Click to expand it.
extension/qfq/qfq/Constants.php
+
2
−
0
View file @
b1974b79
...
...
@@ -506,6 +506,8 @@ const FE_DATE_FORMAT = 'dateFormat'; // value: FORMAT_DATE_INTERNATIONAL | FORM
const
FE_SHOW_SECONDS
=
'showSeconds'
;
// value: 0|1
const
FE_SHOW_ZERO
=
'showZero'
;
// value: 0|1
const
FE_FILE_DESTINATION
=
'fileDestination'
;
// Target pathFilename for an uploaded file.
const
FE_FILE_REPLACE_MODE
=
'fileReplace'
;
// Target pathFilename for an uploaded file.
const
FE_FILE_REPLACE_MODE_ALWAYS
=
'always'
;
// Target pathFilename for an uploaded file.
const
FE_SQL_VALIDATE
=
'sqlValidate'
;
// Action: Query to validate form load
const
FE_EXPECT_RECORDS
=
'expectRecords'
;
// Action: expected number of rows of FE_SQL_VALIDATE
const
FE_MESSAGE_FAIL
=
'messageFail'
;
// Action: Message to display, if FE_SQL_VALIDATE fails.
...
...
This diff is collapsed.
Click to expand it.
extension/qfq/qfq/Save.php
+
12
−
4
View file @
b1974b79
...
...
@@ -218,6 +218,7 @@ class Save {
$newValues
=
array
();
$formValues
=
$this
->
store
->
getStore
(
STORE_FORM
);
$primaryRecord
=
$this
->
store
->
getStore
(
STORE_RECORD
);
// necessary to check if the current formElement exist as a column of the primary table.
foreach
(
$this
->
feSpecNative
AS
$formElement
)
{
// skip non upload formElements
...
...
@@ -229,9 +230,10 @@ class Save {
$this
->
store
->
setVar
(
SYSTEM_FORM_ELEMENT
,
Logger
::
formatFormElementName
(
$formElement
),
STORE_SYSTEM
);
$column
=
$formElement
[
'name'
];
$file
=
$this
->
doUpload
(
$formElement
,
$formValues
[
$column
],
$sip
);
if
(
$file
!==
false
)
{
$newValues
[
$column
]
=
$file
;
$pathFileName
=
$this
->
doUpload
(
$formElement
,
$formValues
[
$column
],
$sip
);
// Only update (save) the new pathFileName to the primaryRecord if the corresponding column exist.
if
(
$pathFileName
!==
false
&&
isset
(
$primaryRecord
[
$column
]))
{
$newValues
[
$column
]
=
$pathFileName
;
}
}
...
...
@@ -323,7 +325,13 @@ class Save {
}
if
(
file_exists
(
$pathFileName
))
{
throw
new
UserFormException
(
'Copy upload failed - file already exist: '
.
$pathFileName
,
ERROR_IO_FILE_EXIST
);
if
(
isset
(
$formElement
[
FE_FILE_REPLACE_MODE
])
&&
$formElement
[
FE_FILE_REPLACE_MODE
]
==
FE_FILE_REPLACE_MODE_ALWAYS
)
{
if
(
!
unlink
(
$pathFileName
))
{
throw
new
UserFormException
(
'Copy upload failed - file exist and unlink() failed: '
.
$pathFileName
,
ERROR_IO_UNLINK
);
}
}
else
{
throw
new
UserFormException
(
'Copy upload failed - file already exist: '
.
$pathFileName
,
ERROR_IO_FILE_EXIST
);
}
}
Support
::
mkDirParent
(
$pathFileName
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment