From: cajus Date: Mon, 10 Aug 2009 09:05:47 +0000 (+0000) Subject: Updated filters X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ec2b2c99f539fd4d77ba41316b441fd12a70cc61;p=gosa.git Updated filters git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14022 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/contrib/filters/user-filter.xml b/gosa-core/contrib/filters/user-filter.xml deleted file mode 100644 index 6c12d70f3..000000000 --- a/gosa-core/contrib/filters/user-filter.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - users - - - - - - LDAP - (&(!(objectClass=gosaUserTemplate))(|$GENERIC$POSIX$MAIL$SAMBA)(|(cn=$NAME)(sn=$NAME)(givenName=$NAME)(uid=$NAME))) - dn - objectClass - cn - mail - uid - modifyTimestamp - - - LDAP - (&$TEMPLATE(|(cn=$NAME)(sn=$NAME)(givenName=$NAME)(uid=$NAME))) - dn - objectClass - cn - mail - uid - modifyTimestamp - - false - auto - - - - textfield - NAME - - true - * - this is a not valid and failing filter - $ - - LDAP - (&(objectClass=gosaAccount)(|(cn=*$NAME*)(sn=*$NAME*)(givenName=*$NAME*)(uid=*$NAME*))) - cn - 0.5 - 3 - - - - - checkbox - TEMPLATE - - (&(!(objectClass=gosaUserTemplate)(!(objectClass=gosaAccount)))) - (objectClass=gosaUserTemplate) - - - - checkbox - GENERIC - true - - (&(objectClass=gosaAccount)(!(|(objectClass=posixAccount)(objectClass=gosaMailAccount)(objectClass=sambaSamAccount)(objectClass=gosaProxyAccount)))) - - - - checkbox - POSIX - true - - (objectClass=posixAccount) - - - - checkbox - MAIL - true - - (objectClass=gosaMailAccount) - - - - checkbox - SAMBA - true - - (objectClass=sambaSamAccount) - - - - combobox - ROLLE - - - * - - * - All - Alle - - - LDAP - (objectClass=organizationalRole) - cn - cn - - - - - diff --git a/gosa-core/ihtml/themes/default/filter/users.tpl b/gosa-core/ihtml/themes/default/filter/users.tpl deleted file mode 100644 index 7ef964afd..000000000 --- a/gosa-core/ihtml/themes/default/filter/users.tpl +++ /dev/null @@ -1,40 +0,0 @@ -
-

- [F]Filter -

-
- -
-
- {$ALPHABET} -
- {$TEMPLATE} {t}Show templates{/t}
- {$GENERIC} {t}Show functional users{/t}
- {$MAIL} {t}Show mail users{/t}
- {$POSIX} {t}Show POSIX users{/t}
- {$SAMBA} {t}Show samba users{/t}
-
- {$SCOPE} - - - - - - -
- - - {$NAME} -
- - - - - -
- {$APPLY} -
- -
diff --git a/gosa-core/include/class_filter.inc b/gosa-core/include/class_filter.inc index a82994293..dd3c9b335 100644 --- a/gosa-core/include/class_filter.inc +++ b/gosa-core/include/class_filter.inc @@ -14,6 +14,7 @@ class filter { var $bases= array(); var $scope= ""; var $query; + var $initial= false; var $baseMode= false; var $scopeMode= "auto"; var $alphabet= null; @@ -53,6 +54,11 @@ class filter { return false; } + // Transfer initial value + if (isset($this->xmlData['definition']['initial']) && $this->xmlData['definition']['initial'] == "true"){ + $this->initial= true; + } + // Generate formular data if (isset($this->xmlData['element'])) { if (!isset($this->xmlData['element'][0])){ @@ -133,13 +139,55 @@ class filter { function getCombobox($element) { $result= ""; return $result; @@ -296,7 +344,7 @@ class filter { } // Load template - return ("".$smarty->fetch(get_template_path("filter/".$this->xmlData['definition']['template']))); + return ("".$smarty->fetch(get_template_path($this->xmlData['definition']['template'], true))); } @@ -401,6 +449,51 @@ class filter { } + function getCompletitionList($config, $tag, $value="*") + { + global $class_mapping; + $res= array(); + + // Is backend available? + $backend= "filter".$config['backend']; + if (!isset($class_mapping["$backend"])) { + die("Invalid backend specified in search config."); + } + + // Load filter and attributes + $filter= $config['filter']; + $attributes= $config['attribute']; + if (!is_array($attributes)) { + $attributes= array($attributes); + } + + // Make filter + $filter= preg_replace("/\\$$tag/", normalizeLDAP($value), $filter); + if (isset($config['base']) && isset($config['scope']) + && isset($config['category']) && isset($config['objectbase']) ) { + $result= call_user_func(array($backend, 'query'), $config['base'], $config['scope'], $filter, $attributes, + $config["category"], $config["objectbase"]); + } else { + $result= call_user_func(array($backend, 'query'), $this->base, $this->scope, $filter, $attributes, + $this->category, $this->objectStorage, $this->objectBase); + } + + foreach ($result as $entry) { + foreach ($attributes as $attribute) { + if (is_array($entry[$attribute])) { + for ($i= 0; $i<$entry[$attribute]['count']; $i++) { + $res[]= $entry[$attribute][$i]; + } + } else { + $res[]= $entry[$attribute]; + } + } + } + + return $res; + } + + function processAutocomplete() { global $class_mapping; @@ -408,36 +501,11 @@ class filter { foreach ($this->autocompleters as $tag => $config) { if(isset($_POST[$tag])){ - - // Is backend available? - $backend= "filter".$config['backend']; - if (!isset($class_mapping["$backend"])) { - die("Invalid backend specified in search config."); - } - - // Load filter and attributes - $filter= $config['filter']; - $attributes= $config['attribute']; - if (!is_array($attributes)) { - $attributes= array($attributes); - } - - // Make filter - $filter= preg_replace("/\\$$tag/", normalizeLDAP($_POST[$tag]), $filter); - $result= call_user_func(array($backend, 'query'), $this->base, $this->scope, $filter, $attributes, - $this->category, $this->objectStorage, $this->objectBase); + $result= $this->getCompletitionList($config, $tag, $_POST[$tag]); echo ''; diff --git a/gosa-core/plugins/admin/users/class_userManagement.inc b/gosa-core/plugins/admin/users/class_userManagement.inc index 1d1a6e98c..9b4d57f82 100644 --- a/gosa-core/plugins/admin/users/class_userManagement.inc +++ b/gosa-core/plugins/admin/users/class_userManagement.inc @@ -979,11 +979,12 @@ class userManagement extends plugin $this->DivListUsers->setEntries($this->list); # FILTER Test ################################################# - #$filter = new filter(CONFIG_DIR."/filters/user-filter.xml"); + #$filter = new filter(get_template_path("user-filter.xml", true)); #$filter->setObjectStorage(get_people_ou()); #$filter->setCategory("users"); #$filter->setCurrentBase($this->DivListUsers->selectedBase); #$filter->update(); + #session::set('autocomplete', $filter); #if (!$filter->isValid()){ # msg_dialog::display(_("Filter error"), _("The filter is uncomplete!"), ERROR_DIALOG); #} else { diff --git a/gosa-core/plugins/admin/users/user-filter.tpl b/gosa-core/plugins/admin/users/user-filter.tpl new file mode 100644 index 000000000..7ef964afd --- /dev/null +++ b/gosa-core/plugins/admin/users/user-filter.tpl @@ -0,0 +1,40 @@ +
+

+ [F]Filter +

+
+ +
+
+ {$ALPHABET} +
+ {$TEMPLATE} {t}Show templates{/t}
+ {$GENERIC} {t}Show functional users{/t}
+ {$MAIL} {t}Show mail users{/t}
+ {$POSIX} {t}Show POSIX users{/t}
+ {$SAMBA} {t}Show samba users{/t}
+
+ {$SCOPE} + + + + + + +
+ + + {$NAME} +
+ + + + + +
+ {$APPLY} +
+ +
diff --git a/gosa-core/plugins/admin/users/user-filter.xml b/gosa-core/plugins/admin/users/user-filter.xml new file mode 100644 index 000000000..f20b928af --- /dev/null +++ b/gosa-core/plugins/admin/users/user-filter.xml @@ -0,0 +1,116 @@ + + + + + users + + true + + + + + LDAP + (&(!(objectClass=gosaUserTemplate))(|$GENERIC$POSIX$MAIL$SAMBA)(|(cn=$NAME)(sn=$NAME)(givenName=$NAME)(uid=$NAME))) + dn + objectClass + cn + mail + uid + modifyTimestamp + + + LDAP + (&$TEMPLATE(|(cn=$NAME)(sn=$NAME)(givenName=$NAME)(uid=$NAME))) + dn + objectClass + cn + mail + uid + modifyTimestamp + + false + auto + + + + textfield + NAME + + true + * + this is a not valid and failing filter + $ + + LDAP + (&(objectClass=gosaAccount)(|(cn=*$NAME*)(sn=*$NAME*)(givenName=*$NAME*)(uid=*$NAME*))) + cn + 0.5 + 3 + + + + + checkbox + TEMPLATE + + (&(!(objectClass=gosaUserTemplate)(!(objectClass=gosaAccount)))) + (objectClass=gosaUserTemplate) + + + + checkbox + GENERIC + true + + (&(objectClass=gosaAccount)(!(|(objectClass=posixAccount)(objectClass=gosaMailAccount)(objectClass=sambaSamAccount)(objectClass=gosaProxyAccount)))) + + + + checkbox + POSIX + true + + (objectClass=posixAccount) + + + + checkbox + MAIL + true + + (objectClass=gosaMailAccount) + + + + checkbox + SAMBA + true + + (objectClass=sambaSamAccount) + + + + combobox + ROLLE + + + * + + * + All + Alle + + + LDAP + dc=gonicus,dc=de + sub + roles + ou=roles + (objectClass=organizationalRole) + cn + cn + + + + +