public function action_detail($id = 0) { $data["forum"] = Model_Forum::find($id); if ($data["forum"] == null) { Response::redirect("/teachers/forum/"); } if (Input::get("del_id", null) != null) { $del_comment = Model_Comment::find(Input::get("del_id", 0)); if ($del_comment->user_id == $this->user->id) { $del_comment->deleted_at = time(); $del_comment->save(); } } // add if (Input::post("body", "") != "" and Security::check_token()) { // save $comment = Model_Comment::forge(); $comment->body = Input::post("body", ""); $comment->forum_id = $id; $comment->user_id = $this->user->id; $comment->save(); } $data["user"] = $this->user; $view = View::forge("teachers/forum/detail", $data); $this->template->content = $view; }
public function action_detail($id = 0) { $data['pasts'] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", 0)], ["deleted_at", 0]]]); $data["donetrial"] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", -1)], ["deleted_at", 0]]]); $data["forum"] = Model_Forum::find($id); if ($data["forum"] == null) { Response::redirect("/students/forum/"); } if (Input::get("del_id", null) != null) { $del_comment = Model_Comment::find(Input::get("del_id", 0)); if ($del_comment->user_id == $this->user->id) { $del_comment->deleted_at = time(); $del_comment->save(); } } // add if (Input::post("body", "") != "" and Security::check_token()) { // save $comment = Model_Comment::forge(); $comment->body = Input::post("body", ""); $comment->forum_id = $id; $comment->user_id = $this->user->id; $comment->save(); } $data["user"] = $this->user; $view = View::forge("students/forum/detail", $data); $this->template->content = $view; }
public function action_delete($id, $message_id) { if ($comment = Model_Comment::find($id)) { $comment->delete(); Session::set_flash('success', 'Deleted comment #' . $id); } else { Session::set_flash('error', 'Could not delete comment #' . $id); } Response::redirect('messages/view/' . $message_id); }
public function action_delete($id = null) { if ($comment = Model_Comment::find($id)) { $comment->delete(); Session::set_flash('success', 'Deleted comment #' . $id); } else { Session::set_flash('error', 'Could not delete comment #' . $id); } Response::redirect('admin/comments'); }
public function action_view($id = null) { is_null($id) and Response::redirect('blog'); if (!($blog = Model_Blog::find($id))) { Session::set_flash('error', 'Could not find blog #' . $id); Response::redirect('blog'); } $comments = Model_Comment::find('all', array('where' => array('blog_id' => $id))); $data = array('blog' => $blog, 'comments' => $comments); $this->template->title = "Blog"; $this->template->content = View::forge('blog/view', $data); }
public function action_view($id = null) { is_null($id) and Response::redirect('messages'); if (!($message = Model_Message::find($id))) { Session::set_flash('error', 'Could not find message #' . $id); Response::redirect('messages'); } $comments = Model_Comment::find('all', array('where' => array('message_id' => $id))); $data = array('message' => $message, 'comments' => $comments); $this->template->title = "Message"; $this->template->content = View::forge('messages/view', $data); }
public function action_edit($id = null) { $comment = Model_Comment::find($id); if (\Fuel\Core\Input::post()) { $comment->name = \Fuel\Core\Input::post('name'); $comment->comment = \Fuel\Core\Input::post('comment'); if ($comment->save()) { Fuel\Core\Session::set_flash('success', 'Updated comment #' . $id); Fuel\Core\Response::redirect('messages/view/' . $comment->message_id); } else { Fuel\Core\Session::set_flash('error', 'Could not update comment #' . $id); } } else { $this->template->set_global('comment', $comment, false); $this->template->set_global('message', $comment->message_id, false); } $data["subnav"] = array('edit' => 'active'); $this->template->title = 'Comments » Edit'; $data['form'] = View::forge('comments/_form'); $this->template->content = View::forge('comments/edit', $data); }
public function action_delete($id = null) { if (!isset($_SESSION['user_id'])) { return Response::redirect('login'); } is_null($id) and Response::redirect('Comment'); if ($comment = Model_Comment::find($id)) { $comment->delete(); console . log('success', 'Deleted comment #' . $id); } else { console . log('error', 'Could not delete comment #' . $id); } Response::redirect('comment'); }