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

@@ -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);