Add compatibility with MMFCustomersGroups
This commit is contained in:
parent
69c518086e
commit
45028e03a9
1 changed files with 13 additions and 0 deletions
|
@ -68,6 +68,19 @@ class MMFRestrictedCustomersServiceProvider extends ServiceProvider {
|
|||
$priority = 20,
|
||||
$arguments = 3
|
||||
);
|
||||
|
||||
// Filter the list of Customers returned by MMFCustomersGroups when creating/editing a Customers Group.
|
||||
Eventy::addFilter('mmfcustomergroups.groups.create.customers-query', function($customers_query) {
|
||||
$user = auth()->user();
|
||||
// Do not restrict the query if the current user is an admin.
|
||||
if ( $user->role != User::ROLE_ADMIN ) {
|
||||
// Get IDs of mailboxes the current user is allowed to access.
|
||||
$mailboxes = $user->mailboxesIdsCanView();
|
||||
// Restrict the query to the Customers the current user is allowed to access.
|
||||
$customers_query->whereIn('customers.mailbox_id', $mailboxes);
|
||||
}
|
||||
return $customers_query;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue