예제 #1
0
 /**
  * Edit account
  *
  * @param integer $account_id account id
  *
  * @access public
  * @author Dao Anh Minh
  */
 public function action_edit($account_id)
 {
     $view = View::forge('admin/account/edit');
     $account = Model_Account::query()->where('id', $account_id)->get_one();
     if (empty($account)) {
         Session::set_flash('error', 'Tài khoản không tồn tại');
         Response::redirect('admin/account');
     }
     $view->err = array();
     $validate = Model_Account::validate($account_id);
     if (Input::method() == 'POST') {
         if ($validate->run()) {
             $account->set('password', Auth\Auth::instance()->hash_password(Input::post('confirm_pass')))->save();
             Session::set_flash('success', 'Đổi mật khẩu thành công');
             Response::redirect('admin/account');
         } else {
             Session::set_flash('error', 'Có lỗi xảy ra');
             $view->err = $validate->error_message();
         }
     }
     $this->template->title = 'Đổi mật khẩu';
     $this->template->content = $view;
 }