Skip to content

Commit 2a61acd

Browse files
committed
Catch embedded comments recipients
1 parent 3d20e70 commit 2a61acd

4 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/Controllers/NotificationsController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,12 @@ public function newComment(Comment $comment, $request)
155155

156156
}elseif($comment->type == 'note' or !$ticket->hidden){
157157
// Selected recipients
158-
$c_recipients = $comment->type == 'note' ? $request->note_recipients : $request->reply_recipients;
158+
// $comment->a_recipients come from embedded comments i TicketsController
159+
// $request recipients come from a comment modal in Ticket card
160+
$a_recipients = isset($comment->a_recipients) ? $comment->a_recipients : ($comment->type == 'note' ? $request->note_recipients : $request->reply_recipients);
159161

160-
if (count($c_recipients) > 0){
161-
foreach($c_recipients as $member_id){
162+
if (count($a_recipients) > 0){
163+
foreach($a_recipients as $member_id){
162164
$recipient = Member::find($member_id);
163165
if (count($recipient) == 1){
164166
// Register the notified email

src/Controllers/TicketsController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,9 @@ public function add_embedded_comments($request, $ticket, $a_result_errors)
11411141
$comment->html = $a_content['html'];
11421142
$comment->save();
11431143

1144+
// Comment recipients
1145+
if($request->has('comment_' . $i . '_recipients')) $comment->a_recipients = $request->{'comment_' . $i . '_recipients'};
1146+
11441147
// Adds this as a $comment property to check it in NotificationsController
11451148
if($request->has('comment_' . $i . '_notification_text')) $comment->add_in_user_notification_text = 'yes';
11461149

src/Views/tickets/partials/comments/new_in_createedit_ticket_form.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<div class="form-group row">
2828
<label class="col-lg-2 col-form-label">{{ trans('panichd::lang.show-ticket-add-comment-notificate') . trans('panichd::lang.colon') }}</label>
2929
<div class="col-lg-10">
30-
<select class="form-control note_recipients" name="comment_x_note_recipients[]" multiple="multiple" style="display: none; width: 100%" disabled="disabled">
30+
<select class="form-control note_recipients" name="comment_x_recipients[]" multiple="multiple" style="display: none; width: 100%" disabled="disabled">
3131
@foreach ($c_members as $member)
3232
<option value="{{ $member->id }}" {{ ((isset($ticket) && $member->id == $ticket->agent->id) || (!isset($ticket) && $a_current['agent_id'] != auth()->user()->id && $a_current['agent_id'] == $member->id)) ? 'selected="selected"' : '' }}>{{ $member->name . ($member->email == "" ? ' ' . trans('panichd::lang.ticket-owner-no-email') : ' - ' . $member->email) }}
3333
@if ($setting->grab('departments_notices_feature'))
@@ -41,7 +41,7 @@
4141
@endforeach
4242
</select>
4343
@php \Debugbar::info($a_current) @endphp
44-
<select class="form-control reply_recipients" name="comment_x_reply_recipients[]" class="form-control" multiple="multiple" style="display: none; width: 100%" disabled="disabled">
44+
<select class="form-control reply_recipients" name="comment_x_recipients[]" class="form-control" multiple="multiple" style="display: none; width: 100%" disabled="disabled">
4545
@foreach ($c_members as $member)
4646
<option value="{{ $member->id }}" {{ ((isset($ticket) && !is_null($ticket->owner) && $member->id == $ticket->owner->id) || (!isset($ticket) && $a_current['owner_id'] != auth()->user()->id && $a_current['owner_id'] == $member->id)) ? 'selected="selected"' : '' }}>{{ $member->name . ($member->email == "" ? ' ' . trans('panichd::lang.ticket-owner-no-email') : ' - ' . $member->email) }}
4747
@if ($setting->grab('departments_notices_feature'))

src/Views/tickets/partials/comments/new_in_createedit_ticket_scripts.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
_cloned.prop('id', 'comment_' + _num);
1010
_cloned.find('.input_comment_num').val(_num);
1111
_cloned.find('.input_response_type').prop('disabled', false).attr('name', 'response_' + _num);
12-
_cloned.find('.note_recipients').prop('disabled', false).attr('name', 'comment_' + _num + '_note_recipients[]');
13-
_cloned.find('.reply_recipients').attr('name', 'comment_' + _num + '_reply_recipients[]');
12+
_cloned.find('.note_recipients').prop('disabled', false).attr('name', 'comment_' + _num + '_recipients[]');
13+
_cloned.find('.reply_recipients').attr('name', 'comment_' + _num + '_recipients[]');
1414
1515
_cloned.find('.input_comment_text').prop('disabled', false).attr('name', 'comment_' + _num);
1616

0 commit comments

Comments
 (0)