From 7cf3e98090a3e9f0a9cc960d07c5f259adab6a19 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Thu, 14 Nov 2013 08:39:08 -0500
Subject: [PATCH] Merge remote-tracking branch 'origin/stable-3.0.5'

---
 interface/lib/classes/listform_actions.inc.php |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/interface/lib/classes/listform_actions.inc.php b/interface/lib/classes/listform_actions.inc.php
index acb0b96..fe167a9 100644
--- a/interface/lib/classes/listform_actions.inc.php
+++ b/interface/lib/classes/listform_actions.inc.php
@@ -125,8 +125,10 @@
 		  }
 		}
 		
+		if($_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order_in_php']) $php_sort = true;
+		
 		// Getting Datasets from DB
-		$records = $app->db->queryAllRecords($this->getQueryString());
+		$records = $app->db->queryAllRecords($this->getQueryString($php_sort));
 
 		$this->DataRowColor = "#FFFFFF";
 		$records_new = '';
@@ -147,6 +149,9 @@
             $this->sortKeys = array($order_by => $order_dir);
             uasort($records_new, array($this, '_sort'));
         }
+        if($php_sort) {
+			$records_new = array_slice($records_new, $app->listform->getPagingValue('offset'), $app->listform->getPagingValue('records_per_page'));
+		}
         
 		$app->tpl->setLoop('records',$records_new);
 
@@ -185,7 +190,7 @@
 		return $rec;
 	}
 	
-	public function getQueryString() {
+	public function getQueryString($no_limit = false) {
 		global $app;
 		$sql_where = '';
 
@@ -231,7 +236,8 @@
 		}
 		$select = implode(', ', $table_selects);
 
-		$sql = 'SELECT '.$select.$extselect.' FROM '.$app->listform->listDef['table'].($app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')."$join WHERE $sql_where $order_by_sql $limit_sql";
+		$sql = 'SELECT '.$select.$extselect.' FROM '.$app->listform->listDef['table'].($app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')."$join WHERE $sql_where $order_by_sql";
+		if($no_limit == false) $sql .= " $limit_sql";
 		//echo $sql;
 		return $sql;
 	}

--
Gitblit v1.9.1