diff --git a/README.md b/README.md
index 5c0f39b..c0c5613 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
Once enabled, the plugin will send an email notification to a configurable list of emails whenever a new user gets registered.
## Configuration
-Each journal must be configured individually since the settings are not shared.
+Each journal/press must be configured individually since the settings are not shared.
### Recipients
The emails must be defined through the plugin settings, the interface supports adding a list of recipients.
diff --git a/RegistrationNotificationSettingsForm.inc.php b/RegistrationNotificationSettingsForm.inc.php
index a5883b5..83dc96b 100644
--- a/RegistrationNotificationSettingsForm.inc.php
+++ b/RegistrationNotificationSettingsForm.inc.php
@@ -34,6 +34,11 @@ public function __construct(RegistrationNotificationPlugin $plugin, $contextId)
$this->_plugin = $plugin;
$this->addCheck(new FormValidatorPost($this));
$this->addCheck(new FormValidatorCSRF($this));
+ import('lib.pkp.classes.validation.ValidatorEmail');
+ $emailValidator = new ValidatorEmail;
+ $this->addCheck(new FormValidatorArrayCustom($this, 'email', 'required', 'form.emailRequired', function ($value) use ($emailValidator) {
+ return $emailValidator->isValid($value);
+ }));
}
/**
@@ -41,7 +46,8 @@ public function __construct(RegistrationNotificationPlugin $plugin, $contextId)
*/
public function initData() {
$recipientList = $this->_plugin->getSetting($this->_contextId, 'recipientList');
- $this->setData('recipientList', is_array($recipientList) ? $recipientList : []);
+ $this->setData('email', is_array($recipientList) ? array_keys($recipientList) : []);
+ $this->setData('name', is_array($recipientList) ? array_values($recipientList) : []);
return parent::initData();
}
@@ -50,6 +56,17 @@ public function initData() {
*/
public function readInputData() {
$this->readUserVars(array('email', 'name'));
+ $emails = $this->getData('email');
+ $names = $this->getData('name');
+ foreach($emails as $i => $email) {
+ //clean empty entries
+ if(empty($email) && empty($names[$i])){
+ unset($emails[$i]);
+ unset($names[$i]);
+ }
+ }
+ $this->setData('email', array_values($emails));
+ $this->setData('name', array_values($names));
return parent::readInputData();
}
@@ -65,15 +82,7 @@ public function fetch($request) {
* @copydoc Form::fetch()
*/
public function execute() {
- import('lib.pkp.classes.validation.ValidatorEmail');
-
- $emailValidator = new ValidatorEmail;
- $data = array_filter(
- array_combine($this->getData('email'), $this->getData('name')),
- [$emailValidator, 'isValid'],
- ARRAY_FILTER_USE_KEY
- );
- $this->_plugin->updateSetting($this->_contextId, 'recipientList', $data, 'object');
+ $this->_plugin->updateSetting($this->_contextId, 'recipientList', array_combine($this->getData('email'), $this->getData('name')), 'object');
return parent::execute();
}
}
diff --git a/locale/en_US/emailTemplates.xml b/locale/en_US/emailTemplates.xml
index 8dc86c5..800fd8b 100644
--- a/locale/en_US/emailTemplates.xml
+++ b/locale/en_US/emailTemplates.xml
@@ -20,7 +20,7 @@
Email: {$userEmail}
-This email was generated by Open Journal Systems' Registration Notification plugin.]]>