public function indexAction() { if ($this->getRequest()->isPost()) { $nome = $this->_request->getParam('nome'); $email = $this->_request->getParam('email'); $senha = md5($this->_request->getParam('senha')); $user = new Application_Model_UserModelo(); $user->setNome($nome); $user->setEmail($email); $user->setSenha($senha); $user->setRole('usuario'); $user->setStatus('0'); $user->setAtivacao(md5(uniqid(rand()))); $dao = new Application_Model_UserDAO(); $mail = new Application_Model_Mail(); $dao->save($user); $url = $this->view->serverUrl() . $this->view->baseUrl(); $mgm = $mail->enviarEmail($url, $user->getEmail(), $user->getAtivacao()); return $this->_redirector->gotoUrl('/index/index?mgm=' . $mgm); } }
public function atualizarAction() { if ($this->getRequest()->isPost()) { $id = $this->_request->getParam('id'); $nome = $this->_request->getParam('nome'); $email = $this->_request->getParam('email'); $role = $this->_request->getParam('role'); if (!isset($role)) { $role = 'usuario'; } $user = new Application_Model_UserModelo(); $user->setId($id); $user->setNome($nome); $user->setEmail($email); $user->setRole($role); $dao = new Application_Model_UserDAO(); if ($dao->atualiza($user)) { return $this->_redirector->gotoUrl('/listar'); } else { return $this->_redirector->gotoUrl('/listar'); } } }