|
49 | 49 | $app->load('tform_actions'); |
50 | 50 |
|
51 | 51 | class page_action extends tform_actions { |
52 | | - |
| 52 | + |
| 53 | + private $record_has_changed = false; |
| 54 | + |
53 | 55 | function onShowNew() { |
54 | 56 | global $app; |
55 | 57 |
|
@@ -87,38 +89,40 @@ function onSubmit() { |
87 | 89 |
|
88 | 90 | parent::onSubmit(); |
89 | 91 | } |
90 | | - |
| 92 | + |
91 | 93 | function onAfterUpdate() { |
92 | | - global $app; |
93 | | - |
94 | | - $record_has_changed = false; |
| 94 | + $this->record_has_changed = false; |
95 | 95 | foreach($this->dataRecord as $key => $val) { |
96 | 96 | if(isset($this->oldDataRecord[$key]) && @$this->oldDataRecord[$key] != $val) { |
97 | 97 | // Record has changed |
98 | | - $record_has_changed = true; |
| 98 | + $this->record_has_changed = true; |
99 | 99 | } |
100 | 100 | } |
| 101 | + } |
101 | 102 |
|
102 | | - if($record_has_changed){ |
| 103 | + function onAfterDatalogSave($insert = false) { |
| 104 | + global $app; |
| 105 | + |
| 106 | + if(!$insert && $this->record_has_changed){ |
103 | 107 | $spamfilter_users = $app->db->queryAllRecords("SELECT * FROM spamfilter_users WHERE policy_id = ?", intval($this->id)); |
104 | 108 |
|
105 | 109 | if(is_array($spamfilter_users) && !empty($spamfilter_users)){ |
106 | 110 | foreach($spamfilter_users as $spamfilter_user){ |
107 | 111 | $app->db->datalogUpdate('spamfilter_users', $spamfilter_user, 'id', $spamfilter_user["id"], true); |
108 | | - |
| 112 | + |
109 | 113 | // check if this is an email domain |
110 | 114 | if(substr($spamfilter_user['email'],0,1) == '@') { |
111 | 115 | $domain = substr($spamfilter_user['email'],1); |
112 | 116 | $forwardings = $app->db->queryAllRecords("SELECT * FROM mail_forwarding WHERE source LIKE ? OR destination LIKE ?", "%@" . $domain, "%@" . $domain); |
113 | | - |
| 117 | + |
114 | 118 | // Force-update aliases and forwards |
115 | 119 | if(is_array($forwardings)) { |
116 | 120 | foreach($forwardings as $rec) { |
117 | 121 | $app->db->datalogUpdate('mail_forwarding', array("source" => $rec['source']), 'forwarding_id', $rec['forwarding_id'],true); |
118 | 122 | } |
119 | 123 | } |
120 | 124 | } |
121 | | - |
| 125 | + |
122 | 126 | } |
123 | 127 | } |
124 | 128 | } |
|
0 commit comments