From f7ca23aa038f131d61f1e8264508cb6a0d4b1052 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sun, 4 May 2003 23:26:21 +0000 Subject: [PATCH] Added a new parameter called "sitename" to the config. --- docs/gotcha.txt | 12 ++++++++++++ etc/WebGUI.conf.original | 2 ++ lib/WebGUI/MessageLog.pm | 4 ++-- lib/WebGUI/URL.pm | 19 +++++++++++++++---- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/docs/gotcha.txt b/docs/gotcha.txt index 4bbcfd530..87f257292 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -8,6 +8,18 @@ versions. Be sure to heed the warnings contained herein as they will save you many hours of grief. +5.3.0 +-------------------------------------------------------------------- + * If you are not using sbin/upgrade.pl then you'll need to do all + of the processing handled by docs/upgrades/upgrade_5.2.5-5.3.0.pl + manually. + + * You must add a new variable to your WebGUI config called "sitename" + and make it equal to your site hostname like this: + + sitename = www.mycompany.com + + 5.2.5 -------------------------------------------------------------------- * You'll need to upgrade HTML::Parser to at least version 3.27. diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index ddde81343..931e02fe1 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -1,3 +1,5 @@ +sitename = www.mycompany.com + dsn = DBI:mysql:WebGUI dbuser = webgui dbpass = password diff --git a/lib/WebGUI/MessageLog.pm b/lib/WebGUI/MessageLog.pm index e3350510e..dc9081649 100644 --- a/lib/WebGUI/MessageLog.pm +++ b/lib/WebGUI/MessageLog.pm @@ -131,7 +131,7 @@ sub addEntry { subject, status) values ($messageLogId,".$u->userId.", ".quote($message).",".quote($url).",".time().",".quote($subject).", ".quote($status).")"); if ($url ne "") { - $message .= "\n".WebGUI::URL::append('http://'.$session{env}{HTTP_HOST}.$url,'mlog='.$messageLogId); + $message .= "\n".WebGUI::URL::append($url,'mlog='.$messageLogId); } _notify($u,$subject,$message); } @@ -203,7 +203,7 @@ sub addInternationalizedEntry { WebGUI::SQL->write("insert into messageLog values ($messageLogId,".$u->userId.", ".quote($message).",".quote($url).",".time().",".quote($message).",".quote($status).")"); if ($url ne "") { - $message .= "\n".WebGUI::URL::append('http://'.$session{env}{HTTP_HOST}.$url,'mlog='.$messageLogId); + $message .= "\n".WebGUI::URL::append($url,'mlog='.$messageLogId); } _notify($u,$subject,$message); } diff --git a/lib/WebGUI/URL.pm b/lib/WebGUI/URL.pm index 6d59b4ab1..a52f140fa 100644 --- a/lib/WebGUI/URL.pm +++ b/lib/WebGUI/URL.pm @@ -48,6 +48,19 @@ These subroutines are available from this package: +#------------------------------------------------------------------- +sub _getSiteURL { + my $site = $session{env}{HTTP_HOST} || $session{config}{sitename}; + my $proto = "http://"; + my $port; + if ($session{env}{SERVER_PORT} == 443) { + $proto = "https://"; + } elsif ($session{env}{SERVER_PORT} != 80) { + $port = ":".$session{env}{SERVER_PORT}; + } + return $proto.$site.$port; +} + #------------------------------------------------------------------- =head2 append ( url, pairs ) @@ -127,8 +140,7 @@ Name value pairs to add to the URL in the form of: =cut sub gateway { - my ($url); - $url = $session{config}{scripturl}.'/'.$_[0]; + my $url = _getSiteURL().$session{config}{scripturl}.'/'.$_[0]; if ($_[1]) { $url = append($url,$_[1]); } @@ -186,8 +198,7 @@ Name value pairs to add to the URL in the form of: =cut sub page { - my ($url); - $url = $session{page}{url}; + my $url = _getSiteURL().$session{page}{url}; if ($_[0]) { $url = append($url,$_[0]); }