- Bugfix: fixed SQL errors with tablesort when 'order' is invalid.

Patch by Kjartan.  Fixes bug #2613.
4.3.x
Dries Buytaert 2003-10-27 21:45:55 +00:00
parent 43ba8cf99c
commit 7b0ddafc38
1 changed files with 16 additions and 12 deletions

View File

@ -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'];
}
}