From: cajus Date: Fri, 14 Aug 2009 14:52:27 +0000 (+0000) Subject: Added base display to lists. Make it react on bases. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=36e8a84484462148d973b3aac6b7c95af5571626;p=gosa.git Added base display to lists. Make it react on bases. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14069 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_filter.inc b/gosa-core/include/class_filter.inc index e1b16a58b..3dca983e0 100644 --- a/gosa-core/include/class_filter.inc +++ b/gosa-core/include/class_filter.inc @@ -11,17 +11,18 @@ class filter { var $objectStorage= array(); var $objectBase= ""; var $base= ""; - var $bases= array(); var $scope= ""; var $query; var $initial= false; - var $baseMode= false; var $scopeMode= "auto"; var $alphabet= null; function filter($filename) { + global $config; + + // Load eventually passed filename if (!$this->load($filename)) { die("Cannot parse $filename!"); } @@ -47,7 +48,6 @@ class filter { // Move information $entry= $this->xmlData['search']; - $this->baseMode= $entry['base']; $this->scopeMode= $entry['scope']; if ($entry['scope'] == "auto") { $this->scope= "one"; @@ -199,11 +199,6 @@ class filter { } - function setBases($bases) { - $this->bases= $bases; - } - - function setObjectStorage($storage) { $this->objectStorage= $storage; } @@ -214,7 +209,7 @@ class filter { } - function setCurrentBase($base) { + function setBase($base) { $this->base= $base; } @@ -224,23 +219,6 @@ class filter { } - function renderBase() - { - $result= ""; - - return $result; - } - - function renderAlphabet($columns= 10) { // Return pre-rendered alphabet if available @@ -299,7 +277,6 @@ class filter { $smarty->assign("ALPHABET", $this->renderAlphabet()); $smarty->assign("APPLY", $this->renderApply()); $smarty->assign("SCOPE", $this->renderScope()); - $smarty->assign("BASE", $this->renderBase()); // Load template and replace elementsHtml[] foreach ($this->elements as $tag => $element) { @@ -414,14 +391,6 @@ class filter { } } - // Save base - if (isset($_POST['BASE']) && $this->baseMode == "true") { - $base= validate($_POST['BASE']); - if (isset($this->bases[$base])) { - $this->base= $base; - } - } - // Save scope if needed if ($this->scopeMode == "auto") { $this->scope= isset($_POST['SCOPE'])?"sub":"one"; @@ -494,6 +463,7 @@ class filter { } } + } ?> diff --git a/gosa-core/include/class_listing.inc b/gosa-core/include/class_listing.inc index 217adbf40..0e34c9c17 100644 --- a/gosa-core/include/class_listing.inc +++ b/gosa-core/include/class_listing.inc @@ -4,12 +4,16 @@ class listing { var $xmlData; var $entries; + var $departments= array(); var $departmentBrowser= false; var $departmentRootVisible= false; var $multiSelect= false; var $template; var $headline; var $module; + var $base; + var $baseMode= false; + var $bases= array(); var $header= array(); var $colprops= array(); var $filters= array(); @@ -26,6 +30,13 @@ class listing { die("Cannot parse $filename!"); } + // Set base for filter + $this->base= session::global_get("CurrentMainBase"); + if ($this->base == null) { + $this->base= $config->current['BASE']; + } + $this->refreshBasesList(); + // Move footer information $this->showFooter= ($config->get_cfg_value("listSummary") == "true"); @@ -62,7 +73,7 @@ class listing { $this->xmlData= $this->xmlData["list"]; // Load some definition values - foreach (array("departmentBrowser", "departmentRootVisible", "multiSelect") as $token) { + foreach (array("departmentBrowser", "departmentRootVisible", "multiSelect", "baseMode") as $token) { if (isset($this->xmlData['definition'][$token]) && $this->xmlData['definition'][$token] == "true"){ $this->$token= true; @@ -101,7 +112,7 @@ class listing { function render() { -echo "sorting, department browsing, filter base handling, copy'n paste handler, snapshot handler
"; +echo "sorting, department browsing, copypaste handler, snapshot handler, daemon handler
"; // Initialize list $result= ""; @@ -126,10 +137,13 @@ echo "sorting, department browsing, filter base handling, copy'n paste handler, $result.= "
"; // No results? Just take an empty colspanned row - if (count($this->entries) == 0) { + if (count($this->entries) + count($this->departments) == 0) { $result.= ""; } + // Fill with department browser if configured this way +############### + // Fill with contents foreach ($this->entries as $row => $entry){ $result.=""; @@ -191,8 +205,9 @@ echo "sorting, department browsing, filter base handling, copy'n paste handler, $smarty->assign($key, $html); } - // Assign action menu + // Assign action menu / base $smarty->assign("ACTIONS", $this->renderActionMenu()); + $smarty->assign("BASE", $this->renderBase()); // Assign separator $smarty->assign("SEPARATOR", "-"); @@ -207,6 +222,10 @@ echo "sorting, department browsing, filter base handling, copy'n paste handler, function setFilter($filter) { $this->filter= &$filter; + if ($this->departmentBrowser){ + # $this->departments= $this->filter->getDepartments(); + } + $this->filter->setBase($this->base); $this->entries= $this->filter->query(); } @@ -219,6 +238,19 @@ echo "sorting, department browsing, filter base handling, copy'n paste handler, # return; #} + if ($this->departmentBrowser){ + # $this->departments= $this->filter->getDepartments(); + } + + // Save base + if (isset($_POST['BASE']) && $this->baseMode == true) { + $base= validate($_POST['BASE']); + if (isset($this->bases[$base])) { + $this->base= $base; + } + } + + $this->filter->setBase($this->base); $this->entries= $this->filter->query(); } @@ -283,6 +315,38 @@ echo "sorting, department browsing, filter base handling, copy'n paste handler, } + function renderBase() + { + $result= ""; + + // Reset the currently used base to the first DN we found if there + // was no match. + if(!$found){ + $this->base = $firstDN; + } + + return $result; + } + + function processElementFilter($data, $config, $row) { preg_match_all("/%\{filter:([^(]+)\((.*)\)\}/", $data, $matches, PREG_SET_ORDER); @@ -767,6 +831,26 @@ echo "sorting, department browsing, filter base handling, copy'n paste handler, return true; } + + function refreshBasesList() + { + global $config; + $ui= get_userinfo(); + + // Do some array munching to get it user friendly + $ids= $config->idepartments; + $d= $ui->get_module_departments($this->module); + $k_ids= array_keys($ids); + $deps= array_intersect($d,$k_ids); + + // Fill internal bases list + $this->bases= array(); + foreach($k_ids as $department){ + $this->bases[$department] = $ids[$department]; + } + } + + } ?>