lib/api
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Sat Sep 6 11:50:58 CEST 2014
lib/api/kolab_api_service_form_value.php | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
New commits:
commit b8f70c69d9a2a5e2ab7f42ab08fe95696236e13d
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sat Sep 6 11:50:29 2014 +0200
Ensure also the primary mail address is globally unique
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index e066d8a..f1e0960 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -673,6 +673,33 @@ class kolab_api_service_form_value extends kolab_api_service
$primary_mail = kolab_recipient_policy::primary_mail($postdata);
+ $auth = Auth::get_instance();
+
+ list($_local, $_domain) = explode("@", $primary_mail);
+ $local = $_local;
+
+ $x = 2;
+ while (($user_found = $auth->find_recipient($local . "@" . $_domain))) {
+ Log::trace(__FUNCTION__ . ": An entry with address " . $local . "@" . $_domain . " was found.");
+
+ if (!empty($postdata['id'])) {
+ $user_found_dn = key($user_found);
+ $user_found_unique_attr = $this->unique_attribute_value($user_found_dn);
+
+ if ($user_found_unique_attr == $postdata['id']) {
+ Log::trace(__FUNCTION__ . ": Entry with address " . $local . "@" . $_domain . " is actually us.");
+ break;
+ }
+ } // empty($postdata['id'])
+
+ // Otherwise this is a new user and therefore the entry found with
+ // this address is definitely not us
+ $local = $_local . $x;
+ $x++;
+ }
+
+ $primary_mail = $local . "@" . $_domain;
+
return $primary_mail;
}
}
More information about the commits
mailing list