summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/kolab_client_task.php2
-rw-r--r--lib/locale/en_US.php1
-rw-r--r--public_html/js/kolab_admin.js28
3 files changed, 21 insertions, 10 deletions
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index e8c121d..3c6402f 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -944,7 +944,7 @@ class kolab_client_task
$this->output->add_translation('ldap.one', 'ldap.sub', 'ldap.base',
'ldap.host', 'ldap.basedn','ldap.scope', 'ldap.conditions',
'ldap.filter_any', 'ldap.filter_both', 'ldap.filter_prefix', 'ldap.filter_suffix',
- 'ldap.filter_exact'
+ 'ldap.filter_exact', 'ldap.filter_notexact'
);
}
}
diff --git a/lib/locale/en_US.php b/lib/locale/en_US.php
index 967141b..4cbe353 100644
--- a/lib/locale/en_US.php
+++ b/lib/locale/en_US.php
@@ -193,6 +193,7 @@ $LANG['ldap.filter_both'] = 'contains';
$LANG['ldap.filter_prefix'] = 'starts with';
$LANG['ldap.filter_suffix'] = 'ends with';
$LANG['ldap.filter_exact'] = 'is equal to';
+$LANG['ldap.filter_notexact'] = 'is not equal to';
$LANG['list.records'] = '$1 to $2 of $3';
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 368557a..1701a8e 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -2074,7 +2074,7 @@ function kolab_admin()
this.form_url_filter_element = function(name, idx, filter)
{
- var options = ['any', 'both', 'prefix', 'suffix', 'exact'],
+ var options = ['any', 'both', 'prefix', 'suffix', 'exact', 'notexact'],
filter_type = $('<select>').attr({name: 'ldap_filter_type_'+name+'['+idx+']'}),
filter_name = $('<input type="text">').attr({name: 'ldap_filter_name_'+name+'['+idx+']'}),
filter_value = $('<input type="text">').attr({name: 'ldap_filter_value_'+name+'['+idx+']'}),
@@ -3275,6 +3275,8 @@ function kolab_admin()
if (next != '&' && next != '|') {
next = filter.indexOf(')', pos);
if (next > 0) {
+ if (filter.charAt(pos+1) == '!' && filter.charAt(pos+2) == '(')
+ next++;
if (elem = this.parse_ldap_filter_entry(filter.substr(pos + 1, next - pos - 1))) {
elem.join = join;
elem.level = level;
@@ -3296,11 +3298,12 @@ function kolab_admin()
// LDAP filter-entry parser
this.parse_ldap_filter_entry = function(entry)
{
- var type = 'exact', name, value;
+ var type = 'exact', not, name, value;
- if (entry.match(/^([a-zA-Z0-9_-]+)=(.*)$/)) {
- name = RegExp.$1;
- value = RegExp.$2;
+ if (entry.match(/^(!?)\(?([a-zA-Z0-9_-]+)=([^\)]*)\)?$/)) {
+ name = RegExp.$2;
+ value = RegExp.$3;
+ not = RegExp.$1.length > 0;
if (value == '*') {
value = ''
@@ -3319,14 +3322,14 @@ function kolab_admin()
type = 'prefix';
}
- return {name: name, type: type, value: value};
+ return {name: name, type: (not ? 'not' : '') + type, value: value};
}
};
// Builds LDAP filter string from the defined structure
this.build_ldap_filter = function(filter)
{
- var i, elem, str = '', last = -1, join = {'AND': '&', 'OR': '|'};
+ var i, elem, not, str = '', last = -1, join = {'AND': '&', 'OR': '|'};
for (i=0; i<filter.length; i++) {
elem = filter[i];
@@ -3335,7 +3338,14 @@ function kolab_admin()
else if (elem.level < last)
str += ')';
- str += '(' + elem.name + '=';
+ str += '('
+
+ if (not = /^not(.*)$/.test(elem.type)) {
+ str += '!(';
+ elem.type = RegExp.$1;
+ }
+
+ str += elem.name + '=';
if (elem.type == 'any')
str += '*';
@@ -3348,7 +3358,7 @@ function kolab_admin()
else
str += elem.value;
- str += ')';
+ str += (not ? ')' : '') + ')';
last = elem.level;
}