Use filter->sort_asc and sort_field which will use either the value specified in query, or defaults set in system. url params order and sort will override.

This commit is contained in:
Isaac Connor 2021-10-25 12:34:28 -04:00
parent 48494a22db
commit d03365c9e7
1 changed files with 20 additions and 9 deletions

View File

@ -6,16 +6,18 @@ $data = array();
// INITIALIZE AND CHECK SANITY // INITIALIZE AND CHECK SANITY
// //
if ( !canView('Events') ) $message = 'Insufficient permissions for user '.$user['Username']; if (!canView('Events'))
$message = 'Insufficient permissions for user '.$user['Username'].'<br/>';
if (empty($_REQUEST['task'])) { if (empty($_REQUEST['task'])) {
$message = 'Must specify a task'; $message = 'Must specify a task<br/>';
} else { } else {
$task = $_REQUEST['task']; $task = $_REQUEST['task'];
} }
if (empty($_REQUEST['eids'])) { if (empty($_REQUEST['eids'])) {
if ( isset($_REQUEST['task']) && $_REQUEST['task'] != 'query' ) $message = 'No event id(s) supplied'; if (isset($_REQUEST['task']) && $_REQUEST['task'] != 'query')
$message = 'No event id(s) supplied<br/>';
} else { } else {
$eids = $_REQUEST['eids']; $eids = $_REQUEST['eids'];
} }
@ -39,10 +41,19 @@ $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
$advsearch = isset($_REQUEST['advsearch']) ? json_decode($_REQUEST['advsearch'], JSON_OBJECT_AS_ARRAY) : array(); $advsearch = isset($_REQUEST['advsearch']) ? json_decode($_REQUEST['advsearch'], JSON_OBJECT_AS_ARRAY) : array();
// Order specifies the sort direction, either asc or desc // Order specifies the sort direction, either asc or desc
$order = (isset($_REQUEST['order']) and (strtolower($_REQUEST['order']) == 'asc')) ? 'ASC' : 'DESC'; $order = $filter->sort_asc() ? 'ASC' : 'DESC';
if (isset($_REQUEST['order'])) {
if (strtolower($_REQUEST['order']) == 'asc')) {
$order = 'ASC';
} else if (strtolower($_REQUEST['order']) == 'desc')) {
$order = 'DESC';
} else {
Warning("Invalid value for order " . $_REQUEST['order']);
}
}
// Sort specifies the name of the column to sort on // Sort specifies the name of the column to sort on
$sort = 'StartDateTime'; $sort = $filter->sort_field();
if (isset($_REQUEST['sort'])) { if (isset($_REQUEST['sort'])) {
$sort = $_REQUEST['sort']; $sort = $_REQUEST['sort'];
if ($sort == 'EndDateTime') { if ($sort == 'EndDateTime') {