Code

Updated gotomasses
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 17 Aug 2007 13:38:27 +0000 (13:38 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 17 Aug 2007 13:38:27 +0000 (13:38 +0000)
Not finished yet

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

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

index e5d464f4d8f8f0d409e532726e95b73bb400c715..87af0b6e2ba4ed118c6227ff908c2ca2170d5d68 100644 (file)
@@ -19,8 +19,9 @@ class goto_task extends plugin
   var $Taret    = array();
 
   var $Actions  = array();
-
-  var $attributes     = array("Minute","Hour","Day","Month","Weekday","Action","Comment","Target");
+  var $OGroup   = "";
+  var $OGroups  = array();
+  var $attributes     = array("OGroup","Minute","Hour","Day","Month","Weekday","Action","Comment","Target");
 
 
   function goto_task($config,$parent,$data = array())
@@ -47,6 +48,11 @@ class goto_task extends plugin
       }
     }
 
+    /* Create ogroup select list */
+    $this->OGroups = array("keep_current"     => "["._("Keep current")."]",
+                           "unset_membership" => "["._("Quit group membership")."]");
+    $this->OGroups = array_merge($this->OGroups,$this->parent->get_object_groups());
+
     /* Prepare list of available actions */
     $this->Actions = $this->parent->get_actions();
   }
@@ -150,6 +156,7 @@ class goto_task extends plugin
     $smarty->assign("Months"  , $tmp['Month']);
     $smarty->assign("Weekdays", $tmp['Weekday']);
 
+    $smarty->assign("OGroups"  , $this->OGroups);
     $smarty->assign("Expert"  , $this->Expert);
 
     $smarty->assign("Actions"     , $this->Actions);
@@ -194,6 +201,15 @@ class goto_task extends plugin
     }
   }
 
+  function save()
+  {
+    $tmp = array();
+    foreach($this->attributes as $attr){
+      $tmp[$attr] = $this->$attr;
+    }
+    return($tmp);
+  }
+
 
   /* Return values for listboxes. 
    */
index c81ec3bd032f08341892e4ccc2f47b5ad8e4819f..216e9966531a9612f7fb37643c8959b116ec2bf3 100644 (file)
@@ -15,7 +15,7 @@ class gotomasses extends plugin
 
   /* Queue tasks */
   var $tasks = array();
-
+  var $current =false;
   var $dialog = NULL;
 
   function gotomasses($config, $dn= NULL)
@@ -25,13 +25,18 @@ class gotomasses extends plugin
   
     /* Include config object */
     $this->config= $config;
+
+    $this->load_csv_data();
   }
 
 
 
   function execute()
   {
-    /* Check posts */
+    /************
+     * Handle posts 
+     ************/
+
     $s_entry = $s_action = "";
     $arr = array("/^edit_/"=>"edit","/^remove_/"=>"remove");
     foreach($arr as $regex => $action){
@@ -44,6 +49,10 @@ class gotomasses extends plugin
       }
     }
 
+    /************
+     * List posts 
+     ************/
+
     /* Remove entry from list */
     if($s_action == "remove" && isset($this->tasks[$s_entry])){
       unset($this->tasks[$s_entry]);
@@ -53,6 +62,7 @@ class gotomasses extends plugin
     if($s_action == "edit" && isset($this->tasks[$s_entry])){
       $entry = $this->tasks[$s_entry];
       $this->dialog = new goto_task($this->config,$this,$entry);
+      $this->current = $s_entry;
     }
   
     /* Close dialog */
@@ -63,7 +73,15 @@ class gotomasses extends plugin
     /* Close dialog */
     if(isset($_POST['save_goto_task'])){
       $this->dialog->save_object();
-      $this->dialog = NULL;
+      $msgs = $this->dialog->check();
+      if(count($msgs)){
+        foreach($msgs as $msg){
+          print_red($msg);  
+        }
+      }else{
+        $this->tasks[$this->current] = $this->dialog->save();
+        $this->dialog = NULL;
+      }
     }
  
     /* Display dialogs if currently opened */
@@ -73,7 +91,10 @@ class gotomasses extends plugin
     }
 
 
-    $this->load_csv_data();
+    /************
+     * Handle Divlist 
+     ************/
+
     $smarty = get_smarty();
     $plug = $_GET['plug'];
     $divlist = new divlist("gotomasses");
@@ -183,7 +204,7 @@ class gotomasses extends plugin
       $row    = preg_replace('/  */umi'," ",$row);
       $parts  = split(" ",$row);
 
-      if(count($parts) != 7){
+      if(count($parts) != 8){
         print_red(_("Entry broken, skipped."));
       }else{
 
@@ -194,7 +215,8 @@ class gotomasses extends plugin
         $entry['Month']   = $parts[3];  
         $entry['Weekday'] = $parts[4];  
         $entry['Action']  = $parts[5];  
-        $entry['Target']  = split(",",$parts[6]);  
+        $entry['OGroup']  = $parts[6];  
+        $entry['Target']  = split(",",$parts[7]);  
         $entry['Comment'] = $comment;  
         $this->tasks []   = $entry;
       }
index bb91452dd27445ed37f46df15324d5a6b9f96c2a..4c1e79e726bdfb267b40ee999914b67230a32d96 100644 (file)
@@ -23,12 +23,13 @@ class target_list extends MultiSelectWindow
   var $SubSearch          ;
   var $parent             ;
   var $ui                 ;
-
-
-  
   function target_list($config,$Targets_used)
   {
     MultiSelectWindow::MultiSelectWindow($config, "Targetselection", array("ogroup","gotomasses"));
+
+    $this->Targets_used = $Targets_used;
     
     $this->SetInformation(  _("Select the target objects for your scheduled action."));
     $this->SetTitle(        _("Available targets"));
@@ -155,6 +156,9 @@ class target_list extends MultiSelectWindow
     // Assigning ogroups
     foreach($list as $key => $val){
 
+      if(in_array($val['cn'][0],$this->Targets_used) || 
+         isset($val['macAddress'][0]) && in_array($val['macAddress'][0],$this->Targets_used)) continue;
+
       $title = "title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'";
       if(!isset($val['description'][0])){
         $desc = "";
@@ -210,7 +214,7 @@ class target_list extends MultiSelectWindow
     $Regex    = $this->Regex;
 
     $chk = array(
-        "ogroups"       => "(objectClass=gosaGroupOfNames)" ,
+        "ogroups"       => "(&(objectClass=gosaGroupOfNames)(|(gosaGroupObjects=*S*)(gosaGroupObjects=*W*)))" ,
         "servers"       => "(objectClass=goServer)" ,
         "workstations"  => "(objectClass=gotoWorkstation)");
 
index 6988b0ab3da65f103a74b5c8c6769f9fb521cb18..c673e2210106505bd1fa399673672b3c92b21000 100644 (file)
 
                </td>
        </tr>
+       <tr>
+               <td>
+                       <table>
+                               <tr>
+                                       <td>
+                                               {t}Object group membership{/t}
+                                       </td>
+                                       <td>
+                                               {render acl=$OGroupACL}
+                                               <select name="OGroup">
+                                                       {html_options options=$OGroups selected=$OGroup}
+                                               </select>
+                                               {/render}
+                                       </td>
+                               </tr>
+                       </table>
+
+               </td>
+       </tr>
        <tr>
                <td colspan="2">
                        <h2>{t}Target systems{/t}</h2>