diff --git a/include/ajax.thread.php b/include/ajax.thread.php index a66062e0b933607397803545f98c384d46b5b53c..0369548ed5deb1b855c6f2f9c3127d4eb9b4ff22 100644 --- a/include/ajax.thread.php +++ b/include/ajax.thread.php @@ -74,11 +74,11 @@ class ThreadAjaxAPI extends AjaxController { if (!$user_info) $info['error'] = __('Unable to find user in directory'); - return self::_addcollaborator($thread, null, $form, $info); + return self::_addcollaborator($thread, null, $form, 'addcc', $info); } //Collaborators utils - function addCollaborator($tid, $uid=0) { + function addCollaborator($tid, $type=null, $uid=0) { global $thisstaff; if (!($thread=Thread::lookup($tid)) @@ -90,7 +90,7 @@ class ThreadAjaxAPI extends AjaxController { //If not a post then assume new collaborator form if(!$_POST) - return self::_addcollaborator($thread, $user); + return self::_addcollaborator($thread, $user, null, $type); $user = $form = null; if (isset($_POST['id']) && $_POST['id']) { //Existing user/ @@ -107,7 +107,7 @@ class ThreadAjaxAPI extends AjaxController { array(), $errors))) { $info = array('msg' => sprintf(__('%s added as a collaborator'), Format::htmlchars($c->getName()))); - $c->setCc(); + $type == 'addbcc' ? $c->setBcc() : $c->setCc(); $c->save(); return self::_collaborators($thread, $info); } @@ -119,7 +119,7 @@ class ThreadAjaxAPI extends AjaxController { $info +=array('error' =>__('Unable to add collaborator.').' '.__('Internal error occurred')); } - return self::_addcollaborator($thread, $user, $form, $info); + return self::_addcollaborator($thread, $user, $form, $type, $info); } function updateCollaborator($tid, $cid) { @@ -194,15 +194,15 @@ class ThreadAjaxAPI extends AjaxController { return $resp; } - function _addcollaborator($thread, $user=null, $form=null, $info=array()) { + function _addcollaborator($thread, $user=null, $form=null, $type=null, $info=array()) { global $thisstaff; $info += array( 'title' => __('Add a collaborator'), - 'action' => sprintf('#thread/%d/add-collaborator', - $thread->getId()), - 'onselect' => sprintf('ajax.php/thread/%d/add-collaborator/', - $thread->getId()), + 'action' => sprintf('#thread/%d/add-collaborator/%s', + $thread->getId(), $type), + 'onselect' => sprintf('ajax.php/thread/%d/add-collaborator/%s/', + $thread->getId(), $type), ); ob_start(); diff --git a/include/class.thread.php b/include/class.thread.php index dd10d3a0d326235954f7be5066ccdb5ec182e8c3..b5176ada202836284534f51d75fd2cedbf2b74e9 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -778,6 +778,18 @@ implements TemplateVariable { ), ); + // Thread entry types + static protected $types = array( + 'M' => 'message', + 'R' => 'response', + 'N' => 'note', + 'B' => 'bccmessage', + ); + + function getTypeName() { + return self::$types[$this->type]; + } + function postEmail($mailinfo) { global $ost; @@ -1720,6 +1732,10 @@ implements TemplateVariable { static function getPermissions() { return self::$perms; } + + static function getTypes() { + return self::$types; + } } RolePermission::register(/* @trans */ 'Tickets', ThreadEntry::getPermissions()); diff --git a/include/client/templates/thread-entry.tmpl.php b/include/client/templates/thread-entry.tmpl.php index ad9f3dc9fa33282b4a9bec980cc7daf2ee9fc7fc..e49b3b0389bf1c9d2f7c330ebac9039b536c0fc9 100644 --- a/include/client/templates/thread-entry.tmpl.php +++ b/include/client/templates/thread-entry.tmpl.php @@ -1,6 +1,6 @@ <?php global $cfg; -$entryTypes = array('M'=>'message', 'R'=>'response', 'N'=>'note', 'B' => 'bccmessage'); +$entryTypes = ThreadEntry::getTypes(); $user = $entry->getUser() ?: $entry->getStaff(); if ($entry->staff && $cfg->hideStaffName()) $name = __('Staff'); @@ -11,13 +11,14 @@ if ($cfg->isAvatarsEnabled() && $user) $avatar = $user->getAvatar(); ?> <?php - if ($entryTypes[$entry->type] == 'note') { - $entryTypes[$entry->type] = 'bccmessage'; +$type = $entryTypes[$entry->type]; +if ($type == 'note') { + $type = 'bccmessage'; $entry->type = 'B'; - } +} ?> -<div class="thread-entry <?php echo $entryTypes[$entry->type]; ?> <?php if ($avatar) echo 'avatar'; ?>"> +<div class="thread-entry <?php echo $type; ?> <?php if ($avatar) echo 'avatar'; ?>"> <?php if ($avatar) { ?> <span class="<?php echo ($entry->type == 'M' || $entry->type == 'B') ? 'pull-left' : 'pull-right'; ?> avatar"> <?php echo $avatar; ?> diff --git a/include/staff/templates/collaborators.tmpl.php b/include/staff/templates/collaborators.tmpl.php index 7f80a5804053f2c9b9ecf23d9880f4d5555f7b75..1a50164f1f78421050098dfef38f89de93d9cf0b 100644 --- a/include/staff/templates/collaborators.tmpl.php +++ b/include/staff/templates/collaborators.tmpl.php @@ -65,7 +65,7 @@ if(($users=$thread->getCollaborators())) {?> ?> <td> <div><a class="collaborator" id="addcollaborator" - href="#thread/<?php echo $thread->getId(); ?>/add-collaborator" + href="#thread/<?php echo $thread->getId(); ?>/add-collaborator/addcc" ><i class="icon-plus-sign"></i> <?php echo __('Add Collaborator'); ?></a></div> </td> </table> diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index dd351122439b1d657e8c2aa96e982b828266036d..b5ededef80a34f4bd784568e908c2edf1b8ef8fe 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -1197,7 +1197,7 @@ $(function() { if(el.val().includes("NEW")) { $("li[title='— Add New —']").remove(); - var url = 'ajax.php/thread/' + tid + '/add-collaborator' ; + var url = 'ajax.php/thread/' + tid + '/add-collaborator/' + addTo ; $.userLookup(url, function(user) { e.preventDefault(); if($('.dialog#confirm-action').length) { diff --git a/scp/ajax.php b/scp/ajax.php index c746da68d0650c46ce0b524f789803e70d6b1582..85d010e92b48b47d39643715bd8d9884c4c040c8 100644 --- a/scp/ajax.php +++ b/scp/ajax.php @@ -211,9 +211,9 @@ $dispatcher = patterns('', 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/(?P<type>\w+)/(?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('^(?P<tid>\d+)/add-collaborator/(?P<type>\w+)$', 'addCollaborator'), url_get('^(?P<tid>\d+)/collaborators/(?P<cid>\d+)/view$', 'viewCollaborator'), url_post('^(?P<tid>\d+)/collaborators/(?P<cid>\d+)$', 'updateCollaborator') )),