Compare commits
3 Commits
a61231e977
...
v0.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
| c99a277e2a | |||
| 5a0906eb43 | |||
| a820fb56e0 |
@@ -1370,6 +1370,20 @@ class OrganisationMembersController extends SimpleController
|
||||
{
|
||||
$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
|
||||
$message = new TwigMailMessage($this->ci->view, 'mail/organisation-membership-request.html.twig');
|
||||
|
||||
@@ -1379,20 +1393,9 @@ class OrganisationMembersController extends SimpleController
|
||||
'organisation' => $organisation,
|
||||
'token' => $token,
|
||||
'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) {
|
||||
$message->addEmailRecipient(new EmailRecipient($recipient->email, $recipient->full_name));
|
||||
$message->addParams([ 'recipient' => $recipient ]);
|
||||
|
||||
@@ -154,6 +154,12 @@ class OrganisationPermissions extends BaseSeed
|
||||
'conditions' => 'always()',
|
||||
'description' => 'View the organisation page of any organisation.',
|
||||
]),
|
||||
'uri_user' => new Permission([
|
||||
'slug' => 'uri_user',
|
||||
'name' => 'View organisation member',
|
||||
'conditions' => 'can_admin_via_orgs(self.id, user.id)',
|
||||
'description' => 'View the user page of any member of your organisation.',
|
||||
]),
|
||||
'uri_organisation_own' => new Permission([
|
||||
'slug' => 'uri_organisation',
|
||||
'name' => 'View own organisation',
|
||||
@@ -262,6 +268,7 @@ class OrganisationPermissions extends BaseSeed
|
||||
$permissions['restore_organisation']->id,
|
||||
$permissions['permenent_delete_organisation']->id,
|
||||
|
||||
$permissions['uri_user']->id,
|
||||
$permissions['uri_organisation']->id,
|
||||
$permissions['uri_deleted_organisations']->id,
|
||||
|
||||
@@ -306,6 +313,7 @@ class OrganisationPermissions extends BaseSeed
|
||||
$permissions['restore_organisation']->id,
|
||||
$permissions['permenent_delete_organisation']->id,
|
||||
|
||||
$permissions['uri_user']->id,
|
||||
$permissions['uri_organisation']->id,
|
||||
$permissions['uri_deleted_organisations']->id,
|
||||
|
||||
@@ -340,13 +348,6 @@ class OrganisationPermissions extends BaseSeed
|
||||
]);
|
||||
}
|
||||
|
||||
$roleAuditer = Role::where('slug', 'auditer')->first();
|
||||
if ($roleAuditer) {
|
||||
$roleAuditer->permissions()->syncWithoutDetaching([
|
||||
Permission::where('slug', 'uri_activities')->first()->id,
|
||||
]);
|
||||
}
|
||||
|
||||
$roleUser = Role::where('slug', 'user')->first();
|
||||
if ($roleUser) {
|
||||
$roleUser->permissions()->syncWithoutDetaching([
|
||||
@@ -362,9 +363,10 @@ class OrganisationPermissions extends BaseSeed
|
||||
$permissions['view_organisation_field_own']->id,
|
||||
$permissions['update_organisation_field_own']->id,
|
||||
|
||||
|
||||
$permissions['uri_organisation_own']->id,
|
||||
$permissions['uri_organisations']->id,
|
||||
|
||||
$permissions['uri_user']->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,11 +43,6 @@ class OrganisationRoles extends BaseSeed
|
||||
'name' => 'Organisations Administrator',
|
||||
'description' => 'This role is meant for "organisation administrators", who can basically do anything related to organisations and their members.',
|
||||
]),
|
||||
new Role([
|
||||
'slug' => 'auditer',
|
||||
'name' => 'Audit Viewer',
|
||||
'description' => 'This role is meant for "auditers", who are allowed to view the activity log.',
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
{% endblock %}
|
||||
|
||||
{% 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>
|
||||
Dear {{recipient.first_name}},
|
||||
</p>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{% extends "tables/users.html.twig" %}
|
||||
|
||||
{% use 'tables/partials/organisation-members/column-info.html.twig' %}
|
||||
{% use 'tables/partials/organisation-members/column-status.html.twig' %}
|
||||
{% use 'tables/partials/organisation-members/column-actions.html.twig' %}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
{% block table_cell_template_info %}
|
||||
<script id="{{table.id}}-column-info" type="text/x-handlebars-template">
|
||||
{%- verbatim %}
|
||||
<td data-text="{{row.last_name}}">
|
||||
<strong>
|
||||
{% endverbatim -%}{% if isOrganisationAdmin(organisation) %}{%- verbatim %}
|
||||
<a href="{{site.uri.public}}/users/u/{{row.user_name}}">{{row.first_name}} {{row.last_name}} ({{row.user_name}})</a>
|
||||
{% endverbatim -%}{% else %}{%- verbatim %}
|
||||
{{row.first_name}} {{row.last_name}} ({{row.user_name}})
|
||||
{% endverbatim -%}{% endif %}{%- verbatim %}
|
||||
</strong>
|
||||
<div class="js-copy-container">
|
||||
<span class="js-copy-target">{{row.email}}</span>
|
||||
<button class="btn btn-xs uf-copy-trigger js-copy-trigger"><i class="fas fa-copy"></i></button>
|
||||
</div>
|
||||
</td>
|
||||
{% endverbatim -%}
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user