protected function check_auth_and_is_mypage($member_id = 0, $is_api = false) { $is_mypage = false; $access_from = 'guest'; $member = null; $member_id = (int) $member_id; if (!$member_id) { $this->check_auth_and_redirect(false); $is_mypage = true; $member = $this->u; $access_from = 'self'; } elseif ($this->check_is_mypage($member_id)) { $is_mypage = true; $member = $this->u; $access_from = 'self'; } else { $member = Model_Member::check_authority($member_id); if (Auth::check()) { $access_from = 'member'; if (Model_MemberRelation::check_relation('friend', $this->u->id, $member_id)) { $access_from = 'friend'; } } } return array($is_mypage, $member, $access_from); }
/** * post_update * * @access public * @return Response (json) */ public function post_update($member_id_to = null, $relation_type = null) { $this->controller_common_api(function () use($member_id_to, $relation_type) { $this->response_body['errors']['message_default'] = sprintf('%sの%sに%sしました。', term('follow'), term('form.update'), term('site.failure')); if (!self::check_relation_type($relation_type)) { throw new HttpNotFoundException(); } if (!is_null(Input::post('id'))) { $member_id_to = (int) Input::post('id'); } $member = Model_Member::check_authority($member_id_to); if ($member_id_to == $this->u->id) { throw new HttpInvalidInputException(); } $member_relation = Model_MemberRelation::get4member_id_from_to($this->u->id, $member_id_to); if (!$member_relation) { $member_relation = Model_MemberRelation::forge(); } $prop = 'is_' . $relation_type; $status_before = (bool) $member_relation->{$prop}; $status_after = !$status_before; \DB::start_transaction(); $member_relation->{$prop} = $status_after; $member_relation->member_id_to = $member_id_to; $member_relation->member_id_from = $this->u->id; $member_relation->save(); \DB::commit_transaction(); $this->response_body['isFollow'] = (int) $status_after; $this->response_body['html'] = $status_after ? sprintf('<span class="glyphicon glyphicon-ok"></span> %s', term('followed')) : term('do_follow'); $this->response_body['attr'] = $status_after ? array('class' => array('add' => 'btn-primary')) : array('class' => array('remove' => 'btn-primary')); $this->response_body['message'] = sprintf('%s%s', term('follow'), $status_after ? 'しました。' : 'を解除しました。'); return $this->response_body; }); }
/** * Confirm reset password * * @access public * @return Response */ public function action_send_reset_password_mail() { // Already logged in Auth::check() and Response::redirect('member'); Util_security::check_method('POST'); Util_security::check_csrf(); $form = $this->form_resend_password(); $val = $form->validation(); if (!$val->run()) { Session::set_flash('error', $val->show_errors()); $this->action_resend_password(); return; } $post = $val->validated(); $message = term('site.password') . 'のリセット方法をメールで送信しました。'; if (!($member_auth = Model_MemberAuth::get4email($post['email']))) { Session::set_flash('message', $message); Response::redirect(conf('login_uri.site')); return; } $member = Model_Member::check_authority($member_auth->member_id); $error_message = ''; $is_transaction_rollback = false; try { $maildata = array(); DB::start_transaction(); $token = Model_MemberPasswordPre::save_with_token($member_auth->member_id, $post['email']); DB::commit_transaction(); $mail = new Site_Mail('memberResendPassword'); $mail->send($post['email'], array('to_name' => $member->name, 'register_url' => sprintf('%s?token=%s', uri::create('member/recover/reset_password'), $token))); Session::set_flash('message', $message); Response::redirect(conf('login_uri.site')); } 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 (\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 = $e->getMessage(); } if ($error_message) { if ($is_transaction_rollback && DB::in_transaction()) { DB::rollback_transaction(); } Session::set_flash('error', $error_message); } $this->action_resend_password(); }
/** * News delete * * @access public * @params integer * @return Response */ public function action_delete($id = null) { $id = (int) $id; \Util_security::check_method('POST'); \Util_security::check_csrf(); $error_message = ''; $is_transaction_rollback = false; try { $member = \Model_Member::check_authority($id); $message = \Site_Member::remove($member); \Session::set_flash('message', $message); } 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 = term('member.view') . 'が存在しません。'; } catch (\Database_Exception $e) { $is_transaction_rollback = true; $error_message = \Site_Controller::get_error_message($e, true); } catch (\FuelException $e) { $is_transaction_rollback = true; if (!($error_message = $e->getMessage())) { $error_message = term('site.left') . 'に失敗しました。'; } } if ($error_message) { if ($is_transaction_rollback && \DB::in_transaction()) { \DB::rollback_transaction(); } \Session::set_flash('error', $error_message); } \Response::redirect(\Site_Util::get_redirect_uri('admin/member')); }
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); }
<?php $is_detail = true; $attr = array('class' => 'timelineBox js-hide-btn', 'id' => 'timelineBox_' . $timeline_id, 'data-id' => $timeline_id, 'data-hidden_btn' => 'btn_dropdown_' . $timeline_id, 'data-hidden_btn_absolute' => 1); if (!empty($timeline_cache_id)) { $is_detail = false; $attr['data-list_id'] = $timeline_cache_id; $attr['data-comment_count'] = $comment_count; $attr['data-like_count'] = $like_count; } $access_from_member_relation = null; if (\Timeline\Site_Util::check_type_to_get_access_from($type)) { $access_from_member_relation = \Site_Member::get_access_from_member_relation($member_id, $self_member_id); } $member = Model_Member::check_authority($member_id); if (isset($liked_timeline_ids)) { echo Form::hidden('liked_timeline_ids', json_encode($liked_timeline_ids), array('id' => 'liked_timeline_ids')); } ?> <div <?php echo Util_Array::conv_array2attr_string($attr); ?> > <div class="row member_contents"> <div class="col-xs-1"><?php echo member_image($member); ?> </div> <div class="col-xs-11"> <div class="member_info"> <b class="fullname"><?php
private static function get_member_filesize_total($member_id) { $member = \Model_Member::check_authority($member_id); return $member->filesize_total; }
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); } } } }