Code

Height configuration
[gosa.git] / gosa-core / include / class_listing.inc
index 4fdc6e2cc88fd12ea7e5b3c8a5c0ffd608e6996c..911c904f06dc254c12121b74081c25d0b17e3bc8 100644 (file)
@@ -49,6 +49,8 @@ class listing {
   var $snapshotHandler= null;
   var $exporter= array();
   var $exportColumns= array();
+  var $useSpan= false;
+  var $height= 0;
 
 
   function listing($filename)
@@ -64,11 +66,15 @@ class listing {
     }
 
     // Set base for filter
-    $this->base= session::global_get("CurrentMainBase");
-    if ($this->base == null) {
+    if ($this->baseMode) {
+      $this->base= session::global_get("CurrentMainBase");
+      if ($this->base == null) {
+        $this->base= $config->current['BASE'];
+      }
+      $this->refreshBasesList();
+    } else {
       $this->base= $config->current['BASE'];
     }
-    $this->refreshBasesList();
 
     // Move footer information
     $this->showFooter= ($config->get_cfg_value("listSummary") == "true");
@@ -97,6 +103,12 @@ class listing {
   }
 
 
+  function setHeight($height)
+  {
+    $this->height= $height;
+  }
+
+
   function setSnapshotHandler($handler)
   {
     $this->snapshotHandler= &$handler;
@@ -110,7 +122,6 @@ class listing {
       $this->departments= $this->getDepartments();
     }
     $this->filter->setBase($this->base);
-    $this->entries= $this->filter->query();
   }
 
 
@@ -253,8 +264,14 @@ class listing {
 
     // Initialize list
     $result= "<input type='hidden' value='$this->pid' name='PID'>\n";
+    $height= 450;
+    if ($this->height != 0) {
+      $result= "<input type='hidden' value='$this->height' id='d_height'>\n";
+      $height= $this->height;
+    }
+    
     $result.= "<div class='contentboxb' id='listing_container' style='border-top:1px solid #B0B0B0;'>\n";
-    $result.= "<table summary='$this->headline' style='width:600px;height:450px;' cellspacing='0' id='t_scrolltable'>
+    $result.= "<table summary='$this->headline' style='width:600px;height:".$height."px;' cellspacing='0' id='t_scrolltable'>
 <tr><td class='scrollhead'><table summary='' style='width:100%;' cellspacing='0' id='t_scrollhead'>\n";
     $this->numColumns= count($this->colprops) + ($this->multiSelect?1:0);
 
@@ -271,7 +288,7 @@ class listing {
     $result.= "<td class='listheader' style='width:13px;border-right:0px;'>&nbsp;</td></table></td></tr>\n";
 
     // New table for the real list contents
-    $result.= "<tr><td colspan='$this->numColumns' class='scrollbody'><div style='width:600px;height:430px;' id='d_scrollbody' class='scrollbody'><table summary='' style='height:100%;width:581px;' cellspacing='0' id='t_scrollbody'>\n";
+    $result.= "<tr><td colspan='$this->numColumns' class='scrollbody'><div style='width:600px;height:".($height-20)."px;' id='d_scrollbody' class='scrollbody'><table summary='' style='height:100%;width:581px;' cellspacing='0' id='t_scrollbody'>\n";
 
     // No results? Just take an empty colspanned row
     if (count($this->entries) + count($this->departments) == 0) {
@@ -283,6 +300,7 @@ class listing {
     $deps= 0;
 
     // Draw department browser if configured and we're not in sub mode
+    $this->useSpan= false;
     if ($this->departmentBrowser && $this->filter->scope != "sub") {
       // Fill with department browser if configured this way
       $departmentIterator= new departmentSortIterator($this->departments, $this->sortDirection[$this->sortColumn]);
@@ -300,6 +318,7 @@ class listing {
           $colspan= 1;
           if (isset($config['span'])){
             $colspan= $config['span'];
+            $this->useSpan= true;
           }
           $result.="<td colspan='$colspan' ".$this->colprops[$index]." class='list1'>".$this->renderCell($config['value'], $entry, $row)."</td>";
           $rest-= $colspan;
@@ -353,7 +372,7 @@ class listing {
     }
 
     // Need to fill the list if it's not full (nobody knows why this is 22 ;-))
-    $emptyListStyle= (count($this->entries) + $deps == 0)?"border:0;":"";
+    $emptyListStyle= (count($this->entries) + (($this->useSpan && count($this->entries))?$deps:0) == 0)?"border:0;":"";
     if ((count($this->entries) + $deps) < 22) {
       $result.= "<tr>";
       for ($i= 0; $i<$this->numColumns; $i++) {
@@ -427,7 +446,7 @@ class listing {
     }
 
     // Save base
-    if (isset($_POST['BASE']) && $this->baseMode == true) {
+    if (isset($_POST['BASE']) && $this->baseMode) {
       $base= validate($_POST['BASE']);
       if (isset($this->bases[$base])) {
         $this->base= $base;
@@ -590,6 +609,10 @@ class listing {
 
   function renderBase()
   {
+    if (!$this->baseMode) {
+      return;
+    }
+
     $result= "<select name='BASE' onChange='mainform.submit()' size='1'>";
     $firstDN= null;
     $found= false;
@@ -894,8 +917,8 @@ class listing {
 
   function getAction()
   {
-    // Do not do anything if this is not our PID
-    if(isset($_REQUEST['PID']) && $_REQUEST['PID'] != $this->pid) {
+    // 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;
     }
 
@@ -1160,7 +1183,7 @@ class listing {
       $attrs[]= $data['ATTR'];
     }
     $filter.= "))";
-    $res= get_list($filter, $this->module, $this->base, $attrs, GL_NONE | GL_SIZELIMIT);
+    $res= get_list($filter, $this->module, $this->base, $attrs, GL_NONE);
 
     // Analyze list of departments
     foreach ($res as $department) {