From 62c45161c4efd101b940134b60bb73881746e5f5 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 10 Jun 2014 14:40:22 +0200 Subject: ACL: Improved UI accessibility --- plugins/acl/acl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/acl/acl.php') diff --git a/plugins/acl/acl.php b/plugins/acl/acl.php index d7e50f978..95d4eda62 100644 --- a/plugins/acl/acl.php +++ b/plugins/acl/acl.php @@ -286,7 +286,7 @@ class acl extends rcube_plugin $textfield = new html_inputfield($attrib); - $fields['user'] = html::label(array('for' => 'iduser'), $this->gettext('username')) + $fields['user'] = html::label(array('for' => $attrib['id']), $this->gettext('username')) . ' ' . $textfield->show(); // Add special entries @@ -401,7 +401,7 @@ class acl extends rcube_plugin } $table->add_row(array('id' => 'rcmrow'.$userid)); - $table->add('user', rcube::Q($user)); + $table->add('user', html::a(array('id' => 'rcmlinkrow'.$userid), rcube::Q($user))); foreach ($items as $key => $right) { $in = $this->acl_compare($userrights, $right); -- cgit v1.2.3 From 43b225d18333530abf17f5ca39140d417cc69490 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 8 Jul 2014 10:10:16 +0200 Subject: Support contact_search_name option in ACL plugin autocompletion --- plugins/acl/acl.js | 6 +----- plugins/acl/acl.php | 27 +++++++++++++++++++-------- plugins/acl/package.xml | 4 ++-- 3 files changed, 22 insertions(+), 15 deletions(-) (limited to 'plugins/acl/acl.php') diff --git a/plugins/acl/acl.js b/plugins/acl/acl.js index d82725c8b..e59ac72a2 100644 --- a/plugins/acl/acl.js +++ b/plugins/acl/acl.js @@ -24,11 +24,7 @@ if (window.rcmail) { if (e.field.id != 'acluser') return; - var value = e.insert; - // get UID from the entry value - if (value.match(/\s*\(([^)]+)\)[, ]*$/)) - value = RegExp.$1; - e.field.value = value; + e.field.value = e.insert.replace(/[ ,;]+$/, ''); }); } } diff --git a/plugins/acl/acl.php b/plugins/acl/acl.php index 95d4eda62..3e3bca9e1 100644 --- a/plugins/acl/acl.php +++ b/plugins/acl/acl.php @@ -88,6 +88,7 @@ class acl extends rcube_plugin $search = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC, true); $reqid = rcube_utils::get_input_value('_reqid', rcube_utils::INPUT_GPC); $users = array(); + $keys = array(); if ($this->init_ldap()) { $max = (int) $this->rc->config->get('autocomplete_max', 15); @@ -105,15 +106,23 @@ class acl extends rcube_plugin } if ($user) { - if ($record['name']) - $user = $record['name'] . ' (' . $user . ')'; - + $display = rcube_addressbook::compose_search_name($record); + $user = array('name' => $user, 'display' => $display); $users[] = $user; + $keys[] = $display ?: $user['name']; } } } - sort($users, SORT_LOCALE_STRING); + if (count($users)) { + // sort users index + asort($keys, SORT_LOCALE_STRING); + // re-sort users according to index + foreach ($keys as $idx => $val) { + $keys[$idx] = $users[$idx]; + } + $users = array_values($keys); + } $this->rc->output->command('ksearch_query_results', $users, $search, $reqid); $this->rc->output->send(); @@ -653,8 +662,9 @@ class acl extends rcube_plugin */ private function init_ldap() { - if ($this->ldap) + if ($this->ldap) { return $this->ldap->ready; + } // get LDAP config $config = $this->rc->config->get('acl_users_source'); @@ -666,7 +676,7 @@ class acl extends rcube_plugin // not an array, use configured ldap_public source if (!is_array($config)) { $ldap_config = (array) $this->rc->config->get('ldap_public'); - $config = $ldap_config[$config]; + $config = $ldap_config[$config]; } $uid_field = $this->rc->config->get('acl_users_field', 'mail'); @@ -692,12 +702,13 @@ class acl extends rcube_plugin ); // search in UID and name fields - $config['search_fields'] = array_values($config['fieldmap']); + $config['search_fields'] = array_values($config['fieldmap']); $config['required_fields'] = array($uid_field); // set search filter - if ($filter) + if ($filter) { $config['filter'] = $filter; + } // disable vlv $config['vlv'] = false; diff --git a/plugins/acl/package.xml b/plugins/acl/package.xml index a99ad4ffa..87e8b1ca2 100644 --- a/plugins/acl/package.xml +++ b/plugins/acl/package.xml @@ -13,9 +13,9 @@ alec@alec.pl yes - 2014-02-04 + 2014-07-08 - 1.3 + 1.4 1.0 -- cgit v1.2.3 From 0a96bdf74d829cd230718243eeb733ad4e71bf5a Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 16 Jul 2014 11:38:01 +0200 Subject: Don't overwrite the whole fieldmap so autocomplete names are resolved correctly --- plugins/acl/acl.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'plugins/acl/acl.php') diff --git a/plugins/acl/acl.php b/plugins/acl/acl.php index 3e3bca9e1..5c4deb770 100644 --- a/plugins/acl/acl.php +++ b/plugins/acl/acl.php @@ -696,10 +696,8 @@ class acl extends rcube_plugin } // add UID field to fieldmap, so it will be returned in a record with name - $config['fieldmap'] = array( - 'name' => $name_field, - 'uid' => $uid_field, - ); + $config['fieldmap']['name'] = $name_field; + $config['fieldmap']['uid'] = $uid_field; // search in UID and name fields $config['search_fields'] = array_values($config['fieldmap']); -- cgit v1.2.3 From ec2733f6c35ca3d470172f9e35ae94399a78c2f4 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 11 Aug 2014 03:35:07 -0400 Subject: Add support for groups --- plugins/acl/acl.php | 22 ++++++++++++++++++++-- plugins/acl/config.inc.php.dist | 9 +++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'plugins/acl/acl.php') diff --git a/plugins/acl/acl.php b/plugins/acl/acl.php index 5c4deb770..33bd91e22 100644 --- a/plugins/acl/acl.php +++ b/plugins/acl/acl.php @@ -112,6 +112,20 @@ class acl extends rcube_plugin $keys[] = $display ?: $user['name']; } } + + if ($this->rc->config->get('acl_groups')) { + $prefix = $this->rc->config->get('acl_group_prefix'); + $result = $this->ldap->list_groups($search, $mode); + + foreach ($result as $record) { + $group = $record['name']; + + if ($group) { + $users[] = array('name' => ($prefix ? $prefix : '') . $group, 'display' => $group); + $keys[] = $group; + } + } + } } if (count($users)) { @@ -448,9 +462,13 @@ class acl extends rcube_plugin $result = 0; foreach ($users as $user) { - $user = trim($user); + $user = trim($user); + $prefix = $this->rc->config->get('acl_groups') ? $this->rc->config->get('acl_group_prefix') : ''; - if (!empty($this->specials) && in_array($user, $this->specials)) { + if ($prefix && strpos($user, $prefix) === 0) { + $username = $user; + } + else if (!empty($this->specials) && in_array($user, $this->specials)) { $username = $this->gettext($user); } else if (!empty($user)) { diff --git a/plugins/acl/config.inc.php.dist b/plugins/acl/config.inc.php.dist index 3f0b1efb6..de1f8b5d2 100644 --- a/plugins/acl/config.inc.php.dist +++ b/plugins/acl/config.inc.php.dist @@ -16,10 +16,15 @@ $config['acl_users_field'] = 'mail'; // The LDAP search filter will be &'d with search queries $config['acl_users_filter'] = ''; +// Enable LDAP groups in user autocompletion. +// Note: LDAP addressbook defined in acl_users_source must include groups config +$config['acl_groups'] = false; + +// Prefix added to the group name to build IMAP ACL identifier +$config['acl_group_prefix'] = 'group:'; + // Include the following 'special' access control subjects in the ACL dialog; // Defaults to array('anyone', 'anonymous') (not when set to an empty array) // Example: array('anyone') to exclude 'anonymous'. // Set to an empty array to exclude all special aci subjects. $config['acl_specials'] = array('anyone', 'anonymous'); - -?> -- cgit v1.2.3