tbrehm
2012-01-25 974ba6765a0c54b7fddfac04b72d0c1bfb6d4132
Fixed: FS#1986 - DNS delete from client
5 files modified
71 ■■■■ changed files
interface/web/dns/dns_slave_edit.php 8 ●●●●● patch | view | raw | blame | history
interface/web/dns/dns_soa_edit.php 33 ●●●● patch | view | raw | blame | history
interface/web/dns/templates/dns_slave_edit.htm 14 ●●●● patch | view | raw | blame | history
interface/web/dns/templates/dns_soa_edit.htm 14 ●●●● patch | view | raw | blame | history
interface/web/sites/web_domain_edit.php 2 ●●● patch | view | raw | blame | history
interface/web/dns/dns_slave_edit.php
@@ -106,6 +106,14 @@
        
        }
        
        if($this->id > 0) {
            //* we are editing a existing record
            $app->tpl->setVar("edit_disabled", 1);
            $app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]);
        } else {
            $app->tpl->setVar("edit_disabled", 0);
        }
        parent::onShowEnd();
    }
    
interface/web/dns/dns_soa_edit.php
@@ -116,6 +116,14 @@
        
        }
        
        if($this->id > 0) {
            //* we are editing a existing record
            $app->tpl->setVar("edit_disabled", 1);
            $app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]);
        } else {
            $app->tpl->setVar("edit_disabled", 0);
        }
        parent::onShowEnd();
    }
    
@@ -180,17 +188,34 @@
        // 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"]);
            $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id WHERE id = ".$this->id);
            $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE id = ".$this->id);
            // And we want to update all rr records too, that belong to this record
            $app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id WHERE id = ".$this->id);
            $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE id = ".$this->id);
            // And we want to update all rr records too, that belong to this record
            $app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id);
        }
    }
    function onBeforeUpdate () {
        global $app, $conf;
        //* Check if the server has been changed
        // We do this only for the admin or reseller users, as normal clients can not change the server ID anyway
        if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
            //* We do not allow users to change a domain which has been created by the admin
            $rec = $app->db->queryOneRecord("SELECT origin from dns_soa WHERE id = ".$this->id);
            if(isset($this->dataRecord["origin"]) && $rec['origin'] != $this->dataRecord["origin"] && $app->tform->checkPerm($this->id,'u')) {
                //* Add a error message and switch back to old server
                $app->tform->errorMessage .= $app->lng('The Zone (soa) can not be changed. Please ask your Administrator if you want to change the Zone name.');
                $this->dataRecord["origin"] = $rec['origin'];
            }
            unset($rec);
        }
    }
    
    function onAfterUpdate() {
@@ -206,13 +231,13 @@
        // 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"]);
            $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id WHERE id = ".$this->id);
            $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE id = ".$this->id);
            // And we want to update all rr records too, that belong to this record
            $app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id WHERE id = ".$this->id);
            $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE id = ".$this->id);
            // And we want to update all rr records too, that belong to this record
            $app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id);
        }
interface/web/dns/templates/dns_slave_edit.htm
@@ -7,10 +7,18 @@
    <fieldset class="inlineLabels"><legend>Secondary DNS Zone</legend>
      <tmpl_if name="is_admin">
      <div class="ctrlHolder">
          <label for="server_id">{tmpl_var name='server_id_txt'}</label>
          <tmpl_if name="edit_disabled">
        <label for="server_id_disabled">{tmpl_var name='server_id_txt'}</label>
        <select name="server_id_disabled" id="server_id_disabled" class="selectInput" disabled="disabled">
          {tmpl_var name='server_id'}
        </select>
        <input type="hidden" name="server_id" value="{tmpl_var name='server_id_value'}" />
        <tmpl_else>
        <label for="server_id">{tmpl_var name='server_id_txt'}</label>
        <select name="server_id" id="server_id" class="selectInput">
                    {tmpl_var name='server_id'}
                </select>
          {tmpl_var name='server_id'}
        </select>
        </tmpl_if>
      </div>
      <div class="ctrlHolder">
          <label for="client_group_id">{tmpl_var name='client_txt'}</label>
interface/web/dns/templates/dns_soa_edit.htm
@@ -7,10 +7,18 @@
    <fieldset class="inlineLabels"><legend>DNS Zone</legend>
      <tmpl_if name="is_admin">
      <div class="ctrlHolder">
          <label for="server_id">{tmpl_var name='server_id_txt'}</label>
          <tmpl_if name="edit_disabled">
        <label for="server_id_disabled">{tmpl_var name='server_id_txt'}</label>
        <select name="server_id_disabled" id="server_id_disabled" class="selectInput" disabled="disabled">
          {tmpl_var name='server_id'}
        </select>
        <input type="hidden" name="server_id" value="{tmpl_var name='server_id_value'}" />
        <tmpl_else>
        <label for="server_id">{tmpl_var name='server_id_txt'}</label>
        <select name="server_id" id="server_id" class="selectInput">
                    {tmpl_var name='server_id'}
                </select>
          {tmpl_var name='server_id'}
        </select>
        </tmpl_if>
      </div>
      <div class="ctrlHolder">
          <label for="client_group_id">{tmpl_var name='client_txt'}</label>
interface/web/sites/web_domain_edit.php
@@ -538,7 +538,7 @@
    function onAfterUpdate() {
        global $app, $conf;
        // make sure that the record belongs to the clinet group and not the admin group when a admin inserts it
        // make sure that the record belongs to the client group and not the admin group when a admin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);