diff --git a/include/ajax.search.php b/include/ajax.search.php index ccd861d1bf5f3f4dd81fc149b471c1c96f383586..0186f8d22294162cfa17e2044dd90b83e7489b04 100644 --- a/include/ajax.search.php +++ b/include/ajax.search.php @@ -198,25 +198,6 @@ class SearchAjaxAPI extends AjaxController { ))); } - function deleteSearch($id) { - global $thisstaff; - - if (!$thisstaff) { - Http::response(403, 'Agent login is required'); - } - elseif (!($search = SavedSearch::lookup($id))) { - Http::response(404, 'No such saved search'); - } - elseif (!$search->delete()) { - Http::response(500, 'Unable to delete search'); - } - - Http::response(200, $this->encode(array( - 'id' => $search->id, - 'success' => true, - ))); - } - function editColumn($column_id) { global $thisstaff; @@ -262,6 +243,28 @@ class SearchAjaxAPI extends AjaxController { include STAFFINC_DIR . 'templates/queue-sorting-edit.tmpl.php'; } + function deleteQueue($id) { + global $thisstaff; + + if (!$thisstaff) { + Http::response(403, 'Agent login is required'); + } + if ($id && (!($queue = CustomQueue::lookup($id)))) { + Http::response(404, 'No such queue'); + } + if (!$queue || !$queue->checkAccess($thisstaff)) { + Http::response(404, 'No such queue'); + } + if ($_POST) { + if (!$queue->delete()) { + Http::response(500, 'Unable to delete queue'); + } + Http::response(201, 'Have a nice day'); + } + + include STAFFINC_DIR . 'templates/queue-delete-confirm.tmpl.php'; + } + function previewQueue($id=false) { global $thisstaff; diff --git a/include/staff/templates/queue-tickets.tmpl.php b/include/staff/templates/queue-tickets.tmpl.php index f87afe61e18d926b2865a348adee13cc067a0f57..045d668e14fc96497f7955e7ff849c1b52049e41 100644 --- a/include/staff/templates/queue-tickets.tmpl.php +++ b/include/staff/templates/queue-tickets.tmpl.php @@ -190,11 +190,15 @@ if ($thisstaff->isAdmin()) { ?> </li> <?php } if ( - ($thisstaff->isAdmin() && $queue->parent_id) - || $queue->isPrivate() -) { ?> + $queue->id > 0 + && ( + ($thisstaff->isAdmin() && $queue->parent_id) + || $queue->isPrivate() +)) { ?> <li class="danger"> - <a class="no-pjax" href="#"><i + <a class="no-pjax confirm-action" href="#" + data-dialog="ajax.php/queue/<?php + echo $queue->id; ?>/delete"><i class="icon-fixed-width icon-trash"></i> <?php echo __('Delete'); ?></a> </li> diff --git a/scp/ajax.php b/scp/ajax.php index 570020809037fb6e0222d9b0717b736db4ebaf71..215079e18c80f65ef5d1b9776fc5f6d586df7a3d 100644 --- a/scp/ajax.php +++ b/scp/ajax.php @@ -266,7 +266,8 @@ $dispatcher = patterns('', url_get('^addColumn$', 'addColumn'), url_get('^condition/add$', 'addCondition'), url_get('^condition/addProperty$', 'addConditionProperty'), - url_get('^counts$', 'collectQueueCounts') + url_get('^counts$', 'collectQueueCounts'), + url('^(?P<id>\d+)/delete$', 'deleteQueue') )) ); diff --git a/scp/css/dropdown.css b/scp/css/dropdown.css index dfb354dc0c9cae4f7bb86dceeaa7149fa7bbda8e..20db72e40be58993f7d80f4aa4fead9ac51c89e9 100644 --- a/scp/css/dropdown.css +++ b/scp/css/dropdown.css @@ -5,7 +5,7 @@ .action-dropdown, .noclick-dropdown { position: absolute; - z-index: 9999998; + z-index: 8; display: none; margin-top: 8px; }