From: hickert Date: Wed, 31 Mar 2010 07:32:24 +0000 (+0000) Subject: Updated FAI filter X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=544f21ca55048b9bc779d47916577b0c082d61d8;p=gosa.git Updated FAI filter git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17414 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/fai/admin/fai/class_filterFAI.inc b/gosa-plugins/fai/admin/fai/class_filterFAI.inc index 5524e0c1f..155b95e47 100644 --- a/gosa-plugins/fai/admin/fai/class_filterFAI.inc +++ b/gosa-plugins/fai/admin/fai/class_filterFAI.inc @@ -4,18 +4,24 @@ class filterFAI extends filterLDAP{ static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "") { - /* Create a new list of FAI object + /* Create a new list of FAI object * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... */ $ObjectTypes = array( - "FAIpartitionTable" => array("OU"=> get_ou('faiPartitionRDN') , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"), - "FAIpackageList" => array("OU"=> get_ou('faiPackageRDN') , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"), - "FAIscript" => array("OU"=> get_ou('faiScriptRDN') , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"), - "FAIvariable" => array("OU"=> get_ou('faiVariableRDN') , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"), - "FAIhook" => array("OU"=> get_ou('faiHookRDN') , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"), - "FAIprofile" => array("OU"=> get_ou('faiProfileRDN') , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"), - "FAItemplate" => array("OU"=> get_ou('faiTemplateRDN') , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate")); - + "FAIpartitionTable" => array("OU"=> get_ou('faiPartitionRDN') , "CHKBOX"=>"ShowPartitions" , + "ACL" => "faiPartitionTable"), + "FAIpackageList" => array("OU"=> get_ou('faiPackageRDN') , "CHKBOX"=>"ShowPackages" , + "ACL" => "faiPackage"), + "FAIscript" => array("OU"=> get_ou('faiScriptRDN') , "CHKBOX"=>"ShowScripts" , + "ACL" => "faiScript"), + "FAIvariable" => array("OU"=> get_ou('faiVariableRDN') , "CHKBOX"=>"ShowVariables" , + "ACL" => "faiVariable"), + "FAIhook" => array("OU"=> get_ou('faiHookRDN') , "CHKBOX"=>"ShowHooks" , + "ACL" => "faiHook"), + "FAIprofile" => array("OU"=> get_ou('faiProfileRDN') , "CHKBOX"=>"ShowProfiles" , + "ACL" => "faiProfile"), + "FAItemplate" => array("OU"=> get_ou('faiTemplateRDN') , "CHKBOX"=>"ShowTemplates" , + "ACL" => "faiTemplate")); global $config; @@ -23,7 +29,7 @@ class filterFAI extends filterLDAP{ $ui = get_userinfo(); $ldap = $config->get_ldap_link(); $ldap->cd($config->current['BASE']); - + $result = array(); foreach($tmp as $entry){ diff --git a/gosa-plugins/fai/admin/fai/class_filterOPSIPackages.inc b/gosa-plugins/fai/admin/fai/class_filterOPSIPackages.inc index 19de355b5..2a52389f1 100644 --- a/gosa-plugins/fai/admin/fai/class_filterOPSIPackages.inc +++ b/gosa-plugins/fai/admin/fai/class_filterOPSIPackages.inc @@ -8,6 +8,7 @@ class filterOPSIPackages extends filterLDAP{ $ui = get_userinfo(); $ldap = $config->get_ldap_link(); $ldap->cd($config->current['BASE']); + $entries = array(); // Append opsi stuff ... if(class_available('opsi') && $base == get_ou("faiBaseRDN").$config->current['BASE']){ @@ -40,19 +41,34 @@ class filterOPSIPackages extends filterLDAP{ } } } - $cn_filter = ""; - if(preg_match("/^.*cn=([^)]*).*/",$filter)){ - $cn_filter = trim(preg_replace("/^.*cn=([^)]*).*/","\\1",$filter),"*"); + + // Parse filter string + list($type,$filter) = preg_split("/;/",$filter); + $types = preg_split("/,/", $type); + + // Remove automatically added '*' from filter + $filter= trim(preg_replace("/\*/",'', $filter)); + if(empty($filter)){ + $filter = ".*"; + }else{ + $filter = preg_quote($filter,'/'); } + + // Build up ldap like object list. foreach($objects as $name => $data) { $data = array_pop($data); - if(!empty($cn_filter) && !preg_match("/".preg_quote($cn_filter,'/')."/", $data['cn'])){ + + // Display only requested object types + if(!in_array($data['type'], $types)) continue; + + // Filter out those entries that doesn't match the filter. + if(!preg_match("/".$filter."/i", $data['cn'])){ continue; } - $item =array(); + $item =array(); $item['objectClass'] = array('count' => 2, $data['type'],"FAKE_OC_OPSI"); $item[] = 'objectClass'; $item['cn'] = $data['cn']; @@ -65,7 +81,6 @@ class filterOPSIPackages extends filterLDAP{ $item[] = 'TYPES'; $item['count'] = '5'; $entries[] = $item; - } } return($entries); diff --git a/gosa-plugins/fai/admin/fai/fai-filter.xml b/gosa-plugins/fai/admin/fai/fai-filter.xml index 006a3d778..50f934be4 100644 --- a/gosa-plugins/fai/admin/fai/fai-filter.xml +++ b/gosa-plugins/fai/admin/fai/fai-filter.xml @@ -17,23 +17,11 @@ FAI - (& - (| - (objectClass=FAIprofile) - (objectClass=FAIhook) - (objectClass=FAItemplate) - (objectClass=FAIscript) - (objectClass=FAIvariable) - (objectClass=FAIpackageList) - (objectClass=FAIpartitionTable) - ) - (cn=$) - ) - + (&(|(objectClass=FAIprofile)(objectClass=FAIhook)(objectClass=FAItemplate)(objectClass=FAIscript)(objectClass=FAIvariable)(objectClass=FAIpackageList)(objectClass=FAIpartitionTable))(cn=$)) OPSIPackages - cn=$ + opsi_netboot,opsi_local;$ cn