Skip to content
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
wants to merge 10 commits into
base: dev
Choose a base branch
from
33 changes: 33 additions & 0 deletions lib/Gocdb_Services/NotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Copy link
Member

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?

} else {
// If the entity has valid users who can approve the role then send the email notification.

Expand Down Expand Up @@ -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);
}
}