diff --git a/include/class.search.php b/include/class.search.php index c89234029c212965d5059d628b3aa7f144507d59..908bb7fa8cc39716b7aba54a5d20558a09b5c7c7 100644 --- a/include/class.search.php +++ b/include/class.search.php @@ -905,7 +905,8 @@ class SavedSearch extends VerySimpleModel { ->filter(array('form__type' => 'G')) ->select_related('form'); foreach ($dfs as $field) { - $otherFields[$field->getId()] = array($field->form, $field); + $otherFields[$field->getId()] = array($field->form, + $field->getImpl()); } } foreach ($otherFields as $id=>$F) { @@ -1154,24 +1155,20 @@ class SavedSearch extends VerySimpleModel { // Ensure the special join is created to support custom data joins $name = @static::getOrmPath($name, $qs); - $name2 = null; if (preg_match('/__answers!\d+__/', $name)) { - // Ensure that only one record is returned from the join through - // the entry and answers joins - $name2 = $this->getAnnotationName().'2'; - $query->annotate(array($name2 => SqlAggregate::MAX($name))); + $qs->annotate(array($name2 => SqlAggregate::MAX($name))); } // Fetch a criteria Q for the query if (list(,$field) = $searchable[$name]) - if ($q = $field->getSearchQ($method, $value, $name2 ?: $name)) + if ($q = $field->getSearchQ($method, $value, $name)) $qs = $qs->filter($q); } } return $qs; } - function getOrmPath($name, $query=null) { + static function getOrmPath($name, $query=null) { // Special case for custom data `__answers!id__value`. Only add the // join and constraint on the query the first pass, when the query // being mangled is received. diff --git a/include/staff/templates/queue-tickets.tmpl.php b/include/staff/templates/queue-tickets.tmpl.php index 57a136b888dcd9e3a3ed05862f3aa289355decf7..e0ed198175d900d8bc61036c7e2edb2d96f755cc 100644 --- a/include/staff/templates/queue-tickets.tmpl.php +++ b/include/staff/templates/queue-tickets.tmpl.php @@ -27,9 +27,9 @@ if (!$view_all_tickets) { } $page = ($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; +$count = count($tickets); $pageNav = new Pagenate($count, $page, PAGE_LIMIT); $pageNav->setURL('tickets.php', $args); -$count = count($tickets); $tickets = $pageNav->paginate($tickets); // Make sure the cdata materialized view is available