diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index e9bca0f6a0b815372fdb528191e7f6951649e859..68aaf24ae5180137412e5f05cad11a23b2e9c0f8 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -568,7 +568,23 @@ class TicketsAjaxAPI extends AjaxController { return self::_addcollaborator($ticket); } + function previewCollaborators($tid) { + global $thisstaff; + + if (!($ticket=Ticket::lookup($tid)) + || !$ticket->checkStaffAccess($thisstaff)) + Http::response(404, 'No such ticket'); + + if (!$ticket->getCollaborators()) + Http::response(404, 'No such ticket'); + ob_start(); + include STAFFINC_DIR . 'templates/collaborators-preview.tmpl.php'; + $resp = ob_get_contents(); + ob_end_clean(); + + return $resp; + } function _addcollaborator($ticket, $user=null, $form=null, $info=array()) { @@ -590,7 +606,9 @@ class TicketsAjaxAPI extends AjaxController { $errors = $info = array(); if ($ticket->updateCollaborators($_POST, $errors)) - Http::response(201, sprintf('Recipients (%d)', $ticket->getNumActiveCollaborators())); + Http::response(201, sprintf('Recipients (%d of %d)', + $ticket->getNumActiveCollaborators(), + $ticket->getNumCollaborators())); if($errors && $errors['err']) $info +=array('error' => $errors['err']); diff --git a/include/staff/templates/collaborators-preview.tmpl.php b/include/staff/templates/collaborators-preview.tmpl.php new file mode 100644 index 0000000000000000000000000000000000000000..45cfecca268ddca8e8c2d9dfc91ef432613ab419 --- /dev/null +++ b/include/staff/templates/collaborators-preview.tmpl.php @@ -0,0 +1,28 @@ +<div> +<table border="0" cellspacing="" cellpadding="1"> +<colgroup><col style="min-width: 250px;"></col></colgroup> +<?php +if (($users=$ticket->getCollaborators())) {?> +<?php + foreach($users as $user) { + echo sprintf('<tr><td %s><i class="icon-%s"></i> %s <em><%s></em></td></tr>', + ($user->isActive()? 'class="faded"' : ''), + ($user->isActive()? 'comments' : 'comment-alt'), + $user->getName(), + $user->getEmail()); + } +} else { + echo "Bro, not sure how you got here!"; +}?> +</table> +<?php +$options = array(); +//TODO: Add options to manage collaborators +if ($options) { + echo '<ul class="tip_menu">'; + foreach($options as $option) + echo sprintf('<li><a href="%s">%s</a></li>', $option['url'], $option['action']); + echo '</ul>'; +} +?> +</div> diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index 3ac6b4efd9d27080490d78b41de17e6d8a87cc70..6fee37da63a4817fb462815677b2a0bf14370f87 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -453,10 +453,12 @@ $tcount+= $ticket->getNumNotes(); <?php $recipients = 'Add Recipients'; if ($ticket->getNumCollaborators()) - $recipients = sprintf('Recipients (%d)', $ticket->getNumActiveCollaborators()); + $recipients = sprintf('Recipients (%d of %d)', + $ticket->getNumActiveCollaborators(), + $ticket->getNumCollaborators()); - echo sprintf('<span><a class="collaborators" - href="#tickets/%d/collaborators/manage"><span id="recipients">%s</span></a></span>', + echo sprintf('<span><a class="collaborators" id="manageCollab" + href="#tickets/%d/collaborators"><span id="recipients">%s</span></a></span>', $ticket->getId(), $recipients); ?> diff --git a/scp/ajax.php b/scp/ajax.php index 7e990934b8abe59b1b9a1aecfd3ccd91cfb06271..8c321ead8182568084e21ccd91091e51fb431c46 100644 --- a/scp/ajax.php +++ b/scp/ajax.php @@ -79,7 +79,8 @@ $dispatcher = patterns('', url_post('^(?P<tid>\d+)/lock$', 'acquireLock'), url_post('^(?P<tid>\d+)/lock/(?P<id>\d+)/renew', 'renewLock'), url_post('^(?P<tid>\d+)/lock/(?P<id>\d+)/release', 'releaseLock'), - url_get('^(?P<tid>\d+)/collaborators/manage$', 'showCollaborators'), + url_get('^(?P<tid>\d+)/collaborators/preview$', 'previewCollaborators'), + url_get('^(?P<tid>\d+)/collaborators$', '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'), diff --git a/scp/js/tips.js b/scp/js/tips.js index 205eb6fc9d2df8edbbd17d3ad43dbfab76145d36..db94a1acb362cb5b64e4b56178a5d6d780e3b00a 100644 --- a/scp/js/tips.js +++ b/scp/js/tips.js @@ -160,6 +160,28 @@ jQuery(function() { clearTimeout($(this).data('timer')); }); + + $('a#manageCollab').live('mouseover', function(e) { + e.preventDefault(); + var elem = $(this); + + var url = 'ajax.php/'+elem.attr('href').substr(1)+'/preview'; + var xoffset = 100; + elem.data('timer', 0); + + if (e.type=='mouseover') { + elem.data('timer',setTimeout(function() { showtip(url, elem, xoffset);},750)) + } else { + showtip(url,elem,xoffset); + } + }).live('mouseout', function(e) { + clearTimeout($(this).data('timer')); + }).live('click', function(e) { + clearTimeout($(this).data('timer')); + $('.tip_box').remove(); + }); + + //Ticket preview $('.ticketPreview').live('mouseover', function(e) { e.preventDefault();