Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/local_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
accounts (e.g. associating a user account with a new cert DN).
-->
<send_email>false</send_email>

<!-- Email list for GOCDB admins -->
<admins_email>gocdb-admins@mailman.egi.eu</admins_email>

<!-- menus
Give the xml element names from config/web_portal/menu.xml
Expand Down
5 changes: 5 additions & 0 deletions lib/Gocdb_Services/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ public function getSendEmails(){
return $sendEmail;
}

public function getGocdbAdminsEmail(){
$gocdbAdminEmail = $this->GetLocalInfoXML()->admins_email;
return $gocdbAdminEmail;
}

public function getAPIAllAuthRealms() {
if (strtolower($this->GetLocalInfoXML()->API_all_auth_realms) === 'true') {
return true;
Expand Down
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 = \Factory::getConfigService()->getGocdbAdminsEmail();
$headers = "From: GOCDB";

\Factory::getEmailService()->send($emailAddress, $subject, $body, $headers);
}
}