Changeset View
Changeset View
Standalone View
Standalone View
lib/api/kolab_api_service_form_value.php
Show First 20 Lines • Show All 1,588 Lines • ▼ Show 20 Lines | |||||
// // domain not found in DNS | // // domain not found in DNS | ||||
// $valid = false; | // $valid = false; | ||||
// } | // } | ||||
} | } | ||||
return $valid; | return $valid; | ||||
} | } | ||||
/** | |||||
* Lists the valid domains given a primary domain name space. | |||||
* | |||||
* Includes the parent domain and any alias or child domains. | |||||
* Considers domains that point to the same base dn to be child domains. | |||||
*/ | |||||
private function _get_valid_domains($my_primary_domain = null) | private function _get_valid_domains($my_primary_domain = null) | ||||
{ | { | ||||
$my_primary_domain = $my_primary_domain !== null | $my_primary_domain = $my_primary_domain !== null | ||||
? $my_primary_domain | ? $my_primary_domain | ||||
: $_SESSION['user']->get_domain(); | : $_SESSION['user']->get_domain(); | ||||
$auth = Auth::get_instance(); | $auth = Auth::get_instance(); | ||||
$conf = Conf::get_instance(); | $conf = Conf::get_instance(); | ||||
$all_domains = $auth->list_domains(); | $all_domains = $auth->list_domains(); | ||||
$all_domains = $all_domains['list']; | $all_domains = $all_domains['list']; | ||||
$all_basedns = Array(); | |||||
$dna = $conf->get('domain_name_attribute'); | $dna = $conf->get('domain_name_attribute'); | ||||
$dra = $conf->get('domain_rootdn_attribute'); | |||||
Log::trace("__get_valid_domains( " . $my_primary_domain . ")"); | Log::trace("_get_valid_domains(" . $my_primary_domain . ")"); | ||||
Log::trace("\$all_domains includes: " . var_export($all_domains, TRUE) . " (must include domain for \$my_primary_domain)"); | |||||
$valid_domains = $my_primary_domain ? array($my_primary_domain) : array(); | $valid_domains = $my_primary_domain ? array($my_primary_domain) : array(); | ||||
foreach ($all_domains as $domain_id => $domain_attrs) { | foreach ($all_domains as $domain_id => $domain_attrs) { | ||||
if (!is_array($domain_attrs[$dna])) { | if (!is_array($domain_attrs[$dna])) { | ||||
$domain_attrs[$dna] = (array)($domain_attrs[$dna]); | $domain_attrs[$dna] = (array)($domain_attrs[$dna]); | ||||
} | } | ||||
if (in_array($my_primary_domain, $domain_attrs[$dna])) { | if (in_array($my_primary_domain, $domain_attrs[$dna])) { | ||||
$valid_domains = array_merge($valid_domains, $domain_attrs[$dna]); | $valid_domains = array_merge($valid_domains, $domain_attrs[$dna]); | ||||
} | } | ||||
if (array_key_exists($dra, $domain_attrs)) { | |||||
if (array_key_exists($domain_attrs[$dra], $all_basedns)) { | |||||
$all_basedns[$domain_attrs[$dra]] = array_merge($all_basedns[$domain_attrs[$dra]], $domain_attrs[$dna]); | |||||
} else { | |||||
$all_basedns[$domain_attrs[$dra]] = $domain_attrs[$dna]; | |||||
} | |||||
} | } | ||||
} | |||||
foreach ($all_basedns as $base_dn => $domains) { | |||||
if (in_array($my_primary_domain, $domains)) { | |||||
$valid_domains = array_merge($valid_domains, $domains); | |||||
} | |||||
} | |||||
$result = array_unique($valid_domains); | |||||
dhoffend: $result is not used afterwords. | |||||
Not Done Inline ActionsAh, yes, the line below should be using $result, as should the return statement. vanmeeuwen: Ah, yes, the line below should be using $result, as should the return statement. | |||||
Log::trace("_get_valid_domains result: " . var_export($result, TRUE)); | |||||
return array_unique($valid_domains); | return array_unique($result); | ||||
} | } | ||||
private function _validate_email_address_in_any_of_my_domains($mail_address) | private function _validate_email_address_in_any_of_my_domains($mail_address) | ||||
{ | { | ||||
$at_index = strrpos($mail_address, "@"); | $at_index = strrpos($mail_address, "@"); | ||||
if (is_bool($at_index) && !$at_index) { | if (is_bool($at_index) && !$at_index) { | ||||
throw new Exception("Invalid email address: No domain name space", 235); | throw new Exception("Invalid email address: No domain name space", 235); | ||||
} else { | } else { | ||||
Show All 27 Lines |
$result is not used afterwords.