Commit bdd888ad authored by Carsten  Rose's avatar Carsten Rose
Browse files

Implements #12341: FormSubmitLog also saves FormName (not only FormId)

parent a3ae0591
Pipeline #5132 failed with stages
in 4 minutes and 52 seconds
......@@ -199,6 +199,11 @@ $UPDATE_ARRAY = array(
"ALTER TABLE `MailLog` CHANGE `header` `header` VARCHAR(2048) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';",
"ALTER TABLE `MailLog` CHANGE `attach` `attach` VARCHAR(4096) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';",
],
'21.4.0' => [
"ALTER TABLE `FormSubmitLog` ADD `formName` VARCHAR(255) NOT NULL DEFAULT '' AFTER `formId`;",
],
);
......
......@@ -26,7 +26,6 @@ use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Report\Monitor;
use IMATHUZH\Qfq\Core\Report\Report;
use IMATHUZH\Qfq\Core\Report\ReportAsFile;
use IMATHUZH\Qfq\Core\Store\Config;
use IMATHUZH\Qfq\Core\Store\FillStoreForm;
use IMATHUZH\Qfq\Core\Store\Session;
use IMATHUZH\Qfq\Core\Store\Sip;
......@@ -828,14 +827,15 @@ class QuickFormQuery {
$userAgent = $_SERVER[CLIENT_HTTP_USER_AGENT] ?? '';
$sipData = json_encode($this->store->getStore(STORE_SIP), JSON_UNESCAPED_UNICODE);
$formId = $this->formSpec[F_ID];
$formName = $this->formSpec[F_NAME];
$recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP);
$feUser = $this->store->getVar(TYPO3_FE_USER, STORE_TYPO3, SANITIZE_ALLOW_ALNUMX);
$pageId = $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3, SANITIZE_ALLOW_ALNUMX);
$sessionId = session_id();
$sql = "INSERT INTO `FormSubmitLog` (`formData`, `sipData`, `clientIp`, `feUser`, `userAgent`, `formId`, `recordId`, `pageId`, `sessionId`, `created`)" .
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())";
$params = [$formData, $sipData, $clientIp, $feUser, $userAgent, $formId, $recordId, $pageId, $sessionId];
$sql = "INSERT INTO `FormSubmitLog` (`formData`, `sipData`, `clientIp`, `feUser`, `userAgent`, `formId`, `formName`, `recordId`, `pageId`, `sessionId`, `created`)" .
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())";
$params = [$formData, $sipData, $clientIp, $feUser, $userAgent, $formId, $formName, $recordId, $pageId, $sessionId];
$this->dbArray[$this->dbIndexQfq]->sql($sql, ROW_REGULAR, $params);
}
......@@ -1745,8 +1745,7 @@ class QuickFormQuery {
* @throws \CodeException
* @throws \UserFormException
*/
public static function buildInlineReport(?int $uid, ?string $reportPathFileNameFull, string $bodytext, string $header): string
{
public static function buildInlineReport(?int $uid, ?string $reportPathFileNameFull, string $bodytext, string $header): string {
if ($uid === null) {
return '';
}
......@@ -2105,8 +2104,7 @@ class QuickFormQuery {
* @throws \UserFormException
* @throws \UserReportException
*/
public function formAsFileBeforeSave($recordId, string $formModeNew): array
{
public function formAsFileBeforeSave($recordId, string $formModeNew): array {
$formFileName = null;
$formNameDB = FormAsFile::formNameFromFormRelatedRecord($recordId, $this->formSpec[F_TABLE_NAME] ?? '', $this->dbArray[$this->dbIndexQfq]);
switch ($this->formSpec[F_TABLE_NAME] ?? '') {
......@@ -2284,8 +2282,7 @@ EOF;
* @throws \DbException
* @throws \UserFormException
*/
private function formAsFileAfterSave($formFileName, string $formModeNew, $formFileNameDelete): void
{
private function formAsFileAfterSave($formFileName, string $formModeNew, $formFileNameDelete): void {
if ($formFileName !== null) {
switch ($formModeNew) {
case FORM_SAVE:
......
......@@ -180,17 +180,18 @@ CREATE TABLE IF NOT EXISTS `MailLog`
CREATE TABLE IF NOT EXISTS `FormSubmitLog`
(
`id` INT(11) NOT NULL AUTO_INCREMENT,
`formData` TEXT NOT NULL,
`sipData` TEXT NOT NULL,
`clientIp` VARCHAR(64) NOT NULL,
`feUser` VARCHAR(64) NOT NULL,
`userAgent` TEXT NOT NULL,
`formId` INT(11) NOT NULL,
`recordId` INT(11) NOT NULL,
`pageId` INT NOT NULL,
`sessionId` VARCHAR(32) NOT NULL,
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`id` INT(11) NOT NULL AUTO_INCREMENT,
`formData` TEXT NOT NULL,
`sipData` TEXT NOT NULL,
`clientIp` VARCHAR(64) NOT NULL,
`feUser` VARCHAR(64) NOT NULL,
`userAgent` TEXT NOT NULL,
`formId` INT(11) NOT NULL,
`formName` VARCHAR(255) NOT NULL,
`recordId` INT(11) NOT NULL,
`pageId` INT NOT NULL,
`sessionId` VARCHAR(32) NOT NULL,
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
INDEX (`feUser`),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment