From ad891547ec30eb350e80733791aab89f4c439583 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 21 May 2005 16:24:20 +0000 Subject: [PATCH] r175: Adding Message_Reporter::redirect() backend --- global.php | 3 ++- includes/class_message_reporter.php | 33 +++++++++++++++++++++++++++++ templates/default/std_redirect.tpl | 5 +++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 templates/default/std_redirect.tpl diff --git a/global.php b/global.php index 3178915..adefdeb 100755 --- a/global.php +++ b/global.php @@ -62,7 +62,8 @@ $globaltemplates = array( 'footer', 'selectoption', 'selectoptgroup', - 'std_error' + 'std_error', + 'std_redirect' ); $template->cache(array_merge($globaltemplates, (array)$fetchtemplates)); diff --git a/includes/class_message_reporter.php b/includes/class_message_reporter.php index e88d926..046c489 100755 --- a/includes/class_message_reporter.php +++ b/includes/class_message_reporter.php @@ -12,6 +12,9 @@ class Message_Reporter { + var $url = ''; + var $useheaders = true; + var $phrase = null; var $process = ''; @@ -57,6 +60,36 @@ class Message_Reporter $this->phrase = 'error_no_permission'; $this->throw(); } + + function redirect($text = '', $url = '') + { + global $bugsys; + + if (is_array($this->phrase) AND empty($this->process)) + { + trigger_error('Message_Reporter::phrase is an array and cannot be used in Message_Reporter::redirect()', E_USER_ERROR); + } + + if (empty($this->process)) + { + $this->process = phrase($this->phrase);; + } + + $this->process = (($text) ? $text : $this->process); + $this->url = (($url) ? $url : $this->url); + + if ($this->userheaders) + { + header("Location: {$this->url}"); + } + + $redirectmessage = $this->process; + $redirecturl = $this->url; + + eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_redirect') . '");'); + exit; + } + } /*=====================================================================*\ diff --git a/templates/default/std_redirect.tpl b/templates/default/std_redirect.tpl new file mode 100644 index 0000000..b958bdf --- /dev/null +++ b/templates/default/std_redirect.tpl @@ -0,0 +1,5 @@ + +$redirectmessage + +If you are not redirected in a few seconds, click here. + \ No newline at end of file -- 2.43.5