-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue 306 - If no other user can approve a role request, email the GOCDB admins #331
Open
jounaidr
wants to merge
10
commits into
GOCDB:dev
Choose a base branch
from
jounaidr:306-email-admins-if-no-approvers
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2c602e4
Update NotificationService.php
jounaidr 1c63fad
Update NotificationService.php
jounaidr 3dcce29
Edit email header
jounaidr 6fc4a56
Fix code smells
jounaidr c801c5f
fix code smells
jounaidr 6e52a97
Address comments
jounaidr 51a56d1
Add gocdb admin email to local config
jounaidr ae87eea
Add method to config service to get gocdb admin email
jounaidr 69c3d26
get gocdb admin email from config
jounaidr 4331d86
fix alignment
jounaidr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,8 @@ public function roleRequest ($roleRequested, $requestingUser, $entity) { | |
} | ||
$projectIds = array_unique ( $projectIds ); | ||
} | ||
// Also send email to GOCDB Admins | ||
$this->sendGocdbAdminsEmail($roleRequested, $requestingUser, $entity->getName()); | ||
} else { | ||
// If the entity has valid users who can approve the role then send the email notification. | ||
|
||
|
@@ -137,4 +139,35 @@ private function sendEmail($roleRequested, $requestingUser, $entityName, $approv | |
|
||
\Factory::getEmailService()->send($emailAddress, $subject, $body, $headers); | ||
} | ||
|
||
private function sendGocdbAdminsEmail($roleRequested, $requestingUser) { | ||
$subject = sprintf( | ||
'GOCDB: A Role request from %1$s %2$s over %3$s has no approving users', | ||
$requestingUser->getForename(), | ||
$requestingUser->getSurname(), | ||
$roleRequested->getOwnedEntity()->getName() | ||
); | ||
|
||
$body = sprintf( | ||
implode("\n", array( | ||
'Dear GOCDB Admins,', | ||
'', | ||
'%1$s %2$s requested the "%3$s" role over %4$s, and there are no '. | ||
'approving users available for the request.', | ||
'', | ||
'You can approve or deny the request here:', | ||
' %5$s/index.php?Page_Type=Role_Requests', | ||
)), | ||
$requestingUser->getForename(), | ||
$requestingUser->getSurname(), | ||
$roleRequested->getRoleType()->getName(), | ||
$roleRequested->getOwnedEntity()->getName(), | ||
$this->getWebPortalURL() | ||
); | ||
|
||
$emailAddress = "[email protected]"; | ||
jounaidr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$headers = "From: GOCDB"; | ||
|
||
\Factory::getEmailService()->send($emailAddress, $subject, $body, $headers); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By putting this here, does that mean if an NGI role is requested and no one at the NGI level can approve, do the GOCDB admins get an email regardless of whether there is someone at the project level who can approve the request?