From ca342a41e216c963553d895dc8b3496b3b044110 Mon Sep 17 00:00:00 2001 From: withanage Date: Fri, 3 Feb 2023 23:11:45 +0100 Subject: [PATCH] https://github.com/pkp/orcidProfile/issues/229 OrcidProfilePlugin-705 --- OrcidProfilePlugin.php | 5 +- OrcidProfileSettingsForm.inc.php | 130 ------------------------------- 2 files changed, 4 insertions(+), 131 deletions(-) delete mode 100644 OrcidProfileSettingsForm.inc.php diff --git a/OrcidProfilePlugin.php b/OrcidProfilePlugin.php index 916eded8..145f97f7 100755 --- a/OrcidProfilePlugin.php +++ b/OrcidProfilePlugin.php @@ -614,7 +614,10 @@ public function sendAuthorMail($author, $updateAuthor = false) // Send to author $mailable->recipients([$author]); - $mailable->view('ssssss'); + $emailTemplateKey = $mailable::getEmailTemplateKey(); + $emailTemplate = Repo::emailTemplate()->getByKey($contextId, $emailTemplateKey); + $mailable->body($emailTemplate->getLocalizedData('body')) + ->subject($emailTemplate->getLocalizedData('subject')); Mail::send($mailable); if ($updateAuthor) { diff --git a/OrcidProfileSettingsForm.inc.php b/OrcidProfileSettingsForm.inc.php deleted file mode 100644 index b3a8a920..00000000 --- a/OrcidProfileSettingsForm.inc.php +++ /dev/null @@ -1,130 +0,0 @@ - 'string', - 'orcidClientId' => 'string', - 'orcidClientSecret' => 'string', - 'sendMailToAuthorsOnPublication' => 'bool', - 'logLevel' => 'string', - 'isSandBox' => 'bool' - ]; - /** @var int $contextId */ - public $contextId; - - /** @var object $plugin */ - public $plugin; - - /** - * Constructor - * - * @param object $plugin - * @param int $contextId - */ - public function __construct(&$plugin, $contextId) - { - $this->contextId = $contextId; - $this->plugin = & $plugin; - - parent::__construct($plugin->getTemplateResource('settingsForm.tpl')); - - if (!$this->plugin->isGloballyConfigured()) { - $this->addCheck(new \PKP\form\validation\FormValidator( - $this, - 'orcidProfileAPIPath', - 'required', - 'plugins.generic.orcidProfile.manager.settings.orcidAPIPathRequired' - )); - } - $this->addCheck(new \PKP\form\validation\FormValidatorPost($this)); - $this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this)); - $this->addCheck(new \PKP\form\validation\FormValidatorCustom($this, 'orcidClientId', 'required', 'plugins.generic.orcidProfile.manager.settings.orcidClientId.error', function ($clientId) { - if (preg_match('/^APP-[\da-zA-Z]{16}|(\d{4}-){3,}\d{3}[\dX]/', $clientId) == 1) { - $this->plugin->setEnabled(true); - return true; - } - $this->plugin->setEnabled(false); - })); - $this->addCheck(new \PKP\form\validation\FormValidatorCustom($this, 'orcidClientSecret', 'required', 'plugins.generic.orcidProfile.manager.settings.orcidClientSecret.error', function ($clientSecret) { - if (preg_match('/^(\d|-|[a-f]){36,64}/', $clientSecret) == 1) { - $this->plugin->setEnabled(true); - return true; - } - $this->plugin->setEnabled(false); - })); - } - - /** - * Initialize form data. - */ - public function initData() - { - $contextId = $this->contextId; - $plugin = & $this->plugin; - $this->_data = []; - foreach (self::CONFIG_VARS as $configVar => $type) { - $this->_data[$configVar] = $plugin->getSetting($contextId, $configVar); - } - } - - /** - * Assign form data to user-submitted data. - */ - public function readInputData() - { - $this->readUserVars(array_keys(self::CONFIG_VARS)); - } - - /** - * Fetch the form. - * - * @copydoc Form::fetch() - * - * @param null|mixed $template - */ - public function fetch($request, $template = null, $display = false) - { - $templateMgr = TemplateManager::getManager($request); - $templateMgr->assign('globallyConfigured', $this->plugin->isGloballyConfigured()); - $templateMgr->assign('pluginName', $this->plugin->getName()); - return parent::fetch($request, $template, $display); - } - - /** - * @copydoc Form::execute() - */ - public function execute(...$functionArgs) - { - $plugin = & $this->plugin; - $contextId = $this->contextId; - foreach (self::CONFIG_VARS as $configVar => $type) { - if ($configVar === 'orcidProfileAPIPath') { - $plugin->updateSetting($contextId, $configVar, trim($this->getData($configVar), "\"\';"), $type); - } else { - $plugin->updateSetting($contextId, $configVar, $this->getData($configVar), $type); - } - } - if (strpos($this->getData('orcidProfileAPIPath'), 'sandbox.orcid.org') == true) { - $plugin->updateSetting($contextId, 'isSandBox', true, 'bool'); - } - - parent::execute(...$functionArgs); - } -}