diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index 1a010c450a2c693a62b2fb360e6a53d76574b77a..48037903077945b7caf6a5871574f3ef5732e59e 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -449,6 +449,26 @@ class TicketsAjaxAPI extends AjaxController { return $resp; } + function addRemoteCollaborator($tid, $bk, $id) { + global $thisstaff; + + if (!($ticket=Ticket::lookup($tid)) + || !$ticket->checkStaffAccess($thisstaff)) + Http::response(404, 'No such ticket'); + elseif (!$bk || !$id) + Http::response(422, 'Backend and user id required'); + elseif (!($backend = AuthenticationBackend::getBackend($bk))) + Http::response(404, 'User not found'); + + $user_info = $backend->lookup($id); + $form = UserForm::getUserForm()->getForm($user_info); + $info = array(); + if (!$user_info) + $info['error'] = 'Unable to find user in directory'; + + return self::_addcollaborator($ticket, null, $form, $info); + } + //Collaborators utils function addCollaborator($tid, $uid=0) { global $thisstaff; diff --git a/scp/ajax.php b/scp/ajax.php index dfbce029a5c672c18ff44af7773c74ebf506bb4b..61f51055ad7af4b80d7439683221e47320687272 100644 --- a/scp/ajax.php +++ b/scp/ajax.php @@ -82,6 +82,7 @@ $dispatcher = patterns('', url_get('^(?P<tid>\d+)/collaborators/manage$', 'showCollaborators'), url_post('^(?P<tid>\d+)/collaborators$', 'updateCollaborators'), url_get('^(?P<tid>\d+)/add-collaborator/(?P<uid>\d+)$', 'addCollaborator'), + url_get('^(?P<tid>\d+)/add-collaborator/auth:(?P<bk>\w+):(?P<id>.+)$', 'addRemoteCollaborator'), url('^(?P<tid>\d+)/add-collaborator$', 'addCollaborator'), url_get('^lookup', 'lookup'), url_get('^search', 'search')