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

Merge branch 'F4649-sqlBefore-and-sqlAfter-for-sendmail' into 'master'

F4649 - Add sqlBefore & sqlAfter to sendmail FE - refs #4649, closes #4649

See merge request !107
parents 638a542a 233ab3bf
Pipeline #1005 passed with stage
in 1 minute and 42 seconds
...@@ -3855,6 +3855,7 @@ Type: sendmail ...@@ -3855,6 +3855,7 @@ Type: sendmail
* *sendMailMode* = `<string>` - **html** - if set, the e-mail body will be rendered as html. * *sendMailMode* = `<string>` - **html** - if set, the e-mail body will be rendered as html.
* *sendMailSubjectHtmlEntity* = `<string>` - **encode|decode|none** - the mail subject will be htmlspecialchar() encoded / decoded (default) or none (untouched). * *sendMailSubjectHtmlEntity* = `<string>` - **encode|decode|none** - the mail subject will be htmlspecialchar() encoded / decoded (default) or none (untouched).
* *sendMailBodyHtmlEntity*= `<string>` - **encode|decode|none** - the mail body will be htmlspecialchar() encoded, decoded (default) or none (untouched). * *sendMailBodyHtmlEntity*= `<string>` - **encode|decode|none** - the mail body will be htmlspecialchar() encoded, decoded (default) or none (untouched).
* *sqlBefore* / *sqlAfter* = `<string>` - can be used like with other action elements (will be fired before/after sending the e-mail).
* To use values of the submitted form, use the STORE_FORM. E.g. `{{name:F:allbut}}` * To use values of the submitted form, use the STORE_FORM. E.g. `{{name:F:allbut}}`
* To use the `id` of a new created or already existing primary record, use the STORE_RECORD. E.g. `{{id:R}}`. * To use the `id` of a new created or already existing primary record, use the STORE_RECORD. E.g. `{{id:R}}`.
......
...@@ -174,23 +174,27 @@ class FormAction { ...@@ -174,23 +174,27 @@ class FormAction {
$this->store->setStore($arr, STORE_LDAP, true); $this->store->setStore($arr, STORE_LDAP, true);
} }
$this->validate($fe);
// If given: fire a sqlBefore query
$this->evaluate->parse($fe[FE_SQL_BEFORE]);
if ($fe[FE_TYPE] === FE_TYPE_SENDMAIL) { if ($fe[FE_TYPE] === FE_TYPE_SENDMAIL) {
$this->doSendMail($fe); $this->doSendMail($fe);
//no further processing of current element necessary. } else {
continue; $rcTmp = $this->doSlave($fe, $recordId);
switch ($rcTmp) {
case ACTION_ELEMENT_MODIFIED:
case ACTION_ELEMENT_DELETED:
$rc = $rcTmp;
break;
default:
break;
}
} }
$this->validate($fe); // If given: fire a $sqlAfter query
$this->evaluate->parse($fe[FE_SQL_AFTER]);
$rcTmp = $this->doSlave($fe, $recordId);
switch ($rcTmp) {
case ACTION_ELEMENT_MODIFIED:
case ACTION_ELEMENT_DELETED:
$rc = $rcTmp;
break;
default:
break;
}
} }
return $rc; return $rc;
...@@ -327,7 +331,6 @@ class FormAction { ...@@ -327,7 +331,6 @@ class FormAction {
* @return int ACTION_ELEMENT_MODIFIED if there are potential(!) changes on the DB like INSERT / UPDATE, * @return int ACTION_ELEMENT_MODIFIED if there are potential(!) changes on the DB like INSERT / UPDATE,
* ACTION_ELEMENT_NO_CHANGE if nothing happened * ACTION_ELEMENT_NO_CHANGE if nothing happened
* ACTION_ELEMENT_DELETED: if a record has been deleted * ACTION_ELEMENT_DELETED: if a record has been deleted
* $sqlAfter won't affect the $rc.
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws UserFormException * @throws UserFormException
...@@ -352,9 +355,6 @@ class FormAction { ...@@ -352,9 +355,6 @@ class FormAction {
// Store the slaveId: it's used and replaced in the update statement. // Store the slaveId: it's used and replaced in the update statement.
$this->store->setVar(VAR_SLAVE_ID, $slaveId, STORE_VAR, true); $this->store->setVar(VAR_SLAVE_ID, $slaveId, STORE_VAR, true);
// If given: fire a sqlBefore query
$this->evaluate->parse($fe[FE_SQL_BEFORE]);
$doInsert = ($slaveId == 0); $doInsert = ($slaveId == 0);
$doUpdate = ($slaveId != 0); $doUpdate = ($slaveId != 0);
$doDelete = ($slaveId != 0) && $fe[FE_SQL_DELETE] != ''; $doDelete = ($slaveId != 0) && $fe[FE_SQL_DELETE] != '';
...@@ -393,9 +393,6 @@ class FormAction { ...@@ -393,9 +393,6 @@ class FormAction {
$this->db->sql("UPDATE " . $this->primaryTableName . " SET " . $fe[FE_NAME] . " = $slaveId WHERE id = ? LIMIT 1", ROW_REGULAR, [$recordId]); $this->db->sql("UPDATE " . $this->primaryTableName . " SET " . $fe[FE_NAME] . " = $slaveId WHERE id = ? LIMIT 1", ROW_REGULAR, [$recordId]);
} }
// If given: fire a $sqlAfter query. $sqlAfter won't affect $rc
$this->evaluate->parse($fe[FE_SQL_AFTER]);
return $rcStatus; return $rcStatus;
} }
......
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