summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4da0824)
raw | patch | inline | side by side (parent: 4da0824)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 12 Mar 2010 13:20:10 +0000 (13:20 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 12 Mar 2010 13:20:10 +0000 (13:20 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16487 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-core/ihtml/themes/modern/userFilterEditor.tpl b/gosa-core/ihtml/themes/modern/userFilterEditor.tpl
index f0a1ae8ce1c1c9327a27fe80a12a20496f34a024..99dd4f20309a0259724b9f26d1e3c72ef6ffa4fc 100644 (file)
<hr>
-<b>Filter</b>
-<textarea name='filter' id='filter' cols="0" style='width:100%; height: 250px;'>{$filter}</textarea>
-
+{foreach from=$queries item=item key=key}
+ <b>{t}Query{/t} #{$key}</b><input type='text' name='backend_{$key}' value='{$item.backend}'>
+ <button type='submit' name='removeQuery_{$key}'>{msgPool type='delButton'}</button>
+ <textarea name='filter_{$key}' id='filter_{$key}' cols="0"
+ style='width:100%; height: 120px;'>{$item.filter}</textarea>
+ <hr>
+{/foreach}
+ <button type='submit' name='addQuery'>{msgPool type='addButton'}</button>
<hr>
<input type='hidden' value='1' name='userFilterEditor'>
index 4d3fbd61e32d237e932da82309a844ef7198707b..a96e1b877347184d76cb14eb71f2d1cb4cc16fb0 100644 (file)
{
public $pathTitle= "Filter";
- protected $filters = array();
+ public $filters = array();
protected $availableCategories = array();
public $objectclasses = array('gosaProperties');
/*! \brief Parses a filter string into an array.
*/
- static function explodeFilterString($filter)
+ static function explodeFilterString($filterStr)
{
- list($parent,$categories, $name, $description, $filter, $flags) = split(";", $filter);
+ list($parent,$categories, $name, $description, $filterList, $flags) = split(";", $filterStr);
// Ensure that we no empty category in our category list.
if(empty($categories)){
if(empty($flags)){
$flags = array();
}else{
- $flags = split(',', $flags);
+ $flags = preg_split('/,/', $flags);
+ }
+
+ // Get filters and their backends
+ $queries = array();
+ foreach(split(",", $filterList) as $data){
+ list($filter, $backend) = preg_split('/:/', $data);
+ $queries[] = array('backend' => $backend, 'filter' => base64_decode($filter));
}
// build up filter entry.
'name' => $name,
'categories' => $categories,
'description' => base64_decode($description),
- 'filter' => base64_decode($filter),
+ 'queries' => $queries,
'flags' => $flags);
return($tmp);
function execute()
{
plugin::execute();
-
+
// Let the filter widget update itself
$this->filterWidget->update();
$tmp.= implode(',', $filter['categories']).";";
$tmp.= $filter['name'].";";
$tmp.= base64_encode($filter['description']).";";
- $tmp.= base64_encode($filter['filter']).";";
+
+ // Add queries
+ foreach($filter['queries'] as $query){
+ $tmp.= base64_encode($query['filter']).":".$query['backend'].",";
+ }
+ $tmp = trim($tmp,",").";";
$tmp.= implode(',', $filter['flags']);
$attrs[] = $tmp;
}
diff --git a/gosa-core/include/class_userFilterEditor.inc b/gosa-core/include/class_userFilterEditor.inc
index 31ea019a7724bdf6ef1e4b166b04e0d9d673ebf0..ea8bc2ead3a6d4d25d6b3e71929417c5e143fbee 100644 (file)
public $selectedCategories = array();
public $share = FALSE;
public $enabled = TRUE;
- public $filter = "(objectClass=*)";
+ public $queries = array();
// The list of all categories mangaged by the current filter object.
// Used in the grop-down box.
$this->parent = $entry['parent'];
$this->name = $entry['name'];
$this->description = $entry['description'];
- $this->filter = userFilterEditor::_autoIndentFilter($entry['filter'], " ");
+
+ foreach($entry['queries'] as $query){
+ $query['filter'] = userFilterEditor::_autoIndentFilter($query['filter'], " ");
+ $this->queries[] = $query;
+ }
$this->selectedCategories = $entry['categories'];
$this->share = in_array("share",$entry['flags']);
$this->enable = in_array("enable",$entry['flags']);
function execute()
{
plugin::execute();
+
+ // Build up HTML compliant html output
+ $queries = array();
+ foreach($this->queries as $key => $query){
+ $query['filter'] = htmlentities($query['filter'],ENT_COMPAT,'UTF-8');
+ $queries[$key] = $query;
+ }
+
$smarty = get_smarty();
$smarty->assign('parent', $this->parent);
$smarty->assign('name', htmlentities($this->name,ENT_COMPAT,'UTF-8'));
- $smarty->assign('filter', htmlentities($this->filter,ENT_COMPAT,'UTF-8'));
+ $smarty->assign('queries', $queries);
$smarty->assign('share', $this->share);
$smarty->assign('enable', $this->enabled);
$smarty->assign('description', htmlentities($this->description,ENT_COMPAT,'UTF-8'));
// Filter needs special handling, it may contain charactes like < and >
// wich are stipped out by get_post() && validate()
- if(isset($_POST['filter'])){
- $f = mb_convert_encoding($_POST['filter'], 'UTF-8');
- if(get_magic_quotes_gpc()){
- $f = stripcslashes($f);
+ foreach($this->queries as $key => $query){
+ if(isset($_POST['filter_'.$key])){
+ $f = mb_convert_encoding($_POST['filter_'.$key], 'UTF-8');
+ if(get_magic_quotes_gpc()){
+ $f = stripcslashes($f);
+ }
+ $this->queries[$key]['filter'] = $f;
+ $this->queries[$key]['backend'] = get_post('backend_'.$key);
}
- $this->filter = $f;
+ }
+
+ foreach($this->queries as $key => $query){
+ if(isset($_POST['removeQuery_'.$key])){
+ unset($this->queries[$key]);
+ $this->queries = array_values($this->queries);
+ }
}
// Get posted flags
if(isset($this->selectedCategories[$cat])) unset($this->selectedCategories[$cat]);
}
}
+
+ // Add new query
+ if(isset($_POST['addQuery'])){
+ $this->queries[] = array('backend'=>'filterLDAP', 'filter' => '(objectClass=*)');
+ }
}
}
}
// Count the number of opening and closing brackets - exclude escaped ones.
- $f = preg_replace('/\\\\[\(\)]/',"",$this->filter);
- $o = substr_count($f, '(');
- $c = substr_count($f, ')');
- if($o != $c){
- $msgs[] = sprintf(_("Please check your filter. You have '%s' opening and '%s' closing brackets!"), $o, $c);
+ foreach($this->queries as $key => $query){
+ $f = preg_replace('/\\\\[\(\)]/',"",$query['filter']);
+ $o = substr_count($f, '(');
+ $c = substr_count($f, ')');
+ if($o != $c){
+ $msgs[] = sprintf(_("Please check your filter #%s. You have '%s' opening and '%s' closing brackets!"), ($key+1),$o, $c);
+ }
}
return($msgs);
$ret['name'] = $this->name;
$ret['description'] = $this->description;
$ret['categories'] = $this->selectedCategories;
- $ret['filter'] = $this->filter;
+ $ret['queries'] = $this->queries;
$ret['flags'] = array();
if($this->share){
$ret['flags'][] = "share";