@[deleted] - Although I really only thought to offer this as a port of fidel's Next/prev ticket button mod to v1.7, I suppose I shouldn't use that as an excuse - ultimately, I'd also rather see these buttons reflect the ordering of the tickets in the listed tickets page. It's probably going to come down to whimsy and/or high demand, though, as the solution would most likely involve duplicating a lot of the sorting code in scp/tickets.php.
In any case, if you're keen to customise this mod to your own designs, you can just drop those SQL queries (or similar, as long as they return a valid ticket ID) into the getPrevId and getNextId functions; i.e.:
+ function getPrevId(&$user) {
+
+ $sql='SELECT ticket_id, '.
+ 'IF(ost_ticket.reopened is NULL, '.
+ 'IF(ost_ticket.lastmessage is NULL, '.
+ 'ost_ticket.created, '.
+ 'ost_ticket.lastmessage), '.
+ 'ost_ticket.reopened) '.
+ 'AS effective_date '.
+ 'FROM ost_ticket '.
+ 'WHERE '.
+ 'IF(ost_ticket.reopened is NULL, '.
+ 'IF(ost_ticket.lastmessage is NULL, '.
+ 'ost_ticket.created, '.
+ 'ost_ticket.lastmessage), '.
+ 'ost_ticket.reopened) '.
+ '< ( '.
+ 'SELECT IF(ost_ticket.reopened is NULL, '.
+ 'IF(ost_ticket.lastmessage is NULL, '.
+ 'ost_ticket.created, '.
+ 'ost_ticket.lastmessage), '.
+ 'ost_ticket.reopened) '.
+ 'FROM ost_ticket '.
+ 'WHERE ticket_id = '.$this->getId().' '.
+ ')'.
+ 'AND status = \''.$this->getStatus().'\' '.
+ 'ORDER BY effective_date DESC LIMIT 1';
+
+ $prev = 0;
+ if (($res=db_query($sql)) && db_num_rows($res)) {
+ list($id)=db_fetch_row($res);
+ $prev = $id;
+ }
+ return $prev;
+ }
+
+ function getNextId(&$user) {
+
+ $sql='SELECT ticket_id, '.
+ 'IF(ost_ticket.reopened is NULL, '.
+ 'IF(ost_ticket.lastmessage is NULL, '.
+ 'ost_ticket.created, '.
+ 'ost_ticket.lastmessage), '.
+ 'ost_ticket.reopened) '.
+ 'AS effective_date '.
+ 'FROM ost_ticket '.
+ 'WHERE '.
+ 'IF(ost_ticket.reopened is NULL, '.
+ 'IF(ost_ticket.lastmessage is NULL, '.
+ 'ost_ticket.created, '.
+ 'ost_ticket.lastmessage), '.
+ 'ost_ticket.reopened) '.
+ '> ( '.
+ 'SELECT IF(ost_ticket.reopened is NULL, '.
+ 'IF(ost_ticket.lastmessage is NULL, '.
+ 'ost_ticket.created, '.
+ 'ost_ticket.lastmessage), '.
+ 'ost_ticket.reopened) '.
+ 'FROM ost_ticket '.
+ 'WHERE ticket_id = '.$this->getId().' '.
+ ')'.
+ 'AND status = \''.$this->getStatus().'\' '.
+ 'ORDER BY effective_date ASC LIMIT 1';
+
+ $next = 0;
+ if (($res=db_query($sql)) && db_num_rows($res)) {
+ list($id)=db_fetch_row($res);
+ $next = $id;
+ }
+ return $next;
+ }