Example #1
0
 /**
  * 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();
 }
Example #2
0
 public function action_delete()
 {
     Util_security::check_method('POST');
     Util_security::check_csrf();
     $form = $this->form_leave();
     $val = $form->validation();
     if (!$val->run()) {
         Session::set_flash('error', $val->show_errors());
         $this->action_index();
         return;
     }
     if (!$this->u->check_registered_oauth(true) && !$this->auth_instance->check_password()) {
         Session::set_flash('error', term('site.password') . 'が正しくありません');
         $this->action_index();
         return;
     }
     $error_message = '';
     $is_transaction_rollback = false;
     try {
         $message = Site_Member::remove($this->u);
         $this->auth_instance->logout();
         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 (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);
     }
     $this->action_index();
 }
Example #3
0
 public function action_change_password()
 {
     Util_security::check_method('POST');
     Util_security::check_csrf();
     $form = $this->form_setting_password();
     $val = $form->validation();
     if (!$val->run()) {
         Session::set_flash('error', $val->show_errors());
         $this->action_password();
         return;
     }
     $post = $val->validated();
     $error_message = '';
     $is_transaction_rollback = false;
     try {
         DB::start_transaction();
         $this->change_password($post['old_password'], $post['password']);
         DB::commit_transaction();
         $mail = new Site_Mail('memberSettingPassword');
         $mail->send($this->u->member_auth->email, array('to_name' => $this->u->name));
         Session::set_flash('message', term('site.password') . 'を変更しました。');
         Response::redirect('member/setting');
     } 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 (WrongPasswordException $e) {
         $is_transaction_rollback = true;
         $error_message = sprintf('現在の%sが正しくありません。', term('site.password'));
     } catch (\Auth\SimpleUserUpdateException $e) {
         $is_transaction_rollback = true;
         $error_message = term('site.password') . 'の変更に失敗しました。';
     } 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_password();
 }
Example #4
0
 /**
  * Mmeber_Profile_Image edit
  * 
  * @access  public
  * @return  Response
  */
 public function action_edit()
 {
     Util_security::check_method('POST');
     Util_security::check_csrf();
     try {
         DB::start_transaction();
         $file = Site_Member::save_profile_image($this->u);
         DB::commit_transaction();
         Session::set_flash('message', term('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');
 }
Example #5
0
 /**
  * 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'));
 }
Example #6
0
 /**
  * Admin account delete
  * 
  * @access  public
  * @params  integer
  * @return  Response
  */
 public function action_delete($id = null)
 {
     \Util_security::check_method('POST');
     \Util_security::check_csrf();
     if (check_original_user($id, true)) {
         throw new \HttpForbiddenException();
     }
     $user = Model_AdminUser::check_authority($id);
     try {
         $auth = \Auth::instance();
         \DB::start_transaction();
         $auth->delete_user($user->username);
         \DB::commit_transaction();
         \Session::set_flash('message', term('admin.user.view') . 'を削除しました。');
     } catch (\FuelException $e) {
         if (\DB::in_transaction()) {
             \DB::rollback_transaction();
         }
         \Session::set_flash('error', $e->getMessage());
     }
     \Response::redirect(\Site_Util::get_redirect_uri('admin/account'));
 }
Example #7
0
 /**
  * News delete
  * 
  * @access  public
  * @params  integer
  * @return  Response
  */
 public function action_delete($id = null)
 {
     \Util_security::check_method('POST');
     \Util_security::check_csrf();
     $content_page = \Content\Model_ContentPage::check_authority($id);
     $error_message = '';
     try {
         \DB::start_transaction();
         $content_page->delete();
         \DB::commit_transaction();
         \Session::set_flash('message', term('content.page') . 'を削除しました。');
     } catch (\Database_Exception $e) {
         $error_message = \Site_Controller::get_error_message($e, true);
     } catch (\FuelException $e) {
         $error_message = $e->getMessage();
     }
     if ($error_message) {
         if (\DB::in_transaction()) {
             \DB::rollback_transaction();
         }
         \Session::set_flash('error', $error_message);
     }
     \Response::redirect(\Site_Util::get_redirect_uri('admin/content/page'));
 }
Example #8
0
 /**
  * Note publish
  * 
  * @access  public
  * @params  integer
  * @return  Response
  */
 public function action_publish($id = null)
 {
     \Util_security::check_method('POST');
     \Util_security::check_csrf();
     $note = Model_Note::check_authority($id, $this->u->id);
     if ($note->is_published) {
         \Session::set_flash('error', '既に公開されています。');
         \Response::redirect('note/detail/' . $id);
     }
     try {
         \DB::start_transaction();
         list($is_changed, $is_published) = $note->save_with_relations($this->u->id, array('is_published' => 1));
         \DB::commit_transaction();
         \Session::set_flash('message', term('note') . 'を公開しました。');
     } catch (\FuelException $e) {
         if (\DB::in_transaction()) {
             \DB::rollback_transaction();
         }
         \Session::set_flash('error', $e->getMessage());
     }
     \Response::redirect('note/detail/' . $id);
 }
Example #9
0
 /**
  * Album_image delete
  * 
  * @access  public
  * @params  integer
  * @return  Response
  */
 public function action_delete($id = null)
 {
     \Util_security::check_method('POST');
     \Util_security::check_csrf();
     $album_image = Model_Albumimage::check_authority($id, $this->u->id);
     $album_id = $album_image->album_id;
     try {
         \DB::start_transaction();
         $album_image->delete();
         \DB::commit_transaction();
         \Session::set_flash('message', term('album_image') . 'を削除しました。');
     } catch (Exception $e) {
         \Session::set_flash('error', $e->getMessage());
         \DB::rollback_transaction();
     }
     \Response::redirect('album/' . $album_id);
 }
Example #10
0
 /**
  * Execute register email.
  * 
  * @access  public
  * @return  Response
  */
 public function action_register($mode = null)
 {
     Util_security::check_method('POST');
     Util_security::check_csrf();
     list($mode, $is_registerd, $is_regist_mode, $action_name, $is_oauth_registerd_user) = $this->get_common_vals($mode);
     $this->set_validation_email($is_oauth_registerd_user);
     $this->set_validation_code();
     $error_message = '';
     $is_transaction_rollback = false;
     try {
         if (!$this->val_obj->run()) {
             throw new ValidationFailedException($this->val_obj->show_errors());
         }
         $post = $this->val_obj->validated();
         if (!$is_oauth_registerd_user && !$this->auth_instance->check_password()) {
             throw new ValidationFailedException(term('site.password') . 'が正しくありません');
         }
         $member_email_pre = Model_MemberEmailPre::get4member_id($this->u->id);
         $code_error_message = sprintf('%sが正しくないか、%sが過ぎてます。再度%sを%sしてください。', term('form.confirm', 'site.code'), term('form.enabled', 'common.timelimit'), term('form.for_confirm', 'site.mail'), term('form.send'));
         $this->check_email_registered($member_email_pre ? $member_email_pre->email : $post['email'], $mode, $code_error_message, true);
         if (!$member_email_pre || !self::check_confirmation_code($member_email_pre, $post['code'])) {
             throw new ValidationFailedException($code_error_message);
         }
         $email = $member_email_pre->email;
         $values = array('email' => $email);
         if (!$is_oauth_registerd_user) {
             $values['password'] = $post['password'];
             $values['old_password'] = $post['password'];
         }
         DB::start_transaction();
         if (!$this->auth_instance->update_user($values, $this->u->id)) {
             throw new FuelException('Change email error.');
         }
         $member_email_pre->delete();
         // 仮登録情報の削除
         DB::commit_transaction();
         $this->set_current_user();
         $mail = new Site_Mail('memberRegisterEmailConfirm');
         $mail->send($email, array('to_name' => $this->u->name));
         Session::set_flash('message', sprintf('%sを%sしました。', term('site.email'), $action_name));
         Response::redirect('member/setting');
     } catch (ValidationFailedException $e) {
         $error_message = $e->getMessage();
     } 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('site.email') . 'の変更に失敗しました。';
     } 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 = sprintf('%sの%sに失敗しました。', term('site.email'), $action_name);
         }
     }
     if ($error_message) {
         if ($is_transaction_rollback && DB::in_transaction()) {
             DB::rollback_transaction();
         }
         Session::set_flash('error', $error_message);
     }
     $this->action_register_confirm($mode);
 }
Example #11
0
 /**
  * Execute confirm signup
  * 
  * @access  public
  * @return  Response
  */
 public function action_confirm_signup()
 {
     Util_security::check_method('POST');
     Util_security::check_csrf();
     if (!($form = Fieldset::instance('confirm_signup'))) {
         $form = $this->get_form_signup_confirm();
     }
     $val = $form->validation();
     $val->fieldset()->field('email')->delete_rule('unique');
     $redirect_uri = conf('login_uri.site');
     $success_message = '仮登録が完了しました。受信したメール内に記載された URL より本登録を完了してください。';
     $error_message = '';
     $is_transaction_rollback = false;
     try {
         if (!$val->run()) {
             throw new \FuelException($val->show_errors());
         }
         $post = $val->validated();
         if (Model_MemberAuth::get4email($post['email'])) {
             if (conf('member.register.email.hideUniqueCheck')) {
                 Session::set_flash('message', $success_message);
                 Response::redirect($redirect_uri);
             }
             throw new FuelException('その' . term('site.email') . 'は登録できません。');
         }
         DB::start_transaction();
         $token = Model_MemberPre::save_with_token($post['email'], $post['password']);
         DB::commit_transaction();
         $mail = new Site_Mail('memberSignup');
         $mail->send($post['email'], array('register_url' => sprintf('%s?token=%s', Uri::create('member/register'), $token)));
         Session::set_flash('message', $success_message);
         Response::redirect($redirect_uri);
     } 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 ($is_transaction_rollback && DB::in_transaction()) {
         DB::rollback_transaction();
     }
     Session::set_flash('error', $error_message);
     $this->action_signup();
 }
Example #12
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);
 }
Example #13
0
 /**
  * Reset action.
  * 
  * @access  public
  * @params  integer
  * @return  Response
  */
 public function action_reset($db_key = null)
 {
     \Util_security::check_method('POST');
     \Util_security::check_csrf();
     if (!($template = \Model_Template::get4name($db_key))) {
         throw new \HttpNotFoundException();
     }
     $error_message = '';
     try {
         \DB::start_transaction();
         $template->delete();
         \DB::commit_transaction();
         \Session::set_flash('message', 'デフォルトに戻しました。');
     } catch (\Database_Exception $e) {
         $error_message = \Site_Controller::get_error_message($e, true);
     } catch (\FuelException $e) {
         $error_message = $e->getMessage();
     }
     if ($error_message) {
         if (\DB::in_transaction()) {
             \DB::rollback_transaction();
         }
         \Session::set_flash('error', $error_message);
     }
     \Response::redirect('admin/content/template/mail');
 }
Example #14
0
 /**
  * Timeline delete
  * 
  * @access  public
  * @params  integer
  * @return  Response
  */
 public function action_delete($id = null)
 {
     try {
         \Util_security::check_method('POST');
         \Util_security::check_csrf();
         if (\Input::post('id')) {
             $id = (int) \Input::post('id');
         }
         \DB::start_transaction();
         $timeline = Model_Timeline::check_authority($id, $this->u->id);
         Site_Model::delete_timeline($timeline, $this->u->id);
         \DB::commit_transaction();
         \Session::set_flash('message', term('timeline') . 'を削除しました。');
         \Response::redirect('timeline/member');
     } catch (\FuelException $e) {
         if (\DB::in_transaction()) {
             \DB::rollback_transaction();
         }
         \Session::set_flash('error', $e->getMessage());
     }
     \Response::redirect('timeline/' . $id);
 }
Example #15
0
 private function change_publish_status($id, $target_status)
 {
     $target_status = \Util_string::cast_bool_int($target_status);
     \Util_security::check_method('POST');
     \Util_security::check_csrf();
     $news = \News\Model_News::check_authority($id);
     $msg_status = $target_status ? term('form.publish') : term('form.unpublish') . 'に';
     $redirect_uri = \Site_Util::get_redirect_uri('admin/news/' . $id);
     if ($news->is_published == $target_status) {
         \Session::set_flash('error', sprintf('既に%sされています。', $msg_status));
         \Response::redirect($redirect_uri);
     }
     try {
         \DB::start_transaction();
         $news->is_published = $target_status;
         if ($news->is_published && !isset_datatime($news->published_at)) {
             $news->published_at = date('Y-m-d H:i:s');
         }
         $news->save();
         //// timeline 投稿
         //if (is_enabled('timeline')) \Timeline\Site_Model::save_timeline($this->u->id, $note->public_flag, 'note', $note->id);
         \DB::commit_transaction();
         \Session::set_flash('message', sprintf('%sを%sしました。', term('news.view'), $msg_status));
     } catch (\FuelException $e) {
         if (\DB::in_transaction()) {
             \DB::rollback_transaction();
         }
         \Session::set_flash('error', $e->getMessage());
     }
     \Response::redirect($redirect_uri);
 }
Example #16
0
 /**
  * Admin change email.
  * 
  * @access  public
  * @return  Response
  */
 public function action_change_email()
 {
     \Util_security::check_method('POST');
     \Util_security::check_csrf();
     $form = $this->form_setting_email();
     $val = $form->validation();
     if ($val->run()) {
         try {
             $post = $val->validated();
             $email = $post['email'];
             \DB::start_transaction();
             if (!$this->auth_instance->update_user(array('email' => $email))) {
                 throw new \FuelException('change email error.');
             }
             \DB::commit_transaction();
             $maildata = array();
             $maildata['from_name'] = conf('mail.admin.from_name');
             $maildata['from_address'] = conf('mail.admin.from_email');
             $maildata['subject'] = term('site.email', 'form.update', 'form.complete') . 'の' . term('site.notice');
             $maildata['to_address'] = $email;
             $maildata['to_name'] = $this->u->username;
             $this->send_change_email_mail($maildata);
             \Session::set_flash('message', term('site.email') . 'を変更しました。');
             \Response::redirect('admin/setting');
         } catch (\EmailValidationFailedException $e) {
             $this->display_error(term('member.view') . '登録: 送信エラー', __METHOD__ . ' email validation error: ' . $e->getMessage());
             return;
         } catch (\EmailSendingFailedException $e) {
             $this->display_error(term('member.view') . '登録: 送信エラー', __METHOD__ . ' email sending error: ' . $e->getMessage());
             return;
         } catch (\Auth\SimpleUserUpdateException $e) {
             if (\DB::in_transaction()) {
                 \DB::rollback_transaction();
             }
             \Session::set_flash('error', sprintf('その%sは登録できません。', term('site.email')));
         } catch (\FuelException $e) {
             if (\DB::in_transaction()) {
                 \DB::rollback_transaction();
             }
             \Session::set_flash('error', term('site.email') . 'の変更に失敗しました。');
         }
     } else {
         \Session::set_flash('error', $val->show_errors());
     }
     $this->action_email();
 }
Example #17
0
 /**
  * Thread delete
  * 
  * @access  public
  * @params  integer
  * @return  Response
  */
 public function action_delete($id = null)
 {
     \Util_security::check_method('POST');
     \Util_security::check_csrf();
     try {
         \DB::start_transaction();
         $thread = Model_Thread::check_authority($id, $this->u->id);
         $thread->delete();
         \DB::commit_transaction();
         \Session::set_flash('message', term('thread') . 'を削除しました。');
     } catch (\FuelException $e) {
         if (\DB::in_transaction()) {
             \DB::rollback_transaction();
         }
         \Session::set_flash('error', $e->getMessage());
     }
     \Response::redirect('thread');
 }