示例#1
0
 public function before_delete(\Orm\Model $obj)
 {
     // カバー写真の確認 & 削除
     if (!($album = \Album\Model_Album::find($obj->album_id))) {
         throw new \FuelException('Invalid album id.');
     }
     if ($album->cover_album_image_id == $obj->id) {
         $album->cover_album_image_id = null;
         $album->save();
     }
     // プロフィール写真の確認 & 削除
     if ($album->foreign_table == 'member') {
         if ($album->member->file_name == $obj->file_name) {
             $album->member->file_name = null;
             $album->member->save();
         }
         // timeline 投稿の削除
         if (is_enabled('timeline')) {
             \Timeline\Model_Timeline::delete4foreign_table_and_foreign_ids('album_image', $obj->id);
         }
     }
     if (is_enabled('timeline')) {
         // timeline_child_data の削除
         \Timeline\Model_TimelineChildData::delete4foreign_table_and_foreign_ids('album_image', $obj->id);
         // timeline view cache の削除
         if (is_enabled('note') && \Config::get('timeline.articles.cache.is_use') && $obj->album->foreign_table == 'note') {
             \Timeline\Site_Model::delete_note_view_cache4album_image_id($obj->id);
         }
     }
     // file 削除
     if ($file = \Model_File::get4name($obj->file_name)) {
         $file->delete();
     }
 }
示例#2
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;
 }
示例#3
0
 public static function save_with_relations($values, $member_id, Model_Album $album = null, $file_tmps = array())
 {
     if (!$album) {
         $album = self::forge();
     }
     $is_new = $album->is_new();
     $album->name = $values['name'];
     $album->body = $values['body'];
     $album->public_flag = $values['public_flag'];
     $album->member_id = $member_id;
     $is_changed = $album->is_changed();
     $is_changed_public_flag = !$is_new && $album->is_changed('public_flag');
     $album->save();
     $moved_files = array();
     $album_image_ids = array();
     if ($file_tmps) {
         list($moved_files, $album_image_ids) = \Site_FileTmp::save_images($file_tmps, $album->id, 'album_id', 'album_image', $values['public_flag']);
     }
     if (\Module::loaded('timeline')) {
         \Timeline\Site_Model::save_timeline($member_id, $values['public_flag'], 'album', $album->id, $album->updated_at, null, null, $album_image_ids);
     }
     if ($is_changed_public_flag && \Module::loaded('timeline')) {
         // timeline の public_flag の更新
         \Timeline\Model_Timeline::update_public_flag4foreign_table_and_foreign_id($values['public_flag'], 'album', $album->id, \Config::get('timeline.types.album'));
     }
     if (!empty($values['is_update_children_public_flag'])) {
         // update album_image public_flag
         Model_AlbumImage::update_public_flag4album_id($album->id, $values['public_flag']);
     }
     return array($album, $moved_files, $is_changed);
 }
示例#4
0
 public function save_with_relations($member_id, $values)
 {
     if (!empty($this->member_id) && $this->member_id != $member_id) {
         throw new \InvalidArgumentException('Parameter member_id is invalid.');
     }
     $is_new = $this->_is_new;
     $this->member_id = $member_id;
     if (isset($values['title'])) {
         $this->title = $values['title'];
     }
     if (isset($values['body'])) {
         $this->body = $values['body'];
     }
     if (isset($values['public_flag'])) {
         $this->public_flag = $values['public_flag'];
     }
     $is_changed_public_flag = $this->is_changed('public_flag');
     $is_changed = $this->is_changed();
     if ($is_changed) {
         $this->save();
     }
     if (is_enabled('timeline')) {
         if (!$is_new && $is_changed_public_flag) {
             // timeline の public_flag の更新
             \Timeline\Model_Timeline::update_public_flag4foreign_table_and_foreign_id($this->public_flag, 'thread', $this->id, \Config::get('timeline.types.thread'));
         } else {
             // timeline 投稿
             \Timeline\Site_Model::save_timeline($member_id, $this->public_flag, 'thread', $this->id, $this->updated_at);
         }
     }
     return $is_changed;
 }
示例#5
0
文件: api.php 项目: uzura8/flockbird
 private static function validate_posted_value($name, $curret_value = null)
 {
     switch ($name) {
         case 'timeline_public_flag':
             $value = Site_Util::validate_posted_public_flag($curret_value);
             break;
         case 'timeline_viewType':
             $value = \Timeline\Site_Model::validate_timeline_viewType(\Input::post('value'));
             break;
         default:
             break;
     }
     return $value;
 }
示例#6
0
文件: test.php 项目: uzura8/flockbird
 public static function force_save_album($member_id, $values, 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();
     if (\Module::loaded('timeline')) {
         \Timeline\Site_Model::save_timeline($member_id, $values['public_flag'], 'album', $album->id, $album->updated_at);
     }
     return $album;
 }
示例#7
0
文件: note.php 项目: uzura8/flockbird
 public function save_with_relations($member_id, $values, $file_tmps = null, $album_images = array(), $files = array())
 {
     if (!empty($this->member_id) && $this->member_id != $member_id) {
         throw new \InvalidArgumentException('Parameter member_id is invalid.');
     }
     $is_new = $this->_is_new;
     $this->member_id = $member_id;
     if (isset($values['title'])) {
         $this->title = $values['title'];
     }
     if (isset($values['body'])) {
         $this->body = $values['body'];
     }
     if (isset($values['public_flag'])) {
         $this->public_flag = $values['public_flag'];
     }
     $is_changed_public_flag = $this->is_changed('public_flag');
     if (!$this->is_published) {
         if (!empty($values['is_published'])) {
             $this->is_published = 1;
         } elseif (empty($values['is_draft'])) {
             $this->is_published = 1;
         }
     }
     $is_published = $this->is_changed('is_published') && $this->is_published;
     if (!empty($values['published_at_time'])) {
         if (!\Util_Date::check_is_same_minute($values['published_at_time'], $this->published_at)) {
             $this->published_at = $values['published_at_time'] . ':00';
         }
     } elseif (!$this->published_at && $is_published) {
         $this->published_at = \Date::time()->format('mysql');
     }
     $is_changed = $this->is_changed();
     if ($is_changed) {
         $this->save();
     }
     $moved_files = array();
     if (is_enabled('album')) {
         $image_public_flag = $this->is_published ? $this->public_flag : FBD_PUBLIC_FLAG_PRIVATE;
         if ($file_tmps) {
             $album_id = \Album\Model_Album::get_id_for_foreign_table($member_id, 'note');
             list($moved_files, $album_image_ids) = \Site_FileTmp::save_images($file_tmps, $album_id, 'album_id', 'album_image', $image_public_flag);
             \Note\Model_NoteAlbumImage::save_multiple($this->id, $album_image_ids);
         }
         // フォーム編集時
         if ($album_images && $files) {
             \Site_Upload::update_image_objs4file_objects($album_images, $files, $image_public_flag);
         } elseif ($is_published && ($saved_album_images = Model_NoteAlbumImage::get_album_image4note_id($this->id))) {
             foreach ($saved_album_images as $saved_album_image) {
                 $saved_album_image->update_public_flag($this->public_flag, true);
             }
         }
     }
     if (is_enabled('timeline')) {
         if ($is_published) {
             // timeline 投稿
             \Timeline\Site_Model::save_timeline($member_id, $this->public_flag, 'note', $this->id, $this->updated_at);
         } elseif (!$is_new && $is_changed_public_flag) {
             // timeline の public_flag の更新
             \Timeline\Model_Timeline::update_public_flag4foreign_table_and_foreign_id($this->public_flag, 'note', $this->id, \Config::get('timeline.types.note'));
         }
     }
     return array($is_changed, $is_published, $moved_files);
 }
示例#8
0
文件: api.php 项目: uzura8/flockbird
 /**
  * Create timeline
  * 
  * @access  public
  * @param   int     $parent_id  target parent id
  * @return  Response(json)
  * @throws  Exception in Controller_Base::controller_common_api
  * @see  Controller_Base::controller_common_api
  */
 public function post_create()
 {
     $this->controller_common_api(function () {
         $this->response_body['errors']['message_default'] = term('timeline') . 'の' . term('form.post') . 'に失敗しました。';
         $moved_files = array();
         $album_image_ids = array();
         $timeline = Model_Timeline::forge();
         $val = \Validation::forge();
         $val->add_model($timeline);
         if (!$val->run()) {
             throw new \ValidationFailedException($val->show_errors());
         }
         $post = $val->validated();
         $file_tmps = \Site_FileTmp::get_file_tmps_and_check_filesize($this->u->id, $this->u->filesize_total);
         if (!strlen($post['body']) && !$file_tmps) {
             throw new \ValidationFailedException('Data is empty.');
         }
         $type_key = 'normal';
         $album_id = (int) \Input::post('album_id', 0);
         if ($file_tmps && $album_id) {
             $album = \Album\Model_Album::check_authority($album_id, $this->u->id);
             if (\Album\Site_Util::check_album_disabled_to_update($album->foreign_table, true)) {
                 throw new \ValidationFailedException('Album id is invalid.');
             }
             $type_key = 'album_image';
         }
         try {
             \DB::start_transaction();
             if ($file_tmps) {
                 if (!$album_id) {
                     $type_key = 'album_image_timeline';
                     $album_id = \Album\Model_Album::get_id_for_foreign_table($this->u->id, 'timeline');
                 }
                 list($moved_files, $album_image_ids) = \Site_FileTmp::save_images($file_tmps, $album_id, 'album_id', 'album_image', $post['public_flag']);
             } else {
                 $album_id = null;
             }
             $timeline = \Timeline\Site_Model::save_timeline($this->u->id, $post['public_flag'], $type_key, $album_id, null, $post['body'], $timeline, $album_image_ids);
             \DB::commit_transaction();
             // thumbnail 作成 & tmp_file thumbnail 削除
             \Site_FileTmp::make_and_remove_thumbnails($moved_files);
         } catch (\Exception $e) {
             if (\DB::in_transaction()) {
                 \DB::rollback_transaction();
             }
             if ($moved_files) {
                 \Site_FileTmp::move_files_to_tmp_dir($moved_files);
             }
             throw $e;
         }
         $data = array('id' => $timeline->id, 'message' => term('timeline') . 'を' . term('form.post') . 'しました。');
         if (conf('service.facebook.shareDialog.myhome.autoPopupAfterCreated')) {
             $link = \Uri::create(Site_Util::get_detail_uri($timeline->id, $timeline->type));
             $data['shareFacebook'] = array('obj' => array('link' => $link));
             if ($album_image_ids && ($album_image = \Album\Model_AlbumImage::find($album_image_ids[0]))) {
                 $data['shareFacebook']['obj']['picture'] = \Site_Util::get_media_uri(img_uri($album_image->file_name, 'thumbnail'), true);
             }
         }
         $this->set_response_body_api($data);
     });
 }
示例#9
0
 public static function save_with_relations($album_id, \Model_Member $member = null, $public_flag = null, $file_path = null, $timeline_type_key = 'album_image', $optional_values = array())
 {
     if (!\Util_Array::array_in_array(array_keys($optional_values), array('name', 'shot_at', 'shot_at_time', 'public_flag'))) {
         throw new \InvalidArgumentException('Parameter optional_values is invalid.');
     }
     if (is_null($public_flag)) {
         $public_flag = isset($optional_values['public_flag']) ? $optional_values['public_flag'] : conf('public_flag.default');
     }
     $album = null;
     if (empty($member)) {
         $album = Model_Album::find($album_id, array('related' => 'member'));
         $member = $album->member;
     }
     $options = \Site_Upload::get_uploader_options($member->id, 'ai', $album_id);
     $uploadhandler = new \Site_Uploader($options);
     $file = $uploadhandler->save($file_path);
     if (!empty($file->error)) {
         throw new \FuelException($file->error);
     }
     $self = new self();
     $self->album_id = $album_id;
     $self->file_name = $file->name;
     $self->public_flag = $public_flag;
     $self->shot_at = self::get_shot_at_for_insert($file->shot_at, isset($optional_values['shot_at_time']) ? $optional_values['shot_at_time'] : null, isset($optional_values['shot_at']) ? $optional_values['shot_at'] : null);
     $self->save();
     // カバー写真の更新
     if ($timeline_type_key == 'album_image_profile') {
         if (!$album) {
             $album = Model_Album::find($album_id);
         }
         $album->cover_album_image_id = $self->id;
         $album->save();
     }
     // timeline 投稿
     if (\Module::loaded('timeline')) {
         switch ($timeline_type_key) {
             case 'album_image_profile':
                 $timeline_foreign_id = $self->id;
                 $timeline_child_foreign_ids = array();
                 break;
             case 'album':
             case 'album_image':
             default:
                 $timeline_foreign_id = $self->album->id;
                 $timeline_child_foreign_ids = array($self->id);
                 break;
         }
         \Timeline\Site_Model::save_timeline($member->id, $public_flag, $timeline_type_key, $timeline_foreign_id, $self->updated_at, null, null, $timeline_child_foreign_ids);
     }
     return array($self, $file);
 }
示例#10
0
 /**
  * Execute index
  * 
  * @access  public
  * @return  Response
  */
 public function action_index()
 {
     // Already logged in
     Auth::check() and Response::redirect('member');
     if (!($member_pre = $this->check_token())) {
         Session::set_flash('error', sprintf('URLが%sです。', term('form.disabled')));
         throw new HttpNotFoundException();
     }
     $form_member_profile = new Form_MemberProfile('regist');
     $add_fields = array();
     $add_fields['token'] = Form_Util::get_model_field('member_pre', 'token');
     $add_fields['password'] = Form_Util::get_model_field('member_auth', 'password');
     if (!$member_pre->password) {
         $add_fields['password_confirm'] = Form_Util::get_model_field('member_auth', 'password', term('site.password', 'form._confirm'));
     }
     $form_member_profile->set_validation($add_fields, 'member_register');
     $form_member_profile->set_validation_message('match_value', ':labelが正しくありません。');
     if (Input::method() == 'POST') {
         Util_security::check_csrf();
         $error_message = '';
         $is_transaction_rollback = false;
         try {
             $form_member_profile->validate();
             $post = $form_member_profile->get_validated_values();
             if ($member_pre->password && $post['password'] != $member_pre->password) {
                 throw new ValidationFailedException(term('site.password') . 'が正しくありません。');
             }
             DB::start_transaction();
             // create new member
             $auth = Auth::instance();
             if (!($member_id = $auth->create_user($member_pre->email, $post['password'], $post['member_name']))) {
                 throw new FuelException('create member error.');
             }
             $member = $auth->get_member();
             // 仮登録情報の削除
             if ($member_pre->invite_member_id) {
                 $member->invite_member_id = $member_pre->invite_member_id;
                 $member->save();
                 // TODO: make friend to invited_member
             }
             $email = $member_pre->email;
             $password = $member_pre->password;
             $member_pre->delete();
             // member_profile 登録
             $form_member_profile->set_member_obj($member);
             $form_member_profile->seve();
             // email が重複する member_pre の削除
             if ($member_pres = \Model_MemberPre::query()->where('email', $email)->get()) {
                 foreach ($member_pres as $member_pre) {
                     $member_pre->delete();
                 }
             }
             // timeline 投稿
             if (is_enabled('timeline')) {
                 \Timeline\Site_Model::save_timeline($member_id, null, 'member_register', $member_id, $member->created_at);
             }
             DB::commit_transaction();
             $mail = new Site_Mail('memberRegister');
             $mail->send($member_pre->email, array('to_name' => $member->name));
             if ($auth->login($email, $password)) {
                 Session::set_flash('message', sprintf('%sが%sしました。', term('site.registration'), term('form.complete')));
                 Response::redirect('member');
             }
             Session::set_flash('error', 'ログインに失敗しました');
             Response::redirect(conf('login_uri.site'));
         } catch (ValidationFailedException $e) {
             $error_message = Site_Controller::get_error_message($e);
         } catch (EmailValidationFailedException $e) {
             Util_Toolkit::log_error('send mail error: ' . __METHOD__ . ' validation error');
             $error_message = 'メール送信エラー';
         } catch (EmailSendingFailedException $e) {
             Util_Toolkit::log_error('send mail error: ' . __METHOD__ . ' sending error');
             $error_message = 'メール送信エラー';
         } catch (\Auth\SimpleUserUpdateException $e) {
             $is_transaction_rollback = true;
             $error_message = 'そのアドレスは登録できません';
         } catch (\Database_Exception $e) {
             $is_transaction_rollback = true;
             $error_message = \Site_Controller::get_error_message($e, true);
         } catch (FuelException $e) {
             $is_transaction_rollback = true;
             $error_message = Site_Controller::get_error_message($e);
         }
         if ($error_message) {
             if ($is_transaction_rollback && DB::in_transaction()) {
                 DB::rollback_transaction();
             }
             Session::set_flash('error', $error_message);
         }
     }
     $this->set_title_and_breadcrumbs(term('member.view', 'site.registration', 'form.confirm'), array('member/signup' => term('site.signup')));
     $this->template->content = View::forge('member/register/index', array('val' => $form_member_profile->get_validation(), 'member_public_flags' => $form_member_profile->get_member_public_flags(), 'profiles' => $form_member_profile->get_profiles(), 'member_profile_public_flags' => $form_member_profile->get_member_profile_public_flags(), 'member_pre' => $member_pre));
 }
示例#11
0
文件: base.php 项目: uzura8/flockbird
 /**
  * Api delete common controller
  * 
  * @access  protected
  * @param   string  $table         Delete target table
  * @param   int     $id            Delete target record's id
  * @param   string  $method        Excecuting method name
  * @param   string  $content_name  Delete target content name for message
  * @return  Response(json)  
  */
 protected function api_delete_common($table, $id = null, $method = null, $content_name = '')
 {
     $this->controller_common_api(function () use($table, $id, $method, $content_name) {
         if (!$method) {
             $method = 'delete';
         }
         $id = intval(\Input::post('id') ?: $id);
         $model = Site_Model::get_model_name($table);
         $obj = $model::check_authority($id, IS_ADMIN ? 0 : $this->u->id);
         if (is_enabled('album') && $table == 'album') {
             if ($result = \Album\Site_Util::check_album_disabled_to_update($obj->foreign_table)) {
                 throw new \DisableToUpdateException($result['message']);
             }
         }
         \DB::start_transaction();
         if ($table == 'timeline') {
             $result = \Timeline\Site_Model::delete_timeline($obj, $this->u->id);
         } else {
             $result = $obj->{$method}();
         }
         \DB::commit_transaction();
         $target_conntent_name = $content_name ?: Site_Model::get_content_name($table);
         $data = array('result' => (bool) $result, 'message' => sprintf('%s%sしました。', $target_conntent_name ? $target_conntent_name . 'を' : '', term('form.delete')));
         $this->set_response_body_api($data);
     });
 }
示例#12
0
}
if (!empty($public_flag_info['option_type'])) {
    $data['option_type'] = $public_flag_info['option_type'];
}
echo render('_parts/public_flag_selecter', $data);
?>
		</div><!-- sub_info -->


<?php 
/* comment_list */
$list = null;
$next_id = null;
$all_comment_count = null;
if ($is_detail) {
    list($list, $next_id, $all_records_count) = \Timeline\Site_Model::get_comments($timeline->type, $timeline->id, $timeline->foreign_id);
}
?>

<div class="comment_info">
<?php 
// comment_count_and_link
$data_comment_link = array('id' => $timeline->id, 'count_attr' => array('class' => 'unset_comment_count'), 'link_display_absolute' => true);
if ($is_detail) {
    $data_comment_link['count'] = $all_records_count;
}
echo render('_parts/comment/count_and_link_display', $data_comment_link);
?>

<?php 
// like_count_and_link
示例#13
0
 /**
  * Album upload
  * @access  public
  * @params  integer
  * @return  Response
  */
 public function action_upload($id = null)
 {
     $id = (int) $id;
     $album = Model_Album::check_authority($id, $this->u->id, 'member');
     if (Site_Util::check_album_disabled_to_update($album->foreign_table, true)) {
         throw new \HttpForbiddenException();
     }
     $files = array();
     if (\Input::method() == 'POST') {
         \Util_security::check_csrf();
         $file_tmps = array();
         $moved_files = array();
         try {
             //if (!$val->run()) throw new \FuelException($val->show_errors());
             $file_tmps = \Site_FileTmp::get_file_tmps_uploaded($this->u->id, true);
             \Site_FileTmp::check_uploaded_under_accepted_filesize($file_tmps, $this->u->filesize_total, \Site_Upload::get_accepted_filesize());
             \DB::start_transaction();
             list($moved_files, $album_image_ids) = \Site_FileTmp::save_images($file_tmps, $album->id, 'album_id', 'album_image', $album->public_flag);
             if (\Module::loaded('timeline')) {
                 \Timeline\Site_Model::save_timeline($this->u->id, $album->public_flag, 'album_image', $album->id, null, null, null, $album_image_ids);
             }
             \DB::commit_transaction();
             // thumbnail 作成 & tmp_file thumbnail 削除
             \Site_FileTmp::make_and_remove_thumbnails($moved_files);
             $message = sprintf('%sをアップロードしました。', term('album_image'));
             \Session::set_flash('message', $message);
             $redirect_uri = 'album/detail/' . $album->id;
             if (FBD_FACEBOOK_APP_ID && conf('service.facebook.shareDialog.album.isEnabled') && conf('service.facebook.shareDialog.album.autoPopupAfterUploaded')) {
                 $redirect_uri .= '?created=1';
             }
             \Response::redirect($redirect_uri);
         } catch (\FuelException $e) {
             if (\DB::in_transaction()) {
                 \DB::rollback_transaction();
             }
             if ($moved_files) {
                 \Site_FileTmp::move_files_to_tmp_dir($moved_files);
             }
             $files = \Site_FileTmp::get_file_objects($file_tmps, $this->u->id);
             \Session::set_flash('error', $e->getMessage());
         }
     }
     $this->template->post_header = \View::forge('filetmp/_parts/upload_header');
     $this->template->post_footer = \View::forge('_parts/form/upload_footer');
     $this->set_title_and_breadcrumbs(term('album_image', 'form.upload'), array('/album/' . $id => $album->name), $album->member, 'album');
     $this->template->content = \View::forge('_parts/form/upload', array('id' => $id, 'album' => $album, 'files' => $files));
 }
示例#14
0
 private function save_member()
 {
     $is_changeed = array();
     if ($this->set_member_obj_value('name')) {
         $is_changeed[] = 'name';
     }
     if ($this->set_member_obj_value('sex')) {
         $is_changeed[] = 'sex';
     }
     if ($this->set_member_obj_public_flag('sex')) {
         $is_changeed[] = 'sex_public_flag';
     }
     if ($this->set_member_obj_value('birthyear')) {
         $is_changeed[] = 'birthyear';
     }
     if ($this->set_member_obj_public_flag('birthyear')) {
         $is_changeed[] = 'birthyear_public_flag';
     }
     if ($this->check_is_set_field('member_birthday_month') && $this->check_is_set_field('member_birthday_day')) {
         $this->member_obj->birthday = Util_Date::combine_date_str($this->validated_values['member_birthday_month'], $this->validated_values['member_birthday_day']);
         if ($this->member_obj->is_changed('birthday')) {
             $is_changeed[] = 'birthday';
         }
     }
     if ($this->set_member_obj_public_flag('birthday', false)) {
         $is_changeed[] = 'birthday_public_flag';
     }
     if (!$is_changeed) {
         return;
     }
     $this->member_obj->save();
     // timeline 投稿
     if (!is_enabled('timeline')) {
         return;
     }
     if (!in_array('name', $is_changeed)) {
         return;
     }
     $body = sprintf('%sを %s に変更しました。', term('member.name'), $this->member_obj->name);
     \Timeline\Site_Model::save_timeline($this->member_obj->id, conf('public_flag.maxRange'), 'member_name', $this->member_obj->id, $this->member_obj->updated_at, $body);
 }
示例#15
0
 private static function force_save_album($member_id, $values, 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();
     if (\Module::loaded('timeline')) {
         \Timeline\Site_Model::save_timeline($member_id, $values['public_flag'], 'album_image', $album->id, $album->updated_at);
     }
     //list($album, $moved_files, $is_changed) = Model_Album::save_with_relations($values, $member_id, $album);
     //// 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 $album;
 }
示例#16
0
文件: auth.php 项目: uzura8/flockbird
 public function provider_signup($provider, $response = null)
 {
     $service_name = isset($response['auth']['info']['name']) ? $response['auth']['info']['name'] : $response['auth']['info']['nickname'];
     $input = array('uid' => (string) $response['auth']['uid'], 'token' => $response['auth']['credentials']['token'], 'service_name' => $response['auth']['info']['name']);
     if (!empty($response['auth']['credentials']['expires'])) {
         $input['expires'] = strtotime($response['auth']['credentials']['expires']);
     }
     if ($service_url = $this->get_service_url($provider, $response)) {
         $input['service_url'] = $service_url;
     }
     try {
         $member_oauth = Model_MemberOauth::forge();
         $val = Validation::forge('provider_signup');
         $val->add_model($member_oauth);
         $val->fieldset()->field('member_id')->delete_rule('required');
         if (!$val->run($input)) {
             throw new \FuelException($val->show_errors());
         }
         $input = $val->validated();
         $provider_id = Model_OauthProvider::get_id($provider);
         \DB::start_transaction();
         $member = Model_Member::forge();
         $member->name = str_replace(' ', '', $input['service_name']);
         list($member->sex, $member->sex_public_flag) = Site_Oauth::get_sex($response, $provider);
         list($member->birthyear, $member->birthyear_public_flag) = Site_Oauth::get_birthyear($response, $provider);
         list($member->birthday, $member->birthday_public_flag) = Site_Oauth::get_birthday($response, $provider);
         $member->filesize_total = 0;
         $member->register_type = $provider_id;
         if ($member->save() === false) {
             throw new \FuelException('Member save failed.');
         }
         $member_oauth->member_id = $member->id;
         $member_oauth->oauth_provider_id = $provider_id;
         $member_oauth->uid = $input['uid'];
         $member_oauth->token = $input['token'];
         $member_oauth->secret = $input['secret'];
         $member_oauth->service_name = $input['service_name'];
         if (!empty($input['expires'])) {
             $member_oauth->expires = $input['expires'];
         }
         if (!empty($input['service_url'])) {
             $member_oauth->service_url = $input['service_url'];
         }
         if ($member_oauth->save() === false) {
             throw new \FuelException('Oauth data save failed.');
         }
         if (!empty($response['auth']['info']['email'])) {
             Model_Memberauth::save_email($response['auth']['info']['email'], $member->id);
         }
         if (conf('auth.oauth.saveTermsUnAgreement')) {
             Model_MemberConfig::set_value($member->id, 'terms_un_agreement', 1);
         }
         // timeline 投稿
         if (is_enabled('timeline')) {
             \Timeline\Site_Model::save_timeline($member->id, null, 'member_register', $member->id, $member->created_at);
         }
         \DB::commit_transaction();
         if (!empty($response['auth']['info']['image'])) {
             $this->save_profile_image($response['auth']['provider'], $response['auth']['info']['image'], $member);
         }
     } catch (\FuelException $e) {
         if (\DB::in_transaction()) {
             \DB::rollback_transaction();
         }
         if (conf('auth.oauth.log.isOutputErrorLog.provider_signup')) {
             \Util_Toolkit::log_error('OAuth provider_signup error: ' . isset($e) ? $e->getMessage() : '');
         }
         return $this->login_failed();
     }
     $this->force_login($member->id);
     if (conf('auth.oauth.forceSetRememberMe')) {
         Auth::remember_me();
     }
     return $this->login_succeeded();
 }