Skip to content

Commit 74829e1

Browse files
committed
Fixed: FS#838 - DNS serial is updated by viewing records.
Changed: removed datalog update function in tform.inc.php and just left the stub function there for legacy support with a call to the new function in the db_mysql.inc.php.
1 parent 2155fb1 commit 74829e1

File tree

3 files changed

+40
-33
lines changed

3 files changed

+40
-33
lines changed

interface/lib/classes/db_mysql.inc.php

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -217,23 +217,14 @@ public function update($tablename, $form, $bedingung, $debug = 0)
217217
}
218218
*/
219219

220-
//** Function to fill the datalog with a full differential record.
221-
public function datalogSave($db_table, $action, $primary_field, $primary_id, $record_old, $record_new) {
222-
global $app,$conf;
223-
224-
// Insert backticks only for incomplete table names.
225-
if(stristr($db_table,'.')) {
226-
$escape = '';
227-
} else {
228-
$escape = '`';
229-
}
230-
220+
public function diffrec($record_old, $record_new) {
231221
$diffrec_full = array();
232222
$diff_num = 0;
233223

234224
if(is_array($record_old) && count($record_old) > 0) {
235225
foreach($record_old as $key => $val) {
236-
if(!isset($record_new[$key]) || $record_new[$key] != $val) {
226+
// if(!isset($record_new[$key]) || $record_new[$key] != $val) {
227+
if($record_new[$key] != $val) {
237228
// Record has changed
238229
$diffrec_full['old'][$key] = $val;
239230
$diffrec_full['new'][$key] = $record_new[$key];
@@ -257,12 +248,34 @@ public function datalogSave($db_table, $action, $primary_field, $primary_id, $re
257248
}
258249
}
259250

251+
return array('diff_num' => $diff_num, 'diff_rec' => $diffrec_full);
252+
253+
}
254+
255+
//** Function to fill the datalog with a full differential record.
256+
public function datalogSave($db_table, $action, $primary_field, $primary_id, $record_old, $record_new) {
257+
global $app,$conf;
258+
259+
// Insert backticks only for incomplete table names.
260+
if(stristr($db_table,'.')) {
261+
$escape = '';
262+
} else {
263+
$escape = '`';
264+
}
265+
266+
$tmp = $this->diffrec($record_old, $record_new);
267+
$diffrec_full = $tmp['diff_rec'];
268+
$diff_num = $tmp['diff_num'];
269+
unset($tmp);
270+
260271
// Insert the server_id, if the record has a server_id
261272
$server_id = (isset($record_old["server_id"]) && $record_old["server_id"] > 0)?$record_old["server_id"]:0;
262273
if(isset($record_new["server_id"])) $server_id = $record_new["server_id"];
263274

264275

265276
if($diff_num > 0) {
277+
//print_r($diff_num);
278+
//print_r($diffrec_full);
266279
$diffstr = $app->db->quote(serialize($diffrec_full));
267280
$username = $app->db->quote($_SESSION["s"]["user"]["username"]);
268281
$dbidx = $primary_field.":".$primary_id;

interface/lib/classes/tform.inc.php

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,11 @@ function getDataRecord($primary_id) {
10171017

10181018
function datalogSave($action,$primary_id, $record_old, $record_new) {
10191019
global $app,$conf;
1020-
1020+
1021+
$app->db->datalogSave($this->formDef['db_table'], $action, $this->formDef['db_table_idx'], $primary_id, $record_old, $record_new);
1022+
return true;
1023+
1024+
/*
10211025
// Add backticks for incomplete table names.
10221026
if(stristr($this->formDef['db_table'],'.')) {
10231027
$escape = '';
@@ -1026,26 +1030,6 @@ function datalogSave($action,$primary_id, $record_old, $record_new) {
10261030
}
10271031
10281032
$this->diffrec = array();
1029-
/*
1030-
if(is_array($record_new) && count($record_new) > 0) {
1031-
foreach($record_new as $key => $val) {
1032-
if(@$record_old[$key] != $val) {
1033-
// Record has changed
1034-
$diffrec[$key] = array('old' => @$record_old[$key],
1035-
'new' => $val);
1036-
}
1037-
}
1038-
} elseif(is_array($record_old)) {
1039-
foreach($record_old as $key => $val) {
1040-
if($record_new[$key] != $val) {
1041-
// Record has changed
1042-
$diffrec[$key] = array('new' => $record_new[$key],
1043-
'old' => $val);
1044-
}
1045-
}
1046-
}
1047-
$this->diffrec = $diffrec;
1048-
*/
10491033
10501034
// Full diff records for ISPConfig, they have a different format then the simple diffrec
10511035
$diffrec_full = array();
@@ -1098,6 +1082,7 @@ function datalogSave($action,$primary_id, $record_old, $record_new) {
10981082
}
10991083
11001084
return true;
1085+
*/
11011086

11021087
}
11031088

interface/web/dns/dns_soa_edit.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,11 @@ function onSubmit() {
135135
}
136136
}
137137

138+
/*
138139
// Update the serial number of the SOA record
139140
$soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = ".$this->id);
140141
$this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]);
142+
*/
141143

142144

143145
//* Check if soa, ns and mbox have a dot at the end
@@ -176,6 +178,13 @@ function onAfterInsert() {
176178
function onAfterUpdate() {
177179
global $app, $conf;
178180

181+
$tmp = $app->db->diffrec($this->oldDataRecord,$app->tform->getDataRecord($this->id));
182+
if($tmp['diff_num'] > 0) {
183+
// Update the serial number of the SOA record
184+
$soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = ".$this->id);
185+
$app->db->query("UPDATE dns_soa SET serial = '".$app->validate_dns->increase_serial($soa["serial"])."' WHERE id = ".$this->id);
186+
}
187+
179188
// make sure that the record belongs to the client group and not the admin group when a dmin inserts it
180189
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
181190
$client_group_id = intval($this->dataRecord["client_group_id"]);

0 commit comments

Comments
 (0)