/** * {@inheritDoc} */ public function getCpf() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCpf', array()); return parent::getCpf(); }
public function editarAction() { $tp = new LoginTipo(); $ut = new Util(); $us = new Usuarios(); $tiposLogin = $tp->getAllLoginTipo(); $request = $this->getRequest(); $id = $request->getParam('id'); $usuario = $us->getUserByLoginId($id); if (!$usuario) { $this->_helper->redirector('listar', 'usuarios'); } if ($request->isPost()) { $erro = false; $msg = ''; $nascimento = empty($request->getPost('Nascimento')) ? NULL : $ut->dateToSql($request->getPost('Nascimento')); $now = $ut->nowDateSql(); $rg = $ut->limpaDados($request->getPost('Rg')); $cpf = $ut->limpaDados($request->getPost('Cpf')); $telefone = $ut->limpaDados($request->getPost('Telefone')); $celular = $ut->limpaDados($request->getPost('Celular')); $us->setNome($request->getPost('Nome')); $us->setSobrenome($request->getPost('Sobrenome')); $us->setEmail($request->getPost('Email')); $us->setLoginId($id); $us->setRg($rg); $us->setCpf($cpf); $us->setNascimento($nascimento); $us->setTelefone($telefone); $us->setCelular($celular); $us->setSexo($request->getPost('Sexo')); $us->setCadastradoEm($now); $data = array('nome' => $us->getNome(), 'sobrenome' => $us->getSobrenome(), 'email' => $us->getEmail(), 'login_id' => $us->getLoginId(), 'rg' => $us->getRg(), 'cpf' => $us->getCpf(), 'nascimento' => $us->getNascimento(), 'telefone' => $us->getTelefone(), 'celular' => $us->getCelular(), 'sexo' => $us->getSexo()); $us->saveUser($data, $id); $adapter = new Zend_File_Transfer_Adapter_Http(); $adapter->setDestination(APPLICATION_PATH . '/../data/temp'); $upload = new Zend_File_Transfer(); $files = $upload->getFileInfo(); if ($files['Avatar']['tmp_name']) { if (!file_exists(ROOT_DIR . DS . 'painel' . DS . 'images' . DS . 'usuario' . DS . $id)) { mkdir(ROOT_DIR . DS . 'painel' . DS . 'images' . DS . 'usuario' . DS . $id, 0777, true); } foreach ($files as $file => $info) { if ($upload->isUploaded($file)) { //$extension = substr($info['name'], strrpos($info['name'], '.') + 1); $filename = 'avatar.jpg'; $adapter->addFilter('Rename', array('target' => APPLICATION_PATH . '/../data/temp/' . $filename, 'overwrite' => true)); $adapter->receive($info['name']); if (!$adapter->receive()) { $messages = $adapter->getMessages(); echo implode("\n", $messages); exit; } //setFileName::Url2 $us->setAvatar($filename); $imanee = new Imanee\Imanee(APPLICATION_PATH . '/../data/temp/' . $filename); //resized $imanee->resize(300, 300, false)->write(ROOT_DIR . DS . 'painel' . DS . 'images' . DS . 'usuario' . DS . $id . DS . $filename, 80); //full //$imanee->resize(1024, 768) // ->write(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'galeria' . DS . $album_id . DS . 'f_' . $filename, 80); unlink(APPLICATION_PATH . '/../data/temp/' . $filename); } } } if ($erro) { $msg = 'Ocorreu um erro, tente novamente'; $this->view->msg = $msg; } else { $this->_helper->redirector('listar', 'usuarios'); } } $this->view->usuario = $usuario; $this->view->tipos = $tiposLogin; $this->view->util = $ut; $this->render(); }