Code

Updated user filter
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 12 Mar 2010 13:30:49 +0000 (13:30 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 12 Mar 2010 13:30:49 +0000 (13:30 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16488 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_userFilter.inc
gosa-core/include/class_userFilterEditor.inc

index a96e1b877347184d76cb14eb71f2d1cb4cc16fb0..f713e4860bb517565245444406ee8f7ed5b792ee 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 
index ea8bc2ead3a6d4d25d6b3e71929417c5e143fbee..f118b56183157d953f5bbb0aba43251594292874 100644 (file)
@@ -16,20 +16,20 @@ class userFilterEditor extends plugin
   public $enabled = TRUE;
   public $queries = array();
 
+  public $listing = NULL;
+
   // The list of all categories mangaged by the current filter object.
   // Used in the grop-down box.
-  public $availableCategories = array();
-  public $fixedFilters = array();
   public $orig_name = "";
+  
 
 
   /*! \brief    Instantiate the filter editing dialog. 
    *            Parses the filter info into editable data.
    */
-  function __construct($entry, $categories, $fixedFilters)
+  function __construct($entry, $listing)
   {
-    $this->availableCategories = $categories;
-    $this->fixedFilters = $fixedFilters;
+    $this->listing = &$listing;
     if($entry){
       $this->entry = $entry;
       $this->parent = $entry['parent'];
@@ -117,6 +117,8 @@ class userFilterEditor extends plugin
   {
     plugin::execute();
 
+    $smarty = get_smarty();
+
     // Build up HTML compliant html output
     $queries = array();
     foreach($this->queries as $key => $query){
@@ -124,7 +126,10 @@ class userFilterEditor extends plugin
       $queries[$key] = $query; 
     }  
 
-    $smarty = get_smarty();
+    // Build up list of hard coded filters 
+    $filter= $this->listing->getFilter();
+
+    $smarty->assign("fixedFilters", array_keys($filter->searches));
     $smarty->assign('parent', $this->parent);
     $smarty->assign('name', htmlentities($this->name,ENT_COMPAT,'UTF-8'));
     $smarty->assign('queries', $queries);
@@ -132,8 +137,7 @@ class userFilterEditor extends plugin
     $smarty->assign('enable', $this->enabled);
     $smarty->assign('description', htmlentities($this->description,ENT_COMPAT,'UTF-8'));
     $smarty->assign('selectedCategories', $this->selectedCategories);
-    $smarty->assign('availableCategories', $this->availableCategories);
-    $smarty->assign('fixedFilters', $this->fixedFilters);
+    $smarty->assign('availableCategories', array_unique($this->listing->categories));
     return($smarty->fetch(get_template_path('userFilterEditor.tpl', FALSE)));
   }
 
@@ -193,7 +197,16 @@ class userFilterEditor extends plugin
 
       // Add new query 
       if(isset($_POST['addQuery'])){
-        $this->queries[] = array('backend'=>'filterLDAP', 'filter' => '(objectClass=*)');
+
+        $filter= $this->listing->getFilter();
+        $backend = 'filterLDAP';
+        $query = "(objectClass=*)";
+        if(isset($filter->searches[$this->parent])){
+          $query = $filter->searches[$this->parent]['query']['filter'];
+          $backend = $filter->searches[$this->parent]['query']['backend'];
+        }
+
+        $this->queries[] = array('backend'=> $backend, 'filter' => userFilterEditor::_autoIndentFilter($query,"  "));
       }
     }
   }