Only sort children after reading additional entries

This commit is contained in:
Deon George 2009-08-22 12:56:11 +10:00
parent 76ddeccf8c
commit 26fa2ba2c5
3 changed files with 39 additions and 3 deletions

View File

@ -147,10 +147,8 @@ class AJAXTree extends HTMLTree {
debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs);
$children = array();
$pchildren = $parent_entry->getChildren();
usort($pchildren,'pla_compare_dns');
foreach ($pchildren as $child) {
foreach ($parent_entry->getChildren() as $child) {
if (! $this->getEntry($child))
$this->addEntry($child);

View File

@ -301,6 +301,8 @@ abstract class Tree {
if ($nolimit)
@set_time_limit($_SESSION[APPCONFIG]->getValue('search','time_limit'));
$this->entries[$dnlower]->readingChildren(true);
foreach ($ldap['children'] as $child) {
if (DEBUG_ENABLED)
debug_log('Adding (%s)',64,0,__FILE__,__LINE__,__METHOD__,$child);
@ -309,6 +311,8 @@ abstract class Tree {
$this->entries[$dnlower]->addChild($child);
}
$this->entries[$dnlower]->readingChildren(false);
if (count($this->entries[$dnlower]->getChildren()) == $ldap['child_limit'])
$this->entries[$dnlower]->setSizeLimited();
else

View File

@ -33,6 +33,10 @@ class TreeItem {
private $size_limited = true;
# Last template used to edit this entry
private $template = null;
# Do we need to sort the children
private $childsort = true;
# Are we reading the children
private $reading_children = false;
public function __construct($server_id,$dn) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
@ -115,9 +119,38 @@ class TreeItem {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->children);
if ($this->childsort && ! $this->reading_children) {
usort($this->children,'pla_compare_dns');
$this->childsort = false;
}
return $this->children;
}
public function readingChildren($bool) {
$this->reading_children = $bool;
}
/**
* Do the children require resorting
*/
public function isChildSorted() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->childsort);
return $this->childsort;
}
/**
* Mark the children as sorted
*/
public function childSorted() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs);
$this->childsort = false;
}
/**
* Add a child to this DN entry.
*
@ -131,6 +164,7 @@ class TreeItem {
return;
array_push($this->children,$dn);
$this->childsort = true;
}
/**