From bde912a1fe3fc9da2ab65a7ba0b3bb5a1f38d792 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 8 Oct 2012 11:32:49 +0200 Subject: [PATCH] Create identity for each email address of a new user --- plugins/kolab_auth/config.inc.php.dist | 3 ++- plugins/kolab_auth/kolab_auth.php | 16 +++++++++++----- plugins/kolab_auth/package.xml | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/plugins/kolab_auth/config.inc.php.dist b/plugins/kolab_auth/config.inc.php.dist index 12f43e65..6ddfc630 100644 --- a/plugins/kolab_auth/config.inc.php.dist +++ b/plugins/kolab_auth/config.inc.php.dist @@ -11,8 +11,9 @@ $rcmail_config['kolab_auth_filter'] = '(&(objectClass=kolabInetOrgPerson)(|(uid= $rcmail_config['kolab_auth_login'] = 'email'; // Use this fields (from fieldmap configuration) for default identity. -// Note: These aren't LDAP attributes, but field names in config // If the value array contains more than one field, first non-empty will be used +// Note: These aren't LDAP attributes, but field names in config +// Note: If there's more than one email address, as many identities will be created $rcmail_config['kolab_auth_name'] = array('name', 'cn'); $rcmail_config['kolab_auth_email'] = array('email'); diff --git a/plugins/kolab_auth/kolab_auth.php b/plugins/kolab_auth/kolab_auth.php index c5d89ecb..fb19e9e2 100644 --- a/plugins/kolab_auth/kolab_auth.php +++ b/plugins/kolab_auth/kolab_auth.php @@ -206,8 +206,15 @@ class kolab_auth extends rcube_plugin public function user_create($args) { if (!empty($this->data['user_email'])) { - $args['user_email'] = $this->data['user_email']; + // addresses list is supported + if (array_key_exists('email_list', $args)) { + $args['email_list'] = array_unique($this->data['user_email']); + } + else { + $args['user_email'] = $this->data['user_email'][0]; + } } + if (!empty($this->data['user_name'])) { $args['user_name'] = $this->data['user_name']; } @@ -374,12 +381,11 @@ class kolab_auth extends rcube_plugin break; } } - // User email for identity (first log in) + // User email(s) for identity (first log in) foreach ((array)$email_attr as $field) { - $email = is_array($record[$field]) ? $record[$field][0] : $record[$field]; + $email = is_array($record[$field]) ? array_filter($record[$field]) : $record[$field]; if (!empty($email)) { - $this->data['user_email'] = $email; - break; + $this->data['user_email'] = array_merge((array)$this->data['user_email'], (array)$email); } } diff --git a/plugins/kolab_auth/package.xml b/plugins/kolab_auth/package.xml index abbd21f1..6200c4c9 100644 --- a/plugins/kolab_auth/package.xml +++ b/plugins/kolab_auth/package.xml @@ -20,7 +20,7 @@ 2012-10-08 - 0.3 + 0.4 0.1