public function mail_add($ticket_id, $created_at) { $dao = Model_Mail::data_access(); $mail = $dao->filter(Model_Mail::TicketId, $ticket_id)->find(); if (empty($mail)) { $newmail = new Model_Mail(); $newmail->ticket_id = $ticket_id; $newmail->created_at = $created_at; return $newmail->save(); } return $mail; }
public function action_send() { if ($this->request->is_post()) { $user_id = $this->get_post('receiver', null); $receiver = Model_User::find_by_id($user_id); if ($receiver) { $title = $this->get_post('title', 'no title'); $content = $this->get_raw_post('content', 'no content'); $mail = new Model_Mail(); $mail->from_user = $this->current_user->user_id; $mail->to_user = $receiver->user_id; $mail->content = $content; $mail->title = $title; $mail->save(); $this->redirect('/mail/outbox'); } else { $message = __('common.:user_not_found', array(':user' => $user_id)); throw new Exception_Page($message); } } }