-
Notifications
You must be signed in to change notification settings - Fork 0
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 #18 from IQSS/email_sender_overwrite
Add global email sender configuration and functionality
- Loading branch information
Showing
7 changed files
with
51 additions
and
1 deletion.
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
36 changes: 36 additions & 0 deletions
36
pprOjsPlugin/services/email/PPREmailSenderOverwrite.inc.php
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/** | ||
* Service to overwrite the senders email | ||
* | ||
*/ | ||
class PPREmailSenderOverwrite { | ||
|
||
private $pprPlugin; | ||
|
||
public function __construct($plugin) { | ||
$this->pprPlugin = $plugin; | ||
} | ||
|
||
function register() { | ||
|
||
$globalEmailSender = $this->pprPlugin->getPluginSettings()->globalEmailSender(); | ||
|
||
if (!empty($globalEmailSender)) { | ||
HookRegistry::register('Mail::send', array($this, 'overwriteSender')); | ||
} | ||
} | ||
|
||
/** | ||
* Overwrite the sender of the email | ||
*/ | ||
function overwriteSender($hookName, $hookArgs) { | ||
|
||
$globalEmailSender = $this->pprPlugin->getPluginSettings()->globalEmailSender(); | ||
|
||
$mail = $hookArgs[0]; | ||
$mail->setFrom($globalEmailSender, 'Peer Pre-Review'); | ||
return false; | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -63,6 +63,7 @@ class PPRPluginSettings { | |
|
||
'accessKeyLifeTime' => ['int', 30], | ||
'fileUploadTextOverrideEnabled' => ['bool', null], | ||
'globalEmailSender' => ['string', '[email protected]'], | ||
); | ||
private $pprPlugin; | ||
|
||
|
@@ -287,11 +288,14 @@ public function reviewerSurveyHtml() { | |
return $this->getValue('reviewerSurveyHtml'); | ||
} | ||
|
||
|
||
public function accessKeyLifeTime() { | ||
return $this->getValue('accessKeyLifeTime'); | ||
} | ||
|
||
public function globalEmailSender() { | ||
return $this->getValue('globalEmailSender'); | ||
} | ||
|
||
private function getValue($propertyName) { | ||
return $this->pprPlugin->getSetting($this->contextId, $propertyName) ?? self::CONFIG_VARS[$propertyName][1]; | ||
} | ||
|
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 |
---|---|---|
|
@@ -64,6 +64,7 @@ public function test_default_values() { | |
'reviewerSurveyHtml' => [null, null], | ||
'accessKeyLifeTime' => [null, 30], | ||
'fileUploadTextOverrideEnabled' => [null, null], | ||
'globalEmailSender' => [null, '[email protected]'], | ||
); | ||
|
||
foreach (PPRPluginSettings::CONFIG_VARS as $configVar => $varInfo) { | ||
|