From: hickert Date: Tue, 7 Sep 2010 07:09:27 +0000 (+0000) Subject: Allow to modify filters X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=def12423b7d712ccaaba0f81be3a597f03ae0fad;p=gosa.git Allow to modify filters git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19537 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/groupware/personal/groupware/class_filterEditor.inc b/gosa-plugins/groupware/personal/groupware/class_filterEditor.inc index a34d92d4e..54f91d56d 100644 --- a/gosa-plugins/groupware/personal/groupware/class_filterEditor.inc +++ b/gosa-plugins/groupware/personal/groupware/class_filterEditor.inc @@ -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']); diff --git a/gosa-plugins/groupware/personal/groupware/class_filterManager.inc b/gosa-plugins/groupware/personal/groupware/class_filterManager.inc index e3502e367..c1a64dc82 100644 --- a/gosa-plugins/groupware/personal/groupware/class_filterManager.inc +++ b/gosa-plugins/groupware/personal/groupware/class_filterManager.inc @@ -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; + } } } } diff --git a/gosa-plugins/groupware/personal/groupware/filterEditor.tpl b/gosa-plugins/groupware/personal/groupware/filterEditor.tpl index 5afc16047..0f1b1c457 100644 --- a/gosa-plugins/groupware/personal/groupware/filterEditor.tpl +++ b/gosa-plugins/groupware/personal/groupware/filterEditor.tpl @@ -2,12 +2,12 @@ - - + + - - + +
::
@@ -18,3 +18,4 @@ +