lib/client
Aleksander Machniak
machniak at kolabsys.com
Fri Oct 24 11:55:16 CEST 2014
lib/client/kolab_client_task_ou.php | 39 +++++++++++++++++-------------------
1 file changed, 19 insertions(+), 20 deletions(-)
New commits:
commit 1e36295ff2a2ff54e3f879e36450e2552e3a2956
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Fri Oct 24 05:54:19 2014 -0400
Fix organizational units tree if base_dn contains items other than dc= (#3770)
diff --git a/lib/client/kolab_client_task_ou.php b/lib/client/kolab_client_task_ou.php
index a286d34..2a99f92 100644
--- a/lib/client/kolab_client_task_ou.php
+++ b/lib/client/kolab_client_task_ou.php
@@ -197,7 +197,7 @@ class kolab_client_task_ou extends kolab_client_task
// build the list for sorting
foreach (array_keys($list) as $dn) {
$names = $this->explode_dn($dn);
- $sort_name = $names['domain'] . ':' . implode(',', array_reverse($names['path']));
+ $sort_name = $names['root'] . ':' . implode(',', array_reverse($names['path']));
$list[$dn] = mb_strtolower($sort_name);
}
@@ -231,10 +231,10 @@ class kolab_client_task_ou extends kolab_client_task
if ($item['level']) {
// create a parent unit entry if it does not exist (search result)
- $parent = $this->domain_dn($item['domain']);
+ $parent = $item['root'];
foreach ($item['path'] as $sub) {
- // convert special characters back into entities (#
+ // convert special characters back into entities (#3744)
$sub = str_replace(',', "\\2C", $sub);
$parent = "ou=$sub,$parent";
@@ -263,39 +263,38 @@ class kolab_client_task_ou extends kolab_client_task
$items = $this->explode_dn($dn);
return array(
- 'name' => array_shift($items['path']),
- 'path' => array_reverse($items['path']),
- 'level' => count($items['path']),
- 'domain' => $items['domain'],
+ 'name' => array_shift($items['path']),
+ 'path' => array_reverse($items['path']),
+ 'level' => count($items['path']),
+ 'root' => $items['root'],
);
}
/**
- * Converts domain name into DN string
+ * Tokenizes OU's DN string
*/
- private function domain_dn($domain)
- {
- return "dc=" . implode(',dc=', explode('.', $domain));
- }
-
private function explode_dn($dn)
{
- $path = kolab_utils::explode_dn($dn);
- $domain = array();
+ $path = kolab_utils::explode_dn($dn);
+ $root = array();
foreach ($path as $idx => $item) {
- if (strpos($item, 'dc=') === 0) {
+ $pos = strpos($item, '=');
+ $key = substr($item, 0, $pos);
+
+ if ($key != 'ou') {
unset($path[$idx]);
- $domain[] = substr($item, 3);
+ // convert special characters back into entities (#3744)
+ $root[] = str_replace(',', "\\2C", $item);
}
else {
- $path[$idx] = substr($item, 3);
+ $path[$idx] = substr($item, $pos + 1);
}
}
return array(
- 'domain' => implode('.', $domain),
- 'path' => $path,
+ 'root' => implode(',', $root),
+ 'path' => $path,
);
}
}
More information about the commits
mailing list