mirror of
https://github.com/magicbug/Cloudlog
synced 2026-08-13 17:49:35 -04:00
Add support for managed email configuration
Introduces logic to detect and enforce centrally managed email settings. When managed, email options are displayed as read-only and cannot be changed by users; attempts to save changes are blocked with a notice. The email options view now conditionally renders a read-only summary and test email form if management is enabled.
This commit is contained in:
parent
9fe5b808a5
commit
2bd503cdcd
3 changed files with 82 additions and 1 deletions
|
|
@ -274,6 +274,7 @@ class Options extends CI_Controller {
|
|||
|
||||
$data['page_title'] = $this->lang->line('options_cloudlog_options');
|
||||
$data['sub_heading'] = $this->lang->line('options_email');
|
||||
$data['is_managed'] = ($this->config->item('managed_service') || $this->config->item('managed_email_protocol')) ? true : false;
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('options/email');
|
||||
|
|
@ -282,6 +283,11 @@ class Options extends CI_Controller {
|
|||
|
||||
// Handles saving the radio options to the options system.
|
||||
function email_save() {
|
||||
// Check if email is managed - if so, redirect with message
|
||||
if ($this->config->item('managed_service') || $this->config->item('managed_email_protocol')) {
|
||||
$this->session->set_flashdata('notice', 'Email settings are centrally managed and cannot be changed here.');
|
||||
redirect('options');
|
||||
}
|
||||
|
||||
// Get Language Options
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,28 @@ class OptionsLib {
|
|||
function get_option($option_name) {
|
||||
// Make Codeigniter functions available to library
|
||||
$CI =& get_instance();
|
||||
|
||||
// Check for managed email configuration overrides
|
||||
$email_settings_map = array(
|
||||
'emailProtocol' => 'managed_email_protocol',
|
||||
'smtpEncryption' => 'managed_email_smtp_encryption',
|
||||
'emailAddress' => 'managed_email_address',
|
||||
'emailSenderName' => 'managed_email_sender_name',
|
||||
'smtpHost' => 'managed_email_smtp_host',
|
||||
'smtpPort' => 'managed_email_smtp_port',
|
||||
'smtpUsername' => 'managed_email_smtp_username',
|
||||
'smtpPassword' => 'managed_email_smtp_password'
|
||||
);
|
||||
|
||||
// If this is an email setting and managed email is configured, return managed value
|
||||
if (array_key_exists($option_name, $email_settings_map)) {
|
||||
$managed_key = $email_settings_map[$option_name];
|
||||
$managed_value = $CI->config->item($managed_key);
|
||||
if ($managed_value !== NULL && $managed_value !== FALSE) {
|
||||
return $managed_value;
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($option_name, 'option_') !== false) {
|
||||
if(!$CI->config->item($option_name)) {
|
||||
//Load the options model
|
||||
|
|
|
|||
|
|
@ -38,8 +38,60 @@
|
|||
<?php echo $this->session->flashdata('testmailSuccess'); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (isset($is_managed) && $is_managed) { ?>
|
||||
<!-- Managed Email - Read-only display with test email -->
|
||||
<div class="alert alert-info">
|
||||
<i class="fas fa-info-circle"></i> Email settings are centrally managed and cannot be changed here.
|
||||
</div>
|
||||
|
||||
<h5>Current Email Configuration</h5>
|
||||
<table class="table table-sm">
|
||||
<tr>
|
||||
<th style="width: 30%;"><?php echo lang('options_outgoing_protocol'); ?>:</th>
|
||||
<td><?php echo $this->optionslib->get_option('emailProtocol'); ?></td>
|
||||
</tr>
|
||||
<?php if($this->optionslib->get_option('emailProtocol') == 'smtp') { ?>
|
||||
<tr>
|
||||
<th><?php echo lang('options_smtp_encryption'); ?>:</th>
|
||||
<td><?php echo $this->optionslib->get_option('smtpEncryption') ?: 'None'; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo lang('options_smtp_host'); ?>:</th>
|
||||
<td><?php echo $this->optionslib->get_option('smtpHost'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo lang('options_smtp_port'); ?>:</th>
|
||||
<td><?php echo $this->optionslib->get_option('smtpPort'); ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<th><?php echo lang('options_email_address'); ?>:</th>
|
||||
<td><?php echo $this->optionslib->get_option('emailAddress'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo lang('options_email_sender_name'); ?>:</th>
|
||||
<td><?php echo $this->optionslib->get_option('emailSenderName'); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
<h5>Test Email</h5>
|
||||
<?php echo form_open('options/sendTestMail', ['id' => 'testMailForm']); ?>
|
||||
<input class="btn btn-primary" id="testMailBtn" type="submit" value="<?php echo lang('options_send_testmail'); ?>" />
|
||||
<span id="testMailSpinner" class="spinner-border spinner-border-sm ms-2" role="status" aria-hidden="true" style="display: none;"></span>
|
||||
<small class="form-text text-muted"><?php echo lang('options_send_testmail_hint'); ?></small>
|
||||
</form>
|
||||
|
||||
<?php echo form_open('options/email_save'); ?>
|
||||
<script>
|
||||
document.getElementById('testMailForm').addEventListener('submit', function() {
|
||||
document.getElementById('testMailBtn').disabled = true;
|
||||
document.getElementById('testMailSpinner').style.display = 'inline-block';
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php } else { ?>
|
||||
<!-- Normal email configuration form -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="emailProtocol"><?php echo lang('options_outgoing_protocol'); ?></label>
|
||||
|
|
@ -124,6 +176,7 @@
|
|||
document.getElementById('testMailSpinner').style.display = 'inline-block';
|
||||
});
|
||||
</script>
|
||||
<?php } // end else - normal email configuration ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue