with all columns and annotations necessary to // render the full page // Impose visibility constraints // ------------------------------------------------------------ //filter if limited visibility or if unlimited visibility and in a queue $ignoreVisibility = $queue->ignoreVisibilityConstraints($thisstaff); if (!$ignoreVisibility || //limited visibility ($ignoreVisibility && ($queue->isAQueue() || $queue->isASubQueue())) //unlimited visibility + not a search ) $tickets->filter($thisstaff->getTicketsVisibility()); // do not show children tickets unless agent is doing a search if ($queue->isAQueue() || $queue->isASubQueue()) $tickets->filter(Q::any( array('ticket_pid' => null, 'flags__hasbit' => TICKET::FLAG_LINKED))); // Make sure the cdata materialized view is available TicketForm::ensureDynamicDataView(); // Identify columns of output $columns = $queue->getColumns(); // Figure out REFRESH url — which might not be accurate after posting a // response list($path,) = explode('?', $_SERVER['REQUEST_URI'], 2); $args = array(); parse_str($_SERVER['QUERY_STRING'], $args); // Remove commands from query unset($args['id']); if ($args['a'] !== 'search') unset($args['a']); $refresh_url = $path . '?' . http_build_query($args); // Establish the selected or default sorting mechanism if (isset($_GET['sort']) && is_numeric($_GET['sort'])) { $sort = $_SESSION['sort'][$queue->getId()] = array( 'col' => (int) $_GET['sort'], 'dir' => (int) $_GET['dir'], ); } elseif (isset($_GET['sort']) // Drop the leading `qs-` && (strpos($_GET['sort'], 'qs-') === 0) && ($sort_id = substr($_GET['sort'], 3)) && is_numeric($sort_id) && ($sort = QueueSort::lookup($sort_id)) ) { $sort = $_SESSION['sort'][$queue->getId()] = array( 'queuesort' => $sort, 'dir' => (int) $_GET['dir'], ); } elseif (isset($_SESSION['sort'][$queue->getId()])) { $sort = $_SESSION['sort'][$queue->getId()]; } elseif ($queue_sort = $queue->getDefaultSort()) { $sort = $_SESSION['sort'][$queue->getId()] = array( 'queuesort' => $queue_sort, 'dir' => (int) $_GET['dir'] ?: 0, ); } // Handle current sorting preferences $sorted = false; foreach ($columns as $C) { // Sort by this column ? if (isset($sort['col']) && $sort['col'] == $C->id) { $tickets = $C->applySort($tickets, $sort['dir']); $sorted = true; } } // Apply queue sort if it's not already sorted by a column if (!$sorted) { // Apply queue sort-dropdown selected preference if (isset($sort['queuesort'])) $sort['queuesort']->applySort($tickets, $sort['dir']); else // otherwise sort by created DESC $tickets->order_by('-created'); } // Apply pagination $page = ($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; $pageNav = new Pagenate(PHP_INT_MAX, $page, PAGE_LIMIT); $tickets = $pageNav->paginateSimple($tickets); if (isset($tickets->extra['tables'])) { // Creative twist here. Create a new query copying the query criteria, sort, limit, // and offset. Then join this new query to the $tickets query and clear the // criteria, sort, limit, and offset from the outer query. $criteria = clone $tickets; $criteria->limit(500); $criteria->annotations = $criteria->related = $criteria->aggregated = $criteria->annotations = $criteria->ordering = []; $tickets->constraints = $tickets->extra = []; $criteria->extra(array('select' => array('relevance' => 'Z1.relevance'))); $tickets = $tickets->filter(['ticket_id__in' => $criteria->values_flat('ticket_id')]); $tickets->order_by(new SqlCode('relevance'), QuerySet::DESC); # Index hint should be used on the $criteria query only $tickets->clearOption(QuerySet::OPT_INDEX_HINT); } $tickets->distinct('ticket_id'); $Q = $queue->getBasicQuery(); if ($Q->constraints) { if (count($Q->constraints) > 1) { foreach ($Q->constraints as $value) { if (!$value->constraints) $empty = true; } } } if (($Q->extra && isset($Q->extra['tables'])) || !$Q->constraints || $empty) { $skipCount = true; $count = '-'; } $count = $count ?: $queue->getCount($thisstaff); $pageNav->setTotal($count, true); $pageNav->setURL('tickets.php', $args); ?>

getName(); ?> getSupplementalCriteria())) echo sprintf(' ', Format::htmlchars($queue->describeCriteria($crit))); ?>

  • id > 0 && $queue->isOwner($thisstaff)) { ?>
$status)); }?>
canManageTickets(); if ($canManageTickets) { ?> getLocalHeading()); if ($C->isSortable()) { $args = $_GET; $dir = $sort['col'] != $C->id ?: ($sort['dir'] ? 'desc' : 'asc'); $args['dir'] = $sort['col'] != $C->id ?: (int) !$sort['dir']; $args['sort'] = $C->id; $heading = sprintf('%s', Http::build_query($args), $dir, $heading); } echo sprintf('', $C->getWidth(), $C->id, $heading); } ?> '; if ($canManageTickets) { ?> render($T); if ($style = $styles ? 'style="'.$styles.'"' : '') { echo ""; } else { echo ""; } } echo ''; } ?>
%s
$contents
$contents
         '; echo $ferror?Format::htmlchars($ferror):__('Query returned 0 results.'); echo ''; } ?>
0 || $skipCount) { //if we actually had any tickets returned. ?>
showing(); ?> getPageLinks().' '; ?>