From 928f6a9651e75ce7bfd5ac813f3a988149d26b5b Mon Sep 17 00:00:00 2001 From: yashodha Date: Fri, 13 Sep 2019 14:52:27 +0530 Subject: [PATCH] CRM-21777 - Set readonly for the smtp fields initialised in civicrm_settings.php --- CRM/Admin/Form/Setting/Smtp.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/CRM/Admin/Form/Setting/Smtp.php b/CRM/Admin/Form/Setting/Smtp.php index 45dc52dcce..27a2a83121 100644 --- a/CRM/Admin/Form/Setting/Smtp.php +++ b/CRM/Admin/Form/Setting/Smtp.php @@ -54,14 +54,24 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting { ]; $this->addRadio('outBound_option', ts('Select Mailer'), $outBoundOption); + $props = array(); + $settings = Civi::settings()->getMandatory('mailing_backend'); + //Load input as readonly whose values are overridden in civicrm.settings.php. + foreach ($settings as $setting => $value) { + if (isset($value)) { + $props[$setting]['readonly'] = TRUE; + $setStatus = TRUE; + } + } + CRM_Utils_System::setTitle(ts('Settings - Outbound Mail')); $this->add('text', 'sendmail_path', ts('Sendmail Path')); $this->add('text', 'sendmail_args', ts('Sendmail Argument')); - $this->add('text', 'smtpServer', ts('SMTP Server')); - $this->add('text', 'smtpPort', ts('SMTP Port')); - $this->addYesNo('smtpAuth', ts('Authentication?')); - $this->addElement('text', 'smtpUsername', ts('SMTP Username')); - $this->addElement('password', 'smtpPassword', ts('SMTP Password')); + $this->add('text', 'smtpServer', ts('SMTP Server'), CRM_Utils_Array::value('smtpServer', $props)); + $this->add('text', 'smtpPort', ts('SMTP Port'), CRM_Utils_Array::value('smtpPort', $props)); + $this->addYesNo('smtpAuth', ts('Authentication?'), CRM_Utils_Array::value('smtpAuth', $props)); + $this->addElement('text', 'smtpUsername', ts('SMTP Username'), CRM_Utils_Array::value('smtpUsername', $props)); + $this->addElement('password', 'smtpPassword', ts('SMTP Password'), CRM_Utils_Array::value('smtpPassword', $props)); $this->_testButtonName = $this->getButtonName('refresh', 'test'); @@ -70,6 +80,10 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting { $buttons = $this->getElement('buttons')->getElements(); $buttons[] = $this->createElement('submit', $this->_testButtonName, ts('Save & Send Test Email'), ['crm-icon' => 'fa-envelope-o']); $this->getElement('buttons')->setElements($buttons); + + if (!empty($setStatus)) { + CRM_Core_Session::setStatus("Some fields are loaded as 'readonly' as they have been set (overridden) in civicrm.settings.php.", '', 'info', array('expires' => 0)); + } } /** -- 2.25.1