예제 #1
0
파일: member.php 프로젝트: uzura8/flockbird
 /**
  * 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'));
 }
예제 #2
0
파일: page.php 프로젝트: uzura8/flockbird
 /**
  * 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'));
 }
예제 #3
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'));
 }
예제 #4
0
파일: news.php 프로젝트: uzura8/flockbird
 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);
 }