/** * Add an entry in the tree view ; the entry is added in the * children array of its parent * * @param dn DN to add * @param string $dn the dn of the entry to create */ public function addEntry($dn) { if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); } $server = $this->getServer(); $dnlower = $this->indexDN($dn); # @todo Temporarily removed, some non-ascii char DNs that do exist, fail here for some reason? #if (! ($server->dnExists($dn))) # return; if (isset($this->entries[$dnlower])) { debug_dump_backtrace('Calling add entry to an entry that ALREADY exists?', 1); } if (DEBUG_ENABLED) { debug_log('New ENTRY (%s).', 64, 0, __FILE__, __LINE__, __METHOD__, $dn); } $tree_factory = new TreeItem($server->getIndex(), $dn); $tree_factory->setObjectClasses($server->getDNAttrValue($dn, 'objectClass')); if (($isleaf = $server->getDNAttrValue($dn, 'hassubordinates')) && !strcasecmp($isleaf[0], 'false')) { $tree_factory->setLeaf(); } $this->entries[$dnlower] = $tree_factory; # Is this entry in a base entry? if (in_array_ignore_case($dn, $server->getBaseDN(null))) { $this->entries[$dnlower]->setBase(); # If the parent entry is not in the tree, we add it. This routine will in itself # recall this method until we get to the top of the tree (the base). } else { $parent_dn = $server->getContainer($dn); if (DEBUG_ENABLED) { debug_log('Parent DNs (%s)', 64, 0, __FILE__, __LINE__, __METHOD__, $parent_dn); } if ($parent_dn) { $parent_entry = $this->getEntry($parent_dn); if (!$parent_entry) { $this->addEntry($parent_dn); $parent_entry = $this->getEntry($parent_dn); } # Update this DN's parent's children list as well. $parent_entry->addChild($dn); } } }