public function registrarAction() { $this->_helper->layout->setLayout('layout_login'); $form = new Application_Form_Registrar(); if ($this->_request->isPost() && $form->isValid($this->_request->getParams())) { $_usuario = new Application_Model_Usuario(); $usuario = array('login' => $form->getValue('login'), 'pwd' => md5($form->getValue('pwd')), 'nombre' => $form->getValue('nombre'), 'activo' => 1); $_usuario->insert($usuario); $this->_helper->FlashMessenger('Usuario registrado'); $this->_redirect('/index/login'); } $this->view->form = $form; }
public function indexAction() { require_once APPLICATION_PATH . '/forms/Cadastro.php'; $this->view->form = new Application_Form_Cadastro(); if ($this->_request->isPost()) { $this->view->form->setDefaults($this->_request->getPost()); $data = $this->view->form->getValues(); $usuarioModel = new Application_Model_Usuario(); $contatoModel = new Application_Model_Contato(); $enderecoModel = new Application_Model_Endereco(); if ($this->view->form->isValid($data)) { $data['tipo'] = 'cliente'; $data['senha'] = md5($data['senha']); unset($data['repita_senha']); $id = $usuarioModel->insert($data); $usuario = array(); $usuario['usuario'] = $data['usuario']; $id2 = $contatoModel->insert($usuario); $id3 = $enderecoModel->insert($usuario); return $this->_helper->redirector('editar', 'cadastro'); } } }
public function resetAction() { // insertando el dump inicial: $_conf = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini'); $env = APPLICATION_ENV; $db_name = $_conf->{$env}->resources->db->params->dbname; $sql_file = APPLICATION_PATH . '/../docs/' . $db_name . '.sql'; $sql_string = file_get_contents($sql_file); $db = Zend_Db_Table::getDefaultAdapter(); $db->query('DROP DATABASE IF EXISTS ' . $db_name); $db->query($sql_string); //Ubigeos $db->query(file_get_contents(APPLICATION_PATH . '/../docs/ubigeos_peru.sql')); // insertando usuarios $_u = new Application_Model_Usuario(); $pwd = md5('1234'); foreach (range(1, rand(150, 250)) as $i) { $username = '******' . substr(md5(rand(100, 10000)), 24); $u = array('login' => $username, 'pwd' => $pwd, 'nombre' => $username, 'activo' => rand(0, 1)); $_u->insert($u); } $this->_helper->FlashMessenger('DB restaurada'); $this->_redirect('/'); }