|
|
**NOTE : this is a work in progress. No expiration is yet implemented on Framaforms, causing large database management problems. .**
|
|
|
Framaforms implements automatic webforms and submissions deletion after 6 months in the PostgreSQL database if no user action is undertaken.
|
|
|
|
|
|
The webforms and their submissions should be automatically deleted under 6 months in the PostgreSQL database if no user action is taken.
|
|
|
The user should be notified 2 weeks in advance of their webform submission, and a link should enable them to give 6 more months of lifetime to their webform.
|
|
|
|
|
|
## SQL QUERIES
|
|
|
**The following queries can be executed through a hook on webform access by a user, or on the Drupal hook_cron. The queries should be executed once a day.**
|
|
|
|
|
|
#### DELETE SUBMISSIONS
|
|
|
The following postgres query gets all webform **submissions** that are over 6 months old :
|
|
|
```
|
|
|
select sid, to_timestamp(submitted) from webform_submissions where to_timestamp(submitted) < date_trunc('day', NOW() - interval '6 months') ;
|
|
|
```
|
|
|
|
|
|
The following should delete them :
|
|
|
```
|
|
|
delete from webform_submissions where to_timestamp(submitted) < date_trunc('day', NOW() - interval '6 months');
|
|
|
```
|
|
|
|
|
|
#### DELETE WEBFORMS
|
|
|
The creation timestamp for webforms is stored in the 'created' column of the 'node' table. We also need to filter for node types because all Drupal nodes are stored in the same 'node' table regardless of what they are (page, article, webform).
|
|
|
Hence the following request :
|
|
|
```
|
|
|
delete from node where (type='form1' or type='webform') and to_timestamp(created) < date_trunc('day', NOW() - interval '6 months');
|
|
|
```
|
|
|
|
|
|
## USER NOTIFICATION
|
|
|
|
|
|
#### TIMELINE
|
|
|
## TIMELINE
|
|
|

|
|
|
|
|
|
#### PROCESS
|
|
|
* each day, the Drupal automated cron checks in the DB for rows aged over 6 months, minus two weeks (24 weeks). It will place their nid in a new row of the *framaforms_expired* table.
|
|
|
* Framaforms will get the corresponding user emails and notify them of their webform expiration, giving them the possibility to change the expiration date (always with a maximum of 6 months in the future). If the email was sent, the *notified* row in the *framaforms_expired* table will be set to 1.
|
|
|
* Framaforms will also check for webforms having reached their deletion date (35 weeks), whose owner was notified, but did nothing. In which case, the webform will be deleted, as well as the entry in the *framaforms_expired* table. |
|
|
\ No newline at end of file |
|
|
## PROCESS
|
|
|
* each day, the Drupal automated cron checks in the DB for rows aged over 6 months, minus two weeks (24 weeks). It will place their nid in a new row of the `framaforms_expired` table.
|
|
|
* Framaforms will get the corresponding user emails and notify them of their webform expiration, giving them the possibility to change the expiration date (always with a maximum of 6 months in the future). If the email was sent, the `notified` column in the `framaforms_expired` table will be set to 1.
|
|
|
* Framaforms will also check for webforms having reached their deletion date (35 weeks), whose owner was notified, but did nothing. In which case, the webform will be deleted, as well as the entry in the `framaforms_expired` table.
|
|
|
|
|
|
## COSTUMIZING EXPIRATION DELAYS
|
|
|
The following variables can be modified at the top of `framaforms_cron()` in order to change the expiration delays :
|
|
|
* `notification_period` : amount of time between the notification of the user and the actual expiration of the webform. This is set by default to *two weeks*, but you can set it to `1 month`, `3 weeks`, `1 day`, etc, following php relative time formats (https://www.php.net/manual/en/datetime.formats.relative.php).
|
|
|
* `deletion_period` : amount of time between the notification of the user and the actual deletion of data from the database. This is set by default to `9 weeks` (approx. 2 months).
|
|
|
* `cron_frequency` : amount of time between two cron runs. The module will check at each call to Drupal cron when `framaforms_cron()` was last run. `-1 day` means that "framaforms_cron should be run only if the last run is older that 1 day". You can also set it to `-1 week`, `-2 days`, `-2 months`, to your liking, but don't forget the `-` sign.
|
|
|
|
|
|
|
|
|
**If you do not wish to implement webform expiration in your Framaforms instance** (meaning all webforms and submissions will live forever in your database), you can :
|
|
|
* Go to `yourdomainname.example/admin/cron` and set the cron run to "never", deactivating Drupal cron alltogether.
|
|
|
* If other modules need cron runs, you'll need to dive into the code : you can comment the whole `framaforms_cron()` function or just add `return;` as its first line to avoid running it. |
|
|
\ No newline at end of file |