Code

Updated totomasses.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 24 Aug 2007 09:07:14 +0000 (09:07 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 24 Aug 2007 09:07:14 +0000 (09:07 +0000)
DNS and DHCP settings will be stored onced for each task, not for each target

git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7128 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/addons/gotomasses/class_goto_task.inc
plugins/addons/gotomasses/class_gotomasses.inc
plugins/addons/gotomasses/goto_task.tpl

index 6ea40603e0b5a90acdc01576267774f4cad57730..dc4652f3e1746197261ee6304e56748120df463a 100644 (file)
@@ -28,7 +28,7 @@ class goto_task extends plugin
   var $Initial_Target   = array();
   var $Actions  = array();
   var $new      = FALSE;
-  var $attributes     = array("OGroup","Minute","Hour","Day","Month","Weekday","Action","Comment","Target","Initial_Target");
+  var $attributes     = array("Zone","Section","OGroup","Minute","Hour","Day","Month","Weekday","Action","Comment","Target","Initial_Target");
 
   var $configure_dhcp = FALSE;
   var $configure_dns = FALSE;
@@ -54,6 +54,13 @@ class goto_task extends plugin
       $this->new = TRUE;
     }
 
+    if(!empty($this->Zone) && !preg_match("/^\"\"$/",$this->Zone)){
+      $this->configure_dns = TRUE;
+    }
+    if(!empty($this->Section) && !preg_match("/^\"\"$/",$this->Section)){
+      $this->configure_dhcp = TRUE;
+    }
+
     /* Set dns and dhcp attributes */
     foreach(getAvailableZones($this->config) as $zone){
       $name = preg_replace("#^[^/]+/#","",$zone);
@@ -119,8 +126,7 @@ class goto_task extends plugin
           $DHCP = $_POST['Section'];
         }
         if(is_mac($MAC)){
-          $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME,
-                                          "ZONE" => $DNS , "SECTION" => $DHCP);
+          $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME);
         }
       }
     }
@@ -135,7 +141,7 @@ class goto_task extends plugin
           $line = fgets($fp,512);
           $tmp = preg_split("/(,|;)/",$line);
 
-          $MAC = $IP = $NAME = $ZONE = $SECTION ="";
+          $MAC = $IP = $NAME
           if(isset($tmp[0])){
             $MAC = trim($tmp[0]);
           }
@@ -145,14 +151,8 @@ class goto_task extends plugin
           if(isset($tmp[2])){
             $NAME = trim($tmp[2]);
           }
-          if(isset($tmp[3])){
-            $ZONE = trim($tmp[3]);
-          }
-          if(isset($tmp[4])){
-            $SECTION = trim($tmp[4]);
-          }
           if(is_mac($MAC)){
-            $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME,"ZONE"=> $ZONE,"SECTION"=>$SECTION);
+            $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME);
           }
         }
       }
@@ -209,29 +209,13 @@ class goto_task extends plugin
       $divlist->SetHeader(array(
                             array("string" => _("Target systems") ,"attach" => "style='width:120px;'"),
                             array("string" => _("IP")      , "attach" => "style='width:90px;'"),
-                            array("string" => _("DNS")     ),
-                            array("string" => _("DHCP")    , "attach" => "style='width:120px;'"),
                             array("string" => _("Name")    , "attach" => "style='width:150px;'"),
                             array("string" => _("Actions") , "attach" => "style='width:44px;border-right:0px;text-align:right;'")));
       foreach($this->Initial_Target as $key => $target){
         $field1 = array("string" => $target['MAC']  ,"attach" => "style='width:120px;'");
         $field2 = array("string" => $target['IP']   ,"attach" => "style='width:90px;'");
-        if(isset($this->Zones[$target['ZONE']])){
-          $field2a = array("string" =>"<div style='overflow:hidden'><nobr>". 
-                                      $this->Zones[$target['ZONE']]."</nobr></div>");
-        }else{
-          $field2a = array("string" => "<div style='overflow:hidden'><nobr>".
-                                      $target['ZONE']."</nobr></div>");
-        }
-        if(isset($this->Sections[$target['SECTION']])){
-          $field2b = array("string" => "<div style='overflow:hidden'><nobr>".
-                                      $this->Sections[$target['SECTION']]."</nobr></div>","attach" => "style='width:120px;'");
-        }else{
-          $field2b = array("string" => "<div style='overflow:hidden'><nobr>".
-                                      $target['SECTION']."</nobr></div>"   ,"attach" => "style='width:120px;'");
-        }
         $field3 = array("string" =>  $target['NAME'] ,"attach" => "style='width:150px;'");
-        $divlist->AddEntry(array($field1,$field2,$field2a,$field2b,$field3,preg_replace("/%KEY%/",$key,$field_del)));
+        $divlist->AddEntry(array($field1,$field2,$field3,preg_replace("/%KEY%/",$key,$field_del)));
       } 
     }else{
       $divlist->SetHeader(array(
@@ -273,7 +257,7 @@ class goto_task extends plugin
   }
 
 
-   function create_tree($arr,$base,$current = "")
+  function create_tree($arr,$base,$current = "")
   {
     $ret = array();
     foreach($arr as $r => $name){
@@ -364,6 +348,7 @@ class goto_task extends plugin
           $this->Zone = get_post("Zone");
         }
       }else{
+        $this->Zone = "\"\"";
         $this->configure_dns = FALSE;
       }
 
@@ -374,6 +359,7 @@ class goto_task extends plugin
         }
       }else{
         $this->configure_dhcp = FALSE;
+        $this->Section = "\"\"";
       }
 
       foreach($this->attributes as $attr){
@@ -411,6 +397,12 @@ class goto_task extends plugin
     foreach($this->attributes as $attr){
       $tmp[$attr] = $this->$attr;
     }
+    if(!$this->configure_dns){
+      $tmp['Zone'] = "\"\"";
+    }
+    if(!$this->configure_dhcp){
+      $tmp['Section'] = "\"\"";
+    }
     return($tmp);
   }
 
index 037ac99b6b9b2b0038bd569f31ff42d4e20521ea..df9512cacee3e1d89b4cf05a6a7b436c31f76f01 100644 (file)
@@ -316,7 +316,7 @@ class gotomasses extends plugin
       $row    = preg_replace('/  */umi'," ",$row);
       $parts  = split(" ",$row);
 
-      if(count($parts) != 8){
+      if(count($parts) != 10){
         print_red(_("Entry broken, skipped."));
       }else{
 
@@ -328,16 +328,16 @@ class gotomasses extends plugin
         $entry['Weekday'] = $parts[4];  
         $entry['Action']  = $parts[5];  
         $entry['OGroup']  = $parts[6];  
+        $entry['Zone']    = $parts[7];  
+        $entry['Section'] = $parts[8];  
         if($entry['Action'] == "initial_install"){
-          $tmp2 = split(";",$parts[7]);
+          $tmp2 = split(";",$parts[9]);
           foreach($tmp2 as $target){
             $tmp = split(",",$target);
             $entry['Initial_Target'][]  = array(
                           "MAC"     => $tmp[0],
                           "IP"      => $tmp[1],
-                          "NAME"    => $tmp[2],
-                          "ZONE"    => $tmp[3],
-                          "SECTION" => $tmp[4]);
+                          "NAME"    => $tmp[2]);
           }
           $entry['Target']  = array();
         }else{
@@ -368,10 +368,11 @@ class gotomasses extends plugin
       }
       $str .= str_pad($task['Action'] ,5," ")." ";
       $str .= str_pad($task['OGroup'] ,5," ")." ";
+      $str .= str_pad($task['Zone']   ,5," ")." ";
+      $str .= str_pad($task['Section'],5," ")." ";
       if($task['Action'] == "initial_install"){
         foreach($task['Initial_Target'] as $target){
-          $str .= trim($target['MAC']).",".trim($target['IP']).",".trim($target['NAME']).",".
-                  trim($target['ZONE']).",".trim($target['SECTION']).";";
+          $str .= trim($target['MAC']).",".trim($target['IP']).",".trim($target['NAME']).";";
         }
       }else{
         foreach($task['Target'] as $target){
index fde439624d53c98abbb67c86ff0cf8de90b052a1..8a4139e95c36bfb91794ad0371904cc6c7f0c069 100644 (file)
                                                </select>
                                        </td>
                                </tr>
+                               <tr>
+                                       <td><input class='center' {if $configure_dns} checked {/if} id='configure_dns'
+                                               type='checkbox' name='configure_dns' value='1' onClick="changeState('Zone');">
+                                               <label for='configure_dns'>{t}Configure DNS{/t}</label>
+                                       </td>
+                                       <td>
+                                               <select name="Zone" id="Zone" {if !$configure_dns} disabled {/if}>
+                                                       {html_options options=$Zones selected=$Zone}
+                                               </select>
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td><input class='center' {if $configure_dhcp} checked {/if} id='configure_dhcp' 
+                                                       type='checkbox' name='configure_dhcp' value='1' onClick="changeState('Section');">
+                                               <label for='configure_dhcp'>{t}Configure DHCP{/t}</label>
+                                       </td>
+                                       <td>
+                                               <select name="Section" id="Section" {if !$configure_dhcp} disabled {/if}>
+                                                       {html_options options=$Sections selected=$Section}
+                                               </select>
+                                       </td>
+                               </tr>
                        </table>
                </td>
                <td style='vertical-align:top'>
                                        <td>{t}IP address{/t}
                                        </td>
                                        <td><input type="text" name="task_IP" value=""> 
-                                       </td>
-                               </tr>
-                               <tr>
-                                       <td><input class='center' {if $configure_dns} checked {/if} id='configure_dns'
-                                               type='checkbox' name='configure_dns' value='1' >
-                                               <label for='configure_dns'>{t}Configure DNS{/t}</label>
-                                       </td>
-                                       <td>
-                                               <select name="Zone">
-                                                       {html_options options=$Zones selected=$Zone}
-                                               </select>
-                                       </td>
-                               </tr>
-                               <tr>
-                                       <td><input class='center' {if $configure_dhcp} checked {/if} id='configure_dhcp' 
-                                                       type='checkbox' name='configure_dhcp' value='1' >
-                                               <label for='configure_dhcp'>{t}Configure DHCP{/t}</label>
-                                       </td>
-                                       <td>
-                                               <select name="Section">
-                                                       {html_options options=$Sections selected=$Section}
-                                               </select>
                                                <input type="submit" name="add_target" value="{t}Add{/t}">
                                        </td>
                                </tr>