public function preDispatch(Zend_Controller_Request_Abstract $request) { $resource = $request->getActionName(); $privilegio = $request->getControllerName(); $modulo = $request->getModuleName(); $privilegio = $modulo . ':' . $privilegio; $storageObj = $this->_authEngine->getStorage()->read(); $role = 'visitante'; if ($this->_authEngine->hasIdentity()) { $auth = $this->_authEngine->getStorage()->read(); $id = $auth['usuario_id']; $usuarioModel = new Application_Model_Usuario(); $usuario = $usuarioModel->find($id)->current(); $role = $usuario['tipo']; } try { if (!$this->_acl->has($privilegio)) { throw new Zend_Exception('Recurso não encontrado: ' . $privilegio); } if (!$this->_acl->isAllowed($role, $privilegio, $resource)) { $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector'); $redirector->gotoUrlAndExit('/error/errorpermission'); } } catch (Zend_Exception $e) { // echo $e->getMessage(); } catch (Zend_Acl_Exception $e) { // echo $e->getMessage(); } }
public function indexAction() { Zend_Loader::loadClass('Zend_Auth'); $authClass = Zend_Auth::getInstance(); if ($authClass->hasIdentity()) { $auth = $authClass->getStorage()->read(); $id = $auth['usuario_id']; require_once APPLICATION_PATH . '/forms/AlterarDados.php'; $this->view->form = $form = new Application_Form_AlterarDados(); $usuarioModel = new Application_Model_Usuario(); if ($this->_request->isPost()) { $this->view->form->setDefaults($this->_request->getPost()); $data = $this->view->form->getValues(); if ($this->view->form->isValid($data)) { if ($data['senha'] != '') { $data['senha'] = md5($data['senha']); } else { unset($data['senha']); } unset($data['repita_senha']); $usuarioModel->update($data, 'idusuario = ' . $id); return $this->_helper->redirector('index'); } } $usuario = $usuarioModel->find($id)->current(); $this->view->form->setDefaults($usuario->toArray()); } }
public static function getLoggetUser() { if (Misc::isLogged()) { $id = Misc::getLoggetUserId(); $usuarioModel = new Application_Model_Usuario(); $usuario = $usuarioModel->find($id)->current(); return $usuario; } return null; }
public function redefinirAction() { $token = $this->_getParam('token'); $modelAlteracaoSenha = new Application_Model_AlteracaoSenha(); $alteracaoSenha = $modelAlteracaoSenha->find($token); if ($alteracaoSenha) { $alteracaoSenha = $alteracaoSenha[0]; if ($alteracaoSenha['tas_dataalteracao']) { $this->view->mensagem = "Solicitação já atendida."; } else { $modelUsuario = new Application_Model_Usuario(); $usuario = $modelUsuario->find($alteracaoSenha['tu_id']); $this->view->login = $usuario['tl_login']; $this->view->token = $token; } } else { $this->view->mensagem = "Token não cadastrado."; } }
public function editarAction() { Zend_Loader::loadClass('Zend_Auth'); $authClass = Zend_Auth::getInstance(); if ($authClass->hasIdentity()) { $auth = $authClass->getStorage()->read(); $id = $auth['usuario_id']; $usuarioModel = new Application_Model_Usuario(); $usuario = $usuarioModel->find($id)->current(); } if (isset($usuario)) { //$user = $usuario['usuario']; $user = $auth['usuario_id']; $enderecoModel = new Application_Model_Endereco(); $row = $enderecoModel->fetchRow($enderecoModel->select()->where('usuario = ?', $user)); if ($row->completo = '0') { $this->view->endereco = '1'; } else { $this->view->endereco = '0'; } $contatoModel = new Application_Model_Contato(); $rowdois = $contatoModel->fetchRow($contatoModel->select()->where('usuario = ?', $user)); if ($rowdois->completo = '0') { $this->view->contato = '1'; } else { $this->view->contato = '0'; } } }