From 6ea872562509ef1662afa9e43b1a4ece85fb961e Mon Sep 17 00:00:00 2001 From: elvill Date: Fri, 10 Aug 2018 14:33:32 +0200 Subject: [PATCH] Feature #4432 - Form Submit Log, as a new FormSubmitLog QFQ-Form, with code in the manual for a FE page to browse the table. Also added code in the manual for a MailLog FE page. --- extension/Documentation/Manual.rst | 151 +++++++++++++++--- extension/ext_conf_template.txt | 3 + extension/qfq/qfq/Constants.php | 5 + extension/qfq/qfq/QuickFormQuery.php | 32 ++++ .../qfq/qfq/database/DatabaseUpdateData.php | 1 - extension/qfq/sql/formEditor.sql | 21 +++ 6 files changed, 193 insertions(+), 20 deletions(-) diff --git a/extension/Documentation/Manual.rst b/extension/Documentation/Manual.rst index 7b0f91b1..b07878c2 100644 --- a/extension/Documentation/Manual.rst +++ b/extension/Documentation/Manual.rst @@ -326,6 +326,10 @@ Extension Manager: QFQ Configuration | sqlLog | fileadmin/protected/log/sql.log | Filename to log SQL commands: relative to or absolute. If the | | | | directory does not exist, create it. | +-------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+ +| formSubmitLogMode | all | *all*: every form submission will be logged. | +| | | *none*: no logging. | +| | | See `Form Submit Log page`_ for example qfq code to display the log. | ++-------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+ | mailLog | fileadmin/protected/log/mail.log | Filename to log `sendEmail` commands: relative to or absolute. | | | | If the directory does not exist, create it. | +-------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+ @@ -733,25 +737,29 @@ version, the system tables will be automatically installed or updated. System tables ^^^^^^^^^^^^^ -+-------------+------------+------------+ -| Name | Use | Database | -+=============+============+============+ -| Clipboard | Temporary | QFQ | -+-------------+------------+------------+ -| Cron | Persistent | QFQ | -+-------------+------------+------------+ -| Dirty | Temporary | QFQ | Data | -+-------------+------------+------------+ -| Form | Persistent | QFQ | -+-------------+------------+------------+ -| FormElement | Persistent | QFQ | -+-------------+------------+------------+ -| MailLog | Persistent | QFQ | Data | -+-------------+------------+------------+ -| Period | Persistent | Data | -+-------------+------------+------------+ -| Split | Persistent | Data | -+-------------+------------+------------+ ++---------------+------------+------------+ +| Name | Use | Database | ++===============+============+============+ +| Clipboard | Temporary | QFQ | ++---------------+------------+------------+ +| Cron | Persistent | QFQ | ++---------------+------------+------------+ +| Dirty | Temporary | QFQ | Data | ++---------------+------------+------------+ +| Form | Persistent | QFQ | ++---------------+------------+------------+ +| FormElement | Persistent | QFQ | ++---------------+------------+------------+ +| FormSubmitLog | Persistent | QFQ | Data | ++---------------+------------+------------+ +| MailLog | Persistent | QFQ | Data | ++---------------+------------+------------+ +| Period | Persistent | Data | ++---------------+------------+------------+ +| Split | Persistent | Data | ++---------------+------------+------------+ + +See `Mail Log page`_ and `Form Submit Log page`_ for some Frontend views for these tables. * Check Bug #5459 - support of system tables in different DBs not supported. @@ -918,6 +926,109 @@ configuration_ * Clear 'CC' and 'Bcc' * Write a note and the original configured receiver at the top of the email body. +_`Mail Log page` + +Mail Log page +------------- + +For debugging purposes you may like to add a Mail Log page in the frontend. +The following QFQ code could be used for that purpose (put it in a QFQ PageContent element): :: + + # Page parameters + 1.sql = SELECT @grId := '{{grId:C0:digit}}' AS _grId + 2.sql = SELECT @summary := IF('{{summary:CE:alnumx}}' = 'true', 'true', 'false') AS _s + + # Filters + 10 { + sql = SELECT gr.id, IF(gr.id = @grId, "' selected>", "'>"), gr.value, ' (Id: ', gr.id, ')' + FROM gGroup AS gr + INNER JOIN MailLog AS ml ON ml.grId = gr.id + GROUP BY gr.id + head =
Filter By Group: Summary
+ } + + # Mail Log + 50 { + sql = SELECT id, '', grId, '', xId, '', + REPLACE(receiver, ',', '
'), '', REPLACE(sender, ',', '
'), '', + DATE_FORMAT(modified, '%d.%m.%Y
%H:%i:%s'), '', + CONCAT('', subject, '
', IF(@summary = 'true', CONCAT(SUBSTR(body, 1, LEAST(IF(INSTR(body, '\n') = 0, 50, INSTR(body, '\n')), IF(INSTR(body, '
') = 0, 50, INSTR(body, '
')))-1), ' ...'), CONCAT('
', REPLACE(body, '\n', '
'))) ) + FROM MailLog WHERE (grId = @grId OR @grId = 0) + ORDER BY modified DESC + LIMIT 100 + head = + tail =
IdgrIdxIdToFromDateE-Mail
+ rbeg = + rend = + } + +_`Form Submit Log page` + +Form Submit Log page +-------------------- + +For debugging purposes you may like to add a Form Submit Log page in the frontend. +The following QFQ code could be used for that purpose (put it in a QFQ PageContent element): :: + + # Filters + 20.shead =
+ 20 { + sql = SELECT id, IF(id = '{{formId:SC0}}', "' selected>", "'>"), name + FROM Form ORDER BY name + head = + rbeg =