示例#1
0
 public function before_delete(\Orm\Model $obj)
 {
     // カバー写真の確認 & 削除
     if (!($album = \Album\Model_Album::find($obj->album_id))) {
         throw new \FuelException('Invalid album id.');
     }
     if ($album->cover_album_image_id == $obj->id) {
         $album->cover_album_image_id = null;
         $album->save();
     }
     // プロフィール写真の確認 & 削除
     if ($album->foreign_table == 'member') {
         if ($album->member->file_name == $obj->file_name) {
             $album->member->file_name = null;
             $album->member->save();
         }
         // timeline 投稿の削除
         if (is_enabled('timeline')) {
             \Timeline\Model_Timeline::delete4foreign_table_and_foreign_ids('album_image', $obj->id);
         }
     }
     if (is_enabled('timeline')) {
         // timeline_child_data の削除
         \Timeline\Model_TimelineChildData::delete4foreign_table_and_foreign_ids('album_image', $obj->id);
         // timeline view cache の削除
         if (is_enabled('note') && \Config::get('timeline.articles.cache.is_use') && $obj->album->foreign_table == 'note') {
             \Timeline\Site_Model::delete_note_view_cache4album_image_id($obj->id);
         }
     }
     // file 削除
     if ($file = \Model_File::get4name($obj->file_name)) {
         $file->delete();
     }
 }
 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);
     }
 }
示例#3
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));
             }
         }
     }
 }
示例#4
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));
         }
     }
 }