Code

Added simple paging to gosa deamon
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 24 Jan 2008 08:35:26 +0000 (08:35 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 24 Jan 2008 08:35:26 +0000 (08:35 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8580 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/addons/gotomasses/class_gotomasses.inc

index 4225b18f70d7bd11c6f0703240c84eac1f8238b2..0bafd52128f86e728e4457bc0acdd62a552608f5 100644 (file)
@@ -19,6 +19,9 @@ class gotomasses extends plugin
   var $sort_by  = "QueuePosition";
   var $sort_dir = "up";
 
+  var $range    = 25;
+  var $start    = 0;
+
   function gotomasses(&$config, $dn= NULL)
   {
     /* Include config object */
@@ -207,7 +210,21 @@ class gotomasses extends plugin
     $this->divlist->execute();
     $entries = $this->get_queued_entries();
     $this->divlist->SetEntries($entries);
-    return($this->divlist->Draw());
+
+
+    $smarty = get_smarty();
+    $smarty->assign("start",$this->start);
+    $smarty->assign("start_real", ($this->start + 1));
+    $smarty->assign("ranges", array("10" => "10",
+                                    "20" => "20",
+                                    "25" => "25",
+                                    "50" => "50",
+                                    "100"=> "100",
+                                    "200"=> "200",
+                                    "9999" => "*"));
+    $smarty->assign("range",$this->range);
+    $smarty->assign("div",$this->divlist->Draw());
+    return($smarty->fetch (get_template_path('gotomasses.tpl', TRUE, dirname(__FILE__))));
   }
 
 
@@ -257,7 +274,11 @@ class gotomasses extends plugin
   function get_queued_entries()
   {
     
-    $entries = $this->o_queue->get_queued_entries();
+
+    $start  = $this->range * $this->start; 
+    $stop   = $start + $this->range; 
+    
+    $entries = $this->o_queue->get_queued_entries($start,$stop);
 
     if(!is_array($entries)){
       msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "<br><br>".$this->o_queue->get_error()), ERROR_DIALOG);
@@ -308,6 +329,18 @@ class gotomasses extends plugin
       }
       $this->sort_by = $sort;
     }
+    if(isset($_POST['range']) && is_numeric($_POST['range'])){
+      $this->range = $_POST['range'];
+    }
+    if(isset($_POST['next_page'])){
+      $this->start ++;
+    }
+    if(isset($_POST['last_page'])){
+      $this->start --;
+      if($this->start < 0 ){
+        $this->start = 0;
+      }
+    }
   }