diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-10-27 21:45:55 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-10-27 21:45:55 +0000 |
commit | 7b0ddafc38e1ab3a01329d74521227cd12bf18eb (patch) | |
tree | 6f02dddfc2c8741cfdf5b098b55a3395de418466 /includes/tablesort.inc | |
parent | 43ba8cf99c88543485aab2df42b9dbabaad46be1 (diff) | |
download | brdo-7b0ddafc38e1ab3a01329d74521227cd12bf18eb.tar.gz brdo-7b0ddafc38e1ab3a01329d74521227cd12bf18eb.tar.bz2 |
- Bugfix: fixed SQL errors with tablesort when 'order' is invalid.
Patch by Kjartan. Fixes bug #2613.
Diffstat (limited to 'includes/tablesort.inc')
-rw-r--r-- | includes/tablesort.inc | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/includes/tablesort.inc b/includes/tablesort.inc index 44a0db948..0ba06f196 100644 --- a/includes/tablesort.inc +++ b/includes/tablesort.inc @@ -55,20 +55,24 @@ function tablesort_get_querystring() { } function tablesort_get_order($headers) { - if ($_GET['order'] != NULL) { - return $_GET['order']; + $order = $_GET['order']; + foreach ($headers as $header) { + if ($order == $header['data']) { + return $header['data']; + } + + if ($header['sort'] == 'asc' || $header['sort'] == 'desc') { + $default = $header['data']; + } + } + + if ($default) { + return $default; } else { - foreach ($headers as $header) { - if ($header["sort"] == 'asc' || $header["sort"] == 'desc') { - return $header["data"]; - } - elseif (!$first) { - // the first column specified is initial 'order by' field unless otherwise specified - $first = $header["data"]; - } - } - return $first; + // The first column specified is initial 'order by' field unless otherwise specified + $first = reset($header); + return $first['data']; } } |