Skip to content
Snippets Groups Projects
Commit b8652e25 authored by Jared Hancock's avatar Jared Hancock
Browse files

search: Properly pagenate search results

Also re-implement the "exclude answered tickets" and "exclude assigned
tickets" from open queue options.
parent 8f9ad9b4
Branches
Tags
No related merge requests found
...@@ -1637,7 +1637,7 @@ class MySqlCompiler extends SqlCompiler { ...@@ -1637,7 +1637,7 @@ class MySqlCompiler extends SqlCompiler {
* (string) token to be placed into the compiled SQL statement. For * (string) token to be placed into the compiled SQL statement. For
* MySQL, this is always the string '?'. * MySQL, this is always the string '?'.
*/ */
function input(&$what, $slot=false) { function input($what, $slot=false) {
if ($what instanceof QuerySet) { if ($what instanceof QuerySet) {
$q = $what->getQuery(array('nosort'=>true)); $q = $what->getQuery(array('nosort'=>true));
$this->params = array_merge($q->params); $this->params = array_merge($q->params);
...@@ -2066,7 +2066,12 @@ class MysqlExecutor { ...@@ -2066,7 +2066,12 @@ class MysqlExecutor {
} }
function __toString() { function __toString() {
return $this->sql; $self = $this;
$x = 0;
return preg_replace_callback('/\?/', function($m) use ($self, &$x) {
$p = $self->params[$x++];
return db_real_escape($p, is_string($p));
}, $this->sql);
} }
} }
......
...@@ -127,5 +127,9 @@ class PageNate { ...@@ -127,5 +127,9 @@ class PageNate {
return $html; return $html;
} }
function paginate(QuerySet $qs) {
return $qs->limit($this->getLimit())->offset($this->getStart());
}
} }
?> ?>
...@@ -366,7 +366,7 @@ implements AuthenticatedUser { ...@@ -366,7 +366,7 @@ implements AuthenticatedUser {
} }
function showAssignedTickets() { function showAssignedTickets() {
return $this->group->show_assigned_tickets; return $this->show_assigned_tickets;
} }
function getTeams() { function getTeams() {
......
...@@ -42,7 +42,10 @@ default: ...@@ -42,7 +42,10 @@ default:
case 'open': case 'open':
$status='open'; $status='open';
$results_type=__('Open Tickets'); $results_type=__('Open Tickets');
$tickets->filter(array('isanswered'=>0)); if (!$cfg->showAnsweredTickets())
$tickets->filter(array('isanswered'=>0));
if (!$cfg || !($cfg->showAssignedTickets() || $thisstaff->showAssignedTickets()))
$tickets->filter(array('staff_id'=>0));
break; break;
} }
...@@ -78,6 +81,7 @@ $tickets->select_related('lock', 'dept', 'staff', 'user', 'user__default_email', ...@@ -78,6 +81,7 @@ $tickets->select_related('lock', 'dept', 'staff', 'user', 'user__default_email',
$pagelimit=($_GET['limit'] && is_numeric($_GET['limit']))?$_GET['limit']:PAGE_LIMIT; $pagelimit=($_GET['limit'] && is_numeric($_GET['limit']))?$_GET['limit']:PAGE_LIMIT;
$page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1;
$pageNav=new Pagenate($tickets->count(), $page,$pagelimit); $pageNav=new Pagenate($tickets->count(), $page,$pagelimit);
$tickets = $pageNav->paginate($tickets);
TicketForm::ensureDynamicDataView(); TicketForm::ensureDynamicDataView();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment