Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c99a277e2a |
@@ -1370,6 +1370,20 @@ class OrganisationMembersController extends SimpleController
|
|||||||
{
|
{
|
||||||
$timeout = $this->ci->config['organisation.membership.timeout'];
|
$timeout = $this->ci->config['organisation.membership.timeout'];
|
||||||
|
|
||||||
|
$admin_fallback = false;
|
||||||
|
$recipientsQuery = $organisation->administrators();
|
||||||
|
|
||||||
|
if ($recipientsQuery->count() == 0) {
|
||||||
|
$admin_fallback = true;
|
||||||
|
$role = $this->ci->classMapper->getClassMapping('role')::where('slug', 'organisations-admin')->with('users')->first();
|
||||||
|
if ($role->users()->count() == 0) {
|
||||||
|
$role = $this->ci->classMapper->getClassMapping('role')::where('slug', 'site-admin')->with('users')->first();
|
||||||
|
}
|
||||||
|
$recipientsQuery = $role->users();
|
||||||
|
}
|
||||||
|
|
||||||
|
$recipients = $recipientsQuery->get();
|
||||||
|
|
||||||
// Create and send approval email
|
// Create and send approval email
|
||||||
$message = new TwigMailMessage($this->ci->view, 'mail/organisation-membership-request.html.twig');
|
$message = new TwigMailMessage($this->ci->view, 'mail/organisation-membership-request.html.twig');
|
||||||
|
|
||||||
@@ -1379,20 +1393,9 @@ class OrganisationMembersController extends SimpleController
|
|||||||
'organisation' => $organisation,
|
'organisation' => $organisation,
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'approval_expiration' => ($timeout > 0 ? floor($timeout / 86400) . ' days' : false),
|
'approval_expiration' => ($timeout > 0 ? floor($timeout / 86400) . ' days' : false),
|
||||||
|
'admin_fallback' => $admin_fallback,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$recipientsQuery = $organisation->administrators();
|
|
||||||
|
|
||||||
if ($recipientsQuery->count() == 0) {
|
|
||||||
$role = $this->ci->classMapper->getClassMapping('role')::where('slug', 'organisations-admin')->with('users')->first();
|
|
||||||
if ($role->users()->count() == 0) {
|
|
||||||
$role = $this->ci->classMapper->getClassMapping('role')::where('slug', 'site-admin')->with('users')->first();
|
|
||||||
}
|
|
||||||
$recipientsQuery = $role->users();
|
|
||||||
}
|
|
||||||
|
|
||||||
$recipients = $recipientsQuery->get();
|
|
||||||
|
|
||||||
foreach($recipients as $recipient) {
|
foreach($recipients as $recipient) {
|
||||||
$message->addEmailRecipient(new EmailRecipient($recipient->email, $recipient->full_name));
|
$message->addEmailRecipient(new EmailRecipient($recipient->email, $recipient->full_name));
|
||||||
$message->addParams([ 'recipient' => $recipient ]);
|
$message->addParams([ 'recipient' => $recipient ]);
|
||||||
|
|||||||
@@ -3,6 +3,12 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
{% if admin_fallback %}
|
||||||
|
<hr style="color: #990000" />
|
||||||
|
<h3 style="color: #990000">You are receiving this email as an organisation/site administrator!</h3>
|
||||||
|
<p style="color: #990000">This email has been sent to you in lieu of <b>{{organisation.name}}</b> as there are currently no approved administrators for the organisation.</p>
|
||||||
|
<hr style="color: #990000" />
|
||||||
|
{% endif %}
|
||||||
<p>
|
<p>
|
||||||
Dear {{recipient.first_name}},
|
Dear {{recipient.first_name}},
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user