summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 200ee84)
raw | patch | inline | side by side (parent: 200ee84)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 10 Aug 2009 09:05:47 +0000 (09:05 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 10 Aug 2009 09:05:47 +0000 (09:05 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14022 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/contrib/filters/user-filter.xml | [deleted file] | patch | blob | history |
gosa-core/ihtml/themes/default/filter/users.tpl | [deleted file] | patch | blob | history |
gosa-core/include/class_filter.inc | patch | blob | history | |
gosa-core/plugins/admin/users/class_userManagement.inc | patch | blob | history | |
gosa-core/plugins/admin/users/user-filter.tpl | [new file with mode: 0644] | patch | blob |
gosa-core/plugins/admin/users/user-filter.xml | [new file with mode: 0644] | patch | blob |
diff --git a/gosa-core/contrib/filters/user-filter.xml b/gosa-core/contrib/filters/user-filter.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<filter>
- <definition>
- <target>users</target>
- <template>users.tpl</template>
- </definition>
-
- <search>
- <query>
- <backend>LDAP</backend>
- <filter>(&(!(objectClass=gosaUserTemplate))(|$GENERIC$POSIX$MAIL$SAMBA)(|(cn=$NAME)(sn=$NAME)(givenName=$NAME)(uid=$NAME)))</filter>
- <attribute>dn</attribute>
- <attribute>objectClass</attribute>
- <attribute>cn</attribute>
- <attribute>mail</attribute>
- <attribute>uid</attribute>
- <attribute>modifyTimestamp</attribute>
- </query>
- <query>
- <backend>LDAP</backend>
- <filter>(&$TEMPLATE(|(cn=$NAME)(sn=$NAME)(givenName=$NAME)(uid=$NAME)))</filter>
- <attribute>dn</attribute>
- <attribute>objectClass</attribute>
- <attribute>cn</attribute>
- <attribute>mail</attribute>
- <attribute>uid</attribute>
- <attribute>modifyTimestamp</attribute>
- </query>
- <base>false</base>
- <scope>auto</scope>
- </search>
-
- <element>
- <type>textfield</type>
- <tag>NAME</tag>
- <!--<regex>^...</regex>-->
- <alphabet>true</alphabet>
- <default>*</default>
- <unset>this is a not valid and failing filter</unset>
- <set>$</set>
- <autocomplete>
- <backend>LDAP</backend>
- <filter>(&(objectClass=gosaAccount)(|(cn=*$NAME*)(sn=*$NAME*)(givenName=*$NAME*)(uid=*$NAME*)))</filter>
- <attribute>cn</attribute>
- <frequency>0.5</frequency>
- <characters>3</characters>
- </autocomplete>
- </element>
-
- <element>
- <type>checkbox</type>
- <tag>TEMPLATE</tag>
- <default></default>
- <unset>(&(!(objectClass=gosaUserTemplate)(!(objectClass=gosaAccount))))</unset>
- <set>(objectClass=gosaUserTemplate)</set>
- </element>
-
- <element>
- <type>checkbox</type>
- <tag>GENERIC</tag>
- <default>true</default>
- <unset></unset>
- <set>(&(objectClass=gosaAccount)(!(|(objectClass=posixAccount)(objectClass=gosaMailAccount)(objectClass=sambaSamAccount)(objectClass=gosaProxyAccount))))</set>
- </element>
-
- <element>
- <type>checkbox</type>
- <tag>POSIX</tag>
- <default>true</default>
- <unset></unset>
- <set>(objectClass=posixAccount)</set>
- </element>
-
- <element>
- <type>checkbox</type>
- <tag>MAIL</tag>
- <default>true</default>
- <unset></unset>
- <set>(objectClass=gosaMailAccount)</set>
- </element>
-
- <element>
- <type>checkbox</type>
- <tag>SAMBA</tag>
- <default>true</default>
- <unset></unset>
- <set>(objectClass=sambaSamAccount)</set>
- </element>
-
- <element>
- <type>combobox</type>
- <tag>ROLLE</tag>
- <unset></unset>
- <set></set>
- <default>*</default>
- <value>
- <key>*</key>
- <set>All</set>
- <set xml:lang="de">Alle</set>
- </value>
- <autocomplete>
- <backend>LDAP</backend>
- <filter>(objectClass=organizationalRole)</filter>
- <attribute>cn</attribute>
- <key>cn</key>
- </autocomplete>
- </element>
-
-</filter>
-
diff --git a/gosa-core/ihtml/themes/default/filter/users.tpl b/gosa-core/ihtml/themes/default/filter/users.tpl
+++ /dev/null
@@ -1,40 +0,0 @@
-<div class="contentboxh">
- <p class="contentboxh">
- <img src="images/launch.png" align="right" alt="[F]">Filter
- </p>
-</div>
-
-<div class="contentboxb">
- <div style="border-top:1px solid #AAAAAA"></div>
- {$ALPHABET}
- <div style="border-top:1px solid #AAAAAA"></div>
- {$TEMPLATE} {t}Show templates{/t}<br>
- {$GENERIC} {t}Show functional users{/t}<br>
- {$MAIL} {t}Show mail users{/t}<br>
- {$POSIX} {t}Show POSIX users{/t}<br>
- {$SAMBA} {t}Show samba users{/t}<br>
- <div style="border-top:1px solid #AAAAAA"></div>
- {$SCOPE}
-
- <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
- <tr>
- <td>
- <label for="Regex">
- <img alt="Zeige die Benutzer, auf die Folgendes passt" src="images/lists/search.png" align=middle>
- </label>
- </td>
- <td width="99%">
- {$NAME}
- </td>
- </tr>
- </table>
-
- <table summary="" width="100%" style="background:#EEEEEE;border-top:1px solid #B0B0B0;">
- <tr>
- <td width="100%" align="right">
- {$APPLY}
- </td>
- </tr>
- </table>
-
-</div>
index a829942939f92646e73e802514e31ecad23926ad..dd3c9b335a14e40e00d74a8779dedfddcdabaf5f 100644 (file)
var $bases= array();
var $scope= "";
var $query;
+ var $initial= false;
var $baseMode= false;
var $scopeMode= "auto";
var $alphabet= null;
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])){
function getCombobox($element)
{
$result= "<select name='".$element['tag']."' size='1' onClick='document.mainform.submit();'>";
+
+ // Fill with presets
foreach ($element['value'] as $value) {
$selected= "";
if ($this->elementValues[$element['tag']] == $value['key']) {
$selected= " selected";
}
- $result.= "<option value='".$value['key']."'$selected>{t}".$value['set']."{/t}</option>";
+
+ // Handle translations
+ if (is_array($value['set'])) {
+ $li= null;
+
+ // Get language index if available
+ $lang= preg_replace('/_.*$/', '', $GLOBALS['t_language']);
+ $mapper= array();
+ foreach($value['set'] as $index => $lv){
+ if (preg_match('/_attr$/', $index) && isset($lv['xml:lang']) && $lv['xml:lang'] == $lang) {
+ $li= preg_replace('/_attr$/', '', $index);
+ if (isset($mapper[$li])) {
+ unset($mapper[$li]);
+ }
+ } else {
+ $mapper[$index]= $index;
+ }
+ }
+
+ // Use some default if no index is available
+ if (!$li) {
+ $li= array_shift($mapper);
+ }
+
+ $result.= "<option value='".$value['key']."'$selected>".$value['set'][$li]."</option>";
+ } else {
+ $result.= "<option value='".$value['key']."'$selected>".$value['set']."</option>";
+ }
}
+
+ // Use autocompleter for additional data
+ if (isset($element['autocomplete'])) {
+ $list= $this->getCompletitionList($element['autocomplete'], $element['tag']);
+ foreach ($list as $value) {
+ $selected= "";
+ if ($this->elementValues[$element['tag']] == $value) {
+ $selected= " selected";
+ }
+ $result.= "<option value='$value'$selected>$value</option>";
+ }
+ }
+
$result.= "</select>";
return $result;
}
// Load template
- return ("<input type='hidden' name='FILTER_LOADED' value='1'>".$smarty->fetch(get_template_path("filter/".$this->xmlData['definition']['template'])));
+ return ("<input type='hidden' name='FILTER_LOADED' value='1'>".$smarty->fetch(get_template_path($this->xmlData['definition']['template'], true)));
}
}
+ 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;
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 '<ul>';
foreach ($result as $entry) {
- foreach ($attributes as $attribute) {
- if (is_array($entry[$attribute])) {
- for ($i= 0; $i<$entry[$attribute]['count']; $i++) {
- echo '<li>'.$entry[$attribute][$i].'</li>';
- }
- } else {
- echo '<li>'.$entry[$entry][$attribute].'</li>';
- }
- }
+ echo '<li>'.$entry.'</li>';
}
echo '</ul>';
diff --git a/gosa-core/plugins/admin/users/class_userManagement.inc b/gosa-core/plugins/admin/users/class_userManagement.inc
index 1d1a6e98c23869c5e1045472353781df90984c19..9b4d57f82e1203b6253974af70f064b0dddd7079 100644 (file)
$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
--- /dev/null
@@ -0,0 +1,40 @@
+<div class="contentboxh">
+ <p class="contentboxh">
+ <img src="images/launch.png" align="right" alt="[F]">Filter
+ </p>
+</div>
+
+<div class="contentboxb">
+ <div style="border-top:1px solid #AAAAAA"></div>
+ {$ALPHABET}
+ <div style="border-top:1px solid #AAAAAA"></div>
+ {$TEMPLATE} {t}Show templates{/t}<br>
+ {$GENERIC} {t}Show functional users{/t}<br>
+ {$MAIL} {t}Show mail users{/t}<br>
+ {$POSIX} {t}Show POSIX users{/t}<br>
+ {$SAMBA} {t}Show samba users{/t}<br>
+ <div style="border-top:1px solid #AAAAAA"></div>
+ {$SCOPE}
+
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+ <tr>
+ <td>
+ <label for="Regex">
+ <img alt="Zeige die Benutzer, auf die Folgendes passt" src="images/lists/search.png" align=middle>
+ </label>
+ </td>
+ <td width="99%">
+ {$NAME}
+ </td>
+ </tr>
+ </table>
+
+ <table summary="" width="100%" style="background:#EEEEEE;border-top:1px solid #B0B0B0;">
+ <tr>
+ <td width="100%" align="right">
+ {$APPLY}
+ </td>
+ </tr>
+ </table>
+
+</div>
diff --git a/gosa-core/plugins/admin/users/user-filter.xml b/gosa-core/plugins/admin/users/user-filter.xml
--- /dev/null
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<filter>
+ <definition>
+ <target>users</target>
+ <template>user-filter.tpl</template>
+ <initial>true</initial>
+ </definition>
+
+ <search>
+ <query>
+ <backend>LDAP</backend>
+ <filter>(&(!(objectClass=gosaUserTemplate))(|$GENERIC$POSIX$MAIL$SAMBA)(|(cn=$NAME)(sn=$NAME)(givenName=$NAME)(uid=$NAME)))</filter>
+ <attribute>dn</attribute>
+ <attribute>objectClass</attribute>
+ <attribute>cn</attribute>
+ <attribute>mail</attribute>
+ <attribute>uid</attribute>
+ <attribute>modifyTimestamp</attribute>
+ </query>
+ <query>
+ <backend>LDAP</backend>
+ <filter>(&$TEMPLATE(|(cn=$NAME)(sn=$NAME)(givenName=$NAME)(uid=$NAME)))</filter>
+ <attribute>dn</attribute>
+ <attribute>objectClass</attribute>
+ <attribute>cn</attribute>
+ <attribute>mail</attribute>
+ <attribute>uid</attribute>
+ <attribute>modifyTimestamp</attribute>
+ </query>
+ <base>false</base>
+ <scope>auto</scope>
+ </search>
+
+ <element>
+ <type>textfield</type>
+ <tag>NAME</tag>
+ <!--<regex>^...</regex>-->
+ <alphabet>true</alphabet>
+ <default>*</default>
+ <unset>this is a not valid and failing filter</unset>
+ <set>$</set>
+ <autocomplete>
+ <backend>LDAP</backend>
+ <filter>(&(objectClass=gosaAccount)(|(cn=*$NAME*)(sn=*$NAME*)(givenName=*$NAME*)(uid=*$NAME*)))</filter>
+ <attribute>cn</attribute>
+ <frequency>0.5</frequency>
+ <characters>3</characters>
+ </autocomplete>
+ </element>
+
+ <element>
+ <type>checkbox</type>
+ <tag>TEMPLATE</tag>
+ <default></default>
+ <unset>(&(!(objectClass=gosaUserTemplate)(!(objectClass=gosaAccount))))</unset>
+ <set>(objectClass=gosaUserTemplate)</set>
+ </element>
+
+ <element>
+ <type>checkbox</type>
+ <tag>GENERIC</tag>
+ <default>true</default>
+ <unset></unset>
+ <set>(&(objectClass=gosaAccount)(!(|(objectClass=posixAccount)(objectClass=gosaMailAccount)(objectClass=sambaSamAccount)(objectClass=gosaProxyAccount))))</set>
+ </element>
+
+ <element>
+ <type>checkbox</type>
+ <tag>POSIX</tag>
+ <default>true</default>
+ <unset></unset>
+ <set>(objectClass=posixAccount)</set>
+ </element>
+
+ <element>
+ <type>checkbox</type>
+ <tag>MAIL</tag>
+ <default>true</default>
+ <unset></unset>
+ <set>(objectClass=gosaMailAccount)</set>
+ </element>
+
+ <element>
+ <type>checkbox</type>
+ <tag>SAMBA</tag>
+ <default>true</default>
+ <unset></unset>
+ <set>(objectClass=sambaSamAccount)</set>
+ </element>
+
+ <element>
+ <type>combobox</type>
+ <tag>ROLLE</tag>
+ <unset></unset>
+ <set></set>
+ <default>*</default>
+ <value>
+ <key>*</key>
+ <set>All</set>
+ <set xml:lang="de">Alle</set>
+ </value>
+ <autocomplete>
+ <backend>LDAP</backend>
+ <base>dc=gonicus,dc=de</base>
+ <scope>sub</scope>
+ <category>roles</category>
+ <objectbase>ou=roles</objectbase>
+ <filter>(objectClass=organizationalRole)</filter>
+ <attribute>cn</attribute>
+ <key>cn</key>
+ </autocomplete>
+ </element>
+
+</filter>
+