r665: Renaming product from "BugStrike" to "Bugdar"
[bugdar.git] / includes / class_message_reporter.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]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 /**
16 * The URL used for redirect
17 * @var string
18 */
19 var $url = '';
20
21 /**
22 * Use a Location header to redirect
23 * @var bool
24 */
25 var $useheaders = false;
26
27 /**
28 * Phrase array; null by default
29 * @var array
30 */
31 var $phrase = null;
32
33 /**
34 * The processed text for a message
35 * @var string
36 */
37 var $process = '';
38
39 /**
40 * Throws a fatal user-end error message
41 *
42 * @param string The text of a message
43 */
44 function error($text = '')
45 {
46 global $bugsys;
47 global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar;
48
49 if (count($this->phrase) > 0 AND empty($this->process))
50 {
51 trigger_error('Message_Reporter->phrase is an array so please use Message_Reporter::error_list_process() to prepare it', E_USER_ERROR);
52 }
53
54 $this->process = ($text ? $text : $this->process);
55
56 $this->check_process();
57
58 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_error') . '");');
59 exit;
60 }
61
62 /**
63 * Converts the phrase array into a list for use in error()
64 */
65 function error_list_process()
66 {
67 if (!is_array($this->phrase) OR count($this->phrase) < 1)
68 {
69 return;
70 }
71
72 $this->process = "\n\n<ol style=\"list-style-type: decimal\">";
73 foreach ($this->phrase AS $phrase)
74 {
75 $this->process .= "\n\t<li>" . $phrase . "</li>";
76 }
77 $this->process .= "\n</ol>";
78 }
79
80 /**
81 * Throws a common no-permission error
82 */
83 function error_permission()
84 {
85 global $bugsys;
86
87 $this->error($bugsys->lang->string('You do not have permission to access this page. If you think that this is an error, please contact an administrator.'));
88 }
89
90 /**
91 * Performs a front-end redirect by either header or <meta>
92 *
93 * @param string Redirect message text
94 * @param string URL to take the user
95 */
96 function redirect($text = '', $url = '')
97 {
98 global $bugsys;
99 global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar;
100
101 $this->process = ($text ? $text : $this->process);
102 $this->url = ($url ? $url : $this->url);
103
104 $this->check_process();
105
106 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_redirect') . '");');
107
108 if ($this->useheaders)
109 {
110 header("Location: {$this->url}");
111 }
112
113 exit;
114 }
115
116 /**
117 * Displays a fatal warning/notice that is usually not an error
118 *
119 * @param string Warning text
120 */
121 function message($text = '')
122 {
123 global $bugsys;
124 global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar;
125
126 $this->process = ($text ? $text : $this->process);
127
128 $this->check_process();
129
130 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_message') . '");');
131 exit;
132 }
133
134 /**
135 * Checks to make sure that there is some text in the processed variable
136 */
137 function check_process()
138 {
139 if (empty($this->process))
140 {
141 trigger_error('Message_Reporter requires some text to display a message', E_USER_ERROR);
142 }
143 }
144 }
145
146 /*=====================================================================*\
147 || ###################################################################
148 || # $HeadURL$
149 || # $Id$
150 || ###################################################################
151 \*=====================================================================*/
152 ?>