Skip to content

Commit

Permalink
Merge pull request #15305 from yashodha/CRM_21777
Browse files Browse the repository at this point in the history
CRM-21777 - Set readonly for the smtp fields initialised in civicrm_s…
  • Loading branch information
eileenmcnaughton authored Sep 30, 2019
2 parents 53e64ff + 042b739 commit 592fc2b
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions CRM/Admin/Form/Setting/Smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,24 @@ public function buildQuickForm() {
];
$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');

Expand All @@ -70,6 +80,10 @@ public function buildQuickForm() {
$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));
}
}

/**
Expand Down

0 comments on commit 592fc2b

Please sign in to comment.