config = $config; $this->ui = get_userinfo(); $this->allowedBases = $onlyAllowThisBases; session::set('filterBaseSelect_WhiteList', $this->allowedBases); # // Build filter # if (session::global_is_set(get_class($this)."_filter")){ # $filter= session::global_get(get_class($this)."_filter"); # } else { $filter = new filter(get_template_path("baseSelect-filter.xml")); # } $this->setFilter($filter); // Build headpage $headpage = new listing(get_template_path("baseSelect-list.xml")); $headpage->registerElementFilter("depLabel", "baseSelectDialog::filterDepLabel"); $headpage->setFilter($filter); $this->registerAction("open","openEntry"); $this->registerAction("cancelBaseSelect","cancelBaseSelect"); parent::__construct($config, $this->ui, "departments", $headpage); } // An action handler which enables to switch into deparmtment by clicking the names. function openEntry($action,$entry) { $headpage = $this->getHeadpage(); $headpage->setBase(array_pop($entry)); } function execute() { $str = management::execute(); $str.= "

 

"; return($str); } // A filter which allows to open a department by clicking on the departments name. static function filterDepLabel($row,$dn,$params,$ou,$pid,$base) { $ou = $ou[0]; if($dn == $base){ $ou ="."; } $dn= LDAP::fix(func_get_arg(1)); return("$ou"); } function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") { if(count($target) == 1){ $this->BaseToUse = array_pop($target); } } function save_object() { // Damn ... , we've to call post detection manually & thus twice ... // #FIXME - We should fix the class handling in the plugins to match the class_management style. // - save_object isn't needed anymore, just call execute... $this->handleActions($this->detectPostActions()); } function isClosed() { return($this->dialogClose); } function isSelected() { return($this->BaseToUse); } function setCurrentBase($base) { $headpage = $this->getHeadpage(); $headpage->setBase = $base; } function cancelBaseSelect() { $this->dialogClose = TRUE; } function detectPostActions() { $action = management::detectPostActions(); if(isset($_POST['cancelBaseSelect'])) $action['action'] = "cancelBaseSelect"; return($action); } } class filterBaseSelect extends filterLDAP { static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "") { $res= filterLDAP::query($base, $scope, $filter, $attributes, $category, $objectStorage); return(filterBaseSelect::filterEntries($res)); } static function filterEntries($res) { if(!session::is_set('filterBaseSelect_WhiteList')) return $res; $list = session::get('filterBaseSelect_WhiteList'); foreach($res as $key => $entry){ if(!isset($list[$entry['dn']])) unset($res[$key]); } return(array_values($res)); } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>