Changeset View
Changeset View
Standalone View
Standalone View
lib/api/kolab_api_service_form_value.php
Show First 20 Lines • Show All 834 Lines • ▼ Show 20 Lines | private function generate_uid($postdata, $attribs = array()) | ||||
$userdata = kolab_recipient_policy::normalize_userdata($postdata); | $userdata = kolab_recipient_policy::normalize_userdata($postdata); | ||||
$uid = kolab_recipient_policy::uid($userdata); | $uid = kolab_recipient_policy::uid($userdata); | ||||
Log::debug("uid from recipient policy: " . var_export($uid, TRUE)); | Log::debug("uid from recipient policy: " . var_export($uid, TRUE)); | ||||
$orig_uid = $uid; | $orig_uid = $uid; | ||||
$auth = Auth::get_instance($_SESSION['user']->get_domain()); | $auth = Auth::get_instance($_SESSION['user']->get_domain()); | ||||
$conf = Conf::get_instance(); | |||||
$all_domains = array(); | |||||
if ($conf->get('unique_uid_across_domains') == "true") { | |||||
$domainslist = $auth->list_domains(); | |||||
foreach ($domainslist['list'] as $domainobj) { | |||||
$domain = $domainobj['associateddomain']; | |||||
if (is_array($domain)) { | |||||
$domain = $domain[0]; | |||||
} | |||||
$all_domains[] = $domain; | |||||
} | |||||
} else { | |||||
$all_domains[] = $_SESSION['user']->get_domain(); | |||||
} | |||||
$x = 2; | $x = 2; | ||||
while (($user_found = $auth->user_find_by_attribute(array('uid' => $uid)))) { | while (true) { | ||||
$user_found = null; | |||||
foreach ($all_domains as $domain) { | |||||
$user_found = $auth->user_find_by_attribute_per_domain($domain, array('uid' => $uid)); | |||||
if (!empty($postdata['id'])) { | if (!empty($postdata['id'])) { | ||||
$user_found_dn = key($user_found); | $user_found_dn = key($user_found); | ||||
$user_found_unique_attr = $this->unique_attribute_value($user_found_dn); | $user_found_unique_attr = $this->unique_attribute_value($user_found_dn); | ||||
//console("user with uid $uid found", $user_found_unique_attr); | //console("user with uid $uid found", $user_found_unique_attr); | ||||
if ($user_found_unique_attr == $postdata['id']) { | if ($user_found_unique_attr == $postdata['id']) { | ||||
//console("that's us."); | //console("that's us."); | ||||
break; | $user_found = null; | ||||
break; // foreach domain | |||||
} | |||||
} | |||||
if ($user_found) { | |||||
break; // foreach domain | |||||
} | } | ||||
} | } | ||||
if ($user_found) { | |||||
$uid = $orig_uid . $x; | $uid = $orig_uid . $x; | ||||
$x++; | $x++; | ||||
} else { | |||||
break; // while true | |||||
} | |||||
} | } | ||||
return $uid; | return $uid; | ||||
} | } | ||||
} | } | ||||
private function generate_uidnumber($postdata, $attribs = array()) | private function generate_uidnumber($postdata, $attribs = array()) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 818 Lines • Show Last 20 Lines |