Exemplo n.º 1
0
 public static function save_profile_image(Model_Member $member, $file_path = null)
 {
     if (conf('upload.types.img.types.m.save_as_album_image')) {
         $album_id = \Album\Model_Album::get_id_for_foreign_table($member->id, 'member');
         list($album_image, $file) = \Album\Model_AlbumImage::save_with_relations($album_id, $member, conf('public_flag.maxRange'), $file_path, 'album_image_profile');
         $member->file_name = $album_image->file_name;
         $member->save();
     } else {
         if ($member->file_name) {
             Model_File::delete_with_timeline($member->file_name);
         }
         $options = Site_Upload::get_uploader_options($member->id);
         $uploadhandler = new Site_Uploader($options);
         $file = $uploadhandler->save($file_path);
         if (!empty($file->error)) {
             throw new FuelException($file->error);
         }
         $member->file_name = $file->name;
         $member->save();
         // timeline 投稿
         if (is_enabled('timeline')) {
             \Timeline\Site_Model::save_timeline($member->id, conf('public_flag.maxRange'), 'profile_image', $file->id, $member->updated_at);
         }
     }
     return $file;
 }
Exemplo n.º 2
0
 /**
  * Site index
  * 
  * @access  public
  * @return  Response
  */
 public function action_index()
 {
     $data = array();
     if (Config::get('page.site.index.timeline.isEnabled') && is_enabled('timeline')) {
         $data['timelines'] = \Timeline\Site_Util::get_list4view(\Auth::check() ? $this->u->id : 0, 0, false, null, $this->common_get_list_params(array('desc' => 1, 'latest' => 1, 'limit' => Config::get('page.site.index.timeline.list.limit')), Config::get('page.site.index.timeline.list.limit_max'), true));
         $data['timelines']['see_more_link'] = array('uri' => 'timeline');
         //$this->template->post_footer = \View::forge('timeline::_parts/load_timelines');
     }
     if (Config::get('page.site.index.news.isEnabled') && is_enabled('news')) {
         list($limit, $page) = $this->common_get_pager_list_params(\Config::get('page.site.index.news.list.limit'), \Config::get('page.site.index.news.list.limit_max'));
         $data['news_list'] = \News\Site_Model::get_list($limit, $page, \Auth::check());
         $data['news_list']['see_more_link'] = array('uri' => 'news');
     }
     if (Config::get('page.site.index.albumImage.isEnabled') && is_enabled('album')) {
         list($limit, $page) = $this->common_get_pager_list_params(\Config::get('page.site.index.albumImage.list.limit'), \Config::get('page.site.index.albumImage.list.limit_max'));
         $data['album_images'] = \Album\Model_AlbumImage::get_pager_list(array('related' => array('album'), 'where' => \Site_Model::get_where_params4list(0, \Auth::check() ? $this->u->id : 0), 'order_by' => array('id' => 'desc'), 'limit' => $limit), $page);
         $data['album_images']['liked_album_image_ids'] = conf('like.isEnabled') && \Auth::check() ? \Site_Model::get_liked_ids('album_image', $this->u->id, $data['album_images']['list']) : array();
         $data['album_images']['column_count'] = \Config::get('page.site.index.albumImage.list.column_count');
         //$this->template->post_footer = \View::forge('image/_parts/list_footer');
     }
     $this->template->post_footer = \View::forge('site/_parts/index_footer');
     if (conf('site.index.slide.isEnabled', 'page')) {
         if (conf('site.index.slide.recentAlbumImage.isEnabled', 'page')) {
             $images = \Album\Site_Util::get_top_slide_image_uris();
         } else {
             $images = Config::get('page.site.index.slide.images');
         }
         $this->template->post_header_content = View::forge('site/_parts/slide', array('image_uris' => $images));
     }
     $this->set_title_and_breadcrumbs('', null, null, null, null, true, true);
     $this->template->content = View::forge('site/index', $data);
     if (!empty($data['news_list']['list'])) {
         $this->template->content->set_safe('html_bodys', \News\Site_Model::convert_raw_bodys($data['news_list']['list']));
     }
 }
Exemplo n.º 3
0
 public function before_delete(\Orm\Model $obj)
 {
     // Delete album_image file.
     $album_images = \Album\Model_AlbumImage::get4album_id($obj->id);
     foreach ($album_images as $album_image) {
         $album_image->delete();
     }
     // delete timeline
     if (is_enabled('timeline')) {
         \Timeline\Model_Timeline::delete4foreign_table_and_foreign_ids('album', $obj->id);
     }
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
0
 public static function get_album_image4note_id($note_id, $limit = 0, $sort = array('id' => 'asc'), $with_count_all = false)
 {
     $album_image_ids = \Util_db::conv_col(\DB::select('album_image_id')->from('note_album_image')->where('note_id', $note_id)->execute()->as_array());
     if (!$album_image_ids) {
         return $with_count_all ? array(array(), 0) : array();
     }
     $query = \Album\Model_AlbumImage::query()->related(array('album'))->where(array('id', 'in', $album_image_ids));
     if ($with_count_all) {
         $count_all = $query->count();
     }
     if ($sort) {
         foreach ($sort as $column => $order) {
             $query->order_by($column, $order);
         }
     }
     if ($limit) {
         $query->rows_limit($limit);
     }
     $list = $query->get();
     return $with_count_all ? array($list, $count_all) : $list;
 }
Exemplo n.º 6
0
 public function delete_with_relations()
 {
     // album_image の削除
     if (\Module::loaded('album') && ($album_images = Model_NoteAlbumImage::get_album_image4note_id($this->id))) {
         $album_image_ids = array();
         foreach ($album_images as $album_image) {
             $album_image_ids[] = $album_image->id;
         }
         \Album\Model_AlbumImage::delete_multiple($album_image_ids);
     }
     // timeline 投稿の削除
     if (\Module::loaded('timeline')) {
         \Timeline\Model_Timeline::delete4foreign_table_and_foreign_ids('note', $this->id);
     }
     // note の削除
     $this->delete();
 }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
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 = intval(\Input::post('id') ?: $id);
         $timeline = Model_Timeline::check_authority($id, $this->u->id);
         list($public_flag, $model) = \Site_Util::validate_params_for_update_public_flag($timeline->public_flag);
         \DB::start_transaction();
         if (Site_Util::check_type($timeline->type, 'album_image_timeline')) {
             $album_image_ids = Model_TimelineChildData::get_foreign_ids4timeline_id($timeline->id);
             \Album\Model_AlbumImage::update_multiple_each($album_image_ids, array('public_flag' => $public_flag));
         }
         $timeline->public_flag = $public_flag;
         $timeline->save();
         \DB::commit_transaction();
         $data = array('model' => $model, 'id' => $id, 'public_flag' => $public_flag, 'is_mycontents' => true, 'without_parent_box' => true);
         $this->set_response_body_api($data, '_parts/public_flag_selecter');
     });
 }
Exemplo n.º 9
0
            ?>
			<div class="date_box">
				<small><?php 
            echo site_get_time($album->created_at);
            ?>
</small>
<?php 
            $is_mycontents = Auth::check() && $u->id == $album->member_id;
            echo render('_parts/public_flag_selecter', array('model' => 'album', 'id' => $album->id, 'public_flag' => $album->public_flag, 'is_mycontents' => $is_mycontents, 'view_icon_only' => true, 'disabled_to_update' => $disable_to_update, 'have_children_public_flag' => true, 'child_model' => 'album_image'));
            ?>
			</div><!-- date_box -->
<?php 
        } else {
            echo render('_parts/member_contents_box', array('member' => $album->member, 'id' => $album->id, 'public_flag' => $album->public_flag, 'public_flag_view_icon_only' => true, 'public_flag_disabled_to_update' => $disable_to_update, 'have_children_public_flag' => true, 'model' => 'album', 'date' => array('datetime' => $album->created_at), 'child_model' => 'album_image'));
        }
        $album_image_count = \Album\Model_AlbumImage::get_list_count(array('where' => \Site_Model::get_where_public_flag4access_from($access_from, array(array('album_id', $album->id)))));
        ?>
			<div class="article">
				<div class="body"><?php 
        echo convert_body($album->body, array('nl2br' => false, 'truncate_width' => conf('articles.trim_width.body', 'album')));
        ?>
</div>
				<small><?php 
        echo render('_parts/image_count_link', array('count' => $album_image_count, 'uri' => 'album/slide/' . $album->id . '#slidetop'));
        ?>
</small>
			</div><!-- article -->
<?php 
        $dropdown_btn_group_attr = array('id' => 'btn_dropdown_' . $album->id, 'class' => array('dropdown', 'boxBtn'));
        $get_uri = sprintf('album/api/menu/%d.html', $album->id);
        $dropdown_btn_attr = array('class' => 'js-dropdown_content_menu', 'data-uri' => sprintf('album/api/menu/%d.html', $album->id), 'data-member_id' => $album->member_id, 'data-menu' => '#menu_' . $album->id, 'data-loaded' => 0);
Exemplo n.º 10
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');
 }
Exemplo n.º 11
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);
             }
         }
     }
 }
Exemplo n.º 12
0
 public function delete_with_album_image($member_id)
 {
     $album_image_ids = array();
     $deleted_files = null;
     if (Site_Util::check_type($this->type, 'album_image_timeline')) {
         try {
             $album = \Album\Model_Album::check_authority($this->foreign_id, $member_id);
         } catch (\FuelException $e) {
             $album = null;
         }
         $album_image_ids = $album ? Model_TimelineChildData::get_foreign_ids4timeline_id($this->id) : null;
     }
     if ($album_image_ids) {
         \Album\Model_AlbumImage::delete_multiple($album_image_ids);
     }
     $this->delete();
 }