From cdd23787e2b72cad74d84b1bbc1b4650d7ad2f0a Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 11 Sep 2013 14:01:38 +0200 Subject: [PATCH] Fix so kolab_delegation plugin can modify list of addresses in identity form (Bug #2191) --- plugins/kolab_auth/kolab_auth.php | 4 ++++ plugins/kolab_auth/kolab_auth_ldap.php | 4 +++- plugins/kolab_delegation/kolab_delegation.php | 24 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/plugins/kolab_auth/kolab_auth.php b/plugins/kolab_auth/kolab_auth.php index e6171d21..7c615537 100644 --- a/plugins/kolab_auth/kolab_auth.php +++ b/plugins/kolab_auth/kolab_auth.php @@ -490,6 +490,10 @@ class kolab_auth extends rcube_plugin $emails = array_merge($emails, array_filter($values)); } + // kolab_delegation might want to modify this addresses list + $plugin = $rcmail->plugins->exec_hook('kolab_auth_emails', array('emails' => $emails)); + $emails = $plugin['emails']; + if (!empty($emails)) { $args['form']['addressing']['content']['email'] = array( 'type' => 'select', diff --git a/plugins/kolab_auth/kolab_auth_ldap.php b/plugins/kolab_auth/kolab_auth_ldap.php index 4584c60b..2cddb3f5 100644 --- a/plugins/kolab_auth/kolab_auth_ldap.php +++ b/plugins/kolab_auth/kolab_auth_ldap.php @@ -119,6 +119,7 @@ class kolab_auth_ldap extends rcube_ldap_generic $entries = $result->entries(true); $dn = key($entries); $entry = array_pop($entries); + $entry = rcube_ldap_generic::normalize_entry($entry); $entry = $this->field_mapping($dn, $entry); return $entry; @@ -287,7 +288,8 @@ class kolab_auth_ldap extends rcube_ldap_generic if ($limit && $limit <= $i) { break; } - $dn = $result->get_dn(); + $dn = $result->get_dn(); + $entry = rcube_ldap_generic::normalize_entry($entry); $list[$dn] = $this->field_mapping($dn, $entry); $i++; } diff --git a/plugins/kolab_delegation/kolab_delegation.php b/plugins/kolab_delegation/kolab_delegation.php index 156e81f4..23e0107c 100644 --- a/plugins/kolab_delegation/kolab_delegation.php +++ b/plugins/kolab_delegation/kolab_delegation.php @@ -55,6 +55,9 @@ class kolab_delegation extends rcube_plugin $this->add_hook('calendar_list_filter', array($this, 'calendar_list_filter')); $this->add_hook('calendar_load_itip', array($this, 'calendar_load_itip')); + // delegation support in kolab_auth plugin + $this->add_hook('kolab_auth_emails', array($this, 'kolab_auth_emails')); + if ($this->rc->task == 'settings') { // delegation management interface $this->register_action('plugin.delegation', array($this, 'controller_ui')); @@ -240,6 +243,27 @@ class kolab_delegation extends rcube_plugin } } + /** + * Delegation support in kolab_auth plugin + */ + public function kolab_auth_emails($args) + { + // Add delegators addresses to address selector in user identity form + + if (!empty($_SESSION['delegators'])) { + // @TODO: Consider not adding all delegator addresses to the list. + // Instead add only address of currently edited identity + foreach ($_SESSION['delegators'] as $emails) { + $args['emails'] = array_merge($args['emails'], $emails); + } + + $args['emails'] = array_unique($args['emails']); + sort($args['emails']); + } + + return $args; + } + /** * Delegation UI handler */