Skip to content
Snippets Groups Projects
Commit 2afff6a2 authored by Jared Hancock's avatar Jared Hancock Committed by Peter Rotich
Browse files

queues: Fix several issues reported by @kest874

- Fix crash on new ticket
- Fix crash on user and org dialog popup from ticket
- Fix missing queue mass-action buttons
parent 2391a45a
Branches
Tags
No related merge requests found
......@@ -124,8 +124,10 @@ class ModelMeta implements ArrayAccess {
function extend(ModelMeta $child, $meta) {
$this->subclasses[$child->model] = $child;
// Merge 'joins' settings (instead of replacing)
if (isset($this->meta['joins']))
$meta['joins'] += $this->meta['joins'];
if (isset($this->meta['joins'])) {
$meta['joins'] = array_merge($meta['joins'] ?: array(),
$this->meta['joins']);
}
return $meta + $this->meta + self::$base;
}
......@@ -1358,6 +1360,9 @@ class QuerySet implements IteratorAggregate, ArrayAccess, Serializable, Countabl
* after this is run, the changes should be made in a clone.
*/
function total() {
if (isset($this->total))
return $this->total;
// Optimize the query with the CALC_FOUND_ROWS if
// - the compiler supports it
// - the iterator hasn't yet been built, that is, the query for this
......
......@@ -72,6 +72,29 @@ elseif ($queue_sort = $queue->getDefaultSort()) {
'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;
}
}
if (!$sorted && isset($sort['queuesort'])) {
// Apply queue sort-dropdown selected preference
$sort['queuesort']->applySort($tickets, $sort['dir']);
}
// Apply pagination
$page = ($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1;
$count = $tickets->total();
$pageNav = new Pagenate($count, $page, PAGE_LIMIT);
$pageNav->setURL('tickets.php', $args);
$tickets = $pageNav->paginate($tickets);
?>
<!-- SEARCH FORM START -->
......@@ -190,8 +213,6 @@ if ($canManageTickets) { ?>
<th style="width:12px"></th>
<?php
}
$sorted = false;
foreach ($columns as $C) {
$heading = Format::htmlchars($C->getLocalHeading());
if ($C->isSortable()) {
......@@ -204,27 +225,12 @@ foreach ($columns as $C) {
}
echo sprintf('<th width="%s" data-id="%d">%s</th>',
$C->getWidth(), $C->id, $heading);
// Sort by this column ?
if (isset($sort['col']) && $sort['col'] == $C->id) {
$tickets = $C->applySort($tickets, $sort['dir']);
$sorted = true;
}
}
if (!$sorted && isset($sort['queuesort'])) {
$sort['queuesort']->applySort($tickets, $sort['dir']);
}
?>
</tr>
</thead>
<tbody>
<?php
$page = ($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1;
$count = $tickets->total();
$pageNav = new Pagenate($count, $page, PAGE_LIMIT);
$pageNav->setURL('tickets.php', $args);
$tickets = $pageNav->paginate($tickets);
foreach ($tickets as $T) {
echo '<tr>';
if ($canManageTickets) { ?>
......
......@@ -385,7 +385,9 @@ if($_POST && !$errors):
__('Contact admin for such access'));
} else {
$vars = $_POST;
$vars['uid'] = $user? $user->getId() : 0;
if ($vars['uid'] && (!User::lookup($vars['uid'])))
$vars['uid'] = 0;
$vars['cannedattachments'] = $response_form->getField('attachments')->getClean();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment