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.
|
||||
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.
|
||||
if ( empty($groups) ) return;
|
||||
// Get the list of e-mails included in the selected groups.
|
||||
if ( empty($groups_cc) && empty($groups_bcc) ) return;
|
||||
|
||||
// Cc - Get the list of e-mails included in the selected groups.
|
||||
if ( !empty($groups_cc) ) {
|
||||
$emails = new Collection;
|
||||
foreach ( $groups as $group_id ) {
|
||||
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.
|
||||
// Update the list of Cc emails.
|
||||
$cc = array_unique(array_merge(
|
||||
$conversation->getCcArray(),
|
||||
$emails->toArray()
|
||||
));
|
||||
$conversation->setCc($cc);
|
||||
}
|
||||
|
||||
// Bcc - Get the list of e-mails included in the selected groups.
|
||||
if ( !empty($groups_bcc) ) {
|
||||
$emails = new Collection;
|
||||
foreach ( $groups_bcc as $group_id ) {
|
||||
$group = CustomersGroup::find($group_id);
|
||||
$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();
|
||||
}, 20, 2);
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
@include('partials/flash_messages')
|
||||
|
||||
<!-- List of Customers Groups that should be included in this Conversation -->
|
||||
<div class="form-group{{ $errors->has('groups') ? ' has-error' : '' }}">
|
||||
<label for="groups" class="col-sm-2 control-label">{{ __('Groups selection') }}</label>
|
||||
<!-- List of Customers Groups that should be included in this Conversation as Cc: -->
|
||||
<div class="form-group{{ $errors->has('groups_cc') ? ' has-error' : '' }}">
|
||||
<label for="groups_cc" class="col-sm-2 control-label">{{ __('Groups selection - Cc:') }}</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="multi-container">
|
||||
@foreach ( $groups as $group )
|
||||
|
@ -22,7 +22,34 @@
|
|||
>
|
||||
<input
|
||||
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 }}"
|
||||
value="{{ $group->id }}"
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue