diff --git a/gosa-core/include/class_userFilterEditor.inc b/gosa-core/include/class_userFilterEditor.inc
index ea8bc2ead3a6d4d25d6b3e71929417c5e143fbee..f51e3499b3923c758cd710abfbed760e11e540aa 100644 (file)
public $enabled = TRUE;
public $queries = array();
+ public $listing = NULL;
+
// The list of all categories mangaged by the current filter object.
// Used in the grop-down box.
- public $availableCategories = array();
- public $fixedFilters = array();
public $orig_name = "";
+
/*! \brief Instantiate the filter editing dialog.
* Parses the filter info into editable data.
*/
- function __construct($entry, $categories, $fixedFilters)
+ function __construct($entry, $listing)
{
- $this->availableCategories = $categories;
- $this->fixedFilters = $fixedFilters;
+ $this->listing = &$listing;
if($entry){
$this->entry = $entry;
$this->parent = $entry['parent'];
{
plugin::execute();
+ $smarty = get_smarty();
+
// Build up HTML compliant html output
$queries = array();
foreach($this->queries as $key => $query){
$queries[$key] = $query;
}
- $smarty = get_smarty();
+ // Build up list of hard coded filters
+ $filter= $this->listing->getFilter();
+
+ $smarty->assign("fixedFilters", array_keys($filter->searches));
$smarty->assign('parent', $this->parent);
$smarty->assign('name', htmlentities($this->name,ENT_COMPAT,'UTF-8'));
$smarty->assign('queries', $queries);
$smarty->assign('enable', $this->enabled);
$smarty->assign('description', htmlentities($this->description,ENT_COMPAT,'UTF-8'));
$smarty->assign('selectedCategories', $this->selectedCategories);
- $smarty->assign('availableCategories', $this->availableCategories);
- $smarty->assign('fixedFilters', $this->fixedFilters);
+ $smarty->assign('availableCategories', array_unique($this->listing->categories));
return($smarty->fetch(get_template_path('userFilterEditor.tpl', FALSE)));
}
// Add new query
if(isset($_POST['addQuery'])){
- $this->queries[] = array('backend'=>'filterLDAP', 'filter' => '(objectClass=*)');
+
+ $filter= $this->listing->getFilter();
+ $backend = 'LDAP';
+ $query = "(objectClass=*)";
+ if(isset($filter->searches[$this->parent])){
+
+ $tmp = $filter->searches[$this->parent];
+ if(isset($tmp['query'][count($this->queries)])){
+ $query = $tmp['query'][count($this->queries)]['filter'];
+ $backend = $tmp['query'][count($this->queries)]['backend'];
+ }elseif(isset($tmp['query']['filter'])){
+ $query = $tmp['query']['filter'];
+ $backend = $tmp['query']['backend'];
+ }
+ }
+
+ $this->queries[] = array('backend'=> $backend, 'filter' => userFilterEditor::_autoIndentFilter($query," "));
}
}
}