Ejemplo n.º 1
0
 public function saveUser(User $user)
 {
     $data = array('role_id' => $user->getRoleId(), 'id_kho' => $user->getIdKho(), 'username' => $user->getUsername(), 'email' => $user->getEmail(), 'display_name' => $user->getDisplayName(), 'password' => $user->getPassword(), 'ho_ten' => $user->getHoTen(), 'dia_chi' => $user->getDiaChi(), 'mo_ta' => $user->getMoTa(), 'dien_thoai_co_dinh' => $user->getDienThoaiCoDinh(), 'di_dong' => $user->getDiDong(), 'twitter' => $user->getTwitter(), 'hinh_anh' => $user->getHinhAnh(), 'state' => $user->getState());
     $user_id = (int) $user->getUserId();
     if ($user_id == 0) {
         $this->tableGateway->insert($data);
     } else {
         if ($this->getUserByArrayConditionAndArrayColumn(array('user_id' => $user_id), array('username'))) {
             $this->tableGateway->update($data, array('user_id' => $user_id));
         } else {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 2
0
 public function xoaTaiKhoanAction()
 {
     $id = $this->params('id');
     $user_table = $this->getServiceLocator()->get('Permission\\Model\\UserTable');
     $user = $user_table->getUserByArrayConditionAndArrayColumn(array('user_id' => $id, 'state' => 1), array());
     if (!$user) {
         $this->flashMessenger()->addErrorMessage('Tài khoản không tồn tại');
         return $this->redirect()->toRoute('tai_khoan');
     } else {
         $user_moi = new User();
         $user_moi->exchangeArray($user[0]);
         $user_moi->setState(0);
         $user_table->saveUser($user_moi);
         $this->flashMessenger()->addSuccessMessage('Chúc mừng, xóa tài khoản thành công!');
         return $this->redirect()->toRoute('tai_khoan');
     }
 }