summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dbdbf64)
raw | patch | inline | side by side (parent: dbdbf64)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 10 Mar 2010 09:58:16 +0000 (09:58 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 10 Mar 2010 09:58:16 +0000 (09:58 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16369 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_userFilter.inc | patch | blob | history |
index 91ae157ebf49301b3acb8f5f493aa2988764abd1..b193210ecdeb6c407503f835a410849098a393ee 100644 (file)
// Load list of filters
if(isset($this->attrs['gosaUserDefinedFilter'])){
for($i=0; $i< $this->attrs['gosaUserDefinedFilter']['count']; $i++){
- list($categories, $name, $description, $filter, $flags) = split(";", $this->attrs['gosaUserDefinedFilter'][$i]);
-
- // Ensure that we no empty category in our category list.
- if(empty($categories)){
- $categories = array();
- }else{
- $categories = split(',', $categories);
- }
-
- // Ensure that we no empty entry in out flags list.
- if(empty($flags)){
- $flags = array();
- }else{
- $flags = split(',', $flags);
+ $tmp = userFilter::explodeFilterString($this->attrs['gosaUserDefinedFilter'][$i]);
+ if(isset($tmp['name'])){
+ $this->filters[$tmp['name']]= $tmp;
}
-
- // build up filter entry.
- $tmp = array(
- 'name' => $name,
- 'categories' => $categories,
- 'description' => base64_decode($description),
- 'filter' => base64_decode($filter),
- 'flags' => $flags);
-
-
- $this->filters[$name] = $tmp;
}
}
$this->filterWidget->setListData($this->filters, $this->convertFilterList());
}
+
+ /*! \brief Parses a filter string into an array.
+ */
+ static function explodeFilterString($filter)
+ {
+ list($categories, $name, $description, $filter, $flags) = split(";", $filter);
+
+ // Ensure that we no empty category in our category list.
+ if(empty($categories)){
+ $categories = array();
+ }else{
+ $categories = split(',', $categories);
+ }
+
+ // Ensure that we no empty entry in out flags list.
+ if(empty($flags)){
+ $flags = array();
+ }else{
+ $flags = split(',', $flags);
+ }
+
+ // build up filter entry.
+ $tmp = array(
+ 'name' => $name,
+ 'categories' => $categories,
+ 'description' => base64_decode($description),
+ 'filter' => base64_decode($filter),
+ 'flags' => $flags);
+
+ return($tmp);
+ }
+
/*! \brief Converts the list of filters ($this->filters) into data which is useable
* for the sortableList object ($this->filterWidget).
}
+ /*! \brief Returns user defined filter for a given list of categories,
+ * if no categories were specified all enabled filters will be returned.
+ */
+ static function getFilter($category=array())
+ {
+ global $config;
+ $ldap=$config->get_ldap_link();
+ $ui = get_userinfo();
+ $ldap->cd($config->current['BASE']);
+ $ldap->search("(&(objectClass=gosaProperties)(gosaUserDefinedFilter=*))",array('gosaUserDefinedFilter'));
+ $filter = array();
+ while($attrs = $ldap->fetch()){
+ for($i=0; $i < $attrs['gosaUserDefinedFilter']['count']; $i++){
+ $tmp = userFilter::explodeFilterString($attrs['gosaUserDefinedFilter'][$i]);
+ if(!isset($tmp['name'])) continue;
+
+ // The filter is visible if it is shared or if is one of our own creations.
+ // ... and enabled.
+ $visible = in_array('enable', $tmp['flags']) &&
+ ($attrs['dn'] == $ui->dn || in_array('share', $tmp['flags']));
+
+ // Add filter if it matches the category list
+ if($visible && (count($category) == 0 || array_intersect($category, $tmp['categories']))){
+ $filter[$tmp['name']] = $tmp;
+ }
+ }
+ }
+ return($filter);
+ }
+
+
/*! \brief Write user-filter modifications back to the ldap.
*/
function save()