Example #1
0
 public function update_public_flag($public_flag, $is_skip_check_album_disabled_to_update = false)
 {
     if (!$is_skip_check_album_disabled_to_update && ($result = Site_Util::check_album_disabled_to_update($this->album->foreign_table))) {
         throw new \DisableToUpdateException($result['message']);
     }
     $this->public_flag = $public_flag;
     $result = $this->save();
     if (\Module::loaded('timeline')) {
         \Timeline\Model_Timeline::check_and_update_public_flag4child_data($public_flag, 'album_image', $this->id);
     }
     return $result;
 }
Example #2
0
 private static function get_validation_object(Model_AlbumImage $album_image)
 {
     $val = \Validation::forge();
     $val->add_model($album_image);
     $val->fieldset()->field('file_name')->delete_rule('required');
     if (Site_Util::check_album_disabled_to_update($album_image->album->foreign_table, true)) {
         $val->fieldset()->field('public_flag')->delete_rule('required');
         $val->fieldset()->delete('public_flag');
     } else {
         $val->add('original_public_flag')->add_rule('in_array', \Site_Util::get_public_flags());
     }
     $val->add('shot_at_time', '撮影日時')->add_rule('required')->add_rule('datetime_except_second')->add_rule('datetime_is_past');
     if (is_enabled_map('image/edit', 'album')) {
         $val->add('latitude', '緯度')->add_rule('numeric_between', -90, 90);
         $val->add('longitude', '経度')->add_rule('numeric_between', -180, 180);
     }
     return $val;
 }
Example #3
0
 /**
  * Album upload image
  * 
  * @access  public
  * @return  Response
  */
 public function action_upload_image($album_id = null)
 {
     \Util_security::check_method('POST');
     \Util_security::check_csrf();
     $album = Model_Album::check_authority($album_id, $this->u->id, 'member');
     if (Site_Util::check_album_disabled_to_update($album->foreign_table, true)) {
         throw new \HttpForbiddenException();
     }
     try {
         $val = self::get_validation_public_flag();
         if (!$val->run()) {
             throw new \ValidationFailedException($val->show_errors());
         }
         $post = $val->validated();
         \DB::start_transaction();
         list($album_image, $file) = Model_AlbumImage::save_with_relations($album_id, $this->u, $post['public_flag'], null, 'album_image');
         \DB::commit_transaction();
         \Session::set_flash('message', '写真を投稿しました。');
     } catch (\ValidationFailedException $e) {
         \Session::set_flash('error', $e->getMessage());
     } catch (\FuelException $e) {
         if (\DB::in_transaction()) {
             \DB::rollback_transaction();
         }
         \Session::set_flash('error', $e->getMessage());
     }
     \Response::redirect('album/' . $album_id);
 }
Example #4
0
 /**
  * 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 = (int) $id;
         if (\Input::post('id')) {
             $id = (int) \Input::post('id');
         }
         $icon_only_flag = (int) \Input::post('icon_only_flag', 0);
         $have_children_public_flag = (int) \Input::post('have_children_public_flag', 0);
         $is_update_children_public_flag = (int) \Input::post('is_update_children_public_flag', 0);
         $album = Model_Album::check_authority($id, $this->u->id, 'member');
         if ($result = Site_Util::check_album_disabled_to_update($album->foreign_table)) {
             throw new \DisableToUpdateException($result['message']);
         }
         list($public_flag, $model) = \Site_Util::validate_params_for_update_public_flag($album->public_flag);
         \DB::start_transaction();
         $album->update_public_flag_with_relations($public_flag, !empty($is_update_children_public_flag));
         \DB::commit_transaction();
         $data = array('model' => $model, 'id' => $id, 'public_flag' => $public_flag, 'is_mycontents' => true, 'without_parent_box' => true, 'view_icon_only' => $icon_only_flag, 'have_children_public_flag' => $have_children_public_flag, 'child_model' => 'album_image');
         $this->set_response_body_api($data, '_parts/public_flag_selecter');
     });
 }