[Global Options] Added Email settings
Added email settings under global options to select whether its using smtp or sendmail on the server.
这个提交包含在:
父节点
f7da92ff0c
当前提交
7b0862e7be
共有 6 个文件被更改,包括 237 次插入 和 9 次删除
|
|
@ -149,4 +149,107 @@ class Options extends CI_Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// function used to display the /appearance url
|
||||||
|
function email() {
|
||||||
|
|
||||||
|
$data['page_title'] = "Cloudlog Options";
|
||||||
|
$data['sub_heading'] = "Email";
|
||||||
|
|
||||||
|
$this->load->view('interface_assets/header', $data);
|
||||||
|
$this->load->view('options/email');
|
||||||
|
$this->load->view('interface_assets/footer');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handles saving the radio options to the options system.
|
||||||
|
function email_save() {
|
||||||
|
|
||||||
|
// Get Language Options
|
||||||
|
|
||||||
|
$data['page_title'] = "Cloudlog Options";
|
||||||
|
$data['sub_heading'] = "Email";
|
||||||
|
|
||||||
|
$this->load->helper(array('form', 'url'));
|
||||||
|
|
||||||
|
$this->load->library('form_validation');
|
||||||
|
|
||||||
|
$this->form_validation->set_rules('emailProtocol', 'Email Protocol', 'required');
|
||||||
|
|
||||||
|
if ($this->form_validation->run() == FALSE)
|
||||||
|
{
|
||||||
|
$this->load->view('interface_assets/header', $data);
|
||||||
|
$this->load->view('options/email');
|
||||||
|
$this->load->view('interface_assets/footer');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
// Update emailProtocol choice within the options system
|
||||||
|
$emailProtocolupdate = $this->optionslib->update('emailProtocol', $this->input->post('emailProtocol'), 'yes');
|
||||||
|
|
||||||
|
// If emailProtocolupdate update is complete set a flashsession with a success note
|
||||||
|
if($emailProtocolupdate == TRUE) {
|
||||||
|
$this->session->set_flashdata('success', 'Outgoing Email Protocol changed to '.$this->input->post('emailProtocol'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update smtpEncryption choice within the options system
|
||||||
|
$smtpEncryptionupdate = $this->optionslib->update('smtpEncryption', $this->input->post('smtpEncryption'), 'yes');
|
||||||
|
|
||||||
|
// If smtpEncryption update is complete set a flashsession with a success note
|
||||||
|
if($smtpEncryptionupdate == TRUE) {
|
||||||
|
$this->session->set_flashdata('success', 'SMTP Encryption changed to '.$this->input->post('smtpEncryption'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update smtpHost choice within the options system
|
||||||
|
$smtpHostupdate = $this->optionslib->update('smtpHost', $this->input->post('smtpHost'), 'yes');
|
||||||
|
|
||||||
|
// If smtpHost update is complete set a flashsession with a success note
|
||||||
|
if($smtpHostupdate == TRUE) {
|
||||||
|
$this->session->set_flashdata('success', 'SMTP Host changed to '.$this->input->post('smtpHost'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update smtpPort choice within the options system
|
||||||
|
$smtpPortupdate = $this->optionslib->update('smtpPort', $this->input->post('smtpPort'), 'yes');
|
||||||
|
|
||||||
|
// If smtpPort update is complete set a flashsession with a success note
|
||||||
|
if($smtpPortupdate == TRUE) {
|
||||||
|
$this->session->set_flashdata('success', 'SMTP Port changed to '.$this->input->post('smtpPort'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update smtpUsername choice within the options system
|
||||||
|
$smtpUsernameupdate = $this->optionslib->update('smtpUsername', $this->input->post('smtpUsername'), 'yes');
|
||||||
|
|
||||||
|
// If smtpUsername update is complete set a flashsession with a success note
|
||||||
|
if($smtpUsernameupdate == TRUE) {
|
||||||
|
$this->session->set_flashdata('success', 'SMTP Username changed to '.$this->input->post('smtpUsername'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update smtpPassword choice within the options system
|
||||||
|
$smtpPasswordupdate = $this->optionslib->update('smtpPassword', $this->input->post('smtpPassword'), 'yes');
|
||||||
|
|
||||||
|
// If smtpPassword update is complete set a flashsession with a success note
|
||||||
|
if($smtpPasswordupdate == TRUE) {
|
||||||
|
$this->session->set_flashdata('success', 'SMTP Password changed to '.$this->input->post('smtpPassword'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update emailcrlf choice within the options system
|
||||||
|
$emailcrlfupdate = $this->optionslib->update('emailcrlf', $this->input->post('emailcrlf'), 'yes');
|
||||||
|
|
||||||
|
// If emailcrlf update is complete set a flashsession with a success note
|
||||||
|
if($emailcrlfupdate == TRUE) {
|
||||||
|
$this->session->set_flashdata('success', 'Email CRLF changed to '.$this->input->post('emailcrlf'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update emailnewline choice within the options system
|
||||||
|
$emailnewlineupdate = $this->optionslib->update('emailnewline', $this->input->post('emailnewline'), 'yes');
|
||||||
|
|
||||||
|
// If emailnewline update is complete set a flashsession with a success note
|
||||||
|
if($emailnewlineupdate == TRUE) {
|
||||||
|
$this->session->set_flashdata('success', 'Email Newline changed to '.$this->input->post('emailnewline'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect back to /appearance
|
||||||
|
redirect('/options/email');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -516,8 +516,6 @@ class User extends CI_Controller {
|
||||||
|
|
||||||
$check_email = $this->user_model->check_email_address($this->input->post('email', true));
|
$check_email = $this->user_model->check_email_address($this->input->post('email', true));
|
||||||
|
|
||||||
print_r($check_email);
|
|
||||||
|
|
||||||
if($check_email == TRUE) {
|
if($check_email == TRUE) {
|
||||||
// Generate password reset code 50 characters long
|
// Generate password reset code 50 characters long
|
||||||
$this->load->helper('string');
|
$this->load->helper('string');
|
||||||
|
|
@ -530,6 +528,20 @@ class User extends CI_Controller {
|
||||||
$this->data['reset_code'] = $reset_code;
|
$this->data['reset_code'] = $reset_code;
|
||||||
$this->load->library('email');
|
$this->load->library('email');
|
||||||
|
|
||||||
|
if($this->optionslib->get_option('emailProtocol') == "smtp") {
|
||||||
|
$config = Array(
|
||||||
|
'protocol' => $this->optionslib->get_option('emailProtocol'),
|
||||||
|
'smtp_host' => $this->optionslib->get_option('smtpHost'),
|
||||||
|
'smtp_port' => $this->optionslib->get_option('smtpPort'),
|
||||||
|
'smtp_user' => $this->optionslib->get_option('smtpUsername'),
|
||||||
|
'smtp_pass' => $this->optionslib->get_option('smtpPassword'),
|
||||||
|
'crlf' => "\r\n",
|
||||||
|
'newline' => "\r\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->email->initialize($config);
|
||||||
|
}
|
||||||
|
|
||||||
$message = $this->load->view('email/forgot_password', $this->data, TRUE);
|
$message = $this->load->view('email/forgot_password', $this->data, TRUE);
|
||||||
|
|
||||||
$this->email->from('noreply@cloudlog.co.uk', 'Cloudlog');
|
$this->email->from('noreply@cloudlog.co.uk', 'Cloudlog');
|
||||||
|
|
@ -538,10 +550,16 @@ class User extends CI_Controller {
|
||||||
$this->email->subject('Cloudlog Account Password Reset');
|
$this->email->subject('Cloudlog Account Password Reset');
|
||||||
$this->email->message($message);
|
$this->email->message($message);
|
||||||
|
|
||||||
$this->email->send();
|
if (! $this->email->send())
|
||||||
|
{
|
||||||
|
// Redirect to login page with message
|
||||||
|
$this->session->set_flashdata('warning', 'Email settings are incorrect.');
|
||||||
|
redirect('user/login');
|
||||||
|
} else {
|
||||||
// Redirect to login page with message
|
// Redirect to login page with message
|
||||||
$this->session->set_flashdata('notice', 'Password Reset Processed.');
|
$this->session->set_flashdata('notice', 'Password Reset Processed.');
|
||||||
redirect('user/login');
|
redirect('user/login');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// No account found just return to login page
|
// No account found just return to login page
|
||||||
$this->session->set_flashdata('notice', 'Password Reset Processed.');
|
$this->session->set_flashdata('notice', 'Password Reset Processed.');
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class OptionsLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to update options within the options table
|
// Function to update options within the options table
|
||||||
function update($option_name, $option_value) {
|
function update($option_name, $option_value, $auto_load = NULL) {
|
||||||
// Make Codeigniter functions available to library
|
// Make Codeigniter functions available to library
|
||||||
$CI =& get_instance();
|
$CI =& get_instance();
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ class OptionsLib {
|
||||||
$CI->load->model('options_model');
|
$CI->load->model('options_model');
|
||||||
|
|
||||||
// call library function to save update
|
// call library function to save update
|
||||||
$result = $CI->options_model->update($option_name, $option_value);
|
$result = $CI->options_model->update($option_name, $option_value, $auto_load);
|
||||||
|
|
||||||
// return True or False on whether its completed.
|
// return True or False on whether its completed.
|
||||||
return $result;
|
return $result;
|
||||||
|
|
|
||||||
|
|
@ -65,13 +65,14 @@ class Options_model extends CI_Model {
|
||||||
* - option_name: name of the option with no spaces
|
* - option_name: name of the option with no spaces
|
||||||
* - option_value: the value of the option name
|
* - option_value: the value of the option name
|
||||||
*/
|
*/
|
||||||
function update($option_name, $option_value) {
|
function update($option_name, $option_value, $auto_load = NULL) {
|
||||||
$this->db->where('option_name', $option_name);
|
$this->db->where('option_name', $option_name);
|
||||||
$query = $this->db->get('options');
|
$query = $this->db->get('options');
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'option_name' => $option_name,
|
'option_name' => $option_name,
|
||||||
'option_value' => $option_value,
|
'option_value' => $option_value,
|
||||||
|
'autoload' => $auto_load,
|
||||||
);
|
);
|
||||||
|
|
||||||
if($query->num_rows() > 0) {
|
if($query->num_rows() > 0) {
|
||||||
|
|
|
||||||
105
application/views/options/email.php
普通文件
105
application/views/options/email.php
普通文件
|
|
@ -0,0 +1,105 @@
|
||||||
|
<div class="container settings">
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<!-- Nav Start -->
|
||||||
|
<?php $this->load->view('options/sidebar') ?>
|
||||||
|
<!-- Nav End -->
|
||||||
|
|
||||||
|
<!-- Content -->
|
||||||
|
<div class="col-md-9">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header"><h2><?php echo $page_title; ?> - <?php echo $sub_heading; ?></h2></div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if($this->session->flashdata('success')) { ?>
|
||||||
|
<!-- Display Success Message -->
|
||||||
|
<div class="alert alert-success">
|
||||||
|
<?php echo $this->session->flashdata('success'); ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php if($this->session->flashdata('message')) { ?>
|
||||||
|
<!-- Display Message -->
|
||||||
|
<div class="alert-message error">
|
||||||
|
<?php echo $this->session->flashdata('message'); ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php if(validation_errors()) { ?>
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<a class="close" data-dismiss="alert">x</a>
|
||||||
|
<?php echo validation_errors(); ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php echo form_open('options/email_save'); ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="emailProtocol">Outgoing Protocol</label>
|
||||||
|
<select name="emailProtocol" class="form-control" id="emailProtocol">
|
||||||
|
<option value="sendmail" <?php if($this->optionslib->get_option('emailProtocol')== "sendmail") { echo "selected=\"selected\""; } ?>>Sendmail</option>
|
||||||
|
<option value="smtp" <?php if($this->optionslib->get_option('emailProtocol')== "smtp") { echo "selected=\"selected\""; } ?>>SMTP</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="smtpEncryption">SMTP Encryption</label>
|
||||||
|
<select name="smtpEncryption" class="form-control" id="smtpEncryption">
|
||||||
|
<option value="" <?php if($this->optionslib->get_option('smtpEncryption') == "") { echo "selected=\"selected\""; } ?>>None</option>
|
||||||
|
<option value="tls" <?php if($this->optionslib->get_option('smtpEncryption') == "tls") { echo "selected=\"selected\""; } ?>>TLS</option>
|
||||||
|
<option value="ssl" <?php if($this->optionslib->get_option('smtpEncryption') == "ssl") { echo "selected=\"selected\""; } ?>>SSL</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="smtpHost" class="col-sm-2 col-form-label">SMTP Host</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="text" name="smtpHost" class="form-control" id="smtpHost" value="<?php if($this->optionslib->get_option('smtpHost') != "") { echo $this->optionslib->get_option('smtpHost'); } ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="smtpPort" class="col-sm-2 col-form-label">SMTP Port</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="number" name="smtpPort" class="form-control" id="smtpPort" value="<?php if($this->optionslib->get_option('smtpPort') != "") { echo $this->optionslib->get_option('smtpPort'); } ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="smtpUsername" class="col-sm-2 col-form-label">SMTP Username</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="text" name="smtpUsername" class="form-control" id="smtpUsername" value="<?php if($this->optionslib->get_option('smtpUsername') != "") { echo $this->optionslib->get_option('smtpUsername'); } ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="smtpPassword" class="col-sm-2 col-form-label">SMTP Password</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="password" name="smtpPassword" class="form-control" id="smtpPassword" value="<?php if($this->optionslib->get_option('smtpPassword') != "") { echo $this->optionslib->get_option('smtpPassword'); } ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="emailcrlf" class="col-sm-2 col-form-label">crlf</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="text" name="emailcrlf" class="form-control" id="emailcrlf" value="<?php if($this->optionslib->get_option('emailcrlf') != "") { echo $this->optionslib->get_option('emailcrlf'); } ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="emailnewline" class="col-sm-2 col-form-label">newline</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="text" name="emailnewline" class="form-control" id="emailnewline" value="<?php if($this->optionslib->get_option('emailnewline') != "") { echo $this->optionslib->get_option('emailnewline'); } ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Save the Form -->
|
||||||
|
<input class="btn btn-primary" type="submit" value="Save" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
<ul class="list-group list-group-flush">
|
<ul class="list-group list-group-flush">
|
||||||
<li class="list-group-item"><a class="nav-link" href="<?php echo site_url('options/appearance'); ?>">Appearance</a></li>
|
<li class="list-group-item"><a class="nav-link" href="<?php echo site_url('options/appearance'); ?>">Appearance</a></li>
|
||||||
<li class="list-group-item"><a class="nav-link" href="<?php echo site_url('options/radio'); ?>">Radios</a></li>
|
<li class="list-group-item"><a class="nav-link" href="<?php echo site_url('options/radio'); ?>">Radios</a></li>
|
||||||
|
<li class="list-group-item"><a class="nav-link" href="<?php echo site_url('options/email'); ?>">Email</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
正在加载…
在新工单中引用