-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #411 from rowan04/410-remove-hardwired-email-addre…
…sses Add config calls so email addresses aren't hardwired into code
- Loading branch information
Showing
5 changed files
with
47 additions
and
7 deletions.
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
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
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 |
---|---|---|
|
@@ -243,6 +243,8 @@ public function getRequestByConfirmationCode($code) { | |
*/ | ||
private function composeEmail($primaryIdString, $currentIdString, $primaryAuthType, $currentAuthType, $isLinking, $isRegistered, $isPrimary, $link=null) { | ||
|
||
$configService = \Factory::getConfigService(); | ||
|
||
$subject = "Validation of " . ($isLinking ? "linking" : "recovering") . " your GOCDB account"; | ||
|
||
$body = "Dear GOCDB User," | ||
|
@@ -274,7 +276,8 @@ private function composeEmail($primaryIdString, $currentIdString, $primaryAuthTy | |
. "\n\n$link"; | ||
} | ||
|
||
$body .= "\n\nIf you did not create this request, please immediately contact [email protected]"; | ||
$emailSendTo = $configService->getEmailTo(); | ||
$body .= "\n\nIf you did not create this request, please immediately contact " . $emailSendTo; | ||
|
||
return array('subject'=>$subject, 'body'=>$body); | ||
} | ||
|
@@ -293,6 +296,8 @@ private function composeEmail($primaryIdString, $currentIdString, $primaryAuthTy | |
*/ | ||
private function sendConfirmationEmails($primaryUser, $currentUser, $code, $primaryIdString, $currentIdString, $primaryAuthType, $currentAuthType, $isLinking, $isRegistered) { | ||
|
||
$configService = \Factory::getConfigService(); | ||
|
||
// Create link to be clicked in email | ||
$portalUrl = \Factory::getConfigService()->GetPortalURL(); | ||
$link = $portalUrl."/index.php?Page_Type=User_Validate_Identity_Link&c=" . $code; | ||
|
@@ -304,7 +309,8 @@ private function sendConfirmationEmails($primaryUser, $currentUser, $code, $prim | |
$primaryBody = $composedPrimaryEmail['body']; | ||
|
||
// If "sendmail_from" is set in php.ini, use second line ($headers = '';): | ||
$headers = "From: GOCDB <[email protected]>"; | ||
$emailSentFrom = $configService->getEmailFrom(); | ||
$headers = "From: GOCDB <" . $emailSentFrom . ">"; | ||
|
||
// Mail command returns boolean. False if message not accepted for delivery. | ||
if (!mail($primaryUser->getEmail(), $primarySubject, $primaryBody, $headers)) { | ||
|
@@ -414,4 +420,4 @@ public function confirmIdentityLinking($code, $currentIdString) { | |
|
||
return $request; | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -113,6 +113,8 @@ private function sendEmail($roleRequested, $requestingUser, $entityName, $approv | |
$roleRequested->getOwnedEntity()->getName() | ||
); | ||
|
||
$configService = \Factory::getConfigService(); | ||
|
||
$body = sprintf( | ||
implode("\n", array( | ||
'Dear %1$s,', | ||
|
@@ -123,17 +125,23 @@ private function sendEmail($roleRequested, $requestingUser, $entityName, $approv | |
' %6$s/index.php?Page_Type=Role_Requests', | ||
'', | ||
'Note: This role could already have been approved or denied by another GOCDB User', | ||
'', | ||
'Please do not reply to this email. If you would like to get in touch with the ' . | ||
'GOCDB admins please send an email to: %7$s', | ||
)), | ||
$approvingUser->getForename(), | ||
$requestingUser->getForename(), | ||
$requestingUser->getSurname(), | ||
$roleRequested->getRoleType()->getName(), | ||
$roleRequested->getOwnedEntity()->getName(), | ||
$this->getWebPortalURL() | ||
$this->getWebPortalURL(), | ||
$configService->getEmailTo() | ||
); | ||
|
||
$emailAddress = $approvingUser->getEmail(); | ||
$headers = "From: GOCDB <[email protected]>"; | ||
|
||
$emailSentFrom = $configService->getEmailFrom(); | ||
$headers = "From: GOCDB <" . $emailSentFrom . ">"; | ||
|
||
\Factory::getEmailService()->send($emailAddress, $subject, $body, $headers); | ||
} | ||
|
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 |
---|---|---|
|
@@ -176,8 +176,14 @@ function sendWarningEmail($user, $elapsedMonths, $deletionThreshold) | |
{ | ||
$emailAddress = $user->getEmail(); | ||
|
||
$configService = \Factory::getConfigService(); | ||
|
||
$emailSentFrom = $configService->getEmailFrom(); | ||
|
||
$emailSendTo = $configService->getEmailTo(); | ||
|
||
// Email content | ||
$headers = "From: GOCDB <[email protected]>"; | ||
$headers = "From: GOCDB <" . $emailSentFrom . ">"; | ||
$subject = "GOCDB: User account deletion notice"; | ||
|
||
$body = "Dear ". $user->getForename() .",\n\n" . | ||
|
@@ -202,7 +208,9 @@ function sendWarningEmail($user, $elapsedMonths, $deletionThreshold) | |
$body .= "\n"; | ||
$body .= "You can prevent the deletion of this account by visiting the " . | ||
"GOCDB portal while authenticated with one of the above " . | ||
"identifiers.\n"; | ||
"identifiers.\n\n"; | ||
$body .= "Please do not reply to this email. If you would like to get in touch " . | ||
"with the GOCDB admins please send an email to: " . $emailSendTo . "\n"; | ||
|
||
|
||
// Handle all mail related printing/debugging | ||
|