Пример #1
0
 public static function setup_album_image($member_id, $album_image_values = null, $create_count = 1, $album_id = null)
 {
     $public_flag = isset($album_image_values['public_flag']) ? $album_image_values['public_flag'] : conf('public_flag.default');
     if (!$album_id) {
         $album_values = array('name' => 'test album_image.', 'body' => 'This is test for album_image.', 'public_flag' => $public_flag);
         $album = static::force_save_album($member_id, $album_values);
         $album_id = $album->id;
     }
     if (!$album_image_values) {
         $album_image_values = array('name' => 'test', 'public_flag' => conf('public_flag.default'));
     }
     for ($i = 0; $i < $create_count; $i++) {
         $upload_file_path = static::setup_upload_file();
         list($album_image, $file) = Model_AlbumImage::save_with_relations($album_id, null, null, $upload_file_path, 'album', $album_image_values);
     }
     return $album_image;
 }
Пример #2
0
 private static function force_save_album($member_id, $values, $upload_file_path, Model_Album $album = null)
 {
     // album save
     if (!$album) {
         $album = Model_Album::forge();
     }
     $album->name = $values['name'];
     $album->body = $values['body'];
     $album->public_flag = $values['public_flag'];
     $album->member_id = $member_id;
     $album->save();
     // album_image save
     $member = \Model_Member::check_authority($member_id);
     list($album_image, $file) = Model_AlbumImage::save_with_relations($album->id, $member, $values['public_flag'], $upload_file_path, 'album');
     return array($album, $album_image, $file);
 }
Пример #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);
 }
Пример #4
0
 private function get_album_image($values, $create_count = 1, $album_id = null)
 {
     $public_flag = isset($values['public_flag']) ? $values['public_flag'] : FBD_PUBLIC_FLAG_ALL;
     if (!$album_id) {
         $album_values = array('name' => 'test album_image.', 'body' => 'This is test for album_image.', 'public_flag' => $public_flag);
         self::$album = self::force_save_album(self::$member_id, $album_values);
     }
     for ($i = 0; $i < $create_count; $i++) {
         self::$upload_file_path = self::setup_upload_file();
         list($album_image, $file) = Model_AlbumImage::save_with_relations(self::$album->id, self::$member, $public_flag, self::$upload_file_path, 'album', $values);
     }
     self::set_count();
     self::set_timeline_count();
     return $album_image;
 }