/** * Album_image edit * * @access public * @params integer * @return Response */ public function action_edit($id = null) { $album_image = Model_Albumimage::check_authority($id, $this->u->id); $val = self::get_validation_object($album_image); $is_enabled_map = is_enabled_map('image/edit', 'album'); $location = $is_enabled_map ? Model_AlbumimageLocation::get_locations4album_image_id($id) : null; if (\Input::method() == 'POST') { try { \Util_security::check_csrf(); if (!$val->run()) { throw new \FuelException($val->show_errors()); } $post = $val->validated(); if (empty($post['name']) && empty($post['shot_at_time']) && ($is_enabled_map && !strlen($post['latitude']) && !strlen($post['longitude']))) { throw new \FuelException('入力してください'); } $disabled_to_update_message = Site_Util::check_album_disabled_to_update($album_image->album->foreign_table); if ($disabled_to_update_message && isset($post['public_flag']) && $album_image->public_flag != $post['public_flag']) { throw new \FuelException($disabled_to_update_message); } \DB::start_transaction(); $album_image->update_with_relations($post); \DB::commit_transaction(); \Session::set_flash('message', term('album_image') . 'を編集をしました。'); \Response::redirect('album/image/' . $album_image->id); } catch (\FuelException $e) { if (\DB::in_transaction()) { \DB::rollback_transaction(); } \Session::set_flash('error', $e->getMessage()); } } $album_image_page_title = Site_Util::get_album_image_display_name($album_image, term('album_image', 'site.detail')); $this->set_title_and_breadcrumbs(sprintf('%sを%s', term('album_image'), term('form.do_edit')), array('/album/' . $album_image->album_id => $album_image->album->name, '/album/image/' . $id => $album_image_page_title), $album_image->album->member, 'album'); $this->template->post_header = \View::forge('_parts/datetimepicker_header'); $this->template->post_footer = \View::forge('image/_parts/edit_footer'); $this->template->content = \View::forge('image/edit', array('val' => $val, 'album_image' => $album_image, 'location' => $location)); }