Code

Fixed multi query editor
[gosa.git] / gosa-core / include / class_userFilter.inc
index a96e1b877347184d76cb14eb71f2d1cb4cc16fb0..c7da3badbe3eb6ad75544067c77ad6da94b52c6d 100644 (file)
@@ -5,14 +5,11 @@ class userFilter extends plugin
   public $pathTitle= "Filter";
 
   public $filters = array();
-  protected $availableCategories = array();
   
   public $objectclasses = array('gosaProperties');
   public $attributes = array('gosaUserDefinedFilter');
   public $gosaUserDefinedFilter = array();
-
   private $listing = NULL;
-  private $fixedFilter = NULL;
 
   /*! \brief    Returns true if we are able to read and write userFilters 
    *            (schema has to be present, gosaProperties)
@@ -38,10 +35,6 @@ class userFilter extends plugin
     plugin::plugin($config, $ui->dn);
     $this->listing = &$listing;
     $filter= $this->listing->getFilter();
-    $this->fixedFilter = $filter->getFixedFilters();
-
-    // Keep list of currently managed categories.
-    $this->availableCategories = array_unique($this->listing->categories);
 
     // Load list of filters
     if(isset($this->attrs['gosaUserDefinedFilter'])){
@@ -176,13 +169,13 @@ class userFilter extends plugin
     if($action['action'] == 'edit' && count($action['targets']) == 1){
       $key= $this->filterWidget->getKey($action['targets'][0]);
       if(isset($this->filters[$key])){
-        $this->dialog=new userFilterEditor($this->filters[$key], $this->availableCategories, $this->fixedFilter);
+        $this->dialog=new userFilterEditor($this->filters[$key], $this->listing);
       }
     }
 
     // Act on new requests
     if(isset($_POST['addFilter'])){
-      $this->dialog=new userFilterEditor(array(), $this->availableCategories, $this->fixedFilter);
+      $this->dialog=new userFilterEditor(array(), $this->listing);
     }
 
     // Act on remove requests 
@@ -213,6 +206,7 @@ class userFilter extends plugin
   static function getFilter($category=array())
   {
     global $config;
+
     $ldap=$config->get_ldap_link();
     $ui = get_userinfo();
     $ldap->cd($config->current['BASE']);
@@ -224,19 +218,17 @@ class userFilter extends plugin
         if(!isset($tmp['name'])) continue;
           
         // Remove line breaks from the filter, which may were added for better reading. 
-        $c = preg_split('/\n/',$tmp['filter']);
-
-        foreach($c as $key => $str) $c[$key] = trim($str);
-        $tmp['filter'] = implode($c);
+        foreach($tmp['queries'] as $key => $query){
+          $c = preg_split('/\n/',$query['filter']);
+          foreach($c as $cKey => $str) $c[$cKey] = trim($str);
+          $tmp['queries'][$key]['filter'] = mb_convert_encoding(implode($c),'UTF-8');
+        }
  
         // The filter is visible if it is shared or if is one of our own creations.
         //  ... and enabled.
         $visible = in_array('enable', $tmp['flags']) && 
           ($attrs['dn'] == $ui->dn || in_array('share', $tmp['flags']));
          
-        // Convert filter encoding
-        $tmp['filter'] = mb_convert_encoding($tmp['filter'], 'UTF-8');
         // Add filter if it matches the category list
         if($visible && (count($category) == 0 || array_intersect($category, $tmp['categories']))){ 
           $filter[$tmp['name']] = $tmp;