Commit 7b0ddafc authored by Dries's avatar Dries

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

  Patch by Kjartan.  Fixes bug #2613.
parent 43ba8cf9
......@@ -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'];
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment