public function identify($data) { $data = $this->_filterInputIdentify($data)->getUnescaped(); $authAdapter = new Vtx_Auth_Adapter($data['username'], md5($data['password'])); if (!Zend_Auth::getInstance()->authenticate($authAdapter)->isValid()) { throw new Vtx_UserException($this->getMessageErrorAuth()); } $userRow = Zend_Auth::getInstance()->getIdentity(); try { $roleRow = $userRow->findUserRole()->current()->findParentRole(); $role = $roleRow->getDescription(); $roleId = $roleRow->getId(); /* * getCurrentStatus */ /* $modelUserLocality = new Model_UserLocality(); $modelUserLocality = new Model_UserLocality(); $userLocalityRow = $modelUserLocality->getByUserId($userRow->getId()); */ } catch (Exception $e) { $role = 'guest'; $roleId = Zend_Registry::get('config')->acl->roleGuestId; } $userAuthIdentify = new Model_UserAuth(); $userAuthIdentify->setUserId($userRow->getId())->setUsername($data['username'])->setFirstName($userRow->getFirstName())->setSurname($userRow->getSurname())->setRole($role)->setRoleId($roleId)->setRoleLongDescription($roleRow->getLongDescription())->setUserRow($userRow); if (!$userAuthIdentify->getEnterpriseStatus()) { Zend_Auth::getInstance()->clearIdentity(); throw new Vtx_UserException('Empresa inativa'); } Zend_Auth::getInstance()->getStorage()->write($userAuthIdentify); $uri = 'questionnaire'; //if ($roleId == ) return $data['uri'] ? $data['uri'] : $uri; }
public function insertAction() { $this->_helper->viewRenderer->setRender('edit'); if (!$this->getRequest()->isPost()) { return; } $this->view->roleRowData = $roleRowData = $this->_getAllParams(); $insert = $this->aclModel->createRole($roleRowData, $this->userAuth->getRoleId()); if (!$insert['status']) { $this->view->messageError = $insert['messageError']; return; } $this->view->roleInsertSucess = true; $this->_forward('index'); }
public function editAction() { $userId = $this->_getParam('id'); $userRow = $this->userModel->getUserById($userId); if (!$userRow) { throw new Exception('Invalid user'); } $this->view->userId = $userId; $this->_helper->viewRenderer->setRender('edit'); $this->view->getAllPositions = $this->positionModel->getAll(); $this->view->getAllEducation = $this->educationModel->getAll(); $this->view->roles = $this->aclModel->getAllRoles(); $listAdmin = false; if ($this->roleRow->getIsSystemAdmin() == 1) { $this->view->getAllRegional = $this->regionalModel->getAll(); $listAdmin = true; } if ($this->aclModel->isAllowed($this->userAuth->getRole(), 'management:user', 'list-user-by-regional')) { if (!$listAdmin) { $userLocality = $this->userLocalityModel->getUserLocalityByUserId($this->userAuth->getUserId()); $this->view->getAllRegional = $this->dbTable_Regional->getAllRegionalByOneRegionalServiceArea(null, $userLocality->getRegionalId()); } } $userRowData['user'] = array('first_name' => $userRow->getFirstName(), 'surname' => $userRow->getSurname(), 'gender' => $userRow->getGender(), 'born_date' => $userRow->getBornDate(), 'position_id' => $userRow->getPositionId(), 'education_id' => $userRow->getEducationId(), 'email' => $userRow->getEmail(), 'cpf' => $userRow->getCpf(), 'login' => $userRow->getLogin(), 'status' => $userRow->getStatus(), 'password_hint' => $userRow->getPasswordHint()); $this->view->registerRowData = $userRowData; $userLocalityRow = $this->userLocalityModel->getUserLocalityByUserId($userRow->getId()); if ($userLocalityRow) { $this->view->registerRowData['userLocality']['regional_id'] = $userLocalityRow->getRegionalId(); } $userRoleRow = $this->userRoleModel->getUserRoleByUserId($userRow->getId()); $this->view->registerRowData['userRole']['role_id'] = $userRoleRow->getRoleId(); if (!$this->getRequest()->isPost()) { return; } $registerRowData = $this->_getAllParams(); $this->view->registerRowData = $registerRowData; $insert = $this->userModel->updateUserTransaction($registerRowData, $userRow); if (!$insert['status']) { $this->view->messageError = $insert['messageError']; return; } $this->view->itemSuccess = true; $this->view->loadUrlUser = $this->view->baseUrl('/management/user/success/itemUpdateSuccess/true/firstnameSuccess/' . urlencode($registerRowData['user']['first_name'])); }