Created
December 17, 2011 09:56
-
-
Save oscarcarlsson/1489830 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function compose() | |
{ | |
function filter_empty($item) { | |
return (! trim($item) == ""); | |
} | |
$this->load->helper(array('form', 'url', 'MY_form_helper')); | |
$this->load->library('form_validation'); | |
$this->form_validation->set_error_delimiters('<div class="alert-message error"> | |
<a class="close" href="#">×</a><p>', '</p></div>'); | |
/* Vi sätter lite regler användaren måste fixa... */ | |
$this->form_validation->set_rules('receivers[]', 'Mottagare', 'required'); | |
$this->form_validation->set_rules('mail_title', 'Titel', 'required'); | |
$this->form_validation->set_rules('body', 'Brödtext', 'required'); | |
$this->form_validation->set_rules('replyto', 'Svara till-adress', 'required'); | |
if ($this->form_validation->run() == FALSE) | |
{ | |
$receivers = $this->input->post('receivers'); | |
if ($this->session->flashdata('receivers')) | |
$receivers = $this->session->flashdata('receivers'); | |
$replyto = ''; | |
if ($this->input->post('replyto')) | |
$replyto = $this->input->post('replyto'); | |
$mail_title = 'hejsan'; | |
if ($this->input->post('mail_title')) | |
$mail_title = $this->input->post('mail_title'); | |
/* Hämta ut användarens epostadress också... */ | |
$user = $this->Member->get($this->session->userdata('id')); | |
$this->load->helper('form'); | |
$hidden = array(); | |
$hidden[] = form_hidden('user_email', $user->email); | |
$this->template->assign('validation_errors', validation_errors()); | |
$this->template->assign('title', 'Mejla medlemmar'); | |
$this->template->assign('menu', ''); | |
$this->template->assign('description', 'Mejla de medlemmar du tidigare valde ut.'); | |
$this->template->assign('hidden', $hidden); | |
$this->template->assign('jquery', array('mailer.js')); | |
$this->template->assign('receivers', $receivers); | |
$this->template->assign('replyto', $replyto); | |
$this->template->assign('mail_title', $mail_title); | |
$this->template->display('mailer/compose.tmpl'); | |
}else{ | |
$this->session->set_flashdata('receivers', $this->input->post('receivers')); | |
redirect('/mailer/send/'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment