summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7e7abc9)
raw | patch | inline | side by side (parent: 7e7abc9)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 12 Mar 2010 14:17:33 +0000 (14:17 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 12 Mar 2010 14:17:33 +0000 (14:17 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16491 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_filter.inc | patch | blob | history | |
gosa-core/include/class_userFilter.inc | patch | blob | history |
index 8733435bf49eefdd70cb6a54b5aaac2fd1e42e2c..558c58943c4d0ade7b53bd0f26f367cff6a78443 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'])) {
}
/* 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= 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";
}
- // 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 (isset($_POST['act'])){
+ foreach ($this->searches 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 (userFilter::getFilter($categories) as $tag => $config) {
+
+ foreach ($this->searches as $tag => $config) {
+ if($config['fixed']) continue;
+
if ($tag == $this->search) {
- $result.= "<li".($first?$separator:"")."><a href='#'>".image("images/checked.png")." "._($config['description'])."</a></li>";
+ $result.= "<li".($first?$separator:"")."><a href='#'>".image("images/checked.png")." "._($config['label'])."</a></li>";
} else {
- $result.= "<li".($first?$separator:"")."><a href='#' onClick='document.getElementById(\"filter\").value= \"filter-$tag\";mainform.submit();'>".image("images/empty.png")." "._($config['description'])."</a></li>";
+ $result.= "<li".($first?$separator:"")."><a href='#' onClick='document.getElementById(\"filter\").value= \"filter-$tag\";mainform.submit();'>".image("images/empty.png")." "._($config['label'])."</a></li>";
}
$first= false;
index 2bcf9ffd4912122f3d6c0008b8c06e357f84b96f..c7da3badbe3eb6ad75544067c77ad6da94b52c6d 100644 (file)
static function getFilter($category=array())
{
global $config;
+
$ldap=$config->get_ldap_link();
$ui = get_userinfo();
$ldap->cd($config->current['BASE']);
// Remove line breaks from the filter, which may were added for better reading.
foreach($tmp['queries'] as $key => $query){
$c = preg_split('/\n/',$query['filter']);
- foreach($c as $key => $str) $c[$key] = trim($str);
- $tmp['queries'][$key]['filter'] = implode($c);
+ foreach($c as $cKey => $str) $c[$cKey] = trim($str);
+ $tmp['queries'][$key]['filter'] = mb_convert_encoding(implode($c),'UTF-8');
}
// The filter is visible if it is shared or if is one of our own creations.
$visible = in_array('enable', $tmp['flags']) &&
($attrs['dn'] == $ui->dn || in_array('share', $tmp['flags']));
- // Convert filter encoding
- $tmp['filter'] = mb_convert_encoding($tmp['filter'], 'UTF-8');
-
// Add filter if it matches the category list
if($visible && (count($category) == 0 || array_intersect($category, $tmp['categories']))){
$filter[$tmp['name']] = $tmp;