r175: Adding Message_Reporter::redirect() backend
[bugdar.git] / includes / class_message_reporter.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 class Message_Reporter
14 {
15 var $url = '';
16 var $useheaders = true;
17
18 var $phrase = null;
19 var $process = '';
20
21 function error($text = '')
22 {
23 global $bugsys;
24
25 if (is_array($this->phrase) AND empty($this->process))
26 {
27 trigger_error('Message_Reporter::phrase is an array so please use Message_Reporter::error_list_process() to prepare it', E_USER_ERROR);
28 }
29
30 if (empty($this->process))
31 {
32 $this->process = phrase($this->phrase);;
33 }
34
35 $this->process = (($text) ? $text : $this->process);
36
37 $errormessage = $this->process;
38
39 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_error') . '");');
40 exit;
41 }
42
43 function error_list_process()
44 {
45 if (!is_array($this->phrase) OR count($this->phrase) < 1)
46 {
47 return;
48 }
49
50 $this->process = "\n\n<ol style=\"list-style-type: decimal\">";
51 foreach ($this->phrase AS $phrase)
52 {
53 $this->process .= "\n\t<li>" . phrase($phrase) . "</li>";
54 }
55 $this->process .= "\n</ol>";
56 }
57
58 function error_permission()
59 {
60 $this->phrase = 'error_no_permission';
61 $this->throw();
62 }
63
64 function redirect($text = '', $url = '')
65 {
66 global $bugsys;
67
68 if (is_array($this->phrase) AND empty($this->process))
69 {
70 trigger_error('Message_Reporter::phrase is an array and cannot be used in Message_Reporter::redirect()', E_USER_ERROR);
71 }
72
73 if (empty($this->process))
74 {
75 $this->process = phrase($this->phrase);;
76 }
77
78 $this->process = (($text) ? $text : $this->process);
79 $this->url = (($url) ? $url : $this->url);
80
81 if ($this->userheaders)
82 {
83 header("Location: {$this->url}");
84 }
85
86 $redirectmessage = $this->process;
87 $redirecturl = $this->url;
88
89 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_redirect') . '");');
90 exit;
91 }
92
93 }
94
95 /*=====================================================================*\
96 || ###################################################################
97 || # $HeadURL$
98 || # $Id$
99 || ###################################################################
100 \*=====================================================================*/
101 ?>