Code

Fix for #144
authorpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 5 Mar 2010 13:22:19 +0000 (13:22 +0000)
committerpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 5 Mar 2010 13:22:19 +0000 (13:22 +0000)
- Improve tests::is_in_ip_range:
  - Check if the specified address is a valid address at all,
    otherwise return FALSE
  - If both 'to' and 'from' are set to '*' or empty return TRUE
- Add new function ldap_equality_check
  - This function compares a string similar as a LDAP equality match
    would do. It does so by replacing any occurence of a * with a
    regex pattern and test it with preg_match. The default mapping is
    but the  test can be extended  by changing that mapping, so that the
    asterisk can stand for a certain range of chars for example.
  - Add new filters for MAC-Address, FAI-Classes and FAI-release
    based on this.
- Add a new function AddTextCheckbox. This is similar to AddCheckbox
  but also has a parameter regexes that gets a list of regexes (as
  returned by AddRegex with the return_regex=TRUE parameter) which
  are displayed directly after the checkbox.
- Add a function Draw() that gets a smarty object from
  MultiSelectWindow::Draw and additionally renders the special filters
  with a special template.
- Make save_object() handle the somewhat special structure of
  this->array_TextCheckboxes which stores the TextCheckboxes as
  created by AddTextCheckbox
- Make filter_iprange (and its text field ifrom and ipto) use the
  nex AddCheckBox feature.
- Add a template for the event target add list
- Add a new parameter to AddRegex so that it is possible to get a
  regex array instead of returning the objects array_Regexes
- Add new functions GetCheckbox and GetRegex that contain the
  code from the Draw() function to draw textfields and checkboxes.
  This enables inheritting implementations to use these functions
  when altering the behaviour.
- Allow Draw function to return smarty object
  This change allows to change the behaviour of the
  Draw function to return a smarty object.
  If the class that inherits from MultiSelectWindow sets
  $this->DrawReturnsSmartyObject to a true value a
  smarty object is returned instead of html.
  A certain class can now alter this smarty object and after that
  fetch the HTML itself.

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

trunk/gosa-core/include/class_MultiSelectWindow.inc
trunk/gosa-core/include/functions.inc
trunk/gosa-core/include/utils/class_tests.inc
trunk/gosa-plugins/goto/addons/goto/events/EventTargetAddList.tpl [new file with mode: 0644]
trunk/gosa-plugins/goto/addons/goto/events/class_EventTargetAddList.inc

index ba2e4629a04a57e417b7c82d907514c66d0192a8..8aae53bb7bfeb252dd8a5075c0e565db29e0e272 100644 (file)
@@ -70,6 +70,10 @@ class MultiSelectWindow{
   var $footer = "";
   var $post_id    = "1 2 3";
 
+  /*! \brief If this is set to TRUE the Draw() function returns a smarty object */
+  var $DrawReturnsSmartyObject = FALSE;
+  
+
        function ClearElementsList()
        {
     $ui =get_userinfo();
@@ -92,8 +96,8 @@ class MultiSelectWindow{
   }
 
        /* Adds a regex input field to the current dialog */
-       function AddRegex($name,$string,$value,$conn,$image="images/lists/search.png")
-       {
+       function AddRegex($name,$string,$value,$conn,$image="images/lists/search.png", $return_array=FALSE)
+  {
                $arr = array();
 
                /* Check if the given input field name was already used 
@@ -109,8 +113,13 @@ class MultiSelectWindow{
                $arr['name']            = $name;
                $arr['string']          = $string;
                $arr['image']           = $image;       
-               $arr['connAlpha']       = $conn;                // Connect with alphabet select 
-               $this->array_Regexes[] = $arr;
+    $arr['connAlpha']  = $conn;                // Connect with alphabet select
+    if (!$return_array) { 
+       $this->array_Regexes[] = $arr;
+    }
+    else {
+      return($arr);
+    }
        }
 
 
@@ -369,7 +378,60 @@ class MultiSelectWindow{
     $this->IgnoreAccount = !$ignore;
   }
 
-       /*! \brief Draw the list with all list elements and filters */
+  function GetCheckbox($box, $start_table=FALSE)
+  {
+    $ret = "";
+               $boxClick = " onClick='document.mainform.submit();' ";
+               if($box['name'] == SEPERATOR){
+                               $ret = "</td></tr></table><table style='width:100%;border-top:1px solid #B0B0B0;'><tr><td>";
+                               return($ret);
+                       }
+
+    
+    /* Skip disabled boxes */
+               if(!$box['enabled']) return;
+
+               /* Check if box is checked */
+               if($box['default'] == true){
+                   $ret .="<input type='checkbox' name=\"".$box['name']."\" value='1' title=\"".htmlspecialchars($box['value'])."\" checked ".$boxClick.">&nbsp;".$box['string']."<br>";
+               }else{
+                   $ret .="<input type='checkbox' name=\"".$box['name']."\" value='1' title=\"".htmlspecialchars($box['value'])."\" ".$boxClick.">&nbsp;".$box['string']."<br>";
+    }
+
+    return($ret);
+  }
+
+  function GetRegex($regex, $draw_line=TRUE)
+  {
+      $ret = "";
+      $line_css = "";
+      if ($draw_line) {
+        $line_css = "solid #B0B0B0;";
+      }
+                       $ret="<table summary=\"\" style=\"width:100%;border-top:1px $line_css\">
+                               <tr>
+                               <td>
+                               <label for=\"".$regex['name']."\">
+                               <img alt=\"".$regex['string']."\" src=\"".$regex['image']."\" align=middle>
+                               </label>
+                               </td>
+                               <td width=\"99%\">
+                               <input id=\"".$regex['name']."\" type=\"text\" style='width:99%' name=\"".$regex['name']."\" maxlength='20'
+                               value=\"".htmlspecialchars($regex['value'])."\" title=\"".htmlspecialchars($regex['string'])."\"> 
+                               </td>
+                               </tr>
+                               </table>";
+
+      return($ret);
+  }
+
+
+  /*! \brief Draw the list with all list elements and filters
+   *
+   * Returns a string with the HTML code that should be displayed.
+   * If this->DrawReturnsSmartyObject is TRUE (default: FALSE) it
+   * returns a smarty object.
+   * */
        function Draw()
        {
 
@@ -414,44 +476,17 @@ class MultiSelectWindow{
                /* Create checkboxes fields 
                 */
                $boxes = "";
-               $boxClick = " onClick='document.mainform.submit();' ";
-               foreach($this->array_Checkboxes as $box){
-
-                       if($box['name'] == SEPERATOR){
-                               $boxes .= "</td></tr></table><table style='width:100%;border-top:1px solid #B0B0B0;'><tr><td>";
-                               continue;
-                       }
-
-                       /* Skip disabled boxes */
-                       if(!$box['enabled']) continue;
-
-                       /* Check if box is checked */
-                       if($box['default'] == true){
-                               $boxes .="<input type='checkbox' name=\"".$box['name']."\" value='1' title=\"".htmlspecialchars($box['value'])."\" checked ".$boxClick.">&nbsp;".$box['string']."<br>";
-                       }else{
-                               $boxes .="<input type='checkbox' name=\"".$box['name']."\" value='1' title=\"".htmlspecialchars($box['value'])."\" ".$boxClick.">&nbsp;".$box['string']."<br>";
-                       }
-               }
+    foreach($this->array_Checkboxes as $box){
+      $boxes .= $this->GetCheckbox($box);
+    }
                $smarty->assign("CheckBoxes", $boxes);
 
                /* Assign regex fields 
                 */
                $regexes = "";
-               foreach($this->array_Regexes as $regex){
-                       $regexes.="<table summary=\"\" style=\"width:100%;border-top:1px solid #B0B0B0;\">
-                               <tr>
-                               <td>
-                               <label for=\"".$regex['name']."\">
-                               <img alt=\"".$regex['string']."\" src=\"".$regex['image']."\" align=middle>
-                               </label>
-                               </td>
-                               <td width=\"99%\">
-                               <input id=\"".$regex['name']."\" type=\"text\" style='width:99%' name=\"".$regex['name']."\" maxlength='20'
-                               value=\"".htmlspecialchars($regex['value'])."\" title=\"".htmlspecialchars($regex['string'])."\"> 
-                               </td>
-                               </tr>
-                               </table>";
-               }
+    foreach($this->array_Regexes as $regex){
+      $regexes .= $this->GetRegex($regex);
+    }
                $smarty->assign("regexes"                       , $regexes );
 
     /* Hide Filter Part if Requested or empty */
@@ -499,8 +534,13 @@ class MultiSelectWindow{
                $smarty->assign("filterName"    ,       $this->filterName);
                $smarty->assign("is_headpage"   ,       $this->is_headpage);
 
-               $display = $smarty->fetch(get_template_path("MultiSelectWindow.tpl"));
-               return($display);
+    if (!$this->DrawReturnsSmartyObject) {
+      $display = $smarty->fetch(get_template_path("MultiSelectWindow.tpl"));
+      return($display);
+    }
+    else {
+      return($smarty);
+    }
        }
 
   /*! \brief Set the close var (simulates a press of the the close button) */
index 3bf03eab266fe894991d94448a0fe51ae3e229be..62869d6b01a4bcdb7ee4310119e6a874aa01f3fa 100644 (file)
@@ -3225,6 +3225,35 @@ function set_object_info($str = "")
   session::set('objectinfo',$str);
 }
 
+/*! \brief Compare two strings similar as an LDAP search would do it
+ *
+ * This function compares a string similar as a LDAP equality match
+ * would do. It does so by replacing any occurence of a * with a
+ * regex pattern and test it with preg_match. The default mapping is '.*'
+ * but the  test can be extended  by changing that mapping, so that the asterisk
+ * can stand for a certain range of chars for example.
+ *
+ * Example:
+ * \code
+ * ldap_equality_check('halut', '*'); # true
+ * ldap_equality_check('halut/1.2.3', 'halut/*'); # true
+ * ldap_equality_check('halut/1.2.3', 'hal\*\/1.2.3'); # true
+ * \endcode
+ * 
+ * */
+function ldap_equality_check($string1, $string2, $mapping=".*", $case_sensitive=TRUE) {
+  if (!(strstr($string2, '*')) && ($string1 == $string2)) {
+    return TRUE;
+  }
+
+  /* Set modifier string to i if case insensitivity is requested */
+  $modifier = $case_sensitive ? "" : "i"; 
+  $string2 = preg_quote($string2, "/");
+  $string2 = str_replace('\*', $mapping, $string2);
+
+  $result = preg_match('/' . $string2 . '$/' . $modifier, $string1);
+  return $result;
+}
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index a34eac4ca8eb0a04547031e4dd4ce2d4cdaa078d..1be764926c7f4bd9450f9c0b067884e4dfb3d15d 100644 (file)
@@ -262,6 +262,14 @@ class tests {
   /* \brief Check if the specified IP address $address is inside the given network */
   public static function is_in_ip_range($from, $to, $address)
   {
+    if (!preg_match("/[0-2]?[0-9]?[0-9].[0-2]?[0-9]?[0-9].[0-2]?[0-9]?[0-9].[0-2]?[0-9]?[0-9]/", $address)) {
+      return FALSE;
+    }
+
+    if (($from == '*' && $to == '*') || ($from == '' && $to == '')) {
+      return TRUE;
+    }
+
     $from = split('\.', $from);
     $to   = split('\.', $to);
     $ad   = split('\.', $address);
diff --git a/trunk/gosa-plugins/goto/addons/goto/events/EventTargetAddList.tpl b/trunk/gosa-plugins/goto/addons/goto/events/EventTargetAddList.tpl
new file mode 100644 (file)
index 0000000..27d5d76
--- /dev/null
@@ -0,0 +1,149 @@
+        <!-- Avoid posting the first action specified on this page when pressing 'enter' while editing an input field.
+                Mostly "dep_root" was posted the base selector was resetted. -->
+        <input type='image' src='images/empty.png' name='no_action_posted' value='do_nothing' alt='' style='width:2px;height:2px;'>
+
+       <!-- Used to identify the post data, if we don't check this we may execute
+                 actions on a wrong list.
+      -->
+       <input type="hidden" value="{$POST_ID}" name="POST_ID">
+       <table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
+               <tr>
+                       <td style="vertical-align:top; width:50%;">
+                       <div class="contentboxh" {if !$is_headpage}  style="height:20px;" {/if}>
+                               <p class="contentboxh" {if !$is_headpage} style="font-size:12px;" {/if}>
+                                       {$Summary} {$hint} 
+                               </p>
+                       </div>
+                       <div class="contentboxb">
+                               <div style='background:white;padding:0px;'>
+                               <table>
+                                       <tr>
+                                               <td>
+                                               {$Header}
+                                               </td>
+                                               {if $HeaderDropDown != ""}
+                                                       <td>
+                                                               <img src='images/lists/seperator.png' alt='-' align='middle' height='16' width='1' class='center'>
+                                                               <img src='images/rocket.png' alt='' class='center'>
+                                                       </td>
+                                                       <td>
+                                                               {$HeaderDropDown}
+                                                       </td>
+                                               {/if}
+                                       </tr>
+                               </table>
+                               </div>
+                       </div>
+                       <div style='height:4px;'>
+                       </div>
+                               <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+                       {$DivList}
+                       <input type=hidden name="edit_helper">
+                       </div>
+               </td>
+               {if $is_headpage}
+               <td style="vertical-align:top;">
+                       {$UserBox1}
+        {if $Information != ""}
+                       <div class="contentboxh" style="border-bottom:1px solid #B0B0B0;">
+                       <p class="contentboxh">
+                                       <img src="{$infoimage}" align="right" alt="[i]">{t}Information{/t}
+                               </p>
+                       </div>
+                       <div class="contentboxb" style="padding:5px;">
+                               {$Information}
+                       </div>
+                       <br>
+        {/if}
+                       {$UserBox2}
+                       {if !$Skip_Filter_Part }
+                       <div class="contentboxh">
+                       <p class="contentboxh">
+                                       <img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}
+                               </p>
+                       </div>
+                       <div class="contentboxb">
+                               {if $Display_alphabet}
+                               <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+                                       {$alphabet}
+                               </table>
+                               {/if}
+                               { if $CheckBoxes != ""}
+                               <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+                                       <tr>
+                                               <td>
+                                                       {$CheckBoxes}
+                                               </td>
+                                       </tr>
+                               </table>   
+                               {/if}
+                       {$regexes}
+            {$special_filters}
+                       {$apply}
+                       </div>
+                       {$UserBox3}
+                       {/if}
+               </td>
+               {else}
+               <td style="vertical-align:top;">
+                       {$UserBox1}
+                       <div class="contentboxh" style="border-bottom:1px solid #B0B0B0;height:20px;">
+                       <p class="contentboxh">
+                                       <img src="{$infoimage}" align="right" alt="[i]"><font style='font-size:13px;'>{t}Information{/t}</font>
+                               </p>
+                       </div>
+                       <div class="contentboxb" style="padding:5px;">
+                               {$Information}
+                       </div>
+                       {$UserBox2}
+                       <br>
+                       {if !$Skip_Filter_Part }
+                       <div class="contentboxh" style="height:20px;">
+                       <p class="contentboxh">
+                                       <img src="{$launchimage}" align="right" alt="[F]"><font style='font-size:13px;'>{t}Filters{/t}</font>
+                               </p>
+                       </div>
+                       <div class="contentboxb">
+                               {if $Display_alphabet}
+                               <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+                                       {$alphabet}
+                               </table>
+                               {/if}
+                               { if $CheckBoxes != ""}
+                               <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+                                       <tr>
+                                               <td>
+                                                       {$CheckBoxes}
+                                               </td>
+                                       </tr>
+                               </table>   
+                               {/if}
+                       {$regexes}
+            {$special_filters}
+                       {$apply}
+                       {$UserBox3}
+                       </div>
+                       {/if}
+               </td>
+               {/if}
+       </tr>
+</table>
+{if $Display_Save | $Display_Close}
+<p class="seperator">&nbsp;
+</p>
+<div style="text-align:right;" align="right">
+       <p>
+               {if $Display_Save}
+                       <input type="submit" name="SaveMultiSelectWindow" value="{$SaveButtonString}"> 
+               {/if}
+               {if $Display_Close}
+                       <input type="submit" name="CloseMultiSelectWindow" value="{$CloseButtonString}"> 
+               {/if}
+       </p>
+</div>
+{/if}
+{if $IgnoreAccount}
+<input type="hidden" name="ignore">
+{/if}
+<input type="hidden" name="menu_action" id='menu_action'>
+<input type="hidden" name="MultiSelectWindow{$filterName}" value="1">
index fbc32992a6d6002d76e247c681697b9f469da445..fc8e17cad3b66442e41ec5b4be0e5a0e543a18c6 100644 (file)
@@ -26,15 +26,26 @@ class EventTargetAddList extends MultiSelectWindow
   public $display_workstation = TRUE;
   public $display_ogroup = TRUE;
   public $filter_iprange = FALSE;
+  public $filter_mac_addr = FALSE;
+  public $filter_fai_release = FALSE;
+  public $filter_fai_class = FALSE;
 
   public $regex  = "*";
   public $ipfrom = "0.0.0.0";
   public $ipto   = "*";
+  public $mac_addr = "*:*:*:*:*:*";
+  public $fai_release = "*";
+  public $fai_class = "*";
   public $_target_list = array();
 
   public $workstation_list = array();
   public $server_list = array();
 
+  public $array_TextCheckboxes = array();
+
+  public $SubSearch = FALSE;
+  /* Define that Draw has to return a smarty object */
+  public $DrawReturnsSmartyObject = TRUE;
 
   function __construct(&$config,$parent)
   {
@@ -67,15 +78,31 @@ class EventTargetAddList extends MultiSelectWindow
 
     //$name,$string,$value,$conn,$image="images/lists/search.png")
     $this->AddRegex("regex" ,"regex"  ,"*"                , TRUE);
-    $this->AddRegex("ipfrom","ipfrom" ,"0.0.0.0"          , FALSE);
-    $this->AddRegex("ipto"  ,"ipto"   ,"255.255.255.255"  , FALSE);
 
     $this->AddCheckBox("display_server","1"     ,_("Display server"),TRUE);
     $this->AddCheckBox("display_workstation","1",_("Display workstation"),TRUE);
     $this->AddCheckBox("display_ogroup","1"     ,_("Display object groups"),TRUE);
-    $this->AddCheckBox("filter_iprange","1"     ,_("Filter by IP range"),FALSE);
+    
+    /* Add SubSearch checkbox */
+    $this->AddCheckBox(SEPERATOR);
+    $this->AddCheckBox("SubSearch",  msgPool::selectToView("","subsearch"), msgPool::selectToView("","subsearch_small"), false);
+
+    $regexes = array();
+    $regexes[] = $this->AddRegex("ipfrom","ipfrom" ,"0.0.0.0"          , FALSE, "images/lists/search.png", TRUE);
+    $regexes[] = $this->AddRegex("ipto"  ,"ipto"   ,"255.255.255.255"  , FALSE, "images/lists/search.png", TRUE);
+    $this->AddTextCheckBox("filter_iprange","1"     ,_("Filter by IP range"),FALSE, $regexes);
 
+    $regexes = array();
+    $regexes[] = $this->AddRegex("mac_addr", "mac_addr", "*:*:*:*:*:*", FALSE, "images/lists/search.png", TRUE);
+    $this->AddTextCheckBox("filter_mac_addr", "1", _("Filter by MAC address"), FALSE, $regexes);
 
+    $regexes = array();
+    $regexes[] = $this->AddRegex("fai_release", "fai_release", "*", FALSE, "images/lists/search.png", TRUE);
+    $this->AddTextCheckBox("filter_fai_release", "1", _("Filter by FAI release"), FALSE, $regexes);
+
+    $regexes = array();
+    $regexes[] = $this->AddRegex("fai_class", "fai_class", "*", FALSE, "images/lists/search.png", TRUE);
+    $this->AddTextCheckBox("filter_fai_class", "1", _("Filter by FAI class"), FALSE, $regexes);
 
     /* Create a list of servers
      */
@@ -194,22 +221,43 @@ class EventTargetAddList extends MultiSelectWindow
   {
     $_target_list = array();
     if($this->display_server){
-      $_target_list = array_merge($_target_list,
-            get_list("(&(cn=".$this->regex.")(objectClass=goServer))",
-            "server",get_ou("serverRDN").$this->selectedBase,
-            array("cn","objectClass","description","ipHostNumber","macAddress"),GL_NONE));
+      if (!$this->SubSearch) {
+        $_target_list = array_merge($_target_list,
+              get_list("(&(cn=".$this->regex.")(objectClass=goServer))",
+              "server",get_ou("serverRDN").$this->selectedBase,
+              array("cn","objectClass","description","ipHostNumber","macAddress", "FAIclass"),GL_NONE));
+      }else {
+        $_target_list = array_merge($_target_list,
+              get_sub_list("(&(cn=".$this->regex.")(objectClass=goServer))",
+              "server",get_ou("serverRDN"),$this->selectedBase,
+              array("cn","objectClass","description","ipHostNumber","macAddress"),GL_SUBSEARCH));
+      }
     }
     if($this->display_workstation){
-      $_target_list = array_merge($_target_list,
-            get_list("(&(cn=".$this->regex.")(objectClass=gotoWorkstation))",
-            "workstation",get_ou("workstationRDN").$this->selectedBase,
-            array("cn","objectClass","description","ipHostNumber","macAddress"),GL_NONE));
+      if (!$this->SubSearch) {
+        $_target_list = array_merge($_target_list,
+              get_list("(&(cn=".$this->regex.")(objectClass=gotoWorkstation))",
+              "workstation",get_ou("workstationRDN").$this->selectedBase,
+              array("cn","objectClass","description","ipHostNumber","macAddress", "FAIclass"),GL_NONE));
+      }else {
+        $_target_list = array_merge($_target_list,
+              get_sub_list("(&(cn=".$this->regex.")(objectClass=gotoWorkstation))",
+              "workstation",get_ou("workstationRDN"), $this->selectedBase,
+              array("cn","objectClass","description","ipHostNumber","macAddress", "FAIclass"),GL_SUBSEARCH));
+      }
     }
     if($this->display_ogroup){
-      $_target_list = array_merge($_target_list,
-            get_list("(&(cn=".$this->regex.")(member=*)(objectClass=gosaGroupOfNames))",
-            "ogroups",get_ou("ogroupRDN").$this->selectedBase,
-            array("cn","objectClass","description","member"),GL_NONE));
+      if (!$this->SubSearch) {
+        $_target_list = array_merge($_target_list,
+              get_list("(&(cn=".$this->regex.")(member=*)(objectClass=gosaGroupOfNames))",
+              "ogroups",get_ou("ogroupRDN").$this->selectedBase,
+              array("cn","objectClass","description","member", "FAIclass"),GL_NONE));
+      }else {
+        $_target_list = array_merge($_target_list,
+              get_sub_list("(&(cn=".$this->regex.")(member=*)(objectClass=gosaGroupOfNames))",
+              "ogroups",get_ou("ogroupRDN"), $this->selectedBase,
+              array("cn","objectClass","description","member", "FAIclass"),GL_SUBSEARCH));
+      }
     }
     $this->_target_list = $_target_list;
 
@@ -242,6 +290,52 @@ class EventTargetAddList extends MultiSelectWindow
             continue;
           }
         }
+
+        if($this->filter_mac_addr) {
+          if(!isset($obj['macAddress']) || !ldap_equality_check($obj['macAddress'][0], $this->mac_addr, "[0-9A-F]{2}", FALSE)) {
+            continue;
+          }
+        }
+
+        if($this->filter_fai_release) {
+          if(isset($obj['FAIclass'])) {
+            $fai_release = split(':', $obj['FAIclass'][0]);
+            if (isset($fai_release[1])) {
+              $fai_release = $fai_release[1];
+            } else {
+              continue;
+            }
+
+            if (!ldap_equality_check($fai_release, $this->fai_release)) {
+              continue;
+            }
+          }
+          else {
+            continue;
+          }
+        }
+
+        if ($this->filter_fai_class) {
+          if(isset($obj['FAIclass'])) {
+            $fai_classes = split(':', $obj['FAIclass'][0]);
+            $fai_classes = split(' ', $fai_classes[0]);
+
+            $found = FALSE;
+            foreach($fai_classes as $used_class) {
+              if(ldap_equality_check($used_class, $this->fai_class)){
+                $found = TRUE;
+                break;
+              }
+            }
+            if (!$found) {
+              continue;
+            }
+          }
+          else {
+            continue;
+          }
+        }
+
         if(!isset($this->server_list[$obj['dn']])){
           continue;
         }
@@ -252,10 +346,93 @@ class EventTargetAddList extends MultiSelectWindow
             continue;
           }
         }
+
+        if($this->filter_mac_addr){
+          if(!isset($obj['macAddress']) || !ldap_equality_check($obj['macAddress'][0], $this->mac_addr, "[0-9A-F]{2}", FALSE)) {
+            continue;
+          }
+        }
+
+        if($this->filter_fai_release) {
+          if (isset($obj['FAIclass'])) {
+            $fai_release = split(':', $obj['FAIclass'][0]);
+            if (isset($fai_release[1])) {
+              $fai_release = $fai_release[1];
+            } else {
+              continue;
+            }
+            if (!ldap_equality_check($fai_release, $this->fai_release)) {
+              continue;
+            }
+          }
+          else {
+            continue;
+          }
+        }
+
+        if ($this->filter_fai_class) {
+          if(isset($obj['FAIclass'])) {
+            $fai_classes = split(':', $obj['FAIclass'][0]);
+            $fai_classes = split(' ', $fai_classes[0]);
+
+            $found = FALSE;
+            foreach($fai_classes as $used_class) {
+              if(ldap_equality_check($used_class, $this->fai_class)){
+                $found = TRUE;
+                break;
+              }
+            }
+            if (!$found) {
+              continue;
+            }
+          }
+          else {
+            continue;
+          }
+        }
+
         if(!isset($this->workstation_list[$obj['dn']])){
           continue;
         }
       }elseif(in_array("gosaGroupOfNames",$obj['objectClass'])){
+        if($this->filter_fai_release) {
+          if (isset($obj['FAIclass'])) {
+            $fai_release = split(':', $obj['FAIclass'][0]);
+            if (isset($fai_release[1])) {
+              $fai_release = $fai_release[1];
+            } else {
+              continue;
+            }
+            if (!ldap_equality_check($fai_release, $this->fai_release)) {
+              continue;
+            }
+          }
+          else {
+            continue;
+          }
+        }
+
+        if ($this->filter_fai_class) {
+          if(isset($obj['FAIclass'])) {
+            $fai_classes = split(':', $obj['FAIclass'][0]);
+            $fai_classes = split(' ', $fai_classes[0]);
+
+            $found = FALSE;
+            foreach($fai_classes as $used_class) {
+              if(ldap_equality_check($used_class, $this->fai_class)){
+                $found = TRUE;
+                break;
+              }
+            }
+            if (!$found) {
+              continue;
+            }
+          }
+          else {
+            continue;
+          }
+        }
+
         $img = '<img class="center" src="plugins/ogroups/images/select_ogroup.png" alt="O" title="'._("Object group").'">';
       }
 
@@ -268,6 +445,42 @@ class EventTargetAddList extends MultiSelectWindow
     }
   }
 
+  function AddTextCheckbox($name,$value="Unset", $string="Unset", $default=false, $regexes=array())
+  {
+    $arr = array();
+    $MultiDialogFilters = session::get('MultiDialogFilters');
+    if(isset($MultiDialogFilters[$this->filterName][$name])){
+      $arr['default'] = $MultiDialogFilters[$this->filterName][$name];
+      $this->$name = $arr['default'];
+    }else {
+      $arr['default'] = $default;
+      $this->$name = $default;
+    }
+    $arr['name'] = $name;
+    $arr['string'] = $string;
+    $arr['value'] = $value;
+    $arr['enabled'] = true;
+    $arr['regexes'] = $regexes;
+
+    $this->array_TextCheckboxes[] = $arr;
+
+  }
+
+  function Draw() {
+    $smarty = MultiSelectWindow::Draw();
+    $special_filter = "";
+    foreach($this->array_TextCheckboxes as $textcheckbox) {
+      $special_filter .= "<table style='width:100%;border-top:1px solid #B0B0B0;'><tr><td>";
+      $special_filter .= $this->GetCheckbox($textcheckbox);
+      foreach($textcheckbox['regexes'] as $regex) {
+        $special_filter .= $this->GetRegex($regex, FALSE);
+      }
+    }
+    $special_filter .= "</table>";
+    $smarty->assign("special_filters"   , $special_filter);
+    $display = $smarty->fetch(get_template_path('EventTargetAddList.tpl', TRUE, dirname(__FILE__)));
+    return($display);
+  }
 
   /*! \brief  Returns a set of elements selected in a MultiSelectWindow
     @return Array[integer]=integer
@@ -283,6 +496,31 @@ class EventTargetAddList extends MultiSelectWindow
     }
     return($ids);
   }
+
+  function save_object()
+  {
+    MultiSelectWindow::save_object();
+    if(isset($_POST['MultiSelectWindow'.$this->filterName])){
+      foreach($this->array_TextCheckboxes as $key => $box) {
+          $MultiDialogFilters = session::get('MultiDialogFilters');
+          if(isset($_POST[$box['name']])){
+              $this->array_TextCheckboxes[$key]['default'] = true;
+              $this->$box['name'] = true;
+          }else{
+              $this->array_TextCheckboxes[$key]['default'] = false;
+              $this->$box['name'] = false;
+          }
+          $MultiDialogFilters[$this->filterName][$box['name']] = $this->$box['name'];
+
+      foreach($this->array_TextCheckboxes[$key]['regexes'] as $regex_key => $regex_box) {
+          $this->array_TextCheckboxes[$key]['regexes'][$regex_key]['value'] = $_POST[$regex_box['name']];
+          $this->$regex_box['name'] = $_POST[$regex_box['name']];
+          $MultiDialogFilters[$this->filterName][$regex_box['name']] = $this->$regex_box['name'];
+      }
+      session::set('MultiDialogFilters',$MultiDialogFilters);
+      }
+    }
+  }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>