summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-09-23 09:42:57 +0200
committerAleksander Machniak <alec@alec.pl>2013-09-23 09:42:57 +0200
commit55b0e6f4f7b5cb743d73d5e389d05ae0bda2428a (patch)
tree603b00bb13a31ffcb9aa6b87622ab374104d8fd0 /lib
parent00129d3573a699708b4fd9342fbb61a024190192 (diff)
downloadwebadmin-55b0e6f4f7b5cb743d73d5e389d05ae0bda2428a.tar.gz
Code cleanup
Diffstat (limited to 'lib')
-rw-r--r--lib/api/kolab_api_service_form_value.php26
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 12af63c..7f476e9 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -696,8 +696,6 @@ class kolab_api_service_form_value extends kolab_api_service
private function generate_secondary_mail($postdata, $attribs = array())
{
- $secondary_mail_addresses = Array();
-
if (isset($attribs['auto_form_fields'])) {
if (isset($attribs['auto_form_fields']['alias'])) {
$secondary_mail_key = 'alias';
@@ -725,14 +723,8 @@ class kolab_api_service_form_value extends kolab_api_service
}
}
- $_secondary_mail_addresses = kolab_recipient_policy::secondary_mail($postdata);
-
- // TODO: Check for uniqueness. Not sure what to do if not unique.
- $secondary_mail_addresses = Array();
-
- $auth = Auth::get_instance();
- $conf = Conf::get_instance();
- $unique_attr = $this->unique_attribute();
+ $auth = Auth::get_instance();
+ $conf = Conf::get_instance();
// Find the authentication mechanism in order to be able to fall back from a
// '[$domain]' section setting for the mail attributes list, to an '[$auth_mech]'
@@ -753,6 +745,10 @@ class kolab_api_service_form_value extends kolab_api_service
$mail_attrs = array('mail', 'alias');
}
+ $_secondary_mail_addresses = kolab_recipient_policy::secondary_mail($postdata);
+ $secondary_mail_addresses = array();
+ $unique_attr = $this->unique_attribute();
+
foreach ($_secondary_mail_addresses as $num => $alias) {
list($_local, $_domain) = explode("@", $alias);
$local = $_local;
@@ -762,8 +758,9 @@ class kolab_api_service_form_value extends kolab_api_service
Log::trace(__FUNCTION__ . ": An entry with address " . $local . "@" . $_domain . " was found.");
if (!empty($postdata['id'])) {
- $user_found_dn = key($user_found);
+ $user_found_dn = key($user_found);
$user_found_unique_attr = $auth->get_entry_attribute($user_found_dn, $unique_attr);
+
if ($user_found_unique_attr == $postdata['id']) {
Log::trace(__FUNCTION__ . ": Entry with address " . $local . "@" . $_domain . " is actually us.");
break;
@@ -778,16 +775,15 @@ class kolab_api_service_form_value extends kolab_api_service
}
$secondary_mail_addresses[] = $local . "@" . $_domain;
-
}
- if (in_array($postdata['mail'], $secondary_mail_addresses)) {
+ if (($key = array_search($postdata['mail'], $secondary_mail_addresses)) !== false) {
Log::trace("Found primary mail as part of the secondary mail addresses");
- unset($secondary_mail_addresses[array_search($postdata['mail'], $secondary_mail_addresses)]);
+ unset($secondary_mail_addresses[$key]);
}
- return $secondary_mail_addresses;
+ return array_unique($secondary_mail_addresses);
}
}