Code

Added a first set of reference changes - nearly untested
[gosa.git] / plugins / addons / gotomasses / class_gotomasses.inc
index 8b32876efd6969dfddb06ef190e8289d8179bb5e..67d4d3946795321d489cec40fb758f2f035277fe 100644 (file)
@@ -19,13 +19,19 @@ class gotomasses extends plugin
   var $dialog = FALSE;
   var $ids_to_remove = array();
 
-  function gotomasses($config, $dn= NULL)
+
+  function gotomasses(&$config, $dn= NULL)
   {
+    /* Include config object */
+    $this->config= &$config;
+
     /* Define source file */
     $this->data_file = CONFIG_DIR."/gotomasses_machines";
+    $file = search_config($this->config->data['MENU'], "gotomasses", "STORAGE_FILE");
+    if(!empty($file)){
+      $this->data_file = $file;
+    }
   
-    /* Include config object */
-    $this->config= $config;
     $this->load_gotomasses_data();
   }
 
@@ -67,9 +73,13 @@ class gotomasses extends plugin
       }else{
         $this->ids_to_remove = $this->list_get_selected_items();
         $tmp = "";
-        foreach($this->ids_to_remove as $id){
-          $task = $this->tasks[$id];
-          $tmp.= "\n".$this->target_to_string($task);
+        foreach($this->ids_to_remove as $key => $id){
+          if(isset($this->tasks[$id])){
+            $task = $this->tasks[$id];
+            $tmp.= "\n".$this->target_to_string($task);
+          }else{
+            unset($this->ids_to_remove[$key]);
+          }
         }
         $smarty->assign("multiple", TRUE); 
         $smarty->assign("info",sprintf(_("Your are about to delete the following tasks: %s"),"<pre>".$tmp."</pre>"));
@@ -316,7 +326,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,11 +338,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]);
+            $entry['Initial_Target'][]  = array(
+                          "MAC"     => $tmp[0],
+                          "IP"      => $tmp[1],
+                          "NAME"    => $tmp[2]);
           }
           $entry['Target']  = array();
         }else{
@@ -363,9 +378,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 .= $target['MAC'].",".$target['IP'].",".$target['NAME'].";";
+          $str .= trim($target['MAC']).",".trim($target['IP']).",".trim($target['NAME']).";";
         }
       }else{
         foreach($task['Target'] as $target){