/** * Album image detail * * @access public * @params integer * @return Response */ public function action_detail($id = null) { $id = (int) $id; $album_image = Model_Albumimage::check_authority($id); $this->check_browse_authority($album_image->public_flag, $album_image->album->member_id); $locations = is_enabled_map('image/detail', 'album') ? Model_AlbumImageLocation::get_locations4album_image_id($id) : null; // 既読処理 if (\Auth::check()) { $this->change_notice_status2read($this->u->id, 'album_image', $id); } // album image_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_AlbumImageComment::get_list(array('album_image_id' => $id), $limit, $is_latest, $is_desc, $since_id, $max_id, null, false, true); // album_image_like $is_liked_self = \Auth::check() ? Model_AlbumImageLike::check_liked($id, $this->u->id) : false; $data = array('album_image' => $album_image, 'locations' => $locations, '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('album_image_comment', $this->u->id, $list) : array()); // get before and after album_image.id if (conf('display_setting.image.detail.displayNextPageButton', 'album')) { list($data['before_id'], $data['after_id']) = $this->get_before_after_ids($album_image->id); } $slide_file_names = array(); if (conf('display_setting.image.detail.displayGallery.isEnabled', 'album')) { if (conf('display_setting.image.detail.displayNextPageButton', 'album')) { Model_AlbumImage::clear_cache(); } $slide_file_names = $this->get_slide_file_names($album_image); } $title = Site_Util::get_album_image_display_name($album_image, term('album_image', 'site.detail')); $this->set_title_and_breadcrumbs($title, array('/album/' . $album_image->album_id => $album_image->album->name), $album_image->album->member, 'album', null, false, false, array('title' => $album_image->album->name, 'description' => $album_image->name ?: FBD_SITE_NAME, 'image' => \Site_Util::get_image_uri4image_list($album_image, 'ai', 'raw'))); $this->template->subtitle = \View::forge('image/_parts/detail_subtitle', array('album_image' => $album_image)); $this->template->post_header = \View::forge('image/_parts/detail_header'); $this->template->post_footer = \View::forge('image/_parts/detail_footer', array('album_image' => $album_image, 'locations' => $locations, 'slide_file_names' => $slide_file_names)); $this->template->content = \View::forge('image/detail', $data); }
/** * Album image comment delete * * @access public * @params integer * @return Response */ public function action_delete($id = null) { $id = (int) $id; $album_image_comment = Model_AlbumImageComment::check_authority($id, $this->u->id); \Util_security::check_csrf(\Input::get(\Config::get('security.csrf_token_key'))); $album_image_id = $album_image_comment->album_image_id; $album_image_comment->delete(); \Session::set_flash('message', 'コメントを削除しました。'); \Response::redirect('album/image/' . $album_image_id); }
public function test_delete_parent() { $album_image_comment_id = self::$album_image_comment->id; $album_image_comment = Model_AlbumImageComment::find($album_image_comment_id); if (!\Util_Orm::get_count_all('\\Album\\Model_AlbumImageCommentLike', array('album_image_comment_id' => $album_image_comment_id))) { self::execute_like($album_image_comment_id, 6); self::execute_like($album_image_comment_id, 7); } $album_image_comment->delete(); $like_count = \Util_Orm::get_count_all('\\Album\\Model_AlbumImageCommentLike', array('album_image_comment_id' => $album_image_comment_id)); $this->assertEquals(0, $like_count); }
public function test_delete_album_image_multiple4ids() { $timeline_ids = array_unique(\Util_Orm::conv_col2array(\Timeline\Model_TimelineChildData::get4foreign_table_and_foreign_ids('album_image_id', self::$album_image->id), 'timeline_id')); $notices = array(); if (is_enabled('notice')) { $notice_ids = \Util_Orm::conv_col2array(\Notice\Model_Notice::get4foreign_data('album_image', self::$album_image->id), 'id'); $notice_ids += \Util_Orm::conv_col2array(\Notice\Model_Notice::get4parent_data('album_image', self::$album_image->id), 'id'); $notice_ids = array_unique($notice_ids); } $notice_statuses = \Notice\Model_NoticeStatus::query()->where('notice_id', 'in', $notice_ids)->get(); $file_name = self::$album_image->file_name; $file = \Model_File::get4name($file_name); $file_size = $file->filesize; $member_filesize_before = self::$member->filesize_total; // timeline view cache 作成 if (self::$is_check_timeline_view_cache) { $timeline_view_cache_before = \Timeline\Site_Util::make_view_cache4foreign_table_and_foreign_id('album', $album->id, \Config::get('timeline.types.album_image')); } // file if (conf('upload.storageType') == 'db') { $this->assertNotNull(\Model_FileBin::get4name(self::$album_image->file_name)); } // album_image delete. Site_NoOrmModel::delete_album_image_multiple4ids(self::$album_image->id, true); // 件数 $this->assertEmpty(Model_AlbumImage::query()->where('id', self::$album_image->id)->get()); $this->assertEmpty(Model_AlbumImageLike::query()->where('album_image_id', self::$album_image_comment->id)->get()); $this->assertEmpty(Model_AlbumImageComment::query()->where('album_image_id', self::$album_image->id)->get()); $this->assertEmpty(Model_AlbumImageCommentLike::query()->where('album_image_comment_id', self::$album_image_comment->id)->get()); // file $this->assertEmpty(\Model_File::get4name($file_name)); // meber_filesize $this->assertEquals($member_filesize_before - $file_size, self::get_member_filesize_total(self::$member_id)); // timeline if (is_enabled('timeline')) { $timeline_child_datas = \Timeline\Model_TimelineChildData::get4foreign_table_and_foreign_ids('album_image', self::$album_image->id); $this->assertEmpty($timeline_child_datas); if ($timeline_ids) { $this->assertEmpty(\Timeline\Model_Timeline::query()->where('id', 'in', $timeline_ids)->get()); } // timeline view cache check if (self::$is_check_timeline_view_cache && $timeline_ids) { foreach ($timeline_ids as ${$timeline_id}) { $this->assertEmpty(\Timeline\Site_Util::get_view_cache($timeline_id)); } } } // notice if (is_enabled('notice')) { $this->assertEmpty(\Notice\Model_MemberWatchContent::get4foreign_data('album_image', self::$album_image->id)); if ($notice_ids) { $this->assertEmpty(\Notice\Model_Notice::query()->where('id', 'in', $notice_ids)->get()); $this->assertEmpty(\Notice\Model_NoticeStatus::query()->where('notice_id', 'in', $notice_ids)->get()); $this->assertEmpty(\Notice\Model_NoticeMemberFrom::query()->where('notice_id', 'in', $notice_ids)->get()); } if (self::$is_check_notice_cache) { foreach ($notice_statuses as $notice_statuse) { $this->assertEmpty(\Notice\Site_Util::get_unread_count_cache($notice_statuse->member_id)); } } } }
private function save_comment($member_id, $body = null) { if (is_null($body)) { $body = 'This is test comment.'; } $comment = new Model_AlbumImageComment(array('body' => $body, 'album_image_id' => self::$album_image->id, 'member_id' => $member_id)); $comment->save(); return $comment; }