Example #1
0
 /**
  * Site index
  * 
  * @access  public
  * @return  Response
  */
 public function action_index()
 {
     $data = array();
     if (Config::get('page.site.index.timeline.isEnabled') && is_enabled('timeline')) {
         $data['timelines'] = \Timeline\Site_Util::get_list4view(\Auth::check() ? $this->u->id : 0, 0, false, null, $this->common_get_list_params(array('desc' => 1, 'latest' => 1, 'limit' => Config::get('page.site.index.timeline.list.limit')), Config::get('page.site.index.timeline.list.limit_max'), true));
         $data['timelines']['see_more_link'] = array('uri' => 'timeline');
         //$this->template->post_footer = \View::forge('timeline::_parts/load_timelines');
     }
     if (Config::get('page.site.index.news.isEnabled') && is_enabled('news')) {
         list($limit, $page) = $this->common_get_pager_list_params(\Config::get('page.site.index.news.list.limit'), \Config::get('page.site.index.news.list.limit_max'));
         $data['news_list'] = \News\Site_Model::get_list($limit, $page, \Auth::check());
         $data['news_list']['see_more_link'] = array('uri' => 'news');
     }
     if (Config::get('page.site.index.albumImage.isEnabled') && is_enabled('album')) {
         list($limit, $page) = $this->common_get_pager_list_params(\Config::get('page.site.index.albumImage.list.limit'), \Config::get('page.site.index.albumImage.list.limit_max'));
         $data['album_images'] = \Album\Model_AlbumImage::get_pager_list(array('related' => array('album'), 'where' => \Site_Model::get_where_params4list(0, \Auth::check() ? $this->u->id : 0), 'order_by' => array('id' => 'desc'), 'limit' => $limit), $page);
         $data['album_images']['liked_album_image_ids'] = conf('like.isEnabled') && \Auth::check() ? \Site_Model::get_liked_ids('album_image', $this->u->id, $data['album_images']['list']) : array();
         $data['album_images']['column_count'] = \Config::get('page.site.index.albumImage.list.column_count');
         //$this->template->post_footer = \View::forge('image/_parts/list_footer');
     }
     $this->template->post_footer = \View::forge('site/_parts/index_footer');
     if (conf('site.index.slide.isEnabled', 'page')) {
         if (conf('site.index.slide.recentAlbumImage.isEnabled', 'page')) {
             $images = \Album\Site_Util::get_top_slide_image_uris();
         } else {
             $images = Config::get('page.site.index.slide.images');
         }
         $this->template->post_header_content = View::forge('site/_parts/slide', array('image_uris' => $images));
     }
     $this->set_title_and_breadcrumbs('', null, null, null, null, true, true);
     $this->template->content = View::forge('site/index', $data);
     if (!empty($data['news_list']['list'])) {
         $this->template->content->set_safe('html_bodys', \News\Site_Model::convert_raw_bodys($data['news_list']['list']));
     }
 }
 public function before_update(\Orm\Model $obj)
 {
     if (!$obj->is_changed('comment_count') && !$obj->is_changed('like_count')) {
         return;
     }
     $obj->importance_level = \Timeline\Site_Util::get_importance_level($obj->comment_count, $obj->like_count);
 }
Example #3
0
 /**
  * @dataProvider update_like_provider
  */
 public function test_update_like($member_id)
 {
     // timeline_like save
     $is_liked = (bool) Model_TimelineLike::change_registered_status4unique_key(array('timeline_id' => self::$timeline->id, 'member_id' => $member_id));
     $timeline = \DB::select()->from('timeline')->where('id', self::$timeline->id)->execute()->current();
     $timeline_like = \Util_Orm::get_last_row('\\Timeline\\Model_TimelineLike', array('timeline_id' => self::$timeline->id));
     // 件数
     $like_count = \Util_Orm::get_count_all('\\Timeline\\Model_TimelineLike', array('timeline_id' => self::$timeline->id));
     $like_count_after = $is_liked ? self::$timeline_like_count + 1 : self::$timeline_like_count - 1;
     $this->assertEquals($like_count_after, $like_count);
     // 値
     $this->assertEquals($like_count, $timeline['like_count']);
     if ($is_liked) {
         $this->assertEquals(self::$timeline_before->sort_datetime, $timeline['sort_datetime']);
     } else {
         $this->assertNull($timeline_like);
     }
     $timeline_caches = \DB::select()->from('timeline_cache')->where('timeline_id', self::$timeline->id)->execute();
     foreach ($timeline_caches as $timeline_cache) {
         $this->assertEquals($like_count, $timeline_cache['like_count']);
     }
     //// timeline_cache が最新レコードになっているか
     //$timeline_cache = \Util_Orm::get_last_row('\Timeline\Model_TimelineCache');
     //$this->assertEquals(self::$timeline->id, $timeline_cache->timeline_id);
     // timeline view cache check
     if (self::$is_check_view_cache) {
         $this->assertEquals(self::$view_cache_before, \Timeline\Site_Util::get_view_cache(self::$timeline->id));
     }
 }
Example #4
0
 public static function delete_timeline4ids($timeline_ids)
 {
     if (!$timeline_ids) {
         return array();
     }
     foreach ($timeline_idis as $timeline_id) {
         \Timeline\Site_Util::delete_cache($timeline_id);
     }
     return \DB::delete('timeline')->where('id', 'in', $timeline_ids)->execute();
 }
Example #5
0
 /**
  * Timeline member
  * 
  * @access  public
  * @params  integer
  * @return  Response
  */
 public function action_member($member_id = null)
 {
     $member_id = (int) $member_id;
     list($is_mypage, $member) = $this->check_auth_and_is_mypage($member_id);
     $data = \Timeline\Site_Util::get_list4view(\Auth::check() ? $this->u->id : 0, $member->id, false, null, $this->common_get_list_params(array('desc' => 1, 'latest' => 1, 'limit' => conf('articles.limit', 'timeline')), conf('articles.limit_max', 'timeline'), true));
     if ($member) {
         $data['member'] = $member;
     }
     $this->set_title_and_breadcrumbs(sprintf('%sの%s', $is_mypage ? '自分' : $member->name . 'さん', term('timeline', 'site.list')), null, $member);
     $this->template->post_footer = \View::forge('_parts/load_timelines');
     $this->template->content = \View::forge('_parts/list', $data);
 }
Example #6
0
 public static function get_timelines4foreign_table_and_id($foreign_table, $foreign_id)
 {
     if ($foreign_table == 'timeline') {
         if (!($timeline = \Timeline\Model_Timeline::find($foreign_id))) {
             return false;
         }
         return array($timeline->id => $timeline);
     }
     if (!in_array($foreign_table, \Timeline\Site_Util::get_accept_timeline_foreign_tables())) {
         return false;
     }
     return \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids($foreign_table, $foreign_id);
 }
Example #7
0
 /**
  * Mmeber home
  * 
  * @access  public
  * @return  Response
  */
 public function action_home($id = null)
 {
     $id = (int) $id;
     list($is_mypage, $member, $access_from) = $this->check_auth_and_is_mypage($id);
     $member_profiles = Model_MemberProfile::get4member_id($member->id, true);
     $data = array('member' => $member, 'member_profiles' => $member_profiles, 'is_mypage' => $is_mypage, 'access_from' => $access_from, 'display_type' => 'summary');
     if (is_enabled('timeline')) {
         $data['timeline'] = \Timeline\Site_Util::get_list4view(\Auth::check() ? $this->u->id : 0, $member->id, false, null, $this->common_get_list_params(array('desc' => 1, 'latest' => 1, 'limit' => conf('articles.limit', 'timeline')), conf('articles.limit_max', 'timeline'), true));
         $data['timeline']['member'] = $member;
         $this->template->post_footer = \View::forge('timeline::_parts/load_timelines');
     }
     $this->set_title_and_breadcrumbs($member->name . ' さんのページ', array('member/list' => term('member.view', 'site.list')), null, null, array(), false, false, array('title' => $member->name . ' さんのページ', 'image' => Site_Util::get_image_uri4file_name($member->get_image(), 'P_L', 'profile')));
     $this->template->content = \View::forge('member/home', $data);
 }
 public function after_delete(\Orm\Model $obj)
 {
     if (!($timeline = \Timeline\Model_Timeline::find($obj->timeline_id))) {
         return;
     }
     $is_cache_delete = false;
     if (!\Timeline\Model_TimelineChildData::get4timeline_id($obj->timeline_id)) {
         $timeline->delete();
         $is_cache_delete = true;
     } elseif ($timeline->update_public_flag_with_check_child_data()) {
         $is_cache_delete = true;
     }
     if (\Config::get('timeline.articles.cache.is_use') && !$is_cache_delete) {
         \Timeline\Site_Util::delete_cache($timeline->id, $timeline->type);
     }
 }
Example #9
0
 /**
  * @dataProvider update_provider
  */
 public function test_update($self_member_id, $values, $album_image_public_flag_expected, $timeline_public_flag_expected)
 {
     $album = $this->get_album();
     $before = array('name' => $album->name, 'body' => $album->body, 'public_flag' => $album->public_flag);
     // 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'));
     }
     // album update
     list($album, $moved_files, $is_changed) = Model_Album::save_with_relations($values, $self_member_id, $album);
     self::$album = $album;
     // 返り値の確認
     $this->assertNotEmpty($album);
     // 件数(増えていないことを確認)
     $this->assertEquals(self::$album_count, \Util_Orm::get_count_all('\\Album\\Model_Album'));
     // album_image の値を変更した場合の public_flag の確認
     $album_images = Model_AlbumImage::get4album_id($album->id);
     $album_image = array_shift($album_images);
     if (!empty($values['is_update_children_public_flag'])) {
         $this->assertEquals($album_image_public_flag_expected, $album_image->public_flag);
     }
     // timeline 関連
     if (is_enabled('timeline')) {
         // 件数(増えていないことを確認)
         $this->assertEquals(self::$timeline_count, \Util_Orm::get_count_all('\\Timeline\\Model_Timeline'));
         $this->assertEquals(self::$timeline_cache_count, \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCache'));
         $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('album', $album->id, \Config::get('timeline.types.album'));
         $this->assertCount(1, $timelines);
         $timeline = array_shift($timelines);
         $this->assertEquals($album->member_id, $timeline->member_id);
         $this->assertEquals($timeline_public_flag_expected, $timeline->public_flag);
         $this->assertContains($timeline->created_at, \Util_Date::get_datetime_list($album->created_at));
         if ($is_changed) {
             if (self::check_sort_datetime_change(self::$album, $before)) {
                 $this->assertEquals($album->updated_at, $timeline->sort_datetime);
             }
             $this->assertContains($timeline->updated_at, \Util_Date::get_datetime_list($album->updated_at));
         }
         // timeline view cache check
         if (self::$is_check_timeline_view_cache) {
             $this->assertEmpty(\Timeline\Site_Util::get_view_cache($timeline->id));
         }
     }
 }
Example #10
0
 /**
  * @dataProvider update_like_provider
  */
 public function test_update_post_like($member_id)
 {
     $note_id = self::$note_id;
     $note_before = \DB::select()->from('note')->where('id', $note_id)->execute()->current();
     // note_like save
     \Util_Develop::sleep();
     $is_liked = (bool) Model_NoteLike::change_registered_status4unique_key(array('note_id' => $note_id, 'member_id' => $member_id));
     $note = \DB::select()->from('note')->where('id', $note_id)->execute()->current();
     $note_like = \Util_Orm::get_last_row('\\Note\\Model_NoteLike', array('note_id' => $note_id));
     // 件数
     $like_count = \Util_Orm::get_count_all('\\Note\\Model_NoteLike', array('note_id' => $note_id));
     $like_count_after = $is_liked ? self::$note_like_count + 1 : self::$note_like_count - 1;
     $this->assertEquals($like_count_after, $like_count);
     if (!$is_liked) {
         $this->assertNull($note_like);
     }
     // 値
     $this->assertEquals($like_count, $note['like_count']);
     $this->assertEquals($note_before['sort_datetime'], $note['sort_datetime']);
     // timeline 関連
     if (is_enabled('timeline')) {
         $timeline_id = self::$timeline_id;
         $timeline = \DB::select()->from('timeline')->where('id', $timeline_id)->execute()->current();
         // 値
         $this->assertEquals($like_count, $timeline['like_count']);
         $this->assertEquals(self::$timeline_before->sort_datetime, $timeline['sort_datetime']);
         $timeline_caches = \DB::select()->from('timeline_cache')->where('timeline_id', $timeline_id)->execute();
         foreach ($timeline_caches as $timeline_cache) {
             $this->assertEquals($like_count, $timeline_cache['like_count']);
         }
         //// timeline_cache が最新レコードになっているか
         //$timeline_cache = \Util_Orm::get_last_row('\Timeline\Model_TimelineCache');
         //$this->assertEquals($timeline_id, $timeline_cache->timeline_id);
         // timeline view cache check
         if (self::$is_check_view_cache) {
             try {
                 $timeline_view_cache = \Cache::get(\Timeline\Site_Util::get_cache_key($timeline_id), \Config::get('timeline.articles.cache.expir'));
             } catch (\CacheNotFoundException $e) {
                 $timeline_view_cache = null;
             }
             $this->assertEquals(self::$timeline_view_cache_before, $timeline_view_cache);
         }
     }
 }
Example #11
0
 /**
  * Get timeline list
  * 
  * @access  public
  * @return  Response (html)
  * @throws  Exception in Controller_Base::controller_common_api
  * @see  Controller_Base::controller_common_api
  */
 public function get_list()
 {
     $this->api_accept_formats = 'html';
     $this->controller_common_api(function () {
         $member_id = (int) \Input::get('member_id', 0);
         list($is_mypage, $member) = $member_id ? $this->check_auth_and_is_mypage($member_id, true) : array(null, false);
         $is_mytimeline = \Auth::check() ? (bool) \Input::get('mytimeline', 0) : false;
         $timeline_viewType = $is_mytimeline ? $this->member_config->timeline_viewType : null;
         $is_display_load_before_link = (bool) \Input::get('before_link', false);
         $data = \Timeline\Site_Util::get_list4view(get_uid(), $member_id, $is_mytimeline, $timeline_viewType, $this->common_get_list_params(array('desc' => 1, 'latest' => 1, 'limit' => conf('articles.limit', 'timeline')), conf('articles.limit_max', 'timeline'), true));
         if ($member) {
             $data['member'] = $member;
         }
         if ($is_mytimeline) {
             $data['mytimeline'] = true;
         }
         $data['is_display_load_before_link'] = $is_display_load_before_link;
         $this->set_response_body_api($data, '_parts/list');
     });
 }
Example #12
0
 /**
  * @dataProvider update_like_provider
  */
 public function test_update_like($member_id)
 {
     // timeline_like save
     \Util_Develop::sleep();
     $is_liked = self::execute_like(self::$timeline_comment->id, $member_id);
     self::$timeline_comment = Model_TimelineComment::find(self::$timeline_comment->id);
     $timeline_comment_like = \Util_Orm::get_last_row('\\Timeline\\Model_TimelineCommentLike', array('timeline_comment_id' => self::$timeline_comment->id));
     // 件数
     $like_count = \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCommentLike', array('timeline_comment_id' => self::$timeline_comment->id));
     $like_count_expect = $is_liked ? self::$like_count + 1 : self::$like_count - 1;
     $this->assertEquals($like_count_expect, $like_count);
     // 値
     $this->assertEquals($like_count, self::$timeline_comment->like_count);
     if (!$is_liked) {
         $this->assertNull($timeline_comment_like);
     }
     // timeline view cache check
     if (self::$is_check_view_cache) {
         $this->assertEquals(self::$view_cache_before, \Timeline\Site_Util::get_view_cache(self::$timeline->id));
     }
 }
 private function get_relational_model($obj, $model_from_info)
 {
     if (!$model_from_info) {
         return false;
     }
     if (is_array($model_from_info)) {
         foreach ($model_from_info as $value_from => $type) {
             if ($type == 'model') {
                 $model_from = $value_from;
                 break;
             } elseif ($type == 'timeline_related_table') {
                 if (empty($obj->{$value_from})) {
                     return false;
                 }
                 $namespace = \Timeline\Site_Util::get_namespace4foreign_table($obj->{$value_from});
                 $model_from = \Util_Orm::get_model_name($obj->{$value_from}, $namespace);
             }
         }
     } else {
         $model_from = $model_from_info;
     }
     return $model_from;
 }
Example #14
0
 public static function delete_note_view_cache4album_image_id($album_image_id)
 {
     if (!($note_id = \Note\Model_NoteAlbumImage::get_note_id4album_image_id($album_image_id))) {
         return;
     }
     if (!($timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('note', $note_id))) {
         return;
     }
     $timeline = array_shift($timelines);
     \Timeline\Site_Util::delete_cache($timeline->id, $timeline->type);
 }
Example #15
0
}
$member = Model_Member::check_authority($member_id);
if (isset($liked_timeline_ids)) {
    echo Form::hidden('liked_timeline_ids', json_encode($liked_timeline_ids), array('id' => 'liked_timeline_ids'));
}
?>
<div <?php 
echo Util_Array::conv_array2attr_string($attr);
?>
>
	<div class="row member_contents">
		<div class="col-xs-1"><?php 
echo member_image($member);
?>
</div>
		<div class="col-xs-11">
			<div class="member_info">
				<b class="fullname"><?php 
echo member_name($member, true, true);
?>
</b>
			</div>
			<div class="main">
				<?php 
echo \Timeline\Site_Util::get_article_main_view($timeline_id, $access_from_member_relation, $is_detail);
?>
			</div>
		</div>
	</div>
</div><!-- timelineBox -->
Example #16
0
 public function test_delete()
 {
     $note_id = self::$note_id;
     $this->save_comment(1, 'Test comment1.');
     $this->save_comment(1, 'Test comment2.');
     $note_comment = $this->save_comment(1, 'Test comment3.');
     // set before data.
     $note_before = \DB::select()->from('note')->where('id', $note_id)->execute()->current();
     self::$note_comment_count = \Util_Orm::get_count_all('\\Note\\Model_NoteComment', array('note_id' => self::$note_id));
     // note_comment delete
     \Util_Develop::sleep();
     $note_comment->delete();
     $note = \DB::select()->from('note')->where('id', $note_id)->execute()->current();
     // 件数
     $comment_count = \Util_Orm::get_count_all('\\Note\\Model_NoteComment', array('note_id' => $note_id));
     $this->assertEquals(self::$note_comment_count - 1, $comment_count);
     // 値
     $this->assertEquals($comment_count, $note['comment_count']);
     $this->assertEquals($note_before['sort_datetime'], $note['sort_datetime']);
     // timeline 関連
     if (is_enabled('timeline')) {
         $timeline_id = self::$timeline_id;
         $timeline = \DB::select()->from('timeline')->where('id', $timeline_id)->execute()->current();
         // 値
         $this->assertEquals($comment_count, $timeline['comment_count']);
         $this->assertEquals($note_before['sort_datetime'], $timeline['sort_datetime']);
         // timeline_caches
         $timeline_caches = \DB::select()->from('timeline_cache')->where('timeline_id', $timeline_id)->execute();
         $this->assertCount(2, $timeline_caches);
         foreach ($timeline_caches as $timeline_cache) {
             $this->assertEquals($comment_count, $timeline_cache['comment_count']);
         }
         // timeline view cache check
         if (self::$is_check_view_cache) {
             $timeline_view_cache = \Cache::get(\Timeline\Site_Util::get_cache_key($timeline_id), \Config::get('timeline.articles.cache.expir'));
             $this->assertEquals(self::$view_cache_before, $timeline_view_cache);
         }
     }
 }
Example #17
0
 public function test_delete()
 {
     $timeline_id = self::$timeline_id;
     self::save_comment(self::$member_id, 'Test comment1.');
     self::save_comment(self::$member_id, 'Test comment2.');
     $timeline_comment = self::save_comment(self::$member_id, 'Test comment3.');
     // timeline_comment delete
     \Util_Develop::sleep();
     $timeline_comment->delete();
     $timeline = Model_Timeline::find($timeline_id);
     // 件数
     $comment_count = \Util_Orm::get_count_all('\\Timeline\\Model_TimelineComment', array('timeline_id' => $timeline_id));
     $this->assertEquals(self::$timeline_comment_count + 3 - 1, $comment_count);
     // 値
     $this->assertEquals($comment_count, $timeline->comment_count);
     $this->assertEquals(self::$timeline_before->sort_datetime, $timeline->sort_datetime);
     $timeline_caches = \DB::select()->from('timeline_cache')->where('timeline_id', $timeline_id)->execute();
     foreach ($timeline_caches as $timeline_cache) {
         $this->assertEquals($comment_count, $timeline_cache['comment_count']);
     }
     // timeline view cache check
     if (self::$is_check_view_cache) {
         $this->assertEquals(self::$view_cache_before, \Timeline\Site_Util::get_view_cache($timeline->id));
     }
 }
Example #18
0
 public function test_delete()
 {
     if (!self::$album_image) {
         self::$album_image = $this->get_album_image(array('public_flag' => FBD_PUBLIC_FLAG_MEMBER));
     }
     $album_image_id = self::$album_image->id;
     $file_name = self::$album_image->file_name;
     $file = \Model_File::get4name($file_name);
     $file_size = $file->filesize;
     $file_path = \Site_Upload::get_uploaded_file_path(self::$album_image->file_name);
     $member_filesize_before = self::get_member_filesize_total(self::$member_id);
     // set cover_album_image_id
     self::$album->cover_album_image_id = $album_image_id;
     // 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));
     } elseif (conf('upload.storageType') == 'normal') {
         $this->assertTrue(file_exists($file_path));
     }
     // album_image delete.
     self::$album_image->delete();
     // 件数
     $this->assertEquals(self::$total_count - 1, Model_AlbumImage::get_count());
     // file
     $this->assertEmpty(\Model_File::get4name($file_name));
     $this->assertFalse(file_exists($file_path));
     // meber_filesize
     $this->assertEquals($member_filesize_before - $file_size, self::get_member_filesize_total(self::$member_id));
     // check cover_album_image_id
     $this->assertEmpty(self::$album->cover_album_image_id);
     // timeline
     if (is_enabled('timeline')) {
         $timeline_child_datas = \Timeline\Model_TimelineChildData::get4foreign_table_and_foreign_ids('album_image', $album_image_id);
         $this->assertEmpty($timeline_child_datas);
         // timeline view cache check
         if (self::$is_check_timeline_view_cache) {
             $this->assertEmpty(\Timeline\Site_Util::get_view_cache($timeline->id));
         }
     }
 }
Example #19
0
 public static function delete_album_image_multiple4ids($album_image_ids = array(), $with_delete_timeline = false)
 {
     if (!is_array($album_image_ids)) {
         $album_image_ids = (array) $album_image_ids;
     }
     $delete_target_notice_cache_member_ids = array();
     $delete_target_timeline_ids = array();
     $writable_connection = \MyOrm\Model::connection(true);
     \DBUtil::set_connection($writable_connection);
     \DB::start_transaction();
     foreach ($album_image_ids as $album_image_id) {
         if (is_enabled('notice')) {
             \Notice\Site_NoOrmModel::delete_member_watch_content_multiple4foreign_data('album_image', $album_image_id);
             $notice_ids = \Notice\Site_NoOrmModel::get_notice_ids4foreign_data('album_image', $album_image_id);
             $delete_target_notice_cache_member_ids += \Notice\Site_NoOrmModel::get_notice_status_member_ids4notice_ids($notice_ids);
             \Notice\Site_NoOrmModel::delete_notice_multiple4ids($notice_ids);
         }
         if (is_enabled('timeline') && $with_delete_timeline) {
             $delete_target_timeline_ids += \timeline\site_noormmodel::delete_timeline_multiple4foreign_data('album_image', $album_image_id);
         }
     }
     $file_names = \Util_Orm::conv_col2array(Model_AlbumImage::get4ids($album_image_ids), 'file_name');
     \DB::delete('album_image')->where('id', 'in', $album_image_ids)->execute();
     \DB::commit_transaction();
     \DBUtil::set_connection(null);
     \DB::start_transaction();
     if ($files = \Model_File::get4names($file_names)) {
         foreach ($files as $file) {
             $file->delete();
         }
     }
     \DB::commit_transaction();
     // delete caches
     if ($delete_target_notice_cache_member_ids) {
         foreach ($delete_target_notice_cache_member_ids as $member_id) {
             \Notice\Site_Util::delete_unread_count_cache($member_id);
         }
     }
     if ($delete_target_timeline_ids) {
         foreach ($delete_target_timeline_ids as $timeline_id) {
             \Timeline\Site_Util::delete_cache($timeline_id);
         }
     }
 }
Example #20
0
 /**
  * Create comment common api controller
  * 
  * @access  protected
  * @param   string  $parent_table  target parent table
  * @param   int     $parent_id  target parent record id
  * @param   string  $member_related  related table for get member_id
  * @return  Response (json)
  * @throws  Exception in Controller_Base::controller_common_api
  * @see  Controller_Base::controller_common_api
  */
 protected function api_create_comment_common($parent_table, $parent_id = null, $member_related = null)
 {
     $this->controller_common_api(function () use($parent_table, $parent_id, $member_related) {
         $parent_id = intval(\Input::post('id') ?: $parent_id);
         $parent_model = Site_Model::get_model_name($parent_table);
         $parent_obj = $parent_model::check_authority($parent_id);
         $this->check_browse_authority($parent_obj->public_flag, $member_related ? $parent_obj->{$member_related}->member_id : $parent_obj->member_id);
         $parent_id_prop = $parent_table . '_id';
         $model = Site_Model::get_model_name($parent_table . '_comment');
         // Lazy validation
         $body = trim(\Input::post('body', ''));
         if (!strlen($body)) {
             throw new \ValidationFailedException(sprintf('%sの入力は%sです。', term('form.comment'), term('form.required')));
         }
         if ($parent_table == 'timeline' && \Timeline\Site_Util::check_type_for_post_foreign_table_comment($parent_obj->type)) {
             throw new \HttpInvalidInputException();
         }
         \DB::start_transaction();
         // Create a new comment
         $comment = $model::forge(array('body' => $body, $parent_id_prop => $parent_id, 'member_id' => $this->u->id));
         $result = (int) $comment->save();
         \DB::commit_transaction();
         $this->set_response_body_api(array('result' => $result, 'id' => $comment->id));
     });
 }
Example #21
0
 public static function make_view_cache4foreign_table_and_foreign_id($foreign_table, $foreign_id, $type = null)
 {
     $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids($foreign_table, $foreign_id, $type);
     $timeline = array_shift($timelines);
     Site_Util::get_article_main_view($timeline->id);
     return \Cache::get(\Timeline\Site_Util::get_cache_key($timeline->id), \Config::get('timeline.articles.cache.expir'));
 }
Example #22
0
}
?>

<!-- share button -->
<?php 
if (conf('site.common.shareButton.isEnabled', 'page') && check_public_flag($timeline->public_flag)) {
    echo render('_parts/services/share', array('uri' => $detail_page_uri, 'text' => \Timeline\Site_Util::get_timeline_ogp_contents($timeline->type, $timeline->body, true)));
}
?>

</div><!-- comment_info -->

<?php 
$comment_get_uri = \Timeline\Site_Util::get_comment_api_uri('get', $timeline->type, $timeline->id, $timeline->foreign_id);
$comment_post_uri = \Timeline\Site_Util::get_comment_api_uri('create', $timeline->type, $timeline->id, $timeline->foreign_id);
$comment_delete_uri = \Timeline\Site_Util::get_comment_api_uri('delete', $timeline->type, $timeline->id, $timeline->foreign_id);
$comment_list_attr = array('class' => 'comment_list unloade_comments', 'id' => 'comment_list_' . $timeline->id, 'data-id' => $timeline->id, 'data-post_uri' => $comment_post_uri, 'data-get_uri' => $comment_get_uri, 'data-get_data' => array('image_size' => 'S'), 'data-input' => '#textarea_comment_' . $timeline->id);
?>
<div <?php 
echo Util_Array::conv_array2attr_string($comment_list_attr);
?>
>
<?php 
if ($is_detail) {
    $data = array('parent' => $timeline, 'list' => $list, 'next_id' => $next_id, 'image_size' => 'S', 'list_more_box_attrs' => array('id' => 'listMoreBox_comment_' . $timeline->id, 'data-uri' => $comment_get_uri, 'data-list' => '#comment_list_' . $timeline->id, 'data-template' => '#comment-template', 'data-is_before' => 1), 'delete_uri' => $comment_delete_uri, 'counter_selector' => '#comment_count_' . $timeline->id, 'absolute_display_delete_btn' => true, 'like_api_uri_prefix' => 'timeline/comment', 'liked_ids' => conf('like.isEnabled') && \Auth::check() ? \Site_Model::get_liked_ids('timeline_comment', $u->id, $list) : array());
    echo render('_parts/comment/list', $data);
}
?>
</div>

<?php 
Example #23
0
 /**
  * @dataProvider save_provider
  */
 public function test_save($is_update_test, $values)
 {
     $note = \Note\Model_Note::forge();
     $before = array();
     if ($is_update_test) {
         $note = $this->get_last_row();
         $before = array('title' => $note->title, 'body' => $note->body, 'public_flag' => $note->public_flag, 'is_published' => $note->is_published, 'sort_datetime' => $note->sort_datetime, 'comment_count' => $note->comment_count, 'like_count' => $note->like_count);
     }
     // timeline view cache 作成
     if (self::$is_check_timeline_view_cache) {
         $timeline_view_cache_before = \Timeline\Site_Util::make_view_cache4foreign_table_and_foreign_id('note', $note->id, \Config::get('timeline.types.note'));
     }
     // note save
     list($is_changed, $is_published, $moved_files) = $note->save_with_relations(self::$self_member_id, $values);
     // 返り値の確認
     $this->assertEmpty($moved_files);
     if (!empty($values['is_draft'])) {
         $this->assertEquals(false, $is_published);
     }
     // 新規投稿
     if (!$is_update_test) {
         $is_draft = !empty($values['is_draft']);
         // 件数
         $this->assertEquals(self::$note_count + 1, \Util_Orm::get_count_all('\\Note\\Model_Note'));
         if (is_enabled('timeline')) {
             if ($is_draft) {
                 $this->assertEquals(self::$timeline_count, \Util_Orm::get_count_all('\\Timeline\\Model_Timeline'));
                 $this->assertEquals(self::$timeline_cache_count, \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCache'));
             } else {
                 $this->assertEquals(self::$timeline_count + 1, \Util_Orm::get_count_all('\\Timeline\\Model_Timeline'));
                 $this->assertEquals(self::$timeline_cache_count + 2, \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCache'));
             }
         }
         // 値
         $this->assertEquals(0, $note->comment_count);
         $this->assertEquals($note->created_at, $note->sort_datetime);
     } else {
         // 件数
         $this->assertEquals(self::$note_count, \Util_Orm::get_count_all('\\Note\\Model_Note'));
         if (is_enabled('timeline')) {
             if ($is_published) {
                 $this->assertEquals(self::$timeline_count + 1, \Util_Orm::get_count_all('\\Timeline\\Model_Timeline'));
                 $this->assertEquals(self::$timeline_cache_count + 2, \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCache'));
             } else {
                 $this->assertEquals(self::$timeline_count, \Util_Orm::get_count_all('\\Timeline\\Model_Timeline'));
                 $this->assertEquals(self::$timeline_cache_count, \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCache'));
             }
         }
         // 値
         $this->assertEquals($before['comment_count'], $note->comment_count);
         if ($is_changed && self::check_sort_datetime_change($note, $before)) {
             $this->assertEquals($note->updated_at, $note->sort_datetime);
         }
     }
     // timeline 関連
     if (is_enabled('timeline')) {
         // 公開済み日記
         if ($note->is_published) {
             $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('note', $note->id, \Config::get('timeline.types.note'));
             $this->assertCount(1, $timelines);
             $timeline = array_shift($timelines);
             $this->assertEquals($note->member_id, $timeline->member_id);
             $this->assertEquals($note->public_flag, $timeline->public_flag);
             $this->assertEquals($note->sort_datetime, $timeline->sort_datetime);
             $this->assertEquals($note->comment_count, $timeline->comment_count);
             if ($is_published) {
                 $this->assertEquals($note->updated_at, $timeline->created_at);
             } else {
                 $this->assertEquals($note->created_at, $timeline->created_at);
             }
             // timeline view cache check
             if (self::$is_check_timeline_view_cache) {
                 $this->assertEmpty(\Timeline\Site_Util::get_view_cache($timeline->id));
             }
         } else {
             $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('note', $note->id, \Config::get('timeline.types.note'));
             $this->assertEmpty($timelines);
         }
     }
 }
Example #24
0
 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));
             }
         }
     }
 }
Example #25
0
 public function after_update(\Orm\Model $obj)
 {
     if (\Util_Orm::check_is_updated($obj, $this->_check_properties, $this->_ignore_properties)) {
         \Timeline\Site_Util::delete_cache($obj->id, $obj->type);
     }
 }
Example #26
0
 public function before_delete(\Orm\Model $obj)
 {
     \Timeline\Site_Util::delete_cache($obj->id, $obj->type);
 }