".$this->renderFilterMenu()." | ";
- $content.= "".
+ $content= "".$this->renderFilterMenu()." | ";
+ $content.= " ".$this->getTextfield('search_filter', $this->value, $this->searches[$this->search])." ".
" | ";
// Return meta data
@@ -237,10 +242,9 @@ class filter {
$this->initial= true;
return $result;
}
-
// Go thru all queries and merge results
foreach ($this->query as $query) {
- if (!isset($query['backend']) || !isset($query['filter']) || !isset($query['attribute'])) {
+ if (!isset($query['backend']) || !isset($query['filter'])) {
die("No backend specified in search config.");
}
@@ -252,12 +256,15 @@ class filter {
// Load filter and attributes
$filter= $query['filter'];
- $attributes= $query['attribute'];
// Handle converters if present
if ($this->converter) {
preg_match('/([^:]+)::(.*)$/', $this->converter, $m);
- $filter= call_user_func(array($m[1], $m[2]), preg_replace('/\$/', $this->value, $filter));
+ if ($this->value == "") {
+ $filter= call_user_func(array($m[1], $m[2]), preg_replace('/\$/', "*", $filter));
+ } else {
+ $filter= call_user_func(array($m[1], $m[2]), preg_replace('/\$/', $this->value, $filter));
+ }
}
// Do not replace escaped \$ - This is required to be able to search for e.g. windows machines.
@@ -267,7 +274,7 @@ class filter {
$filter= preg_replace("/\\$/", "*".normalizeLdap($this->value)."*", $filter);
}
- $result= array_merge($result, call_user_func(array($backend, 'query'), $this->base, $this->scope, $filter, $attributes, $this->category, $this->objectStorage));
+ $result= array_merge($result, call_user_func(array($backend, 'query'), $this->base, $this->scope, $filter, $this->attributes, $this->category, $this->objectStorage));
}
return ($result);
@@ -277,15 +284,24 @@ class filter {
function update()
{
if (isset($_POST['FILTER_PID']) && $_POST['FILTER_PID'] == $this->pid) {
-
// Save input field
if (isset($_POST['search_filter'])) {
$this->value= validate($_POST['search_filter']);
}
// Save scope if needed
- if ($this->scopeMode == "auto") {
- $this->scope= isset($_POST['SCOPE'])?"sub":"one";
+ if ($this->scopeMode == "auto" && isset($_POST['act']) && $_POST['act'] == "toggle-subtree") {
+ $this->scope= ($this->scope == "one")?"sub":"one";
+ }
+
+ // Switch filter?
+ if (isset($_POST['act'])) {
+ foreach ($this->searches as $tag => $cfg) {
+ if ($_POST['act'] == "filter-$tag") {
+ $this->setSearch($tag);
+ break;
+ }
+ }
}
}
@@ -297,27 +313,30 @@ class filter {
global $class_mapping;
$res= array();
- // Is backend available?
- $backend= "filter".$config['backend'];
- if (!isset($class_mapping["$backend"])) {
- die("Invalid backend specified in search config.");
- }
-
- // Load filter and attributes
- $filter= $config['filter'];
- $attributes= $config['attribute'];
+ // Load result attributes
+ $attributes= $config['autocomplete']['attribute'];
if (!is_array($attributes)) {
$attributes= array($attributes);
}
- // Make filter
- $filter= preg_replace("/\\$/", normalizeLdap($value), $filter);
- if (isset($config['base']) && isset($config['scope']) && isset($config['category'])) {
- $result= call_user_func(array($backend, 'query'), $config['base'], $config['scope'], $filter, $attributes,
- $config["category"], $config["objectStorage"]);
- } else {
- $result= call_user_func(array($backend, 'query'), $this->base, $this->scope, $filter, $attributes,
- $this->category, $this->objectStorage);
+ // Do the query
+ $result= array();
+
+ // Is backend available?
+ # FIXME
+ $queries= $config['query'];
+ if (!isset($queries[0])){
+ $queries= array($queries);
+ }
+ foreach ($queries as $query) {
+ $backend= "filter".$query['backend'];
+ if (!isset($class_mapping["$backend"])) {
+ die("Invalid backend specified in search config.");
+ }
+ $filter= preg_replace("/\\$/", "*".normalizeLdap($value)."*", $query['filter']);
+
+ $result= array_merge($result, call_user_func(array($backend, 'query'), $this->base, $this->scope, $filter, $attributes,
+ $this->category, $this->objectStorage));
}
foreach ($result as $entry) {
@@ -347,7 +366,7 @@ class filter {
$max= 25;
if(isset($this->searches[$this->search]['autocomplete'])){
- $result= $this->getCompletitionList($this->searches[$this->search]['autocomplete'], $_POST['search_filter']);
+ $result= $this->getCompletitionList($this->searches[$this->search], $_POST['search_filter']);
$result= array_unique($result);
asort($result);
@@ -392,23 +411,54 @@ class filter {
function renderFilterMenu()
{
// Load shortcut
- $result= "".
- " |