Commit 74829e1a authored by tbrehm's avatar tbrehm

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.
parent 2155fb12
......@@ -217,23 +217,14 @@ class db {
}
*/
//** Function to fill the datalog with a full differential record.
public function datalogSave($db_table, $action, $primary_field, $primary_id, $record_old, $record_new) {
global $app,$conf;
// Insert backticks only for incomplete table names.
if(stristr($db_table,'.')) {
$escape = '';
} else {
$escape = '`';
}
public function diffrec($record_old, $record_new) {
$diffrec_full = array();
$diff_num = 0;
if(is_array($record_old) && count($record_old) > 0) {
foreach($record_old as $key => $val) {
if(!isset($record_new[$key]) || $record_new[$key] != $val) {
// if(!isset($record_new[$key]) || $record_new[$key] != $val) {
if($record_new[$key] != $val) {
// Record has changed
$diffrec_full['old'][$key] = $val;
$diffrec_full['new'][$key] = $record_new[$key];
......@@ -257,12 +248,34 @@ class db {
}
}
return array('diff_num' => $diff_num, 'diff_rec' => $diffrec_full);
}
//** Function to fill the datalog with a full differential record.
public function datalogSave($db_table, $action, $primary_field, $primary_id, $record_old, $record_new) {
global $app,$conf;
// Insert backticks only for incomplete table names.
if(stristr($db_table,'.')) {
$escape = '';
} else {
$escape = '`';
}
$tmp = $this->diffrec($record_old, $record_new);
$diffrec_full = $tmp['diff_rec'];
$diff_num = $tmp['diff_num'];
unset($tmp);
// Insert the server_id, if the record has a server_id
$server_id = (isset($record_old["server_id"]) && $record_old["server_id"] > 0)?$record_old["server_id"]:0;
if(isset($record_new["server_id"])) $server_id = $record_new["server_id"];
if($diff_num > 0) {
//print_r($diff_num);
//print_r($diffrec_full);
$diffstr = $app->db->quote(serialize($diffrec_full));
$username = $app->db->quote($_SESSION["s"]["user"]["username"]);
$dbidx = $primary_field.":".$primary_id;
......
......@@ -1017,7 +1017,11 @@ class tform {
function datalogSave($action,$primary_id, $record_old, $record_new) {
global $app,$conf;
$app->db->datalogSave($this->formDef['db_table'], $action, $this->formDef['db_table_idx'], $primary_id, $record_old, $record_new);
return true;
/*
// Add backticks for incomplete table names.
if(stristr($this->formDef['db_table'],'.')) {
$escape = '';
......@@ -1026,26 +1030,6 @@ class tform {
}
$this->diffrec = array();
/*
if(is_array($record_new) && count($record_new) > 0) {
foreach($record_new as $key => $val) {
if(@$record_old[$key] != $val) {
// Record has changed
$diffrec[$key] = array('old' => @$record_old[$key],
'new' => $val);
}
}
} elseif(is_array($record_old)) {
foreach($record_old as $key => $val) {
if($record_new[$key] != $val) {
// Record has changed
$diffrec[$key] = array('new' => $record_new[$key],
'old' => $val);
}
}
}
$this->diffrec = $diffrec;
*/
// Full diff records for ISPConfig, they have a different format then the simple diffrec
$diffrec_full = array();
......@@ -1098,6 +1082,7 @@ class tform {
}
return true;
*/
}
......
......@@ -135,9 +135,11 @@ class page_action extends tform_actions {
}
}
/*
// Update the serial number of the SOA record
$soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = ".$this->id);
$this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]);
*/
//* Check if soa, ns and mbox have a dot at the end
......@@ -176,6 +178,13 @@ class page_action extends tform_actions {
function onAfterUpdate() {
global $app, $conf;
$tmp = $app->db->diffrec($this->oldDataRecord,$app->tform->getDataRecord($this->id));
if($tmp['diff_num'] > 0) {
// Update the serial number of the SOA record
$soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = ".$this->id);
$app->db->query("UPDATE dns_soa SET serial = '".$app->validate_dns->increase_serial($soa["serial"])."' WHERE id = ".$this->id);
}
// make sure that the record belongs to the client group and not the admin group when a dmin inserts it
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
$client_group_id = intval($this->dataRecord["client_group_id"]);
......
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