Skip to content
Snippets Groups Projects
Commit 94d13ab8 authored by Peter Rotich's avatar Peter Rotich Committed by GitHub
Browse files

Merge pull request #3122 from protich/issue/collab-update

collabs: Thread Collaborators Update
parents 1ed288f5 eb6b3148
Branches
Tags
No related merge requests found
...@@ -230,9 +230,13 @@ class ThreadAjaxAPI extends AjaxController { ...@@ -230,9 +230,13 @@ class ThreadAjaxAPI extends AjaxController {
$errors = $info = array(); $errors = $info = array();
if ($thread->updateCollaborators($_POST, $errors)) if ($thread->updateCollaborators($_POST, $errors))
Http::response(201, sprintf('Recipients (%d of %d)', Http::response(201, $this->json_encode(array(
$thread->getNumActiveCollaborators(), 'id' => $thread->getId(),
$thread->getNumCollaborators())); 'text' => sprintf('Recipients (%d of %d)',
$thread->getNumActiveCollaborators(),
$thread->getNumCollaborators())
)
));
if($errors && $errors['err']) if($errors && $errors['err'])
$info +=array('error' => $errors['err']); $info +=array('error' => $errors['err']);
......
...@@ -197,15 +197,13 @@ class Thread extends VerySimpleModel { ...@@ -197,15 +197,13 @@ class Thread extends VerySimpleModel {
)); ));
} }
if ($cids) { $this->collaborators->filter(array(
$this->collaborators->filter(array( 'thread_id' => $this->getId(),
'thread_id' => $this->getId(), Q::not(array('id__in' => $cids ?: array(0)))
Q::not(array('id__in' => $cids)) ))->update(array(
))->update(array( 'updated' => SqlFunction::NOW(),
'updated' => SqlFunction::NOW(), 'isactive' => 0,
'isactive' => 0, ));
));
}
unset($this->ht['active_collaborators']); unset($this->ht['active_collaborators']);
$this->_collaborators = null; $this->_collaborators = null;
......
...@@ -583,7 +583,8 @@ if ($errors['err'] && isset($_POST['a'])) { ...@@ -583,7 +583,8 @@ if ($errors['err'] && isset($_POST['a'])) {
<label><strong><?php echo __('Collaborators'); ?>:</strong></label> <label><strong><?php echo __('Collaborators'); ?>:</strong></label>
</td> </td>
<td> <td>
<input type='checkbox' value='1' name="emailcollab" id="emailcollab" <input type='checkbox' value='1' name="emailcollab"
id="t<?php echo $ticket->getThreadId(); ?>-emailcollab"
<?php echo ((!$info['emailcollab'] && !$errors) || isset($info['emailcollab']))?'checked="checked"':''; ?> <?php echo ((!$info['emailcollab'] && !$errors) || isset($info['emailcollab']))?'checked="checked"':''; ?>
style="display:<?php echo $ticket->getThread()->getNumCollaborators() ? 'inline-block': 'none'; ?>;" style="display:<?php echo $ticket->getThread()->getNumCollaborators() ? 'inline-block': 'none'; ?>;"
> >
......
...@@ -987,8 +987,9 @@ $(document).on('click', 'a.collaborator, a.collaborators', function(e) { ...@@ -987,8 +987,9 @@ $(document).on('click', 'a.collaborator, a.collaborators', function(e) {
e.preventDefault(); e.preventDefault();
var url = 'ajax.php/'+$(this).attr('href').substr(1); var url = 'ajax.php/'+$(this).attr('href').substr(1);
$.dialog(url, 201, function (xhr) { $.dialog(url, 201, function (xhr) {
$('input#emailcollab').show(); var resp = $.parseJSON(xhr.responseText);
$('#recipients').text(xhr.responseText); $('input#t'+resp.id+'-emailcollab').show();
$('#t'+resp.id+'-recipients').text(resp.text);
$('.tip_box').remove(); $('.tip_box').remove();
}, { }, {
onshow: function() { $('#user-search').focus(); } onshow: function() { $('#user-search').focus(); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment