From 5824ef08a7444e1637c184a1644959f5e5dd233c Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 6 Sep 2010 14:16:06 +0000 Subject: [PATCH] Updated filter Edtor git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19533 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../personal/groupware/class_filterEditor.inc | 69 ++++++++++++------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/gosa-plugins/groupware/personal/groupware/class_filterEditor.inc b/gosa-plugins/groupware/personal/groupware/class_filterEditor.inc index 832f3e9a5..5522daa50 100644 --- a/gosa-plugins/groupware/personal/groupware/class_filterEditor.inc +++ b/gosa-plugins/groupware/personal/groupware/class_filterEditor.inc @@ -7,23 +7,9 @@ class filterEditor extends plugin $this->config = &$config; $this->parent = &$parent; $this->filter = $filter; - } - - function execute() - { - $smarty = get_smarty(); - $smarty->assign('NAME',set_post($this->filter['NAME'])); - $smarty->assign('DESC',set_post($this->filter['DESC'])); - $smarty->assign('filterStr', $this->renderFilter()); - - return($smarty->fetch(get_template_path('filterEditor.tpl',TRUE,dirname(__FILE__)))); - } - - function renderFilter() - { - $filter = $this->filter; - $actions = array( + $this->types = array('OR' => _("or"), 'AND' => _("and")); + $this->actions = array( "MOVE" => _("move mail to"), "COPY" => _("copy mail to"), "FORWARD" => _("forward message to"), @@ -31,7 +17,7 @@ class filterEditor extends plugin "DROP" => _("remove mail"), "REPLY" => _("reply")); - $fields = array( + $this->fields = array( 'subject' => _("Subject"), 'from'=> _("From"), 'body'=> _("Body"), @@ -43,7 +29,7 @@ class filterEditor extends plugin 'age'=> _("Age"), 'size'=> _("Size")); - $comparators = array( + $this->comparators = array( "is" => _("is"), "is not" => _("is not"), "equal" => _("is equal"), @@ -56,8 +42,21 @@ class filterEditor extends plugin "is not in addressbook" => _("is not in the addressbook"), "greater than" => _("is greater than"), "less than" => _("smaller than")); + } - + function execute() + { + $smarty = get_smarty(); + $smarty->assign('NAME',set_post($this->filter['NAME'])); + $smarty->assign('DESC',set_post($this->filter['DESC'])); + $smarty->assign('filterStr', $this->renderFilter()); + + return($smarty->fetch(get_template_path('filterEditor.tpl',TRUE,dirname(__FILE__)))); + } + + function renderFilter() + { + $filter = $this->filter; $cnt = count($filter['CONDITIONS']); $str = "

"._("Filter conditions")."

"; @@ -66,14 +65,14 @@ class filterEditor extends plugin $str .= "
  • "; $str .= _("Check field")." "; $str .= "\n"; $str .= " "._("if it")." "; $str .= "\n"; - foreach($actions as $act => $desc){ + foreach($this->actions as $act => $desc){ $checked = ($act == $action['ACTION'])? ' selected ' : ''; $str.= "\n"; } @@ -106,6 +109,10 @@ class filterEditor extends plugin } $str.= ""; + $str .= " "; + if(count($filter['ACTION']) >= 2){ + $str .= " "; + } return($str); } @@ -132,6 +139,22 @@ class filterEditor extends plugin $this->filter['ACTION'][$id]['VALUE'] = get_post('cValue_'.$id); } } + + if(isset($_POST['removeCondition']) && count($this->filter['CONDITIONS']) >= 2){ + array_pop($this->filter['CONDITIONS']); + } + + if(isset($_POST['addCondition'])){ + $this->filter['CONDITIONS'][] = array('FIELD' => key($this->fields),'COMPARATOR' => key($this->comparators), 'MATCH' => ''); + } + + if(isset($_POST['removeAction']) && count($this->filter['ACTION']) >= 2){ + array_pop($this->filter['ACTION']); + } + + if(isset($_POST['addAction'])){ + $this->filter['ACTION'][] = array('ACTION' => 'MOVE', 'VALUE' => ''); + } } } ?> -- 2.30.2