Code

Updated baseSelectDialog
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Jan 2010 10:53:34 +0000 (10:53 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Jan 2010 10:53:34 +0000 (10:53 +0000)
-Filter out invalid target bases

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

gosa-core/include/class_baseSelectDialog.inc

index a4fbf387aa53b9e7785b0982081bdf41c28f235d..017b7da76ee97eb5c664b0eb44af616333e87a25 100644 (file)
@@ -40,6 +40,7 @@ class baseSelectDialog extends management
     $this->config = $config;
     $this->ui = get_userinfo();
     $this->allowedBases = $onlyAllowThisBases;
+    session::set('filterBaseSelect_WhiteList', &$this->allowedBases);
 
 #    // Build filter
 #    if (session::global_is_set(get_class($this)."_filter")){
@@ -133,5 +134,24 @@ class baseSelectDialog extends management
     return($action);
   } 
 }
+
+class filterBaseSelect extends filterLDAP
+{
+  static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
+  {
+    $res= filterLDAP::query($base, $scope, $filter, $attributes, $category, $objectStorage);
+    return(filterBaseSelect::filterEntries($res));
+  }
+
+  static function filterEntries($res)
+  {
+    if(!session::is_set('filterBaseSelect_WhiteList')) return $res;
+    $list = session::get('filterBaseSelect_WhiteList');
+    foreach($res as $key => $entry){
+      if(!isset($list[$entry['dn']])) unset($res[$key]);
+    }
+    return(array_values($res));
+  }
+}
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>