mourne_rcpp_fw/Mourne-CI/application/controllers/mail.php

146 lines
3.3 KiB
PHP
Raw Normal View History

2021-10-30 19:02:07 +02:00
<?php
class Mail extends MO_Controller
{
public function __construct()
{
parent::__construct();
}
2021-10-30 19:02:07 +02:00
public function index()
{
$this->load->helper('url');
redirect('mail/inbox');
}
2021-10-30 19:02:07 +02:00
public function inbox()
{
$this->headers('mail');
2021-10-30 19:02:07 +02:00
$this->load->model('mail_model');
2021-10-30 19:02:07 +02:00
$data['mails'] = $this->mail_model->get_inbox($this->userid, $this->new_mail);
2021-10-30 19:02:07 +02:00
$this->load->view('mail/inbox', $data);
2021-10-30 19:02:07 +02:00
$this->footer();
2021-10-30 19:02:07 +02:00
}
public function compose($id = 0)
2021-10-30 19:02:07 +02:00
{
$this->headers('mail');
$this->load->model('mail_model');
$this->load->library('form_validation');
$d['draft'] = false;
if ($id && is_numeric($id)) {
$d['draft'] = $this->mail_model->get_draft($id, $this->userid);
}
$this->form_validation->set_rules('name', 'Username', 'required');
$this->form_validation->set_rules('subject', 'Subject', 'required');
$this->form_validation->set_rules('message', 'Message', 'required');
if (!$this->form_validation->run()) {
$this->load->view('mail/new', $d);
} else {
$send = $this->input->post('send');
$draft = $this->input->post('draft');
$data['name'] = $this->input->post('name');
$data['subject'] = $this->input->post('subject');
$data['message'] = $this->input->post('message');
if ($send) {
$this->mail_model->send_message($data, $this->userid);
} else {
$this->mail_model->save_draft($data, $this->userid);
}
}
$this->footer();
2021-10-30 19:02:07 +02:00
}
public function del_draft($id = 0)
2021-10-30 19:02:07 +02:00
{
if ($id && is_numeric($id)) {
$this->load->model("mail_model");
$this->mail_model->delete_draft($id, $this->userid);
}
2021-10-30 19:02:07 +02:00
$this->load->helper('url');
redirect('mail/drafts');
}
2021-10-30 19:02:07 +02:00
public function drafts()
{
$this->load->model('mail_model');
2021-10-30 19:02:07 +02:00
$this->headers('mail');
2021-10-30 19:02:07 +02:00
$data['mails'] = $this->mail_model->get_drafts($this->userid);
2021-10-30 19:02:07 +02:00
$this->load->view('mail/drafts', $data);
2021-10-30 19:02:07 +02:00
$this->footer();
2021-10-30 19:02:07 +02:00
}
public function read($id = 0)
{
if (!$id || !is_numeric($id)) {
$this->load->helper('url');
redirect('mail/inbox');
}
2021-10-30 19:02:07 +02:00
$this->load->model('mail_model');
2021-10-30 19:02:07 +02:00
$this->headers('mail');
2021-10-30 19:02:07 +02:00
$data['mail'] = $this->mail_model->get_mail($id, $this->userid);
2021-10-30 19:02:07 +02:00
$this->load->view('mail/read', $data);
2021-10-30 19:02:07 +02:00
$this->footer();
}
2021-10-30 19:02:07 +02:00
public function sent()
{
$this->headers('mail');
2021-10-30 19:02:07 +02:00
$this->load->model('mail_model');
2021-10-30 19:02:07 +02:00
$data['mails'] = $this->mail_model->get_all_sent($this->userid);
2021-10-30 19:02:07 +02:00
$this->load->view('mail/sent', $data);
2021-10-30 19:02:07 +02:00
$this->footer();
2021-10-30 19:02:07 +02:00
}
public function sread($id = 0)
{
if (!$id || !is_numeric($id)) {
$this->load->helper('url');
redirect('mail/inbox');
}
2021-10-30 19:02:07 +02:00
$this->load->model('mail_model');
2021-10-30 19:02:07 +02:00
$this->headers('mail');
2021-10-30 19:02:07 +02:00
$data['mail'] = $this->mail_model->get_sent($id, $this->userid);
2021-10-30 19:02:07 +02:00
$this->load->view('mail/sread', $data);
2021-10-30 19:02:07 +02:00
$this->footer();
}
2021-10-30 19:02:07 +02:00
public function friends()
{
$this->headers('mail');
2021-10-30 19:02:07 +02:00
$this->footer();
}
2021-10-30 19:02:07 +02:00
}
//nowhitesp