tbrehm
2010-01-19 74829e1a721252733980d16ae69153e2ec6f6ec3
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.
3 files modified
73 ■■■■ changed files
interface/lib/classes/db_mysql.inc.php 37 ●●●●● patch | view | raw | blame | history
interface/lib/classes/tform.inc.php 27 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_soa_edit.php 9 ●●●●● patch | view | raw | blame | history
interface/lib/classes/db_mysql.inc.php
@@ -217,23 +217,14 @@
    }
    */
    
    //** 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 @@
            }
        }
        
        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;
interface/lib/classes/tform.inc.php
@@ -1017,7 +1017,11 @@
        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 @@
                }
                $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 @@
                }
                return true;
                */
        }
interface/web/dns/dns_soa_edit.php
@@ -135,9 +135,11 @@
            }
        }
        
        /*
        // 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 @@
    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"]);