use ErrorDlg view for error messages

this will also fix the js errors when the error page was shown
This commit is contained in:
Uwe Steinmann 2018-04-06 16:34:01 +02:00
parent d97ef62ff1
commit bfc59dc90c
8 changed files with 73 additions and 14 deletions

View File

@ -136,12 +136,17 @@ class UI extends UI_Default {
return $themes;
} /* }}} */
static function exitError($pagetitle, $error) {
static function exitError($pagetitle, $error, $noexit=false, $plain=false) {
global $theme, $dms;
$tmp = 'ErrorDlg';
$view = UI::factory($theme, $tmp);
$view = UI::factory($theme, 'ErrorDlg');
$view->setParam('dms', $dms);
$view->exitError($pagetitle, $error);
$view->setParam('pagetitle', $pagetitle);
$view->setParam('errormsg', $error);
$view->setParam('plain', $plain);
$view();
if($noexit)
return;
exit;
}
}

View File

@ -33,8 +33,7 @@ include $settings->_rootDir . "languages/" . $settings->_language . "/lang.inc";
function _printMessage($heading, $message) { /* {{{ */
global $dms, $theme;
$view = UI::factory($theme, 'Login', array('dms'=>$dms));
$view->exitError($heading, $message, true);
UI::exitError($heading, $message, true);
return;
} /* }}} */

View File

@ -38,7 +38,7 @@ else $end = '';
if(isset($_GET['documentid']) && $_GET['documentid'] && is_numeric($_GET['documentid'])) {
$document = $dms->getDocument($_GET["documentid"]);
if (!is_object($document)) {
$view->exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
} else
$document = null;

View File

@ -30,7 +30,7 @@ include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
if (!$user->isAdmin()) {
$view->exitError(getMLText("admin_tools"),getMLText("access_denied"));
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
$rootfolder = $dms->getFolder($settings->_rootFolderID);

View File

@ -34,24 +34,24 @@ $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) {
$view->exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
$document = $dms->getDocument($_GET["documentid"]);
if (!is_object($document)) {
$view->exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
$accessop = new SeedDMS_AccessOperation($dms, $document, $user, $settings);
$folder = $document->getFolder();
if ($document->getAccessMode($user) < M_READ || !$document->getLatestContent()) {
$view->exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied"));
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied"));
}
/* Could be that the advanced access rights prohibit access on the content */
if (!$document->getLatestContent()) {
$view->exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied"));
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied"));
}
/* Recalculate the status of a document and reload the page if the status

View File

@ -41,7 +41,7 @@ else {
$folder = $dms->getFolder($folderid);
if (!is_object($folder)) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))), getMLText("invalid_folder_id"));
}
if (isset($_GET["orderby"]) && strlen($_GET["orderby"])==1 ) {

View File

@ -1351,7 +1351,7 @@ $(document).ready(function() {
echo "</div>\n";
} /* }}} */
function exitError($pagetitle, $error, $noexit=false, $plain=false) { /* {{{ */
function ___exitError($pagetitle, $error, $noexit=false, $plain=false) { /* {{{ */
/* This is just a hack to prevent creation of js files in an error
* case, because they will contain this error page again. It would be much
@ -2445,6 +2445,38 @@ mayscript>
parent::show();
} /* }}} */
function error(){ /* {{{ */
parent::error();
$dms = $this->params['dms'];
$user = $this->params['user'];
$pagetitle = $this->params['pagetitle'];
$errormsg = $this->params['errormsg'];
$plain = $this->params['plain'];
$noexit = $this->params['noexit'];
if(!$plain) {
$this->htmlStartPage($pagetitle);
$this->globalNavigation();
$this->contentStart();
}
print "<div class=\"alert alert-error\">";
print "<h4>".getMLText('error')."!</h4>";
print htmlspecialchars($errormsg);
print "</div>";
print "<div><button class=\"btn history-back\">".getMLText('back')."</button></div>";
$this->contentEnd();
$this->htmlEndPage();
add_log_line(" UI::exitError error=".$errormsg." pagetitle=".$pagetitle, PEAR_LOG_ERR);
if($noexit)
return;
exit;
} /* }}} */
/**
* Return HTML Template for jumploader
*

View File

@ -32,7 +32,30 @@ require_once("class.Bootstrap.php");
class SeedDMS_View_ErrorDlg extends SeedDMS_Bootstrap_Style {
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$pagetitle = $this->params['pagetitle'];
$errormsg = $this->params['errormsg'];
$plain = $this->params['plain'];
if(!$plain) {
$this->htmlStartPage($pagetitle);
$this->globalNavigation();
$this->contentStart();
}
print "<div class=\"alert alert-error\">";
print "<h4>".getMLText('error')."!</h4>";
print htmlspecialchars($errormsg);
print "</div>";
print "<div><button class=\"btn history-back\">".getMLText('back')."</button></div>";
$this->contentEnd();
$this->htmlEndPage();
add_log_line(" UI::exitError error=".$errormsg." pagetitle=".$pagetitle, PEAR_LOG_ERR);
return;
} /* }}} */
}
?>