From 7a6e69bfe187453b22b80f7854d3bd62d2518c6a Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 13 Dec 2013 16:58:20 -0600 Subject: [PATCH] Allow addition of collaborator from auth backend --- include/ajax.tickets.php | 20 ++++++++++++++++++++ scp/ajax.php | 1 + 2 files changed, 21 insertions(+) diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index 1a010c450..480379030 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 dfbce029a..61f51055a 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') -- GitLab