summaryrefslogtreecommitdiffstats
path: root/Bugzilla.pm
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-07-14 15:01:34 +0200
committermkanat%kerio.com <>2005-07-14 15:01:34 +0200
commitbcfde177dbb9f3748f59af067357e5902335ca46 (patch)
tree9b889e93b023cc3a275867f1fd87571888353d25 /Bugzilla.pm
parentbf0a551fc3ff716b540dc221ab58f80cc2b3d820 (diff)
downloadbugzilla-bcfde177dbb9f3748f59af067357e5902335ca46.tar.gz
bugzilla-bcfde177dbb9f3748f59af067357e5902335ca46.tar.xz
Bug 283989: CGI.pl global init code should be moved to Bugzilla::CGI
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=wurblzap, a=justdave
Diffstat (limited to 'Bugzilla.pm')
-rw-r--r--Bugzilla.pm53
1 files changed, 53 insertions, 0 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm
index 0deb6e16e..d3b1a5970 100644
--- a/Bugzilla.pm
+++ b/Bugzilla.pm
@@ -33,6 +33,59 @@ use Bugzilla::Constants;
use Bugzilla::DB;
use Bugzilla::Template;
use Bugzilla::User;
+use Bugzilla::Error;
+use Bugzilla::Util;
+
+use File::Basename;
+
+#####################################################################
+# Constants
+#####################################################################
+
+# Scripts that are not stopped by shutdownhtml being in effect.
+use constant SHUTDOWNHTML_EXEMPT => [
+ 'doeditparams.cgi',
+ 'editparams.cgi',
+ 'checksetup.pl',
+];
+
+#####################################################################
+# Global Code
+#####################################################################
+
+# If Bugzilla is shut down, do not allow anything to run, just display a
+# message to the user about the downtime. Scripts listed in
+# SHUTDOWNHTML_EXEMPT are exempt from this message.
+#
+# This code must go here. It cannot go anywhere in Bugzilla::CGI, because
+# it uses Template, and that causes various dependency loops.
+if (Param("shutdownhtml")
+ && lsearch(SHUTDOWNHTML_EXEMPT, basename($0)) == -1)
+{
+ my $template = Bugzilla->template;
+ my $vars = {};
+ $vars->{'message'} = 'shutdown';
+ # Generate and return a message about the downtime, appropriately
+ # for if we're a command-line script or a CGI sript.
+ my $extension;
+ if (i_am_cgi() && (!Bugzilla->cgi->param('format')
+ || Bugzilla->cgi->param('format') eq 'html')) {
+ $extension = 'html';
+ }
+ else {
+ $extension = 'txt';
+ }
+ print Bugzilla->cgi->header() if i_am_cgi();
+ my $t_output;
+ $template->process("global/message.$extension.tmpl", $vars, \$t_output)
+ || ThrowTemplateError($template->error);
+ print $t_output . "\n";
+ exit;
+}
+
+#####################################################################
+# Subroutines and Methods
+#####################################################################
my $_template;
sub template {