Change language from Reject to Deny

This commit is contained in:
2022-02-11 13:37:55 +00:00
parent da89a688b9
commit 016f7489c4
13 changed files with 83 additions and 80 deletions

View File

@@ -47,14 +47,14 @@ function attachOrganisationForm() {
}
/**
* Approve/Reject organisation
* Approve/Deny organisation registration
*/
function approveOrganisation(slug, approve, options) {
function approveOrganisationRegistration(slug, approve, options) {
var data = {};
data[site.csrf.keys.name] = site.csrf.name;
data[site.csrf.keys.value] = site.csrf.value;
var url = site.uri.public + '/api/organisations/o/' + slug + '/registration/' + (approve ? 'approve' : 'reject');
var url = site.uri.public + '/api/organisations/o/' + slug + '/registration/' + (approve ? 'approve' : 'deny');
var debugAjax = (typeof site !== "undefined") && site.debug.ajax;
return $.ajax({
@@ -270,14 +270,14 @@ function bindOrganisationButtons(el, options) {
el.find('.js-organisation-approveRegistration').click(function(e) {
e.preventDefault();
approveOrganisation($(this).data('slug'), true, options);
approveOrganisationRegistration($(this).data('slug'), true, options);
});
// Cancel a registration request
el.find('.js-organisation-rejectRegistration').click(function(e) {
el.find('.js-organisation-denyRegistration').click(function(e) {
e.preventDefault();
approveOrganisation($(this).data('slug'), false, options);
approveOrganisationRegistration($(this).data('slug'), false, options);
});
// Delete organisation button

View File

@@ -42,14 +42,6 @@ return [
'DELETE_YES' => 'Yes, delete organisation',
'DELETION_SUCCESSFUL' => 'Successfully deleted organisation <strong>{{name}}</strong>',
'REGISTER' => 'Register organisation',
'REGISTRATION_SUCCESSFUL' => 'Successfully registered organisation <strong>{{name}}</strong>',
'CANCEL_REGISTRATION' => 'Cancel organisation registration',
'CANCEL_REGISTRATION_CONFIRM' => 'Are you sure you want to cancel the registration request for organisation <strong>{{name}}</strong>?',
'CANCEL_REGISTRATION_YES' => 'Yes, cancel organisation registration',
'CANCEL_REGISTRATION_SUCCESSFUL' => 'Successfully cancelled registration of organisation <strong>{{name}}</strong>',
'MEMBER_COUNT' => '# Members <sub>(excl admins)</sub>',
'ADMIN_COUNT' => '# Admins',
@@ -74,13 +66,21 @@ return [
'SLUG' => [
'IN_USE' => 'Organisation slug <strong>{{slug}}</strong> is already in use.',
],
'APPROVAL' => [
'REGISTRATION' => [
'REGISTER' => 'Register organisation',
'SUCCESSFUL' => 'Successfully registered organisation <strong>{{name}}</strong>',
'CANCEL' => 'Cancel organisation registration',
'CANCEL_CONFIRM' => 'Are you sure you want to cancel the registration request for organisation <strong>{{name}}</strong>?',
'CANCEL_YES' => 'Yes, cancel organisation registration',
'CANCEL_SUCCESSFUL' => 'Successfully cancelled registration of organisation <strong>{{name}}</strong>',
'PENDING' => 'This organisation is pending approval!',
'TOKEN_NOT_FOUND' => 'Approval token does not exist / Organisation is already approved/rejected.',
'APPROVED' => 'You have successfully approved the organisation <strong>{{name}}</strong>.',
'REJECTED' => 'You have successfully rejected the organisation <strong>{{name}}</strong>.',
'APPROVE' => 'Approve organisation',
'REJECT' => 'Reject organisation',
'TOKEN_NOT_FOUND' => 'Approval token does not exist / Organisation registration has already been approved/denied.',
'APPROVED' => 'You have successfully approved the registration of organisation <strong>{{name}}</strong>.',
'DENIED' => 'You have successfully denied the registration of organisation <strong>{{name}}</strong>.',
'APPROVE' => 'Approve organisation registration',
'DENY' => 'Deny organisation registration',
],
],
@@ -106,7 +106,7 @@ return [
'APPROVED' => 'Approved',
'PENDING' => 'Pending',
'APPROVE' => 'Approve',
'REJECT' => 'Reject',
'DENY' => 'Deny',
'VIEW_DELETED' => 'View deleted',
'DELETED' => 'Deleted',

View File

@@ -14,16 +14,16 @@ use UserFrosting\Sprinkle\Core\Util\NoCache;
*/
$app->group('/organisations/registration', function () {
$this->get('/approve', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:approveToken');
$this->get('/reject', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:rejectToken');
$this->get('/deny', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:denyToken');
})->add('authGuard')->add(new NoCache());
$app->group('/api/organisations', function () {
$this->post('/registeration', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:register');
$this->post('/registration', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:register');
})->add('authGuard')->add(new NoCache());
$app->group('/api/organisations/o/{slug}/registration', function () {
$this->put('/approve', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:approve');
$this->put('/reject', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:reject');
$this->put('/deny', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:deny');
$this->delete('', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:cancel');
})->add('authGuard')->add(new NoCache());

View File

@@ -27,7 +27,7 @@ use UserFrosting\Sprinkle\Core\Mail\TwigMailMessage;
use UserFrosting\Sprinkle\Core\Mail\EmailRecipient;
/**
* Controller class for organisation registration-related requests, including registering, approving, rejecting, etc.
* Controller class for organisation registration-related requests, including registering, approving, denying, etc.
*
* @author Craig Williams (https://avsdev.uk)
*/
@@ -143,7 +143,7 @@ class OrganisationRegistrationController extends SimpleController
$this->sendApprovalEmail($currentUser, $organisation, $approval->getToken());
}
$ms->addMessageTranslated('success', 'ORGANISATION.REGISTRATION_SUCCESSFUL', $data);
$ms->addMessageTranslated('success', 'ORGANISATION.REGISTRATION.SUCCESSFUL', $data);
});
return $response->withJson([], 200);
@@ -217,7 +217,7 @@ class OrganisationRegistrationController extends SimpleController
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
$ms = $this->ci->alerts;
$ms->addMessageTranslated('success', 'ORGANISATION.CANCEL_REGISTRATION_SUCCESSFUL', [
$ms->addMessageTranslated('success', 'ORGANISATION.REGISTRATION.CANCEL_SUCCESSFUL', [
'name' => $organisationName,
]);
@@ -281,7 +281,7 @@ class OrganisationRegistrationController extends SimpleController
'user_id' => $currentUser->id,
]);
$ms->addMessageTranslated('success', 'ORGANISATION.APPROVAL.APPROVED', [
$ms->addMessageTranslated('success', 'ORGANISATION.REGISTRATION.APPROVED', [
'name' => $organisation->name
]);
@@ -348,7 +348,7 @@ class OrganisationRegistrationController extends SimpleController
$verification = $this->ci->repoOrganisationApproval->complete($data['token'], $currentUser, ['approved' => true]);
if (!$verification) {
$ms->addMessageTranslated('danger', 'ORGANISATION.APPROVAL.TOKEN_NOT_FOUND');
$ms->addMessageTranslated('danger', 'ORGANISATION.REGISTRATION.TOKEN_NOT_FOUND');
return $response->withRedirect($this->ci->router->pathFor('dashboard'));
}
@@ -362,7 +362,7 @@ class OrganisationRegistrationController extends SimpleController
'user_id' => $currentUser->id,
]);
$ms->addMessageTranslated('success', 'ORGANISATION.APPROVAL.APPROVED', [
$ms->addMessageTranslated('success', 'ORGANISATION.REGISTRATION.APPROVED', [
'name' => $organisation->name
]);
@@ -371,7 +371,7 @@ class OrganisationRegistrationController extends SimpleController
}
/**
* Rejects an organisation registration request.
* Denies an organisation registration request.
*
* Processes the request from the email verification link that was emailed to the organisation administrators, checking that:
* 1. The token provided matches an organisation in the database;
@@ -379,7 +379,7 @@ class OrganisationRegistrationController extends SimpleController
* This route requires authorization.
*
* AuthGuard: true
* Route: /organisations/o/{slug}/reject
* Route: /organisations/o/{slug}/deny
* Route Name: {none}
* Request type: GET
*
@@ -387,7 +387,7 @@ class OrganisationRegistrationController extends SimpleController
* @param Response $response
* @param array $args
*/
public function reject(Request $request, Response $response, $args)
public function deny(Request $request, Response $response, $args)
{
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
$ms = $this->ci->alerts;
@@ -420,16 +420,16 @@ class OrganisationRegistrationController extends SimpleController
$requester = $classMapper->getClassMapping('user')::find($verification->requester_id);
$this->sendRejectedEmail($organisation, $requester);
$this->sendDeniedEmail($organisation, $requester);
$organisation->delete();
$this->ci->userActivityLogger->info("User {$currentUser->user_name} rejected the registration request for organisation {$organisation->name}.", [
'type' => 'organisation_rejected',
$this->ci->userActivityLogger->info("User {$currentUser->user_name} denied the registration request for organisation {$organisation->name}.", [
'type' => 'organisation_approval',
'user_id' => $currentUser->id,
]);
$ms->addMessageTranslated('success', 'ORGANISATION.APPROVAL.REJECTED', [
$ms->addMessageTranslated('success', 'ORGANISATION.REGISTRATION.DENIED', [
'name' => $organisation->name
]);
@@ -437,7 +437,7 @@ class OrganisationRegistrationController extends SimpleController
}
/**
* Rejects an organisation registration request.
* Denies an organisation registration request.
*
* Processes the request from the email verification link that was emailed to the organisation administrators, checking that:
* 1. The token provided matches an organisation in the database;
@@ -445,7 +445,7 @@ class OrganisationRegistrationController extends SimpleController
* This route requires authorization.
*
* AuthGuard: true
* Route: /organisations/o/{slug}/reject
* Route: /organisations/o/{slug}/deny
* Route Name: {none}
* Request type: GET
*
@@ -453,7 +453,7 @@ class OrganisationRegistrationController extends SimpleController
* @param Response $response
* @param array $args
*/
public function rejectToken(Request $request, Response $response, $args)
public function denyToken(Request $request, Response $response, $args)
{
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
$ms = $this->ci->alerts;
@@ -499,7 +499,7 @@ class OrganisationRegistrationController extends SimpleController
$verification = $this->ci->repoOrganisationApproval->complete($data['token'], $currentUser, ['approved' => false]);
if ($verification === false) {
$ms->addMessageTranslated('danger', 'ORGANISATION.APPROVAL.TOKEN_NOT_FOUND');
$ms->addMessageTranslated('danger', 'ORGANISATION.REGISTRATION.TOKEN_NOT_FOUND');
return $response->withRedirect($dashboardPage);
}
@@ -507,14 +507,14 @@ class OrganisationRegistrationController extends SimpleController
$organisation = $classMapper->getClassMapping('organisation')::find($verification->organisation_id);
$requester = $classMapper->getClassMapping('user')::find($verification->requester_id);
$this->sendRejectedEmail($organisation, $requester);
$this->sendDeniedEmail($organisation, $requester);
$this->ci->userActivityLogger->info("User {$currentUser->user_name} rejected the registration request for organisation {$organisation->name}.", [
'type' => 'organisation_rejected',
$this->ci->userActivityLogger->info("User {$currentUser->user_name} denied the registration request for organisation {$organisation->name}.", [
'type' => 'organisation_approval',
'user_id' => $currentUser->id,
]);
$ms->addMessageTranslated('success', 'ORGANISATION.APPROVAL.REJECTED', [
$ms->addMessageTranslated('success', 'ORGANISATION.REGISTRATION.DENIED', [
'name' => $organisation->name
]);
@@ -572,7 +572,7 @@ class OrganisationRegistrationController extends SimpleController
return $this->ci->view->render($response, 'modals/organisation.html.twig', [
'organisation' => $organisation,
'form' => [
'action' => 'api/organisations/registeration',
'action' => 'api/organisations/registration',
'method' => 'POST',
'fields' => $fields,
'submit_text' => $translator->translate('REGISTER'),
@@ -694,14 +694,14 @@ class OrganisationRegistrationController extends SimpleController
}
/**
* Send rejected email for specified organisation.
* Send denied email for specified organisation.
*
* @param UserInterface $requester The user to send the rejection notice to
* @param UserInterface $requester The user to send the denial notice to
* @param UserInterface $organisation The organisation to send the email for
*/
protected function sendRejectedEmail(OrganisationInterface $organisation, UserInterface $requester)
protected function sendDeniedEmail(OrganisationInterface $organisation, UserInterface $requester)
{
$message = new TwigMailMessage($this->ci->view, 'mail/organisation-approval-rejected.html.twig');
$message = new TwigMailMessage($this->ci->view, 'mail/organisation-approval-denied.html.twig');
$message->from($this->ci->config['address_book.admin'])
->addParams([

View File

@@ -97,7 +97,7 @@ class BaseOrganisationApproval extends Model
}
/**
* Get the user associated with this approval or rejection of this request.
* Get the user associated with this approval or denial of this request.
*
* @return \Illuminate\Database\Eloquent\Relations\belongsTo
*/

View File

@@ -95,9 +95,9 @@ class OrganisationPermissions extends BaseSeed
]),
'approve_organisation' => new Permission([
'slug' => 'approve_organisation',
'name' => 'Approve/Reject organisation',
'name' => 'Approve/Deny organisation registration',
'conditions' => 'always()',
'description' => 'Approve/Reject organisation registation request.',
'description' => 'Approve/Deny organisation registation request.',
]),
'merge_organisations' => new Permission([
'slug' => 'merge_organisations',

View File

@@ -39,7 +39,8 @@ class OrganisationApprovalRepository extends TokenRepository
$hash = hash($this->algorithm, $token);
// Find an unexpired, incomplete token for the specified hash
$model = $this->classMapper->getClassMapping($this->modelIdentifier)::where('hash', $hash)
$model = $this->classMapper->getClassMapping($this->modelIdentifier)::query()
->where('hash', $hash)
->where('completed', false)
->where(function($query) {
return $query->where('expires_at', '>', Carbon::now())->orWhereNull('expires_at');
@@ -80,7 +81,8 @@ class OrganisationApprovalRepository extends TokenRepository
*/
public function completeWithoutToken(OrganisationInterface $organisation, UserInterface $approver, $params = [])
{
$model = $this->classMapper->getClassMapping($this->modelIdentifier)::where('organisation_id', $organisation->id)
$model = $this->classMapper->getClassMapping($this->modelIdentifier)::query()
->where('organisation_id', $organisation->id)
->where('completed', false)
->first();
@@ -132,14 +134,13 @@ class OrganisationApprovalRepository extends TokenRepository
$hash = hash($this->algorithm, $model->getToken());
$model->fill([
'hash' => $hash,
'completed' => false,
'expires_at' => ($timeout >= 0 ? $expiresAt : null),
'organisation_id' => $organisation->id,
'requester_id' => $requester->id,
'hash' => $hash,
'completed' => false,
'expires_at' => ($timeout >= 0 ? $expiresAt : null),
]);
$model->organisation_id = $organisation->id;
$model->requester_id = $requester->id;
$model->save();
return $model;
@@ -150,7 +151,8 @@ class OrganisationApprovalRepository extends TokenRepository
*/
public function exists(OrganisationInterface $organisation, UserInterface $requester = null, $token = null)
{
$model = $this->classMapper->getClassMapping($this->modelIdentifier)::where('organisation_id', $organisation->id)
$model = $this->classMapper->getClassMapping($this->modelIdentifier)::query()
->where('organisation_id', $organisation->id)
->where('completed', false)
->where(function($query) {
return $query->where('expires_at', '>', Carbon::now())->orWhereNull('expires_at');
@@ -174,7 +176,8 @@ class OrganisationApprovalRepository extends TokenRepository
*/
protected function removeExisting(OrganisationInterface $organisation, UserInterface $requester = null)
{
$model = $this->classMapper->getClassMapping($this->modelIdentifier)::where('organisation_id', $organisation->id);
$model = $this->classMapper->getClassMapping($this->modelIdentifier)::query()
->where('organisation_id', $organisation->id);
if ($requester) {
$model->where('requester_id', $requester->id);

View File

@@ -1,5 +1,5 @@
{% block subject %}
{{site.title}} - organisation registration rejected
{{site.title}} - organisation registration denied
{% endblock %}
{% block body %}
@@ -7,7 +7,7 @@
Dear {{recipient.first_name}},
</p>
<p>
The organisation registration request you submitted at {{site.title}} ({{site.uri.public}}) has been rejected.
The organisation registration request you submitted at {{site.title}} ({{site.uri.public}}) has been denied.
</p>
<p>
With regards,<br>

View File

@@ -26,17 +26,17 @@
</p>
<p>
You may verify or reject this organisation via the control dashboard (<a href="{{site.uri.public}}/organisations">{{site.uri.public}}/organisations</a>).
You may approve or deny this organisation via the control dashboard (<a href="{{site.uri.public}}/organisations">{{site.uri.public}}/organisations</a>).
</p>
<p>
To verify this organisation immediately you may do so by visiting: <a href="{{site.uri.public}}/organisations/registration/approve?token={{token}}">{{site.uri.public}}/organisations/approve?token={{token}}</a>.
To approve this organisation immediately you may do so by visiting: <a href="{{site.uri.public}}/organisations/registration/approve?token={{token}}">{{site.uri.public}}/organisations/approve?token={{token}}</a>.
</p>
<p>
To reject this organisation immediately you may do so by visiting: <a href="{{site.uri.public}}/organisations/registration/reject?token={{token}}">{{site.uri.public}}/organisations/reject?token={{token}}</a>.
To deny this organisation immediately you may do so by visiting: <a href="{{site.uri.public}}/organisations/registration/deny?token={{token}}">{{site.uri.public}}/organisations/deny?token={{token}}</a>.
</p>
{% if approval_expiration %}
<p>
The approcal period for this organisation will expire in {{approval_expiration}} at which point the organisation will be automatically rejected.
The approcal period for this organisation will expire in {{approval_expiration}} at which point the organisation registration will be automatically denied.
</p>
{% endif %}
<p>

View File

@@ -1,16 +1,16 @@
{% extends "modals/modal.html.twig" %}
{% block modal_title %}{{translate("ORGANISATION.CANCEL_REGISTRATION")}}{% endblock %}
{% block modal_title %}{{translate("ORGANISATION.REGISTRATION.CANCEL")}}{% endblock %}
{% block modal_body %}
<form class="js-form" method="delete" action="{{site.uri.public}}/{{form.action}}">
{% include "forms/csrf.html.twig" %}
<div class="js-form-alerts">
</div>
<h4>{{translate("ORGANISATION.CANCEL_REGISTRATION_CONFIRM", {name: organisation.name})}}{% if delete_hard %}<br><small>{{translate("DELETE_CANNOT_UNDONE")}}</small>{% endif %}</h4>
<h4>{{translate("ORGANISATION.REGISTRATION.CANCEL_CONFIRM", {name: organisation.name})}}{% if delete_hard %}<br><small>{{translate("ACTION_CANNOT_UNDONE")}}</small>{% endif %}</h4>
<br>
<div class="btn-group-action">
<button type="submit" class="btn btn-danger btn-lg btn-block">{{translate("ORGANISATION.CANCEL_REGISTRATION_YES")}}</button>
<button type="submit" class="btn btn-danger btn-lg btn-block">{{translate("ORGANISATION.REGISTRATION.CANCEL_YES")}}</button>
<button type="button" class="btn btn-default btn-lg btn-block" data-dismiss="modal">{{translate("CANCEL")}}</button>
</div>
</form>

View File

@@ -46,8 +46,8 @@
</a>
</li>
<li>
<a href="#" class="js-organisation-rejectRegistration" data-slug="{{organisation.slug}}">
<i class="fas fa-thumbs-down fa-fw"></i> {{translate('REJECT')}}
<a href="#" class="js-organisation-denyRegistration" data-slug="{{organisation.slug}}">
<i class="fas fa-thumbs-down fa-fw"></i> {{translate('DENY')}}
</a>
</li>
{% endif %}
@@ -75,12 +75,12 @@
{% if organisation.flag_approved != 1 %}
<hr>
<h4 class="text-danger text-center">
{{ translate('ORGANISATION.APPROVAL.PENDING') }}
{{ translate('ORGANISATION.REGISTRATION.PENDING') }}
</h4>
<div class="text-center">
{% if checkAccess('approve_organisation') %}
<button type="button" class="btn btn-success js-organisation-approveRegistration" data-slug="{{organisation.slug}}">{{translate('APPROVE')}}</button>
<button type="button" class="btn btn-danger js-organisation-rejectRegistration" data-slug="{{organisation.slug}}">{{translate('REJECT')}}</button>
<button type="button" class="btn btn-danger js-organisation-denyRegistration" data-slug="{{organisation.slug}}">{{translate('DENY')}}</button>
{% elseif isOrganisationAdmin(organisation) %}
<button type="button" class="btn btn-danger js-organisation-cancelRegistration" data-slug="{{organisation.slug}}">{{translate('CANCEL_REGISTRATION')}}</button>
{% endif %}

View File

@@ -36,7 +36,7 @@
</button>
{% elseif checkAccess('register_organisation') %}
<button type="button" class="btn btn-success js-organisation-register">
<i class="fas fa-plus-square"></i> {{translate("ORGANISATION.REGISTER")}}
<i class="fas fa-plus-square"></i> {{translate("ORGANISATION.REGISTRATION.REGISTER")}}
</button>
{% endif %}
</div>

View File

@@ -116,12 +116,12 @@
{{#ifx row.flag_approved '==' 0 }}
<li>
<a href="#" data-slug="{{row.slug}}" class="js-organisation-approveRegistration">
<i class="fas fa-thumbs-up"></i> {% endverbatim %}{{translate("ORGANISATION.APPROVAL.APPROVE")}}{% verbatim %}
<i class="fas fa-thumbs-up"></i> {% endverbatim %}{{translate("ORGANISATION.REGISTRATION.APPROVE")}}{% verbatim %}
</a>
</li>
<li>
<a href="#" data-slug="{{row.slug}}" class="js-organisation-rejectRegistration">
<i class="fas fa-thumbs-down"></i> {% endverbatim %}{{translate("ORGANISATION.APPROVAL.REJECT")}}{% verbatim %}
<a href="#" data-slug="{{row.slug}}" class="js-organisation-denyRegistration">
<i class="fas fa-thumbs-down"></i> {% endverbatim %}{{translate("ORGANISATION.REGISTRATION.DENY")}}{% verbatim %}
</a>
</li>
{{/ifx }}