summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2015-03-05 10:24:09 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2015-03-05 10:24:09 (GMT)
commit56a0b8eb70e4567ca7f973409321a031297f96a6 (patch)
tree9cca8f78bab99601e0e07f5bacb0c479b31f109d
parentd5c7eeb50de5e0952a0e303a1cd1e046dbdb0eb0 (diff)
downloadkolab-wap-56a0b8eb70e4567ca7f973409321a031297f96a6.tar.gz
Fix "illegal offset" error and small perf. issue in domain_is_empty() (#4791)
-rw-r--r--lib/Auth/LDAP.php12
-rw-r--r--lib/api/kolab_api_service_domain.php6
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index ce0762e..2e28c1e 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -448,25 +448,29 @@ class LDAP extends Net_LDAP3 {
/**
* Checkes if specified domain is empty (no users assigned)
*
- * @param string $domain Domain name
+ * @param string|array $domain Domain name or domain_info() result
*
* @return bool True if domain is empty, False otherwise
*/
public function domain_is_empty($domain)
{
- $this->_log(LOG_DEBUG, "Auth::LDAP::domain_is_empty($domain)");
-
$domain_name_attribute = $this->conf->get('ldap', 'domain_name_attribute');
if (empty($domain_name_attribute)) {
$domain_name_attribute = 'associateddomain';
}
- $domain = $this->domain_info($domain);
+ if (!is_array($domain)) {
+ $domain = $this->domain_info($domain);
+ }
if (!empty($domain)) {
$domain_dn = key($domain);
$domain_name = $domain[$domain_dn][$domain_name_attribute];
+
+ if (is_array($domain_name)) {
+ $domain_name = $domain_name[0];
+ }
}
else {
return false;
diff --git a/lib/api/kolab_api_service_domain.php b/lib/api/kolab_api_service_domain.php
index dcc8778..f9910df 100644
--- a/lib/api/kolab_api_service_domain.php
+++ b/lib/api/kolab_api_service_domain.php
@@ -160,13 +160,13 @@ class kolab_api_service_domain extends kolab_api_service
&& (empty($postdata['force']) || strtolower($postdata['force']) == 'false')
) {
$domain = $auth->domain_info($postdata['id']);
-
- if ($domain['inetdomainstatus'] != 'deleted' && !$auth->domain_is_empty($postdata['id'])) {
+ if (!empty($domain) && $domain[key($domain)]['inetdomainstatus'] != 'deleted'
+ && !$auth->domain_is_empty($domain)
+ ) {
throw new kolab_api_exception(kolab_api_exception::DOMAIN_NOT_EMPTY);
}
}
-
$attributes = $this->parse_input_attributes('domain', $postdata);
$result = $auth->domain_edit($postdata['id'], $attributes, $postdata['type_id']);