From 9013e4ad731bf13ffbcaf00c8dd1bbded9d6ae80 Mon Sep 17 00:00:00 2001 From: defacer Date: Sun, 13 Nov 2005 04:42:21 +0000 Subject: [PATCH] Now get_sql_sort can be called static-function-imitation style as well. Necessary to solve SC#187 gracefully. --- lib/tablelib.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/tablelib.php b/lib/tablelib.php index fdbdbc549f6..968bda510b7 100644 --- a/lib/tablelib.php +++ b/lib/tablelib.php @@ -287,13 +287,26 @@ class flexible_table { $this->setup = true; } - function get_sql_sort() { - if(!$this->setup) { - return false; + function get_sql_sort($uniqueid = NULL) { + if($uniqueid === NULL) { + // "Non-static" function call + if(!$this->setup) { + return false; + } + $sess = &$this->sess; } - if(!empty($this->sess->sortby)) { + else { + // "Static" function call + global $SESSION; + if(empty($SESSION->flextable[$uniqueid])) { + return ''; + } + $sess = &$SESSION->flextable[$uniqueid]; + } + + if(!empty($sess->sortby)) { $sortstring = ''; - foreach($this->sess->sortby as $column => $order) { + foreach($sess->sortby as $column => $order) { if(!empty($sortstring)) { $sortstring .= ', '; }