Allow for templates describing the errors to be included into the main error template.
This patch also changes the MetadataNotFound and NoState errors to use this structure. Thanks to Andjelko Horvat for implementing this. git-svn-id: http://simplesamlphp.googlecode.com/svn/trunk@2773 44740490-163a-0410-bde0-09ae8108e29a
This commit is contained in:
parent
9cf994c421
commit
8362358f71
|
@ -50,6 +50,14 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception {
|
|||
private $parameters;
|
||||
|
||||
|
||||
/**
|
||||
* Name of custom include template for the error.
|
||||
*
|
||||
* @var string|NULL
|
||||
*/
|
||||
protected $includeTemplate = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for this error.
|
||||
*
|
||||
|
@ -217,6 +225,7 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception {
|
|||
$data['module'] = $this->module;
|
||||
$data['dictTitle'] = $this->dictTitle;
|
||||
$data['dictDescr'] = $this->dictDescr;
|
||||
$data['includeTemplate'] = $this->includeTemplate;
|
||||
|
||||
/* Check if there is a valid technical contact email address. */
|
||||
if($config->getString('technicalcontact_email', 'na@example.org') !== 'na@example.org') {
|
||||
|
|
|
@ -8,13 +8,6 @@
|
|||
*/
|
||||
class SimpleSAML_Error_MetadataNotFound extends SimpleSAML_Error_Error {
|
||||
|
||||
/**
|
||||
* The entityID we were unable to locate.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $entityId;
|
||||
|
||||
|
||||
/**
|
||||
* Create the error
|
||||
|
@ -24,31 +17,11 @@ class SimpleSAML_Error_MetadataNotFound extends SimpleSAML_Error_Error {
|
|||
public function __construct($entityId) {
|
||||
assert('is_string($entityId)');
|
||||
|
||||
$this->includeTemplate = 'core:no_metadata.tpl.php';
|
||||
parent::__construct(array(
|
||||
'METADATANOTFOUND',
|
||||
'ENTITYID' => htmlspecialchars(var_export($entityId, TRUE))
|
||||
'%ENTITYID%' => htmlspecialchars(var_export($entityId, TRUE))
|
||||
));
|
||||
|
||||
$this->entityId = $entityId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the error to the user.
|
||||
*
|
||||
* This function does not return.
|
||||
*/
|
||||
public function show() {
|
||||
|
||||
header('HTTP/1.0 500 Internal Server Error');
|
||||
|
||||
$this->logError();
|
||||
|
||||
$globalConfig = SimpleSAML_Configuration::getInstance();
|
||||
$t = new SimpleSAML_XHTML_Template($globalConfig, 'core:no_metadata.tpl.php');
|
||||
$t->data['entityId'] = $this->entityId;
|
||||
$t->show();
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,44 +14,8 @@ class SimpleSAML_Error_NoState extends SimpleSAML_Error_Error {
|
|||
* Create the error
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->includeTemplate = 'core:no_state.tpl.php';
|
||||
parent::__construct('NOSTATE');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the error to the user.
|
||||
*
|
||||
* This function does not return.
|
||||
*/
|
||||
public function show() {
|
||||
|
||||
header('HTTP/1.0 500 Internal Server Error');
|
||||
|
||||
$errorData = $this->saveError();
|
||||
|
||||
$session = SimpleSAML_Session::getInstance();
|
||||
$attributes = $session->getAttributes();
|
||||
if (isset($attributes['mail'][0])) {
|
||||
$email = $attributes['mail'][0];
|
||||
} else {
|
||||
$email = '';
|
||||
}
|
||||
|
||||
|
||||
$globalConfig = SimpleSAML_Configuration::getInstance();
|
||||
$t = new SimpleSAML_XHTML_Template($globalConfig, 'core:no_state.tpl.php');
|
||||
|
||||
/* Enable error reporting if we have a valid technical contact email. */
|
||||
if($globalConfig->getString('technicalcontact_email', 'na@example.org') !== 'na@example.org') {
|
||||
/* Enable error reporting. */
|
||||
$baseurl = SimpleSAML_Utilities::getBaseURL();
|
||||
$t->data['errorReportAddress'] = $baseurl . 'errorreport.php';
|
||||
$t->data['reportId'] = $errorData['reportId'];
|
||||
$t->data['email'] = $email;
|
||||
}
|
||||
|
||||
$t->show();
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
<?php
|
||||
|
||||
$this->data['header'] = $this->t('{core:no_metadata:header}');
|
||||
$this->includeAtTemplateBase('includes/header.php');
|
||||
|
||||
echo('<h2>' . $this->t('{core:no_metadata:header}') . '</h2>');
|
||||
echo('<p>' . $this->t('{core:no_metadata:not_found_for}') . '</p>');
|
||||
echo('<code style="margin-left: 3em;">' . htmlspecialchars($this->data['entityId']) . '</code>');
|
||||
echo('<p>' . $this->t('{core:no_metadata:config_problem}') . '</p>');
|
||||
|
||||
echo('<ul>');
|
||||
|
@ -13,4 +7,3 @@ echo('<li>' . $this->t('{core:no_metadata:suggestion_user_link}') . '</li>');
|
|||
echo('<li>' . $this->t('{core:no_metadata:suggestion_developer}') . '</li>');
|
||||
echo('</ul>');
|
||||
|
||||
$this->includeAtTemplateBase('includes/footer.php');
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
<?php
|
||||
|
||||
$this->data['header'] = $this->t('{core:no_state:header}');
|
||||
$this->includeAtTemplateBase('includes/header.php');
|
||||
|
||||
echo('<h2>' . $this->t('{core:no_state:header}') . '</h2>');
|
||||
echo('<p>' . $this->t('{core:no_state:description}') . '</p>');
|
||||
|
||||
echo('<h3>' . $this->t('{core:no_state:suggestions}') . '</h3>');
|
||||
echo('<ul>');
|
||||
echo('<li>' . $this->t('{core:no_state:suggestion_goback}') . '</li>');
|
||||
|
@ -19,25 +13,3 @@ echo('<li>' . $this->t('{core:no_state:cause_openbrowser}') . '</li>');
|
|||
echo('<li>' . $this->t('{core:no_state:cause_nocookie}') . '</li>');
|
||||
echo('</ul>');
|
||||
|
||||
|
||||
/* Add error report submit section if we have a valid technical contact. */
|
||||
if (isset($this->data['errorReportAddress'])) {
|
||||
|
||||
echo('<h2>' . $this->t('{core:no_state:report_header}') . '</h2>');
|
||||
|
||||
echo('<form action="' . htmlspecialchars($this->data['errorReportAddress']) . '" method="post">');
|
||||
|
||||
echo('<p>' . $this->t('{core:no_state:report_text}') . '</p>');
|
||||
echo('<p>' . $this->t('{errors:report_email}') . '<input type="text" size="25" name="email" value="' . htmlspecialchars($this->data['email']) . '"/></p>');
|
||||
|
||||
echo('<p>');
|
||||
echo('<textarea style="width: 300px; height: 100px" name="text">' . $this->t('{errors:report_explain}') . '</textarea>');
|
||||
echo('</p>');
|
||||
echo('<p>');
|
||||
echo('<input type="hidden" name="reportId" value="' . $this->data['reportId'] . '" />');
|
||||
echo('<input type="submit" name="send" value="' . $this->t('{errors:report_submit}') . '" />');
|
||||
echo('</p>');
|
||||
echo('</form>');
|
||||
}
|
||||
|
||||
$this->includeAtTemplateBase('includes/footer.php');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
$this->data['header'] = $this->t('error_header');
|
||||
$this->data['header'] = $this->t($this->data['dictTitle']);
|
||||
|
||||
$this->data['head'] = '
|
||||
<meta name="robots" content="noindex, nofollow" />
|
||||
|
@ -8,11 +8,15 @@
|
|||
$this->includeAtTemplateBase('includes/header.php');
|
||||
?>
|
||||
|
||||
|
||||
<h2><?php echo $this->t($this->data['dictTitle']); ?></h2>
|
||||
|
||||
<?php
|
||||
echo htmlspecialchars($this->t($this->data['dictDescr'], $this->data['parameters']));
|
||||
|
||||
/* Include optional information for error. */
|
||||
if (isset($this->data['includeTemplate'])) {
|
||||
$this->includeAtTemplateBase($this->data['includeTemplate']);
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="trackidtext">
|
||||
|
|
Reference in New Issue