From 8034812339c74b750a02d8703de554e3c00f7305 Mon Sep 17 00:00:00 2001 From: Matteo Perelli Date: Sun, 7 Jul 2019 11:37:28 +0200 Subject: [PATCH] Forms elements changed in {fbvElement}. Removed password bouncing between server and input form. --- ReviewerCreditsSettingsForm.inc.php | 38 +++++++++++++++++++++++++---- templates/settingsForm.tpl | 4 +-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/ReviewerCreditsSettingsForm.inc.php b/ReviewerCreditsSettingsForm.inc.php index 44e1f64..f55dc33 100644 --- a/ReviewerCreditsSettingsForm.inc.php +++ b/ReviewerCreditsSettingsForm.inc.php @@ -24,6 +24,9 @@ class ReviewerCreditsSettingsForm extends Form { /** @var $plugin object */ var $plugin; + + /** @var $passwdPlaceholder string */ + var $passwdPlaceholder = '****************'; /** * Constructor @@ -61,10 +64,16 @@ public function __construct($plugin, $contextId) { public function initData() { $contextId = $this->contextId; $plugin =& $this->plugin; + $oldPasswd = $plugin->getSetting($contextId, 'reviewerCreditsJournalPassword'); + if(empty($oldPasswd)){ + $password = ''; + }else{ + $password = $this->passwdPlaceholder; + } $this->_data = array( 'reviewerCreditsJournalLogin' => $plugin->getSetting($contextId, 'reviewerCreditsJournalLogin'), - 'reviewerCreditsJournalPassword' => $plugin->getSetting($contextId, 'reviewerCreditsJournalPassword'), + 'reviewerCreditsJournalPassword' => $password, ); } @@ -92,9 +101,13 @@ public function fetch($request, $template = null, $display = false) { public function execute() { $plugin =& $this->plugin; $contextId = $this->contextId; + $oldPasswd = $plugin->getSetting($contextId, 'reviewerCreditsJournalPassword'); + $newPasswd = $this->getData('reviewerCreditsJournalPassword'); $plugin->updateSetting($contextId, 'reviewerCreditsJournalLogin', $this->getData('reviewerCreditsJournalLogin'), 'string'); - $plugin->updateSetting($contextId, 'reviewerCreditsJournalPassword', $this->getData('reviewerCreditsJournalPassword'), 'string'); + if($newPasswd != $this->passwdPlaceholder && $newPasswd != $oldPasswd){ + $plugin->updateSetting($contextId, 'reviewerCreditsJournalPassword', $this->getData('reviewerCreditsJournalPassword'), 'string'); + } } /** @@ -102,11 +115,26 @@ public function execute() { */ public function customValidator($args){ $username = trim($args); - $password = $this->getData('reviewerCreditsJournalPassword'); - if(empty($username) || empty($password)){ + $plugin =& $this->plugin; + $contextId = $this->contextId; + $oldPasswd = $plugin->getSetting($contextId, 'reviewerCreditsJournalPassword'); + $newPasswd = $this->getData('reviewerCreditsJournalPassword'); + if(empty($username) || empty($newPasswd)){ $output = FALSE; }else{ - $output = $this->plugin->verifyCredentials($username, $password); + if($newPasswd != $this->passwdPlaceholder){ + $password = $newPasswd; + }else{ + $password = $oldPasswd; + } + $output = $plugin->verifyCredentials($username, $password); + } + if(!$output){ + if(empty($oldPasswd)){ + $this->_data['reviewerCreditsJournalPassword'] = ''; + }else{ + $this->_data['reviewerCreditsJournalPassword'] = $this->passwdPlaceholder; + } } return $output; } diff --git a/templates/settingsForm.tpl b/templates/settingsForm.tpl index fc58a99..4020ffa 100644 --- a/templates/settingsForm.tpl +++ b/templates/settingsForm.tpl @@ -26,11 +26,11 @@ - + - +
{fieldLabel name="reviewerCreditsJournalLogin" required="true" key="plugins.generic.reviewerCredits.manager.settings.reviewerCreditsJournalLogin"}{fbvElement type="text" name="reviewerCreditsJournalLogin" id="reviewerCreditsJournalLogin" value=$reviewerCreditsJournalLogin|escape size="40" class="textField"}
{fieldLabel name="reviewerCreditsJournalPassword" required="true" key="plugins.generic.reviewerCredits.manager.settings.reviewerCreditsJournalPassword"}{fbvElement type="text" name="reviewerCreditsJournalPassword" id="reviewerCreditsJournalPassword" value=$reviewerCreditsJournalPassword|escape size="40" class="textField"}