Code

ACL : Fixed dns/mac-ip settings
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Sep 2006 06:12:22 +0000 (06:12 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Sep 2006 06:12:22 +0000 (06:12 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4790 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_servGeneric.inc
plugins/admin/systems/class_termDNS.inc
plugins/admin/systems/network.tpl

index c11ae498d5c617b66268d14c28c7787db83a0465..1f1596829ed103dfac7eea68db09ab6fc72b0804 100644 (file)
@@ -52,6 +52,9 @@ class servgeneric extends plugin
       $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
     }
     $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses);
+    $this->netConfigDNS->set_acl_category("server");
+    $this->netConfigDNS->set_acl_base($this->base);
+  
     /* Save dn for later references */
     $this->orig_dn= $this->dn;
   }
index 1fb01de68033af692405e511454b8e7c7598ef63..afcd002120f77f1eda675f97034da8c0622f4224 100644 (file)
@@ -118,6 +118,12 @@ class termDNS extends plugin
   {
          /* Call parent execute */
     $smarty= get_smarty();
+
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
     $display= "";
 
     $smarty->assign("staticAddress", ""); 
@@ -166,7 +172,15 @@ class termDNS extends plugin
     }else{
       $smarty->assign("DNS_is_account",true); 
     }
+
+    $accountACL = false; 
+    if($this->DNSenabled && $this->acl_is_removeable()){
+      $accountACL = true;
+    }elseif(!$this->DNSenabled && $this->acl_is_createable()){
+      $accountACL = true;
+    }
+    $smarty->assign("accountACL",$accountACL);
+
     /* Add new empty array to our record list */
     if(isset($_POST['AddNewRecord'])){
       $this->dnsEntry['RECORDS'][]  =array("type"=>"aRecord","value"=>"");
@@ -243,7 +257,7 @@ class termDNS extends plugin
     
     /* Ge all non dns attributes (IP/MAC)*/
     foreach($this->attributes as $attr){
-      if(isset($_POST[$attr])){
+      if(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){
         $this->$attr = $_POST[$attr];
       }
     }
@@ -252,7 +266,7 @@ class termDNS extends plugin
     if(($this->DNSenabled) && (isset($_POST['network_tpl_posted']))){
 
       /* Check for posted record changes */
-      if(is_array($this->dnsEntry['RECORDS'])){
+      if(is_array($this->dnsEntry['RECORDS']) && $this->acl_is_writeable("Records")){
         foreach($this->dnsEntry['RECORDS'] as $key => $value){
 
           /* Check if type has changed */
@@ -267,16 +281,15 @@ class termDNS extends plugin
       }
       /* Get all basic DNS attributes (TTL, Clas ..)*/
       foreach($this->DNSattributes as $attr){
-        if(isset($_POST[$attr])){
+        if(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){
           $this->dnsEntry[$attr] = $_POST[$attr];
         }
       }
 
-      /* Enable diable DNS */
-      if(isset($_POST['enableDNS'])){
-        $this->DNS_is_account = true;
-      }else{
+      if($this->DNSenabled && $this->acl_is_removeable() && !isset($_POST['enableDNS'])){
         $this->DNS_is_account = false;
+      }elseif(!$this->DNSenabled && $this->acl_is_createable() && isset($_POST['enableDNS'])){
+        $this->DNS_is_account = true;
       }
     }
   }
@@ -294,7 +307,7 @@ class termDNS extends plugin
   
       /* Check if ip is empty 
        */
-      if ($this->ipHostNumber == "" && chkacl ($this->acl, "ipHostNumber") == ""){
+      if ($this->ipHostNumber == "" && $this->acl_is_writeable("ipHostNumber")){
         $message[]= _("The required field 'IP-address' is not set.");
       }
 
@@ -308,7 +321,7 @@ class termDNS extends plugin
 
     /* Check if mac is empty 
      */
-    if ($this->macAddress == "" && chkacl ($this->acl, "macAddress") == ""){
+    if ($this->macAddress == "" && $this->acl_is_writeable("macAddress")){
       $message[]= _("The required field 'MAC-address' is not set.");
     }
 
@@ -506,22 +519,31 @@ class termDNS extends plugin
   /* Return plugin informations for acl handling  */ 
   function plInfo()
   {
-    return (array(
-          "plShortName"   => _("DNS"),
-          "plDescription" => _("DNS settings"),
-          "plSelfModify"  => FALSE,
-          "plDepends"     => array(),
-          "plPriority"    => 5,
-          "plSection"     => array("administration"),
-          "plCategory"    => array("workstation","terminal","phone","server","component","printer"),
-
-          "plProvidedAcls"=> array(
-            "Records"       => _("DNS records"),
-            "zoneName"      => _("Zone name"),
-            "dNSTTL"        => _("TTL"),
-            "ipHostNumber"  => _("IP address"),
-            "macAddress"    => _("MAC address"))
-          ));
+    $tmp =  array(
+        "plShortName"   => _("DNS"),
+        "plDescription" => _("DNS settings"),
+        "plSelfModify"  => FALSE,
+        "plDepends"     => array(),
+        "plPriority"    => 5,
+        "plSection"     => array("administration"),
+        "plCategory"    => array("workstation","terminal","phone","server","component","printer"),
+
+        "plProvidedAcls"=> array(
+          "ipHostNumber"  => _("IP address"),
+          "macAddress"    => _("MAC address"))
+        );
+
+    /* Hide all dns specific code, if dns is not available
+     */
+    $DNSenabled = false;
+    foreach($_SESSION['config']->data['TABS']['SERVERSERVICE'] as $tab){
+      if(preg_match("/^servdns$/",$tab['CLASS'])){
+        $tmp['plProvidedAcls']["Records"]        = _("DNS records");
+        $tmp['plProvidedAcls']["zoneName"]       = _("Zone name");
+        $tmp['plProvidedAcls']["dNSTTL"]         = _("TTL");
+      }
+    }
+    return($tmp);
   }
 }
 
index dcb3d45210490e3a04ec8090dd85a58e1dc3bb61..7a1bd8fa184de24a6cd816718466cdb5eb32fa0d 100644 (file)
@@ -7,16 +7,28 @@
                        <table  summary="">
                                <tr>
                                        <td><LABEL      for="ipHostNumber">{t}IP-address{/t}{if $IPisMust}{$staticAddress}{/if}</LABEL></td>
-                                       <td><input      id="ipHostNumber"       name="ipHostNumber"     size=25 maxlength=80    value="{$ipHostNumber}"></td>
+                                       <td>
+{render acl=$ipHostNumberACL}
+            <input     id="ipHostNumber"       name="ipHostNumber"     size=25 maxlength=80    value="{$ipHostNumber}">
+{/render}
+          </td>
                                </tr>
                                <tr>
                                        <td><LABEL      for="macAddress">{t}MAC-address{/t}</LABEL>{$staticAddress}</td>
-                                       <td><input      name="macAddress"       id="macAddress" size=25 maxlength=80    value="{$macAddress}"></td>
+                                       <td>
+{render acl=$macAddressACL}
+            <input     name="macAddress"       id="macAddress" size=25 maxlength=80    value="{$macAddress}">
+{/render}
+          </td>
                                </tr>
         {if $autonet==true}
                                <tr>
                                        <td>&nbsp;</td>
-                                       <td><input type="submit" name="autonet" value="{t}Autodetect{/t}"></td>
+                                       <td>
+{render acl=$macAddressACL.$ipHostNumberACL}
+            <input type="submit" name="autonet" value="{t}Autodetect{/t}">
+{/render}
+          </td>
                                </tr>
         {/if}
       </table> 
     {if $DNS_is_account==true}
                <td     style="width:50%;vertical-align:top;border-left:1px solid #b0b0b0;" valign="top">
       <input type="checkbox" name="enableDNS" value="1" 
+
+        {if !$accountACL}
+          disabled
+        {/if}
+
         {if $DNSAccount == true}checked="checked"
         onclick="toggle('test2');
           changeState('zoneName');
                                <tr>
                                        <td><LABEL      for="zoneName">{t}Zone{/t}</LABEL></td>
                                        <td>
+{render acl=$zoneNameACL}
               <select name="zoneName" id="zoneName" {if $DNSAccount == false} disabled='disabled' {/if}>
                 {html_options values=$ZoneKeys output=$Zones selected=$zoneName}
               </select>
+{/render}
           </td>
                                </tr>
                                <tr>
           <td>{t}TTL{/t}</td>
-          <td><input type="text" name="dNSTTL" value="{$dNSTTL}" id="dNSTTL" {if $DNSAccount == false} disabled='disabled' {/if}>
+          <td>
+{render acl=$dNSTTLACL}
+            <input type="text" name="dNSTTL" value="{$dNSTTL}" id="dNSTTL" {if $DNSAccount == false} disabled {/if}>
+{/render}
           </td> 
                                </tr>
                                <tr>
           <td valign="top">{t}Dns records{/t}</td>
           <td>
-            {if $DNSAccount == true}{$records}{/if}
+            {if $DNSAccount == true}
+{render acl=$RecordsACL}
+              {$records}
+{/render}
+            {/if}
             </td>
                                </tr>
                        </table>