summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5e625bc)
raw | patch | inline | side by side (parent: 5e625bc)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 12 Mar 2010 17:23:22 +0000 (17:23 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 12 Mar 2010 17:23:22 +0000 (17:23 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16500 594d385d-05f5-0310-b6e9-bd551577e9d8
index 0c0056b1d7dc2688283541e05c76a4f47b605871..8f733d33907fc9ce62fc61a215bf94c77eafc88d 100644 (file)
--- a/gosa-core/html/setup.php
+++ b/gosa-core/html/setup.php
}
/* Get posted language */
-if(!session::global_is_set('language')){
- session::global_set('language',get_browser_language());
+if(!session::global_is_set('lang')){
+ session::global_set('lang',get_browser_language());
}
if(isset($_POST['lang_selected'])){
if($_POST['lang_selected'] != ""){
index cce1bae49185f90c5eb22d4c6bb1b6231db6f8d4..f4f1daad718af1893101c38c774baf2aadff0807 100644 (file)
class filter {
- var $xmlData;
var $searches= array();
+ var $xmlSearches= array();
+ var $attributes= array();
var $search;
+ var $defaultSearch;
var $category= "";
var $objectStorage= array();
var $base= "";
function load($filename)
{
$contents = file_get_contents($filename);
- $this->xmlData= xml::xml2array($contents, 1);
+ $xmlData= xml::xml2array($contents, 1);
- if (!isset($this->xmlData['filterdef'])) {
+ if (!isset($xmlData['filterdef'])) {
return false;
}
- $this->xmlData= $this->xmlData["filterdef"];
+ $xmlData= $xmlData["filterdef"];
// Load filter
- if (isset($this->xmlData['search'])) {
+ if (isset($xmlData['search'])) {
// Array conversion
- if (!is_array($this->xmlData['search'])) {
- $searches= array($this->xmlData['search']);
+ if (!is_array($xmlData['search'])) {
+ $searches= array($xmlData['search']);
} else {
- $searches= $this->xmlData['search'];
+ $searches= $xmlData['search'];
}
/* Store available searches */
- foreach ($this->xmlData['search'] as $search) {
+ foreach ($xmlData['search'] as $search) {
/* Do multi conversation */
- if (!is_array($search['query'])){
+ if (!isset($search['query'][0])){
$search['query']= array($search['query']);
}
/* Store search */
- $this->searches[$search['tag']]= $search;
+ $this->xmlSearches[$search['tag']]= $search;
}
} else {
}
// Transfer scope
- $this->scopeMode= $this->xmlData['definition']['scope'];
+ $this->scopeMode= $xmlData['definition']['scope'];
if ($this->scopeMode == "auto") {
$this->scope= "one";
} else {
$this->scope= $this->scopeMode;
}
+ // Transfer attributes
+ $this->attributes= $xmlData['definition']['attribute'];
+ if (!is_array($this->attributes)) {
+ $this->attributes= array($this->attributes);
+ }
+
// Transfer initial value
- if (isset($this->xmlData['definition']['initial']) && $this->xmlData['definition']['initial'] == "true"){
+ if (isset($xmlData['definition']['initial']) && $xmlData['definition']['initial'] == "true"){
$this->initial= true;
}
// Transfer category
- if (isset($this->xmlData['definition']['category'])){
- $this->category= $this->xmlData['definition']['category'];
+ if (isset($xmlData['definition']['category'])){
+ $this->category= $xmlData['definition']['category'];
+ }
+ if (!is_array($this->category)) {
+ $this->category= array($this->category);
}
- // Set default search mode
- $this->setSearch($this->xmlData['definition']['default']);
+ // Initialize searches and default search mode
+ $this->reloadFilters();
+ $this->defaultSearch= $xmlData['definition']['default'];
+ $this->setSearch($this->defaultSearch);
return true;
}
- function setSearch($method)
+ function reloadFilters()
+ {
+ $this->searches= array_merge($this->xmlSearches, userFilter::getFilter($this->category));
+ $this->setSearch($this->search);
+ }
+
+
+ function setSearch($method= null)
{
$patch= null;
- if (is_array($this->category)) {
- $categories= $this->category;
- } else {
- $categories= array($this->category);
- }
- $userfilters= userFilter::getFilter($categories);
- // User filter selected?
- if (isset($userfilters[$method])){
- $usermethod= $method;
- $patch= $userfilters[$method]['filter'];
- $method= $userfilters[$method]['parent'];
+ // Maybe our search method has gone?
+ if (!isset($this->searches[$method])) {
+ $method= $this->defaultSearch;
}
- // Move information
+ // Try to use it, but bail out if there's no help...
if (isset($this->searches[$method])) {
- $this->query= array_merge($this->searches[$method]['query']);
- if (!isset($this->query[0])) {
- $this->query= array($this->query);
- }
-
- // Patch first filter?
- if ($patch) {
- $this->query[0]['filter']= $patch;
- $method= $usermethod;
- }
-
+ $this->query= $this->searches[$method]['query'];
$this->search= $method;
} else {
die ("Invalid search module!");
$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.");
}
// Load filter and attributes
$filter= $query['filter'];
- $attributes= $query['attribute'];
// Handle converters if present
if ($this->converter) {
$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);
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']);
}
// Switch filter?
- if (is_array($this->category)) {
- $categories= $this->category;
- } else {
- $categories= array($this->category);
- }
-
if (isset($_POST['act'])) {
- foreach (array_merge($this->searches, userFilter::getFilter($categories)) as $tag => $cfg) {
+ foreach ($this->searches as $tag => $cfg) {
if ($_POST['act'] == "filter-$tag") {
$this->setSearch($tag);
break;
$result= array();
// Is backend available?
+ # FIXME
$queries= $config['query'];
if (!isset($queries[0])){
$queries= array($queries);
$result.= "<ul class='level2'>";
// Build in filters
- foreach ($this->searches as $tag => $config) {
+ foreach ($this->xmlSearches as $tag => $config) {
if ($tag == $this->search) {
$result.= "<li><a href='#'>".image("images/checked.png")." "._($config['label'])."</a></li>";
} else {
// User defined filters
$first= true;
- if (is_array($this->category)) {
- $categories= $this->category;
- } else {
- $categories= array($this->category);
- }
- foreach (userFilter::getFilter($categories) as $tag => $config) {
+ foreach (userFilter::getFilter($this->category) as $tag => $config) {
if ($tag == $this->search) {
$result.= "<li".($first?$separator:"")."><a href='#'>".image("images/checked.png")." "._($config['description'])."</a></li>";
} else {
index c8a385764debb8cd96a303884be872887a1cdd01..fb56f994b191e77d5af1386ab7d9605c46725ec2 100644 (file)
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dns,"Entry saved!");
$this->remove_lock();
$this->closeDialogs();
+
+ // Ask filter to reload information
+ $this->filter->reloadFilters();
}
}
}
index 331c6a921ab516f3b42221efe17281acba8cf135..e0e09c7bc31ea7f911fb5445433c89d93d8abfdb 100644 (file)
if(isset($this->attrs['gosaUserDefinedFilter'])){
for($i=0; $i< $this->attrs['gosaUserDefinedFilter']['count']; $i++){
$tmp = userFilter::explodeFilterString($this->attrs['gosaUserDefinedFilter'][$i]);
- if(isset($tmp['name'])){
- $this->filters[$tmp['name']]= $tmp;
+ if(isset($tmp['tag'])){
+ $this->filters[$tmp['tag']]= $tmp;
}
}
}
// build up filter entry.
$tmp = array(
'parent' => $parent,
- 'name' => $name,
+ 'tag' => $name,
'categories' => $categories,
'description' => base64_decode($description),
- 'queries' => $queries,
+ 'query' => $queries,
'flags' => $flags);
return($tmp);
$data[$name] = array('data' =>
array(
$filter['parent'],
- $filter['name'],
+ $filter['tag'],
$filter['description'],
implode(", ",$filter['categories']),
implode(", ",$filter['flags'])));
while($attrs = $ldap->fetch()){
for($i=0; $i < $attrs['gosaUserDefinedFilter']['count']; $i++){
$tmp = userFilter::explodeFilterString($attrs['gosaUserDefinedFilter'][$i]);
- if(!isset($tmp['name'])) continue;
+ if(!isset($tmp['tag'])) continue;
// Remove line breaks from the filter, which may were added for better reading.
- foreach($tmp['queries'] as $key => $query){
+ foreach($tmp['query'] as $key => $query){
$c = preg_split('/\n/',$query['filter']);
foreach($c as $cKey => $str) $c[$cKey] = trim($str);
- $tmp['queries'][$key]['filter'] = mb_convert_encoding(implode($c),'UTF-8');
+ $tmp['query'][$key]['filter'] = mb_convert_encoding(implode($c),'UTF-8');
}
// The filter is visible if it is shared or if is one of our own creations.
// Add filter if it matches the category list
if($visible && (count($category) == 0 || array_intersect($category, $tmp['categories']))){
- $filter[$tmp['name']] = $tmp;
+ $filter[$tmp['tag']] = $tmp;
}
}
}
foreach($this->filters as $filter){
$tmp = $filter['parent'].";";
$tmp.= implode(',', $filter['categories']).";";
- $tmp.= $filter['name'].";";
+ $tmp.= $filter['tag'].";";
$tmp.= base64_encode($filter['description']).";";
// Add queries
- foreach($filter['queries'] as $query){
+ foreach($filter['query'] as $query){
$tmp.= base64_encode($query['filter']).":".$query['backend'].",";
}
$tmp = trim($tmp,",").";";
diff --git a/gosa-core/include/class_userFilterEditor.inc b/gosa-core/include/class_userFilterEditor.inc
index 3cdbc6f2c69843eccb4ee054ee49564ede316376..6c86f4b519853ff238789b0d69d87d8c9eca2460 100644 (file)
if($entry){
$this->entry = $entry;
$this->parent = $entry['parent'];
- $this->name = $entry['name'];
+ $this->name = $entry['tag'];
$this->description = $entry['description'];
- foreach($entry['queries'] as $query){
+ foreach($entry['query'] as $query){
$query['filter'] = userFilterEditor::_autoIndentFilter($query['filter'], " ");
$this->queries[] = $query;
}
$smarty->assign("fixedFilters", array_keys($filter->searches));
$smarty->assign('parent', $this->parent);
$smarty->assign('backends', $this->backends);
- $smarty->assign('name', htmlentities($this->name,ENT_COMPAT,'UTF-8'));
+ $smarty->assign('tag', htmlentities($this->name,ENT_COMPAT,'UTF-8'));
$smarty->assign('queries', $queries);
$smarty->assign('share', $this->share);
$smarty->assign('enable', $this->enabled);
if(isset($_POST['userFilterEditor'])){
// Get posted strings
- foreach(array('name','description', 'parent') as $attr){
+ foreach(array('tag','description', 'parent') as $attr){
if(isset($_POST[$attr])){
$this->$attr = get_post($attr);
}
{
$ret= array();
$ret['parent'] = $this->parent;
- $ret['name'] = $this->name;
+ $ret['tag'] = $this->name;
$ret['description'] = $this->description;
$ret['categories'] = $this->selectedCategories;
- $ret['queries'] = $this->queries;
+ $ret['query'] = $this->queries;
$ret['flags'] = array();
if($this->share){
$ret['flags'][] = "share";
diff --git a/gosa-core/plugins/admin/users/user-filter.xml b/gosa-core/plugins/admin/users/user-filter.xml
index a0af47afd6fe38754b85aa223ab774273c1dc574..1f96a57ec340f23728ef84e3aed3862ceb7ed102 100644 (file)
<initial>true</initial>
<default>default</default>
<scope>auto</scope>
+ <attribute>dn</attribute>
+ <attribute>objectClass</attribute>
+ <attribute>givenName</attribute>
+ <attribute>sn</attribute>
+ <attribute>uid</attribute>
+ <attribute>userPassword</attribute>
</definition>
<search>
<query>
<backend>LDAP</backend>
<filter>(&(objectClass=gosaAccount)(|(cn=$)(sn=$)(uid=$)))</filter>
- <attribute>dn</attribute>
- <attribute>objectClass</attribute>
- <attribute>givenName</attribute>
- <attribute>sn</attribute>
- <attribute>uid</attribute>
- <attribute>userPassword</attribute>
</query>
<autocomplete>
<attribute>cn</attribute>
<query>
<backend>LDAP</backend>
<filter>(&(objectClass=gosaUserTemplate)((cn=$)(sn=$)(uid=$)))</filter>
- <attribute>dn</attribute>
- <attribute>objectClass</attribute>
- <attribute>givenName</attribute>
- <attribute>sn</attribute>
- <attribute>uid</attribute>
- <attribute>userPassword</attribute>
</query>
<autocomplete>
<attribute>mail</attribute>
<query>
<backend>LDAP</backend>
<filter>(&(objectClass=gosaAccount)(objectClass=posixAccount)(|(cn=$)(sn=$)(uid=$)))</filter>
- <attribute>dn</attribute>
- <attribute>objectClass</attribute>
- <attribute>givenName</attribute>
- <attribute>sn</attribute>
- <attribute>uid</attribute>
- <attribute>userPassword</attribute>
</query>
<autocomplete>
<attribute>cn</attribute>
<query>
<backend>LDAP</backend>
<filter>(&(objectClass=gosaAccount)(objectClass=sambaSamAccount)(|(cn=$)(sn=$)(uid=$)))</filter>
- <attribute>dn</attribute>
- <attribute>objectClass</attribute>
- <attribute>givenName</attribute>
- <attribute>sn</attribute>
- <attribute>uid</attribute>
- <attribute>userPassword</attribute>
</query>
<autocomplete>
<attribute>cn</attribute>
<query>
<backend>LDAP</backend>
<filter>(&(objectClass=gosaAccount)(objectClass=gosaMailAccount)(|(cn=$)(sn=$)(uid=$)(mail=$)))</filter>
- <attribute>dn</attribute>
- <attribute>objectClass</attribute>
- <attribute>givenName</attribute>
- <attribute>sn</attribute>
- <attribute>uid</attribute>
- <attribute>userPassword</attribute>
</query>
<autocomplete>
<attribute>mail</attribute>