Code

Allow to modify filters
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Sep 2010 07:09:27 +0000 (07:09 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Sep 2010 07:09:27 +0000 (07:09 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19537 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/groupware/personal/groupware/class_filterEditor.inc
gosa-plugins/groupware/personal/groupware/class_filterManager.inc
gosa-plugins/groupware/personal/groupware/filterEditor.tpl

index a34d92d4e29e511e9fa06fa50a1b1d56b1776572..54f91d56da5d38b5297c61287b3286310c86d005 100644 (file)
@@ -11,6 +11,7 @@ class filterEditor extends plugin
         $this->types = array(
                 'OR' => _("At least one of the following conditions has to match"), 
                 'AND' => _("All conditions have to match"));
+
         $this->actions = array(
                 "MOVE" => _("move mail to"),
                 "COPY" => _("copy mail to"),
@@ -56,6 +57,22 @@ class filterEditor extends plugin
         return($smarty->fetch(get_template_path('filterEditor.tpl',TRUE,dirname(__FILE__))));
     }
 
+
+
+    function check()
+    {
+        $msgs = array();
+        return($msgs);
+    }
+
+
+    function save()
+    {
+        // Just return the filter array we've modified
+        return($this->filter);
+    }
+
+
     function renderFilter()
     {
         $filter = $this->filter;
@@ -129,12 +146,15 @@ class filterEditor extends plugin
 
     function save_object()
     {
+        // Do nothing if the dialog wasn't submitted yet
+        if(!isset($_POST['filterEditorPosted'])) return;
 
+        // Get the filter confition type if posted
         $this->filter['TYPE'] = (isset($_POST['cType']))? get_post('cType'): $this->filter['TYPE'];
 
+        // Get condition modifications
         foreach($this->filter['CONDITIONS'] as $id => $value){
-            foreach(array(
-                        'cField_' => 'FIELD',
+            foreach(array('cField_' => 'FIELD',
                         'cComparator_'=>'COMPARATOR',
                         'cMatch_'=>'MATCH') as $post => $name){
                 if(isset($_POST[$post.$id])){
@@ -142,15 +162,20 @@ class filterEditor extends plugin
                 }
             }
         }
+
+        // Get Action modifications 
         foreach($this->filter['ACTION'] as $id => $value){
-            if(isset($_POST['cAction_'.$id])){
-                $this->filter['ACTION'][$id]['ACTION'] = get_post('cAction_'.$id);
-            }
-            if(isset($_POST['cValue_'.$id])){
-                $this->filter['ACTION'][$id]['VALUE'] = get_post('cValue_'.$id);
+            foreach(array('cAction_' => 'ACTIOB','cValue_' => 'VALUE') as $post => $name){
+                if(isset($_POST[$post.$id])){
+                    $this->filter['ACTION'][$id][$name] = get_post($post.$id);
+                }
             }
         }
 
+        // Get NAME and DESC if posted
+        if(isset($_POST['NAME'])) $this->filter['NAME'] = get_post('NAME');
+        if(isset($_POST['DESC'])) $this->filter['DESC'] = get_post('DESC');
+
         // Add / remove conditions
         if(isset($_POST['removeCondition']) && count($this->filter['CONDITIONS']) >= 2){
             array_pop($this->filter['CONDITIONS']);
index e3502e367a21d9fa8bd9d0131e913fb3cdadd909..c1a64dc82e5731d3d4a6cc68a30b4c4d29e88f17 100644 (file)
@@ -125,16 +125,25 @@ class filterManager extends plugin{
             }
         }
 
+
         // Close filter editor 
-        if(isset($_POST['filterEditor_cancel'])){
+        if(isset($_POST['filterEditor_cancel']) && $this->filterEditor instanceOf filterEditor){
             $this->currentFilter = NULL;
             $this->filterEditor = NULL;
         }
 
         // Save filter modifications and close the dialog
-        if(isset($_POST['filterEditor_ok'])){
-            $this->filterEditor = NULL;
-            $this->currentFilter = NULL;
+        if(isset($_POST['filterEditor_ok']) && $this->filterEditor instanceOf filterEditor){
+            $this->filterEditor->save_object();
+            $msgs = $this->filterEditor->check();
+            if(count($msgs)){
+                msg_dialog::displayChecks($msgs);
+            }else{
+                $filter = $this->filterEditor->save();
+                $this->filter[$this->currentFilter] = $filter;
+                $this->filterEditor = NULL;
+                $this->currentFilter = NULL;
+            }
         }
     }
 }
index 5afc160478a19b6d3d159e031f33f81aa45485aa..0f1b1c45723f4daa90fd08fe4eebc1a8be575e26 100644 (file)
@@ -2,12 +2,12 @@
 
 <table summary="{t}Generic settings{/t}">
     <tr>
-        <td><LABEL for='name'>{t}Name{/t}</LABEL>:</td>
-        <td><input style='width:300px;' type='text' id='name' name="DESC" value="{$NAME}"></td>
+        <td><LABEL for='NAME'>{t}Name{/t}</LABEL>:</td>
+        <td><input style='width:300px;' type='text' id='NAME' name="NAME" value="{$NAME}"></td>
     </tr>
     <tr>
-        <td><LABEL for='desc'>{t}Description{/t}:</LABEL></td>
-        <td><input style='width:300px;' type='text' id='desc' name="DESC" value="{$DESC}"></td>
+        <td><LABEL for='DESC'>{t}Description{/t}:</LABEL></td>
+        <td><input style='width:300px;' type='text' id='DESC' name="DESC" value="{$DESC}"></td>
     </tr>
 </table>
 
@@ -18,3 +18,4 @@
     <button name='filterEditor_ok'>{msgPool type='okButton'}</button>
     <button name='filterEditor_cancel'>{msgPool type='cancelButton'}</button>
 </div>
+<input type='hidden' value='1' name='filterEditorPosted'>