Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Weblate
Framaforms
Commits
4ceed928
Commit
4ceed928
authored
Oct 01, 2020
by
theo lem
☕
Browse files
Fix deletion period
parent
93564960
Changes
2
Hide whitespace changes
Inline
Side-by-side
CHANGELOG-FRAMAFORMS.md
View file @
4ceed928
...
...
@@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
*
Empty "Share" tab on forms (#106)
*
Unconsistent cache strategies for blocks in hook_block_info (
`framaforms`
module)
*
Automatic deletion of forms to take into account notification period
## [1.0.1] 2020/07/15
...
...
@@ -52,4 +53,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.1] 2020/03/02
### Changed
*
Modules updates not previously committed
\ No newline at end of file
*
Modules updates not previously committed
sites/all/modules/framaforms/includes/framaforms.expiration.inc
View file @
4ceed928
...
...
@@ -112,6 +112,7 @@ function notify_user_of_expiration ($record) {
'subject'
=>
$mail_subject
,
'headers'
=>
array
(),
);
$message
=
drupal_mail
(
'framaforms'
,
'expired_webform'
,
(
string
)
$record
->
mail
,
user_preferred_language
(
$user
),
$mail_params
);
return
$message
[
'send'
];
}
...
...
@@ -168,21 +169,30 @@ function update_modified_nodes () {
* @return void
*/
function
delete_expired_nodes
()
{
// if the user set the deletion period to 0, don't delete the forms
$deletion_period
=
variable_get
(
'framaforms_deletion_period_value'
);
$notification_period
=
variable_get
(
'framaforms_notification_period_value'
);
$external_log_file
=
variable_get
(
'framaforms_external_log_file'
,
'/var/log/framaforms_logfile.log'
);
// create Datetime object for logging purposes
$current_date
=
new
Datetime
();
$current_date
=
date
(
"D d/m/Y - H:i:s"
,
$current_date
->
getTimestamp
());
// if the user set the deletion period to 0, don't delete the forms
if
(
$deletion_period
==
0
){
return
;
}
$deletion_period
.
=
' weeks'
;
$deleted_nodes
=
array
();
watchdog
(
'framaforms'
,
"Suppression des formulaires après notification."
);
$transaction
=
db_transaction
();
try
{
$query
=
db_query
(
"
SELECT fex.nid
SELECT fex.nid
, to_timestamp(fex.date_notified) dn
FROM framaforms_expired fex
WHERE fex.notified = 1
AND to_timestamp(fex.date_notified) <
date_trunc('day',
NOW() - interval'
{
$deletion_period
}
'
)
AND to_timestamp(fex.date_notified) <
=
NOW() - interval'
{
$deletion_period
}
'
- interval'
{
$notification_period
}
'
"
);
$expired_nodes
=
$query
->
fetchAll
();
foreach
(
$expired_nodes
as
$record
){
...
...
@@ -191,7 +201,7 @@ function delete_expired_nodes () {
db_delete
(
'framaforms_expired'
)
->
condition
(
'nid'
,
$record
->
nid
)
->
execute
();
error_log
(
"
{
$current_date
}
: Form #
{
$record
->
nid
}
- user notified on
{
$record
->
dn
}
- was deleted.
\n
"
,
3
,
$external_log_file
);
array_push
(
$deleted_nodes
,
$record
->
nid
);
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment