public function test_timeline_exists() { if (!($list = Model_TimelineCache::find('all'))) { \Util_Develop::output_test_info(__FILE__, __LINE__); $this->markTestSkipped('No record for test.'); } foreach ($list as $obj) { // test for cache exists. $timelines = Model_Timeline::check_authority($obj->timeline_id); $this->assertNotEmpty($timelines); } }
/** * Update public_flag * * @access public * @param int $id target id * @return Response(html) * @throws Exception in Controller_Base::controller_common_api * @see Controller_Base::controller_common_api */ public function post_update_public_flag($id = null) { $this->api_accept_formats = 'html'; $this->controller_common_api(function () use($id) { $id = intval(\Input::post('id') ?: $id); $timeline = Model_Timeline::check_authority($id, $this->u->id); list($public_flag, $model) = \Site_Util::validate_params_for_update_public_flag($timeline->public_flag); \DB::start_transaction(); if (Site_Util::check_type($timeline->type, 'album_image_timeline')) { $album_image_ids = Model_TimelineChildData::get_foreign_ids4timeline_id($timeline->id); \Album\Model_AlbumImage::update_multiple_each($album_image_ids, array('public_flag' => $public_flag)); } $timeline->public_flag = $public_flag; $timeline->save(); \DB::commit_transaction(); $data = array('model' => $model, 'id' => $id, 'public_flag' => $public_flag, 'is_mycontents' => true, 'without_parent_box' => true); $this->set_response_body_api($data, '_parts/public_flag_selecter'); }); }
/** * Timeline delete * * @access public * @params integer * @return Response */ public function action_delete($id = null) { try { \Util_security::check_method('POST'); \Util_security::check_csrf(); if (\Input::post('id')) { $id = (int) \Input::post('id'); } \DB::start_transaction(); $timeline = Model_Timeline::check_authority($id, $this->u->id); Site_Model::delete_timeline($timeline, $this->u->id); \DB::commit_transaction(); \Session::set_flash('message', term('timeline') . 'を削除しました。'); \Response::redirect('timeline/member'); } catch (\FuelException $e) { if (\DB::in_transaction()) { \DB::rollback_transaction(); } \Session::set_flash('error', $e->getMessage()); } \Response::redirect('timeline/' . $id); }