From 9e88184509a9862865627017396577974da1e06f Mon Sep 17 00:00:00 2001 From: SJ Date: Thu, 22 Aug 2013 22:10:52 +0200 Subject: [PATCH] fixed the group email autocomplete stuff --- webui/model/group/group.php | 26 +++++++++++++++++-- .../theme/default/templates/group/add.tpl | 2 +- .../theme/default/templates/group/edit.tpl | 2 +- .../view/theme/mobile/templates/group/add.tpl | 2 +- .../theme/mobile/templates/group/edit.tpl | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/webui/model/group/group.php b/webui/model/group/group.php index 47e1bfad..94df45b8 100644 --- a/webui/model/group/group.php +++ b/webui/model/group/group.php @@ -168,16 +168,38 @@ class ModelGroupGroup extends Model { } } + sort($emails); + + if(strlen($s) == 1 && ENABLE_LDAP_AUTH == 1) { + $emails = array_slice($emails, $page * $page_len, $page_len); + } + return $emails; } public function count_emails($s = '') { - if(strlen($s) < 1) { return 0; } + $count = 0; + + if(strlen($s) < 1) { return $count; } + + if(ENABLE_LDAP_AUTH == 1) { + $ldap = new LDAP(LDAP_HOST, LDAP_HELPER_DN, LDAP_HELPER_PASSWORD); + if($ldap->is_bind_ok()) { + + $query = $ldap->query(LDAP_BASE_DN, "(&(objectClass=" . LDAP_ACCOUNT_OBJECTCLASS . ")(" . LDAP_MAIL_ATTR . "=" . $s . "*))", array()); + + if(isset($query->rows)) { + $count = $query->num_rows; + } + } + } $query = $this->db->query("SELECT COUNT(*) AS num FROM `" . TABLE_EMAIL . "` WHERE email LIKE ?", array($s . "%") ); - return $query->row['num']; + $count += $query->row['num']; + + return $count; } diff --git a/webui/view/theme/default/templates/group/add.tpl b/webui/view/theme/default/templates/group/add.tpl index 28e67932..b19df9d4 100644 --- a/webui/view/theme/default/templates/group/add.tpl +++ b/webui/view/theme/default/templates/group/add.tpl @@ -30,7 +30,7 @@
- +
diff --git a/webui/view/theme/default/templates/group/edit.tpl b/webui/view/theme/default/templates/group/edit.tpl index ab31757e..254ef556 100644 --- a/webui/view/theme/default/templates/group/edit.tpl +++ b/webui/view/theme/default/templates/group/edit.tpl @@ -44,7 +44,7 @@
- +
diff --git a/webui/view/theme/mobile/templates/group/add.tpl b/webui/view/theme/mobile/templates/group/add.tpl index b17c3036..0c1389b2 100644 --- a/webui/view/theme/mobile/templates/group/add.tpl +++ b/webui/view/theme/mobile/templates/group/add.tpl @@ -21,7 +21,7 @@
- +
diff --git a/webui/view/theme/mobile/templates/group/edit.tpl b/webui/view/theme/mobile/templates/group/edit.tpl index d08cd8a4..c7bd19dd 100644 --- a/webui/view/theme/mobile/templates/group/edit.tpl +++ b/webui/view/theme/mobile/templates/group/edit.tpl @@ -23,7 +23,7 @@
- +