示例#1
0
 public static function get_public_flag_range_max4timeline_id($timeline_id)
 {
     if (!($objs = self::get4timeline_id($timeline_id))) {
         return false;
     }
     $public_flag_range_max = false;
     foreach ($objs as $obj) {
         // 暫定的に album_image 限定
         if ($obj->foreign_table != 'album_image') {
             continue;
         }
         $child_obj = \Album\Model_AlbumImage::check_authority($obj->foreign_id);
         if ($public_flag_range_max === false || \Site_Util::check_is_expanded_public_flag_range($public_flag_range_max, $child_obj->public_flag)) {
             $public_flag_range_max = $child_obj->public_flag;
         }
     }
     return $public_flag_range_max;
 }
示例#2
0
文件: util.php 项目: uzura8/flockbird
 public static function get_timeline_images($type, $foreign_id, $timeline_id = null, $access_from = null, $is_detail = false)
 {
     // defaults
     $images = array();
     $images['file_cate'] = 'ai';
     $images['size'] = 'N_M';
     $images['column_count'] = 3;
     switch ($type) {
         case \Config::get('timeline.types.album_image_profile'):
             $images['list'] = array();
             if ($list = \Album\Model_AlbumImage::check_authority($foreign_id)) {
                 $images['list'][] = $list;
                 $images['column_count'] = 2;
             }
             break;
         case \Config::get('timeline.types.profile_image'):
             $images['list'] = array();
             if ($list = \Model_File::find($foreign_id)) {
                 $images['list'][] = $list;
                 $images['file_cate'] = 'm';
                 $images['size'] = 'LL';
                 $images['column_count'] = 2;
             }
             break;
         case \Config::get('timeline.types.note'):
             list($images['list'], $images['count_all']) = \Note\Model_NoteAlbumImage::get_album_image4note_id($foreign_id, $is_detail ? 0 : \Config::get('timeline.articles.thumbnail.limit.default'), array('id' => 'asc'), true);
             $images['parent_page_uri'] = 'note/' . $foreign_id;
             break;
         case \Config::get('timeline.types.thread'):
             list($images['list'], $images['count_all']) = \Thread\Model_ThreadImage::get4thread_id($foreign_id, 3, true);
             $images['file_cate'] = 't';
             $images['size'] = 'M';
             $images['column_count'] = 3;
             $images['parent_page_uri'] = 'thread/' . $foreign_id;
             break;
         case \Config::get('timeline.types.album'):
         case \Config::get('timeline.types.album_image'):
             $images['list'] = array();
             $images['count'] = 0;
             if ($album_image_ids = Model_TimelineChildData::get_foreign_ids4timeline_id($timeline_id)) {
                 list($images['list'], $images['count']) = \Album\Model_AlbumImage::get_list_and_count(array('where' => \Site_Model::get_where_public_flag4access_from($access_from, array(array('id', 'in', $album_image_ids))), $is_detail ? 0 : 'limit' => \Config::get('timeline.articles.thumbnail.limit.default'), 'order_by' => array('created_at' => 'asc')));
             }
             $images['count_all'] = \Album\Model_AlbumImage::get_list_count(array('where' => \Site_Model::get_where_public_flag4access_from($access_from, array(array('album_id', $foreign_id)))));
             $images['parent_page_uri'] = 'album/' . $foreign_id;
             break;
         case \Config::get('timeline.types.album_image_timeline'):
             list($images['list'], $images['count']) = \Album\Model_AlbumImage::get_list_and_count(array('where' => \Site_Model::get_where_public_flag4access_from($access_from, array(array('id', 'in', Model_TimelineChildData::get_foreign_ids4timeline_id($timeline_id)))), $is_detail ? 0 : 'limit' => \Config::get('timeline.articles.thumbnail.limit.album_image_timeline'), 'order_by' => array('created_at' => 'asc')));
             $images['count_all'] = $images['count'];
             $images['parent_page_uri'] = 'timeline/' . $timeline_id;
             break;
         default:
             break;
     }
     return $images;
 }
示例#3
0
 /**
  * Mmeber_Profile_Image delete
  * 
  * @access  public
  * @return  Response
  */
 public function action_delete($album_image_id = null)
 {
     try {
         Util_security::check_csrf();
         if (!conf('upload.types.img.types.m.save_as_album_image')) {
             throw new HttpNotFoundException();
         }
         $album_image = \Album\Model_AlbumImage::check_authority($album_image_id, $this->u->id);
         if ($album_image->album->foreign_table != 'member') {
             throw new FuelException('Disabled to set album image as profile image.');
         }
         DB::start_transaction();
         $album_image->delete();
         DB::commit_transaction();
         Session::set_flash('message', term('profile', 'site.picture') . 'を削除しました。');
     } catch (Database_Exception $e) {
         if (DB::in_transaction()) {
             DB::rollback_transaction();
         }
         Session::set_flash('error', Site_Controller::get_error_message($e, true));
     } catch (FuelException $e) {
         if (DB::in_transaction()) {
             DB::rollback_transaction();
         }
         Session::set_flash('error', $e->getMessage());
     }
     Response::redirect('member/profile/image');
 }
示例#4
0
 public function test_check_type_album_image_timeline()
 {
     if (!($list = Model_Timeline::get4type_key('album_image_timeline'))) {
         $this->markTestSkipped('No record for test.');
     }
     \Util_Develop::output_test_info(__FILE__, __LINE__);
     foreach ($list as $obj) {
         // check for reference data.
         $this->assertEquals('album', $obj->foreign_table);
         $album = \Album\Model_Album::check_authority($obj->foreign_id);
         $this->assertNotEmpty($album);
         // check for member
         $member = \Model_Member::check_authority($obj->member_id);
         $this->assertNotEmpty($member);
         // check for member_id
         $this->assertEquals($album->member_id, $obj->member_id);
         // check for timeline_child_data
         $timeline_child_datas = Model_TimelineChildData::get4timeline_id($obj->id);
         $this->assertNotEmpty($timeline_child_datas);
         $public_flag_max_range = null;
         if ($timeline_child_datas) {
             foreach ($timeline_child_datas as $timeline_child_data) {
                 // check for reference data.
                 $this->assertEquals('album_image', $timeline_child_data->foreign_table);
                 // check for album_image
                 $album_image = \Album\Model_AlbumImage::check_authority($timeline_child_data->foreign_id);
                 $this->assertNotEmpty($album_image);
                 // check for album_id
                 $this->assertEquals($album->id, $album_image->album_id);
                 // check for public_flag.
                 $this->assertEquals($album_image->public_flag, $obj->public_flag);
             }
         }
     }
 }