/** * Note detail * * @access public * @params integer * @return Response */ public function action_detail($id = null) { $note_id = (int) $id; $note = Model_Note::check_authority($note_id); $this->check_browse_authority($note->public_flag, $note->member_id); // 既読処理 if (\Auth::check()) { $this->change_notice_status2read($this->u->id, 'note', $id); } // note_album_image $images = is_enabled('album') ? Model_NoteAlbumImage::get_album_image4note_id($id) : array(); // note_comment $default_params = array('latest' => 1); list($limit, $is_latest, $is_desc, $since_id, $max_id) = $this->common_get_list_params($default_params, conf('view_params_default.detail.comment.limit_max')); list($list, $next_id, $all_comment_count) = Model_NoteComment::get_list(array('note_id' => $note_id), $limit, $is_latest, $is_desc, $since_id, $max_id, null, false, true); // note_like $is_liked_self = \Auth::check() ? Model_NoteLike::check_liked($id, $this->u->id) : false; $title = array('name' => $note->title); $header_info = array(); if (!$note->is_published) { $title['label'] = array('name' => term('form.draft')); $header_info = array('body' => sprintf('この%sはまだ公開されていません。', term('note'))); } $ogp_infos = array('title' => $note->title, 'description' => $note->body); if ($images) { $ogp_infos['image'] = \Site_Util::get_image_uri4image_list($images, 'ai', 'raw'); } $this->set_title_and_breadcrumbs($title, null, $note->member, 'note', $header_info, false, false, $ogp_infos); $this->template->subtitle = \View::forge('_parts/detail_subtitle', array('note' => $note)); $this->template->post_footer = \View::forge('_parts/detail_footer', array('is_mypage' => check_uid($note->member_id))); $data = array('note' => $note, 'images' => $images, 'comments' => $list, 'all_comment_count' => $all_comment_count, 'comment_next_id' => $next_id, 'is_liked_self' => $is_liked_self, 'liked_ids' => conf('like.isEnabled') && \Auth::check() && $list ? \Site_Model::get_liked_ids('note_comment', $this->u->id, $list) : array()); $this->template->content = \View::forge('detail', $data); }
/** * Note delete * * @access public * @params integer * @return Response */ public function action_delete($id = null) { \Util_security::check_csrf(\Input::get(\Config::get('security.csrf_token_key'))); $comment = Model_NoteComment::check_authority($id, $this->u->id); $comment->delete(); \Session::set_flash('message', term('note') . 'を削除しました。'); \Response::redirect('note/detail/' . $comment->note_id); }
private static function save_comment($note_id, $member_id) { $comment = new Model_NoteComment(array('body' => 'Test for note_comment_like.', 'note_id' => $note_id, 'member_id' => $member_id)); $comment->save(); return $comment; }
private static function save_comment($member_id, $body = null) { if (is_null($body)) { $body = 'This is test comment.'; } $comment = Model_NoteComment::forge(array('body' => $body, 'note_id' => self::$note_id, 'member_id' => $member_id)); $comment->save(); return $comment; }