public function cadastrarOuvinte(\Entity\Ouvinte $ouvinte, \Entity\Usuario $usuario, $instituicao_id, $campus_id, $curso_id) { $this->em->getConnection()->beginTransaction(); try { $ouvinte_orig = $this->ouvinte_dao->findOuvinteByCPF($usuario->getCpf()); if ($ouvinte_orig != NULL) { $this->CI->session->set_flashdata('erro', 'Este ouvinte já existe.'); throw new Exception("Este ouvinte já existe", 2); } // TODO: consultar CPF aqui, mover para um método abstrato no usuario_bo $senha = $usuario->getSenha(); $usuario->setSenha(md5($senha)); // cadastra o usuário $this->usuario_dao->insert($usuario); $ouvinte->setUsuario($usuario); $this->_fazerCadastroOuvinteAux($ouvinte, $instituicao_id, $campus_id, $curso_id); $this->em->flush(); $this->em->refresh($usuario); $this->usuario_bo->redefinirUserRegras($usuario->getIdUsuario()); sendEmailAfterRecordUser($usuario->getCpf(), $usuario->getNome(), $usuario->getEmail(), "ouvinte"); return $usuario->getIdUsuario(); } catch (Exception $ex) { $this->em->getConnection()->rollBack(); $this->CI->log->write_log('error', $ex->getMessage()); } return false; }
protected function resetApplication(LoanApplication $a) { $this->em->refresh($a); $jobs = $a->getBorrower()->getEmployment(); $asset = $a->getBorrower()->getAssetAccount(); foreach ($asset as $ass) { $this->em->refresh($ass); } $coBorrowers = $a->getCoBorrower(); $this->em->refresh($a->getBorrower()); foreach ($coBorrowers as $coBorrower) { $coJobs = $coBorrower->getEmployment(); $coAsset = $a->getBorrower()->getAssetAccount(); foreach ($coJobs as $coJob) { $this->em->refresh($coJob); } foreach ($coAsset as $coAss) { $this->em->refresh($coAss); } $this->em->refresh($coBorrower); } foreach ($jobs as $job) { $this->em->refresh($job); } }
public function findOrientadoresByName($name) { if (strlen($name) < 4) { return false; } $orientadores = $this->orientador_dao->findOrientadoresByName($name); $orientadores_pre_encode = array(); foreach ($orientadores as $orientador) { $this->em->refresh($orientador); $orientador->getUsuario()->setCpf(null); $orientador->getUsuario()->setSenha(null); $campus = $orientador->getOrientadorCampus()->get(0)->getCampus(); $user = new stdClass(); $user->usuario = $orientador; $user->campus = $campus; $orientadores_pre_encode[] = $user; } return json_encode($orientadores_pre_encode); }
/** * adiciona o usuário já cadastrado ao papel de autor * @param int $curso_id o id do curso no banco * @return void */ public function fazerCadastroIncremental($curso_id) { $this->em->beginTransaction(); try { $session_user = $this->usuario_bo->getUserSession(); $user = $this->usuario_bo->findUserById($session_user['id']); $autor_orig = $this->autor_dao->find_autor_by_cpf($user->getCpf()); if ($autor_orig != NULL) { $this->CI->session->set_flashdata('erro', 'Este autor já existe.'); throw new Exception("Este autor já existe", 2); } $autor = new Entity\Autor(); $autor->setUsuario($user); $this->fazerCadastroAutorAux($autor, $curso_id); $this->em->flush(); $this->em->refresh($user); $this->usuario_bo->redefinirUserRegras($user->getIdUsuario()); sendEmailAfterRecordUser($user->getCpf(), $user->getNome(), $user->getEmail(), "autor"); return $user->getIdUsuario(); } catch (Exception $e) { $this->em->getConnection()->rollBack(); $this->CI->log->write_log('error', $ex->getMessage()); } }