Example #1
0
 public function find($id)
 {
     $userModel = new Application_Model_UserModelo();
     $result = $this->getDbTable()->find($id);
     if (0 == count($result)) {
         return;
     }
     $row = $result->current();
     $userModel->setNome($row->nome)->setEmail($row->email)->setSenha($row->senha)->setId($row->id)->setRole($row->role)->setStatus($row->status)->setAtivacao($row->ativacao);
     return $userModel;
 }
 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');
         }
     }
 }