diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index fd031f80f5fb7dbecbc5856c59a5cb96bf1fbcf7..fd4c6b1cae6aa0f0148ad12274a9b46d287fb7cd 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -496,7 +496,8 @@ class TicketsAjaxAPI extends AjaxController { __('This ticket'), $assigned); } else { - $info['warn'] = __('Are you sure you want to claim this ticket?'); + $info['warn'] = sprintf(__('Are you sure you want to claim %s?'), + __('this ticket')); } if ($_POST && $form->isValid()) { @@ -521,7 +522,7 @@ class TicketsAjaxAPI extends AjaxController { } - function massProcess($action) { + function massProcess($action, $w=null) { global $thisstaff; $actions = array( @@ -531,6 +532,9 @@ class TicketsAjaxAPI extends AjaxController { 'assign' => array( 'verbed' => __('assigned'), ), + 'claim' => array( + 'verbed' => __('assigned'), + ), 'delete' => array( 'verbed' => __('deleted'), ), @@ -558,12 +562,56 @@ class TicketsAjaxAPI extends AjaxController { $count = $_REQUEST['count']; } switch ($action) { + case 'claim': + $w = 'me'; case 'assign': $inc = 'assign.tmpl.php'; $info[':action'] = '#tickets/mass/assign'; $info[':title'] = sprintf('Assign %s', _N('selected ticket', 'selected tickets', $count)); + $form = AssignmentForm::instantiate($_POST); + + + $assignCB = function($t, $f, $e) { + return $t->assign($f, $e); + }; + + $assignees = array(); + switch ($w) { + case 'agents': + $prompt = __('Select an Agent'); + foreach (Staff::getAvailableStaffMembers() as $id => $name) + $assignees['s'.$id] = $name; + break; + case 'teams': + $prompt = __('Select a Team'); + foreach (Team::getActiveTeams() as $id => $name) + $assignees['t'.$id] = $name; + break; + case 'me': + $info[':action'] = '#tickets/mass/claim'; + $info[':title'] = sprintf('Claim %s', + _N('selected ticket', 'selected tickets', $count)); + $info['warn'] = sprintf(__('Are you sure you want to claim %s?'), + _N('selected ticket', 'selected tickets', $count)); + $verb = sprintf('%s, %s', __('Yes'), __('Claim')); + $id = sprintf('s%s', $thisstaff->getId()); + $assignees = array($id => $thisstaff->getName()); + $vars = $_POST ?: array('assignee' => array($id)); + $form = ClaimForm::instantiate($vars); + $assignCB = function($t, $f, $e) { + return $t->claim($f, $e); + }; + break; + } + + if ($assignees) + $form->setAssignees($assignees); + + if ($prompt && ($f=$form->getField('assignee'))) + $f->configure('prompt', $prompt); + if ($_POST && $form->isValid()) { foreach ($_POST['tids'] as $tid) { if (($t=Ticket::lookup($tid)) @@ -571,7 +619,7 @@ class TicketsAjaxAPI extends AjaxController { // access and assign the task. && $t->checkStaffPerm($thisstaff, Ticket::PERM_ASSIGN) // Do the assignment - && $t->assign($form, $e) + && $assignCB($t, $form, $e) ) $i++; } diff --git a/include/staff/templates/tickets-actions.tmpl.php b/include/staff/templates/tickets-actions.tmpl.php index d52eca94efd3983f72ede9e355e4eae21500a706..10d274ad93f9a689b4f763c9ddd40df394fdca92 100644 --- a/include/staff/templates/tickets-actions.tmpl.php +++ b/include/staff/templates/tickets-actions.tmpl.php @@ -19,7 +19,7 @@ if ($agent->hasPerm(Ticket::PERM_ASSIGN, false)) {?> <div id="action-dropdown-assign" class="action-dropdown anchor-right"> <ul> <li><a class="no-pjax tickets-action" - href="#tickets/mass/assign/<?php echo $agent->getId(); ?>"><i + href="#tickets/mass/claim"><i class="icon-chevron-sign-down"></i> <?php echo __('Claim'); ?></a> <li><a class="no-pjax tickets-action" href="#tickets/mass/assign/agents"><i diff --git a/scp/ajax.php b/scp/ajax.php index 20674f0603c10271b0591a9f8daa7a807c80f9e0..8fcb6146f2f9e6d97bdc2567ac6a22c6259f2e6a 100644 --- a/scp/ajax.php +++ b/scp/ajax.php @@ -161,8 +161,7 @@ $dispatcher = patterns('', url_get('^(?P<tid>\d+)/tasks/(?P<id>\d+)/view$', 'task'), url_post('^(?P<tid>\d+)/tasks/(?P<id>\d+)$', 'task'), url_get('^lookup', 'lookup'), - url_get('^mass/(?P<action>[\w.]+)', 'massProcess'), - url_post('^mass/(?P<action>[\w.]+)', 'massProcess'), + url('^mass/(?P<action>\w+)(?:/(?P<what>\w+))?', 'massProcess'), url('^(?P<tid>\d+)/transfer$', 'transfer'), url('^(?P<tid>\d+)/assign(?:/(?P<to>\w+))?$', 'assign'), url('^(?P<tid>\d+)/claim$', 'claim'),