Commit b7d0b674 authored by Jon Reese's avatar Jon Reese

Merge remote-tracking branch 'parent/develop' into develop

parents c985e2b9 f0f5884d
Pipeline #6447 passed with stage
in 11 seconds
......@@ -141,6 +141,8 @@ class tform_actions {
$app->tform->datalogSave('UPDATE', $this->id, $this->oldDataRecord, $new_data_record);
unset($new_data_record);
unset($old_data_record);
$this->onAfterDatalogSave();
}
if($_REQUEST["next_tab"] == '') {
......@@ -222,6 +224,7 @@ class tform_actions {
$new_data_record = $app->tform->getDataRecord($this->id);
$app->tform->datalogSave('INSERT', $this->id, array(), $new_data_record);
unset($new_data_record);
$this->onAfterDatalogSave(true);
}
......@@ -264,21 +267,19 @@ class tform_actions {
}
function onBeforeUpdate() {
global $app, $conf;
}
function onBeforeInsert() {
global $app, $conf;
}
function onAfterUpdate() {
global $app, $conf;
}
function onAfterInsert() {
global $app, $conf;
}
function onAfterDatalogSave($insert = false) {
}
/**
* Function called on data insert or update error
......@@ -297,7 +298,7 @@ class tform_actions {
*/
function onDelete() {
global $app, $conf, $list_def_file, $tform_def_file;
// Check CSRF Token
$app->auth->csrf_token_check('GET');
......
......@@ -49,7 +49,9 @@ $app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
private $record_has_changed = false;
function onShowNew() {
global $app;
......@@ -87,30 +89,32 @@ class page_action extends tform_actions {
parent::onSubmit();
}
function onAfterUpdate() {
global $app;
$record_has_changed = false;
$this->record_has_changed = false;
foreach($this->dataRecord as $key => $val) {
if(isset($this->oldDataRecord[$key]) && @$this->oldDataRecord[$key] != $val) {
// Record has changed
$record_has_changed = true;
$this->record_has_changed = true;
}
}
}
if($record_has_changed){
function onAfterDatalogSave($insert = false) {
global $app;
if(!$insert && $this->record_has_changed){
$spamfilter_users = $app->db->queryAllRecords("SELECT * FROM spamfilter_users WHERE policy_id = ?", intval($this->id));
if(is_array($spamfilter_users) && !empty($spamfilter_users)){
foreach($spamfilter_users as $spamfilter_user){
$app->db->datalogUpdate('spamfilter_users', $spamfilter_user, 'id', $spamfilter_user["id"], true);
// check if this is an email domain
if(substr($spamfilter_user['email'],0,1) == '@') {
$domain = substr($spamfilter_user['email'],1);
$forwardings = $app->db->queryAllRecords("SELECT * FROM mail_forwarding WHERE source LIKE ? OR destination LIKE ?", "%@" . $domain, "%@" . $domain);
// Force-update aliases and forwards
if(is_array($forwardings)) {
foreach($forwardings as $rec) {
......@@ -118,7 +122,7 @@ class page_action extends tform_actions {
}
}
}
}
}
}
......
......@@ -74,6 +74,7 @@ class cronjob_jailkit_maintenance extends cronjob {
foreach($records as $rec) {
if (!is_dir($rec['document_root']) || !is_dir($rec['document_root'].'/etc/jailkit')) {
$app->db->query("UPDATE `web_domain` SET `last_jailkit_update` = NOW() WHERE `document_root` = ?", $rec['document_root']);
continue;
}
......
......@@ -824,8 +824,7 @@ class ispcmail {
else $rec_string .= $recip;
}
$to = $this->_encodeHeader($rec_string, $this->mail_charset);
//$result = mail($to, $subject, $this->body, implode($this->_crlf, $headers));
$result = mail($to, $enc_subject, $this->body, implode($this->_crlf, $headers));
$result = mail($to, $enc_subject, $this->body, implode($this->_crlf, $headers), "-f $this->_mail_sender");
}
// Reset the subject in case mail is resent
......
......@@ -812,7 +812,7 @@ class monitor_tools {
}
public function send_notification_email($template, $placeholders, $recipients) {
global $conf;
global $app, $conf;
if(!is_array($recipients) || count($recipients) < 1) return false;
if(!is_array($placeholders)) $placeholders = array();
......@@ -829,6 +829,7 @@ class monitor_tools {
//* get mail headers, subject and body
$mailHeaders = '';
$mailFrom = '';
$mailBody = '';
$mailSubject = '';
$inHeader = true;
......@@ -844,6 +845,16 @@ class monitor_tools {
$mailSubject = trim($parts[1]);
continue;
}
if(strtolower($parts[0]) == 'From') {
$mailFrom = trim($parts[1]);
continue;
}
if(strtolower($parts[0]) == 'Cc') {
if (! in_array(trim($parts[1]), $recipients)) {
$recipients[] = trim($parts[1]);
}
continue;
}
unset($parts);
$mailHeaders .= trim($lines[$l]) . "\n";
} else {
......@@ -854,18 +865,14 @@ class monitor_tools {
//* Replace placeholders
$mailHeaders = strtr($mailHeaders, $placeholders);
$mailFrom = strtr($mailFrom, $placeholders);
$mailSubject = strtr($mailSubject, $placeholders);
$mailBody = strtr($mailBody, $placeholders);
for($r = 0; $r < count($recipients); $r++) {
$app->functions->mail($recipients[$r], $mailSubject, $mailBody, $mailHeaders);
$app->functions->mail($recipients[$r], $mailSubject, $mailBody, $mailFrom);
}
unset($mailSubject);
unset($mailHeaders);
unset($mailBody);
unset($lines);
return true;
}
......
Markdown is supported
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