From: cajus Date: Fri, 12 Mar 2010 15:39:23 +0000 (+0000) Subject: Reverted filter X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=68bd96121508977bdc21064df3cfeaf17a92fe14;p=gosa.git Reverted filter git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16498 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_filter.inc b/gosa-core/include/class_filter.inc index f28f400c2..cce1bae49 100644 --- a/gosa-core/include/class_filter.inc +++ b/gosa-core/include/class_filter.inc @@ -61,11 +61,6 @@ class filter { $this->xmlData= $this->xmlData["filterdef"]; - // Transfer category - if (isset($this->xmlData['definition']['category'])){ - $this->category= $this->xmlData['definition']['category']; - } - // Load filter if (isset($this->xmlData['search'])) { @@ -76,11 +71,6 @@ class filter { $searches= $this->xmlData['search']; } - // Fix problem with only one defined query. - if(isset($this->xmlData['search']['query'])){ - $this->xmlData['search'] = array($this->xmlData['search']); - } - /* Store available searches */ foreach ($this->xmlData['search'] as $search) { @@ -90,12 +80,9 @@ class filter { } /* Store search */ - $search['fixed'] = TRUE; $this->searches[$search['tag']]= $search; - } - - $this->reloadUserFilter(); + } } else { return false; } @@ -113,51 +100,48 @@ class filter { $this->initial= true; } + // Transfer category + if (isset($this->xmlData['definition']['category'])){ + $this->category= $this->xmlData['definition']['category']; + } + // Set default search mode $this->setSearch($this->xmlData['definition']['default']); return true; } - function reloadUserFilter() - { - // First remove all user filters - foreach($this->searches as $k => $s) { - if(!$s['fixed']) unset($this->searches[$k]); - } - - // Readd user filter. - foreach(userFilter::getFilter(array($this->category)) as $filter){ - $tmp = array(); - $tmp['tag'] = $filter['name']; - $tmp['label'] = $filter['description']; - $tmp['query'] = array(); - foreach($filter['queries'] as $query){ - if(isset($this->searches[$filter['parent']]['query']['attribute'])){ - $query['attribute'] = $this->searches[$filter['parent']]['query']['attribute']; - }else{ - $query['attribute'] = $this->searches[$filter['parent']]['query'][0]['attribute']; - } - $tmp['query'][] = $query; - } - $tmp['autocomplete'] = $this->searches[$filter['parent']]['autocomplete']; - $tmp['fixed'] = FALSE; - $this->searches[$tmp['tag']] = $tmp; - } - } - function setSearch($method) { $patch= null; + if (is_array($this->category)) { + $categories= $this->category; + } else { + $categories= array($this->category); + } + $userfilters= userFilter::getFilter($categories); + + // User filter selected? + if (isset($userfilters[$method])){ + $usermethod= $method; + $patch= $userfilters[$method]['filter']; + $method= $userfilters[$method]['parent']; + } // Move information if (isset($this->searches[$method])) { - $this->query= $this->searches[$method]['query']; + $this->query= array_merge($this->searches[$method]['query']); if (!isset($this->query[0])) { $this->query= array($this->query); } + // Patch first filter? + if ($patch) { + $this->query[0]['filter']= $patch; + $method= $usermethod; + } + $this->search= $method; } else { die ("Invalid search module!"); @@ -237,9 +221,6 @@ class filter { function render() { - - $this->reloadUserFilter(); - $content= "
".$this->renderFilterMenu().""; $content.= "
".$this->getTextfield('search_filter', $this->value, $this->searches[$this->search])."
". " 
"; @@ -310,8 +291,15 @@ class filter { $this->scope= ($this->scope == "one")?"sub":"one"; } - if (isset($_POST['act'])){ - foreach ($this->searches as $tag => $cfg) { + // Switch filter? + if (is_array($this->category)) { + $categories= $this->category; + } else { + $categories= array($this->category); + } + + if (isset($_POST['act'])) { + foreach (array_merge($this->searches, userFilter::getFilter($categories)) as $tag => $cfg) { if ($_POST['act'] == "filter-$tag") { $this->setSearch($tag); break; @@ -434,9 +422,6 @@ class filter { // Build in filters foreach ($this->searches as $tag => $config) { - - if(!$config['fixed']) continue; - if ($tag == $this->search) { $result.= "
  • ".image("images/checked.png")." "._($config['label'])."
  • "; } else { @@ -451,14 +436,11 @@ class filter { } else { $categories= array($this->category); } - - foreach ($this->searches as $tag => $config) { - if($config['fixed']) continue; - + foreach (userFilter::getFilter($categories) as $tag => $config) { if ($tag == $this->search) { - $result.= "".image("images/checked.png")." "._($config['label']).""; + $result.= "".image("images/checked.png")." "._($config['description']).""; } else { - $result.= "".image("images/empty.png")." "._($config['label']).""; + $result.= "".image("images/empty.png")." "._($config['description']).""; } $first= false;