summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0263ebf)
raw | patch | inline | side by side (parent: 0263ebf)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 12 Mar 2010 15:39:23 +0000 (15:39 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 12 Mar 2010 15:39:23 +0000 (15:39 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16498 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_filter.inc | patch | blob | history |
index f28f400c209e2b2f78dae8ea5ed98a05143eaff8..cce1bae49185f90c5eb22d4c6bb1b6231db6f8d4 100644 (file)
$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'])) {
$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) {
}
/* Store search */
- $search['fixed'] = TRUE;
$this->searches[$search['tag']]= $search;
- }
-
- $this->reloadUserFilter();
+ }
} else {
return false;
}
$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!");
function render()
{
-
- $this->reloadUserFilter();
-
$content= "<table class='filter-wrapper'><tr><td>".$this->renderFilterMenu()."</td><td>";
$content.= "<div class='search-filter'>".$this->getTextfield('search_filter', $this->value, $this->searches[$this->search])."</div>".
" <button class='search-filter' type='submit' title='"._("Search")."'>".image("images/find.png")."</button></td></tr></table>";
$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;
// Build in filters
foreach ($this->searches as $tag => $config) {
-
- if(!$config['fixed']) continue;
-
if ($tag == $this->search) {
$result.= "<li><a href='#'>".image("images/checked.png")." "._($config['label'])."</a></li>";
} else {
} 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.= "<li".($first?$separator:"")."><a href='#'>".image("images/checked.png")." "._($config['label'])."</a></li>";
+ $result.= "<li".($first?$separator:"")."><a href='#'>".image("images/checked.png")." "._($config['description'])."</a></li>";
} else {
- $result.= "<li".($first?$separator:"")."><a href='#' onClick='document.getElementById(\"filter\").value= \"filter-$tag\";mainform.submit();'>".image("images/empty.png")." "._($config['label'])."</a></li>";
+ $result.= "<li".($first?$separator:"")."><a href='#' onClick='document.getElementById(\"filter\").value= \"filter-$tag\";mainform.submit();'>".image("images/empty.png")." "._($config['description'])."</a></li>";
}
$first= false;