Add the ability to include groups in either Cc: or Bcc:
This commit is contained in:
parent
42b9cbdba9
commit
981eb2b31b
2 changed files with 67 additions and 18 deletions
|
@ -102,22 +102,44 @@ class MMFCustomersGroupsServiceProvider extends ServiceProvider {
|
||||||
|
|
||||||
// Update the list of recipients if some groups have been selected.
|
// Update the list of recipients if some groups have been selected.
|
||||||
Eventy::addAction('conversation.send_reply_save', function($conversation, $request) {
|
Eventy::addAction('conversation.send_reply_save', function($conversation, $request) {
|
||||||
$groups = $request->groups;
|
$groups_cc = $request->groups_cc;
|
||||||
|
$groups_bcc = $request->groups_bcc;
|
||||||
// Return early if no group has been selected.
|
// Return early if no group has been selected.
|
||||||
if ( empty($groups) ) return;
|
if ( empty($groups_cc) && empty($groups_bcc) ) return;
|
||||||
// Get the list of e-mails included in the selected groups.
|
|
||||||
$emails = new Collection;
|
// Cc - Get the list of e-mails included in the selected groups.
|
||||||
foreach ( $groups as $group_id ) {
|
if ( !empty($groups_cc) ) {
|
||||||
$group = CustomersGroup::find($group_id);
|
$emails = new Collection;
|
||||||
$emails = $emails->concat($group->emails());
|
foreach ( $groups_cc as $group_id ) {
|
||||||
|
$group = CustomersGroup::find($group_id);
|
||||||
|
$emails = $emails->concat($group->emails());
|
||||||
|
}
|
||||||
|
$emails = $emails->unique('email')->pluck('email');
|
||||||
|
// Update the list of Cc emails.
|
||||||
|
$cc = array_unique(array_merge(
|
||||||
|
$conversation->getCcArray(),
|
||||||
|
$emails->toArray()
|
||||||
|
));
|
||||||
|
$conversation->setCc($cc);
|
||||||
}
|
}
|
||||||
$emails = $emails->unique('email')->pluck('email');
|
|
||||||
// Update the list of cc emails.
|
// Bcc - Get the list of e-mails included in the selected groups.
|
||||||
$cc = array_unique(array_merge(
|
if ( !empty($groups_bcc) ) {
|
||||||
$conversation->getCcArray(),
|
$emails = new Collection;
|
||||||
$emails->toArray()
|
foreach ( $groups_bcc as $group_id ) {
|
||||||
));
|
$group = CustomersGroup::find($group_id);
|
||||||
$conversation->setCc($cc);
|
$emails = $emails->concat($group->emails());
|
||||||
|
}
|
||||||
|
$emails = $emails->unique('email')->pluck('email');
|
||||||
|
// Update the list of Bcc emails.
|
||||||
|
$bcc = array_unique(array_merge(
|
||||||
|
$conversation->getBccArray(),
|
||||||
|
$emails->toArray()
|
||||||
|
));
|
||||||
|
$conversation->setBcc($bcc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Check if this explicit save() call is required.
|
||||||
$conversation->save();
|
$conversation->save();
|
||||||
}, 20, 2);
|
}, 20, 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
@include('partials/flash_messages')
|
@include('partials/flash_messages')
|
||||||
|
|
||||||
<!-- List of Customers Groups that should be included in this Conversation -->
|
<!-- List of Customers Groups that should be included in this Conversation as Cc: -->
|
||||||
<div class="form-group{{ $errors->has('groups') ? ' has-error' : '' }}">
|
<div class="form-group{{ $errors->has('groups_cc') ? ' has-error' : '' }}">
|
||||||
<label for="groups" class="col-sm-2 control-label">{{ __('Groups selection') }}</label>
|
<label for="groups_cc" class="col-sm-2 control-label">{{ __('Groups selection - Cc:') }}</label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<div class="multi-container">
|
<div class="multi-container">
|
||||||
@foreach ( $groups as $group )
|
@foreach ( $groups as $group )
|
||||||
|
@ -22,7 +22,34 @@
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
name="groups[]"
|
name="groups_cc[]"
|
||||||
|
id="group-{{ $group->id }}"
|
||||||
|
value="{{ $group->id }}"
|
||||||
|
>
|
||||||
|
{{ $group->name }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- List of Customers Groups that should be included in this Conversation as Bcc: -->
|
||||||
|
<div class="form-group{{ $errors->has('groups_bcc') ? ' has-error' : '' }}">
|
||||||
|
<label for="groups_bcc" class="col-sm-2 control-label">{{ __('Groups selection - Bcc:') }}</label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<div class="multi-container">
|
||||||
|
@foreach ( $groups as $group )
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<label
|
||||||
|
class="control-label checkbox"
|
||||||
|
for="group-{{ $group->id }}"
|
||||||
|
style="text-align: left;"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="groups_bcc[]"
|
||||||
id="group-{{ $group->id }}"
|
id="group-{{ $group->id }}"
|
||||||
value="{{ $group->id }}"
|
value="{{ $group->id }}"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue