Code

Removed do nothing blocks
[gosa.git] / gosa-core / include / class_userFilterEditor.inc
index 68c26fe642c7463ea2bcf6a6a43f77cf39c11caf..6c86f4b519853ff238789b0d69d87d8c9eca2460 100644 (file)
@@ -21,7 +21,8 @@ class userFilterEditor extends plugin
   // The list of all categories mangaged by the current filter object.
   // Used in the grop-down box.
   public $orig_name = "";
-  
+
+  public $backends = array('LDAP', 'SYSTEMS', 'FAI', 'GroupLDAP','ACL');  
 
 
   /*! \brief    Instantiate the filter editing dialog. 
@@ -33,10 +34,10 @@ class userFilterEditor extends plugin
     if($entry){
       $this->entry = $entry;
       $this->parent = $entry['parent'];
-      $this->name = $entry['name'];
+      $this->name = $entry['tag'];
       $this->description = $entry['description'];
       
-      foreach($entry['queries'] as $query){
+      foreach($entry['query'] as $query){
         $query['filter'] = userFilterEditor::_autoIndentFilter($query['filter'], "  ");
         $this->queries[] = $query;
       }
@@ -131,7 +132,8 @@ class userFilterEditor extends plugin
 
     $smarty->assign("fixedFilters", array_keys($filter->searches));
     $smarty->assign('parent', $this->parent);
-    $smarty->assign('name', htmlentities($this->name,ENT_COMPAT,'UTF-8'));
+    $smarty->assign('backends', $this->backends);
+    $smarty->assign('tag', htmlentities($this->name,ENT_COMPAT,'UTF-8'));
     $smarty->assign('queries', $queries);
     $smarty->assign('share', $this->share);
     $smarty->assign('enable', $this->enabled);
@@ -149,7 +151,7 @@ class userFilterEditor extends plugin
     if(isset($_POST['userFilterEditor'])){
 
       // Get posted strings
-      foreach(array('name','description', 'parent') as $attr){
+      foreach(array('tag','description', 'parent') as $attr){
         if(isset($_POST[$attr])){
           $this->$attr = get_post($attr);
         }
@@ -186,6 +188,7 @@ class userFilterEditor extends plugin
         }elseif(isset($_POST['availableCategory']) && !empty($_POST['availableCategory'])){
           $this->selectedCategories[] = get_post('availableCategory');
         }
+        $this->selectedCategories = array_unique($this->selectedCategories);
       }
 
       // Remove categories
@@ -199,12 +202,18 @@ class userFilterEditor extends plugin
       if(isset($_POST['addQuery'])){
 
         $filter= $this->listing->getFilter();
-        $backend = 'filterLDAP';
+        $backend = 'LDAP';
         $query = "(objectClass=*)";
         if(isset($filter->searches[$this->parent])){
-          $query = $filter->searches[$this->parent]['query']['filter'];
-          $backend = $filter->searches[$this->parent]['query']['backend'];
-          print_a($filter->searches[$this->parent]);
+      
+          $tmp = $filter->searches[$this->parent];  
+          if(isset($tmp['query'][count($this->queries)])){
+            $query = $tmp['query'][count($this->queries)]['filter'];
+            $backend = $tmp['query'][count($this->queries)]['backend'];
+          }elseif(isset($tmp['query']['filter'])){
+            $query = $tmp['query']['filter'];
+            $backend = $tmp['query']['backend'];
+          }
         }
 
         $this->queries[] = array('backend'=> $backend, 'filter' => userFilterEditor::_autoIndentFilter($query,"  "));
@@ -256,10 +265,10 @@ class userFilterEditor extends plugin
   {
     $ret= array();
     $ret['parent'] = $this->parent;
-    $ret['name'] = $this->name;
+    $ret['tag'] = $this->name;
     $ret['description'] = $this->description;
     $ret['categories'] = $this->selectedCategories;
-    $ret['queries'] = $this->queries;
+    $ret['query'] = $this->queries;
     $ret['flags'] = array();
     if($this->share){
       $ret['flags'][] = "share";