From 31abe582d6e3157534a29fc16716370c59850569 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Thu, 3 Jul 2008 12:41:48 +0000
Subject: [PATCH] Error reporting: Fill in email address from attributes, if
 present.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@767 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/Utilities.php | 9 +++++++++
 templates/default/error.php  | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index 0d2298afe..aafa280bd 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -421,6 +421,15 @@ class SimpleSAML_Utilities {
 			$t->data['errorreportaddress'] = NULL;
 		}
 
+		$session = SimpleSAML_Session::getInstance();
+		$attributes = $session->getAttributes();
+		if(is_array($attributes) && array_key_exists('mail', $attributes) && count($attributes['mail']) > 0) {
+			$email = $attributes['mail'][0];
+		} else {
+			$email = '';
+		}
+		$t->data['email'] = $email;
+
 		$t->data['exceptionmsg'] = $emsg;
 		$t->data['exceptiontrace'] = $etrace;
 		
diff --git a/templates/default/error.php b/templates/default/error.php
index 83ad3cc3f..fcc1b1a54 100644
--- a/templates/default/error.php
+++ b/templates/default/error.php
@@ -57,7 +57,7 @@ if (!empty($this->data['errorreportaddress'])) {
 	<form action="<?php echo htmlspecialchars($this->data['errorreportaddress']); ?>" method="post">
 	
 		<p><?php echo $this->t('report_text'); ?></p>
-			<p><?php echo $this->t('report_email'); ?> <input type="text" size="25" name="email" value="" />
+			<p><?php echo $this->t('report_email'); ?> <input type="text" size="25" name="email" value="<?php echo($this->data['email']); ?>" />
 	
 		<p>
 		<textarea style="width: 300px; height: 100px" name="text"><?php echo $this->t('report_explain'); ?></textarea>
-- 
GitLab