public function validarEtapaChave() { // De acordo com indetificação principal? if ($this->campoChave == 'cpf') { $this->valorChave = PLib::coalesce($_POST['cpf'], $_GET['cpf']); $cpf = PLib::validade_cpf($this->valorChave); if ($cpf === fase) { $this->erro = "Informe um CPF válido."; } else { $this->valorChave = Plib::str_mask(PLib::only_numbers($this->valorChave), "###.###.###-##"); } } else { $this->valorChave = sanitize_email($_POST['email']); $email = is_email($this->valorChave); if (!$email) { $this->erro = "Informe um email válido."; } else { $this->valorChave = trim(strtolower($this->valorChave)); } } if ($this->erro == null) { $this->avancar = true; $obterPor = 'getBy' . ucfirst($this->campoChave); // Tentar localizar pessoa $this->pessoa = Pessoas::getInstance()->{$obterPor}($this->valorChave); // Encontramos alguém? if ($this->pessoa != null) { // Trazer dados para sessão $_SESSION['id_pessoa'] = $this->pessoa->id; $this->pessoaNome = $this->pessoa->nome; } else { $this->pessoa = new Pessoa(); // Tentar obter a pessoa por uma integração? /** @var $integracao Integracao */ $integracao = Integracoes::getInstance()->getByServico('PhormarPessoa'); if ($integracao) { $pessoaIntegragao = $integracao->getPessoa($this->valorChave); if ($pessoaIntegragao != null) { $this->pessoa = $pessoaIntegragao; // var_dump($pessoaIntegragao->extras); // var_dump($this->pessoa); // die('ok'); // Salvar pessoa, certificar que esteja registrada $this->certificarPessoa(); } // var_dump($pessoaIntegragao); } // Nova pessoa $this->pessoa->newsletter = true; } $_SESSION['inscricao_chave'] = $this->valorChave; // if ($debug) // PLib::var_dump($this->pessoa,"Pessoa"); // Se confirmação imediata if ($this->evento->confirmacao == 'imediata' || $this->evento->confirmacao == 'posterior') { $this->avancarTexto = "Concluir Inscrição"; } } if ($this->erro == null) { // Aplicar desconto? if ($_POST['ticket'] != null) { $result = Inscricoes::getInstance()->aplicarTicket($this->evento, $_POST['ticket']); if ($result !== true) { $erro = $result; } } } }