/** * 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); }
public static function update_multiple_each($ids, $set_value, $is_disabled_to_update_public_flag = false) { $album_images = Model_AlbumImage::find('all', array('where' => array(array('id', 'in', $ids)))); $result = 0; foreach ($album_images as $album_image) { $is_set = false; if (isset($set_value['name']) && strlen($set_value['name']) && $album_image->name != $set_value['name']) { $album_image->name = $set_value['name']; $is_set = true; } if (isset($set_value['shot_at']) && strlen($set_value['shot_at']) && !\Util_Date::check_is_same_minute($set_value['shot_at'], $album_image->shot_at)) { $album_image->shot_at = $set_value['shot_at'] . ':' . '00'; $is_set = true; } if ($is_set) { $album_image->save(); } if (!$is_disabled_to_update_public_flag && isset($set_value['public_flag']) && $set_value['public_flag'] != 99 && $album_image->public_flag != $set_value['public_flag']) { $album_image->update_public_flag($set_value['public_flag'], true); $is_set = true; } if (isset($set_value['latitude']) && strlen($set_value['latitude']) && isset($set_value['longitude']) && strlen($set_value['longitude'])) { Model_AlbumImageLocation::save4album_image_id($album_image->id, $set_value['latitude'], $set_value['longitude']); } if ($is_set) { $result++; } } return $result; }
/** * Save location data. * * @access public * @param int $id album_image_id * @return Response (json) * @throws Exception in Controller_Base::controller_common_api * @see Controller_Base::controller_common_api */ public function post_save_location($id = null) { $this->controller_common_api(function () use($id) { $this->response_body['errors']['message_default'] = sprintf('%sの%sに失敗しました。', term('site.location'), term('form.save')); $id = intval(\Input::post('id') ?: $id); $album_image = Model_AlbumImage::check_authority($id, $this->u->id, 'album_image_location'); $album_image_location = $album_image->album_image_location ?: Model_AlbumImageLocation::forge(); $val = \Validation::forge(); $val->add_model($album_image_location); $val->fieldset()->field('album_image_id')->delete_rule('required'); if (!$val->run()) { throw new \ValidationFailedException($val->show_errors()); } $post = $val->validated(); $album_image_location->album_image_id = $id; $album_image_location->latitude = $post['latitude']; $album_image_location->longitude = $post['longitude']; \DB::start_transaction(); $status = (bool) $album_image_location->save(); \DB::commit_transaction(); $data = array('status' => $status, 'album_image_location' => $album_image_location->to_array(), 'message' => sprintf('%sを%sしました。', term('site.location'), term('form.save'))); $this->set_response_body_api($data); }); }