Skip to content

Commit

Permalink
Merge pull request #5160 from portabilis/issue-5106
Browse files Browse the repository at this point in the history
Exibe mensagem de erro ao invés de página
  • Loading branch information
edersoares committed Mar 11, 2019
2 parents 61f795f + 4102f5a commit 29d16cd
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 68 deletions.
110 changes: 42 additions & 68 deletions ieducar/intranet/include/clsBase.inc.php
Expand Up @@ -366,91 +366,65 @@ function CadastraAcesso()

function MakeAll()
{
try {
$cronometro = new clsCronometro();
$cronometro->marca('inicio');
$liberado = TRUE;
$cronometro = new clsCronometro();
$cronometro->marca('inicio');
$liberado = TRUE;

$saida_geral = '';

if ($this->convidado) {
@session_start();
$_SESSION['convidado'] = TRUE;
$_SESSION['id_pessoa'] = '0';
session_write_close();
}

$controlador = new clsControlador();
$saida_geral = '';

if ($controlador->Logado() && $liberado || $this->convidado) {
$this->mostraSupenso();

$this->Formular();
$this->VerificaPermicao();
$this->CadastraAcesso();
$saida_geral = '';
if ($this->convidado) {
@session_start();
$_SESSION['convidado'] = TRUE;
$_SESSION['id_pessoa'] = '0';
session_write_close();
}

app(TopMenu::class)->current($this->processoAp, request()->getRequestUri());
View::share('title', $this->titulo);
$controlador = new clsControlador();

if ($this->renderMenu) {
$saida_geral .= $this->MakeBody();
} else {
foreach ($this->clsForm as $form) {
$saida_geral .= $form->RenderHTML();
}
}
if ($controlador->Logado() && $liberado || $this->convidado) {
$this->mostraSupenso();

} elseif ((empty($_POST['login'])) || (empty($_POST['senha'])) && $liberado) {
$force = !empty($_GET['force']) ? true : false;
$this->Formular();
$this->VerificaPermicao();
$this->CadastraAcesso();
$saida_geral = '';

if (!$force) {
$this->mostraSupenso();
}
app(TopMenu::class)->current($this->processoAp, request()->getRequestUri());
View::share('title', $this->titulo);

$saida_geral .= $this->MakeHeadHtml();
$controlador->Logar(false);
$saida_geral .= $this->MakeFootHtml();
if ($this->renderMenu) {
$saida_geral .= $this->MakeBody();
} else {
$controlador->Logar(true);
$referer = $_SERVER['HTTP_REFERER'];

header("Location: " . $referer, true, 302);
die();
}

$view = 'legacy.body';

if (!$this->renderMenu || !$this->renderMenuSuspenso) {
$view = 'legacy.blank';
foreach ($this->clsForm as $form) {
$saida_geral .= $form->RenderHTML();
}
}

echo view($view, ['body' => $saida_geral])->render();

} catch (Exception $e) {

if ($GLOBALS['coreExt']['Config']->modules->error->track) {
$tracker = TrackerFactory::getTracker($GLOBALS['coreExt']['Config']->modules->error->tracker_name);
$tracker->notify($e);
}
} elseif ((empty($_POST['login'])) || (empty($_POST['senha'])) && $liberado) {
$force = !empty($_GET['force']) ? true : false;

if (config('app.debug')) {
throw new \Exception($e->getMessage(), 0, $e);
if (!$force) {
$this->mostraSupenso();
}

$lastError = error_get_last();
$saida_geral .= $this->MakeHeadHtml();
$controlador->Logar(false);
$saida_geral .= $this->MakeFootHtml();
} else {
$controlador->Logar(true);
$referer = $_SERVER['HTTP_REFERER'];

@session_start();
$_SESSION['last_error_message'] = $e->getMessage();
$_SESSION['last_php_error_message'] = $lastError['message'];
$_SESSION['last_php_error_line'] = $lastError['line'];
$_SESSION['last_php_error_file'] = $lastError['file'];
@session_write_close();
header("Location: " . $referer, true, 302);
die();
}

error_log("Erro inesperado (pego em clsBase): " . $e->getMessage());
$view = 'legacy.body';

die("<script>document.location.href = '/module/Error/unexpected';</script>");
if (!$this->renderMenu || !$this->renderMenuSuspenso) {
$view = 'legacy.blank';
}

echo view($view, ['body' => $saida_geral])->render();
}

function setAlertaProgramacao($string)
Expand Down
17 changes: 17 additions & 0 deletions ieducar/modules/FormulaMedia/Views/EditController.php
Expand Up @@ -144,6 +144,23 @@ public function Gerar()
$tipoFormula->getEnums(), $this->getEntity()->get('tipoFormula'));
}

/**
* Apaga um registro no banco de dados e redireciona para a página indicada
* pela opção "delete_success".
*
* @see clsCadastro::Excluir()
*/
public function Excluir()
{
try {
parent::Excluir();
} catch (Throwable $throwable) {
return false;
}

return true;
}


/**
* Implementa uma rotina de criação ou atualização de registro padrão para
Expand Down

0 comments on commit 29d16cd

Please sign in to comment.