public static function userPage($id) { $user = new ForumUser(ForumUser::find($id)); $threads = Thread::findByUser($id); $messages = Message::findByUser($id); View::make('user/userpage.html', array('user' => $user, 'threads' => $threads, 'messages' => $messages)); }
public static function get_user_logged_in() { if (isset($_SESSION['user'])) { $user_id = $_SESSION['user']; $user = ForumUser::find($user_id); return new ForumUser($user); } return null; }
public static function addMessage($thread_id) { $params = $_POST; $time = date('Y-m-d G:i:s'); $attributes = array('content' => $params['content'], 'created' => $time, 'user_id' => $_SESSION['user'], 'thread_id' => $thread_id); $message = new Message($attributes); $errors = $message->errors(); if (count($errors) == 0) { $message->save(); //Updating lastpost of thread $thread = new Thread(Thread::find($thread_id)); $thread->updateLastpost($time); //Updating participants list $user = new ForumUser(ForumUser::find($_SESSION['user'])); ForumUser::changePostAmount($user->id, $thread_id, 1); Redirect::to('/thread/' . $thread_id); } else { $thread = new Thread(Thread::find($thread_id)); View::make('message/message_create.html', array('thread' => $thread, 'errors' => $errors, 'attributes' => $attributes)); } }