From 2db47c00050246de3db73601c737bff0efcae579 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 12 Mar 2010 13:30:49 +0000 Subject: [PATCH] Updated user filter git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16488 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_userFilter.inc | 11 ++----- gosa-core/include/class_userFilterEditor.inc | 31 ++++++++++++++------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/gosa-core/include/class_userFilter.inc b/gosa-core/include/class_userFilter.inc index a96e1b877..f713e4860 100644 --- a/gosa-core/include/class_userFilter.inc +++ b/gosa-core/include/class_userFilter.inc @@ -5,14 +5,11 @@ class userFilter extends plugin public $pathTitle= "Filter"; public $filters = array(); - protected $availableCategories = array(); public $objectclasses = array('gosaProperties'); public $attributes = array('gosaUserDefinedFilter'); public $gosaUserDefinedFilter = array(); - private $listing = NULL; - private $fixedFilter = NULL; /*! \brief Returns true if we are able to read and write userFilters * (schema has to be present, gosaProperties) @@ -38,10 +35,6 @@ class userFilter extends plugin plugin::plugin($config, $ui->dn); $this->listing = &$listing; $filter= $this->listing->getFilter(); - $this->fixedFilter = $filter->getFixedFilters(); - - // Keep list of currently managed categories. - $this->availableCategories = array_unique($this->listing->categories); // Load list of filters if(isset($this->attrs['gosaUserDefinedFilter'])){ @@ -176,13 +169,13 @@ class userFilter extends plugin if($action['action'] == 'edit' && count($action['targets']) == 1){ $key= $this->filterWidget->getKey($action['targets'][0]); if(isset($this->filters[$key])){ - $this->dialog=new userFilterEditor($this->filters[$key], $this->availableCategories, $this->fixedFilter); + $this->dialog=new userFilterEditor($this->filters[$key], $this->listing); } } // Act on new requests if(isset($_POST['addFilter'])){ - $this->dialog=new userFilterEditor(array(), $this->availableCategories, $this->fixedFilter); + $this->dialog=new userFilterEditor(array(), $this->listing); } // Act on remove requests diff --git a/gosa-core/include/class_userFilterEditor.inc b/gosa-core/include/class_userFilterEditor.inc index ea8bc2ead..f118b5618 100644 --- a/gosa-core/include/class_userFilterEditor.inc +++ b/gosa-core/include/class_userFilterEditor.inc @@ -16,20 +16,20 @@ class userFilterEditor extends plugin 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']; @@ -117,6 +117,8 @@ class userFilterEditor extends plugin { plugin::execute(); + $smarty = get_smarty(); + // Build up HTML compliant html output $queries = array(); foreach($this->queries as $key => $query){ @@ -124,7 +126,10 @@ class userFilterEditor extends plugin $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); @@ -132,8 +137,7 @@ class userFilterEditor extends plugin $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))); } @@ -193,7 +197,16 @@ class userFilterEditor extends plugin // Add new query if(isset($_POST['addQuery'])){ - $this->queries[] = array('backend'=>'filterLDAP', 'filter' => '(objectClass=*)'); + + $filter= $this->listing->getFilter(); + $backend = 'filterLDAP'; + $query = "(objectClass=*)"; + if(isset($filter->searches[$this->parent])){ + $query = $filter->searches[$this->parent]['query']['filter']; + $backend = $filter->searches[$this->parent]['query']['backend']; + } + + $this->queries[] = array('backend'=> $backend, 'filter' => userFilterEditor::_autoIndentFilter($query," ")); } } } -- 2.30.2