[name, description, type] array
// to avoid these tasks be done several times. Skipping for the moment.
#'dc' => 'plugins/departments/images/domain.png',
#'dc' => 'plugins/departments/images/dc.png',
#'l' => 'plugins/departments/images/locality.png',
#'c' => 'plugins/departments/images/country.png',
#'o' => 'plugins/departments/images/organization.png',
#'ou' => 'plugins/departments/images/folder.png',
function __construct($bases, $base= "")
{
$this->setBases($bases);
$this->setBase($base);
}
function setBase($base)
{
if (isset($this->pathMapping[$base])) {
$this->base= $base;
} else {
die("Invalid base selected");
}
}
function setBases($bases)
{
global $config;
$this->pathMapping= array();
$selected= $this->base == $config->current['BASE']?"Selected":"";
$this->tree= "
"._("Root")."\n";
$first= true;
$last_indent= 2;
foreach ($bases as $base => $dummy) {
// Build path style display
$elements= explode(',', substr($base, 0, strlen($base) - strlen($config->current['BASE'])));
$elements= array_reverse($elements, true);
$this->pathMapping[$base]= $base == $config->current['BASE']? '/' : ldap::fix(preg_replace('/(^|,)[a-z0-9]+=/i', '/', implode(',', $elements)));
// Skip root for tree
if ($base == $config->current['BASE']) {
continue;
}
$indent= count($elements);
if (!$first && ($indent == $last_indent)) {
$this->tree.= "\n";
}
if ($indent > $last_indent) {
$this->tree.= "\n";
}
if ($indent < $last_indent) {
for ($i= 0; $i < ($last_indent-$indent); $i++) {
$this->tree.= "
\n";
}
$this->tree.= "\n";
}
$selected= $this->base == $base?" class='treeListSelected'":"";
$this->tree.= "- ".ldap::fix(preg_replace('/^[a-z0-9]+=([^,]+),.*$/i', '$1', $base))."";
$last_indent= $indent;
$first= false;
}
// Close tree
for ($i= 0; $i<$last_indent; $i++) {
$this->tree.= "
\n";
}
$this->tree.= "
\n";
echo $this->tree;
// Save bases to session for autocompletion
session::global_set('pathMapping', $this->pathMapping);
}
function render()
{
$result= "";
return $result;
}
function update()
{
echo "update";
}
function getBase()
{
return $this->base;
}
function getAction()
{
// Do not do anything if this is not our PID, or there's even no PID available...
#if(!isset($_REQUEST['PID']) || $_REQUEST['PID'] != $this->pid) {
# return;
#}
}
}
?>