fixed some i18n problems and moved http related functions out of session and into their own class

This commit is contained in:
JT Smith 2004-06-27 23:56:39 +00:00
parent e531d8d5b2
commit f18f408efb
21 changed files with 444 additions and 211 deletions

View file

@ -33,6 +33,9 @@
average page, which leads to much greater scalability. See
docs/migration.txt for API changes.
- Added the ability to select session v. global caches to WSClient.
- Rmoved the httpHeader, httpRedirect, and setCookie subs from
WebGUI::Session and created a new class called WebGUI::HTTP for them. See
docs/migration.txt for details.
6.0.3

View file

@ -140,4 +140,11 @@ gen61i18nfrom60data.pl
We also made the International API object oriented. The old procedural version
is still intact as well. See WebGUI::International for API changes.
5.8 WebGUI::Session Changes
In 6.1 we changed the session API to remove functions that didn't really
belong in WebGUI::Session. The main changes of interest are that you no longer
do HTTP redirects and set cookies via session. Take a look at WebGUI::HTTP for
details.

View file

@ -70,7 +70,10 @@ my $langs = {
WebGUI::SQL->write("update userProfileField set dataDefault=".quote("['".$langs->{$defaultLangId}."']")." where fieldName='language'");
WebGUI::SQL->write("update userProfileData set fieldData='".$langs->{$defaultLangId}."' where fieldName='language' and fieldData<>1");
WebGUI::SQL->write("update userProfileData set fieldData='English' where fieldName='language' and fieldData=1");
WebGUI::SQL->write("alter table page change languageId languageId varchar(50) not null default 'English'");
foreach my $key (keys %{$langs}) {
WebGUI::SQL->write("update page set languageId=".quote($langs->{$key})." where languageId=".$key);
}
WebGUI::Session::close();

View file

@ -17,6 +17,7 @@ use WebGUI::Affiliate;
use WebGUI::Cache;
use WebGUI::ErrorHandler;
use WebGUI::Grouping;
use WebGUI::HTTP;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Operation;
@ -156,17 +157,13 @@ sub page {
$wobjectOutput = _processFunctions();
}
if ($output ne "") {
$output = WebGUI::Session::httpHeader().$output;
} elsif ($session{header}{mimetype} ne "text/html") {
$output = WebGUI::Session::httpHeader().$operationOutput.$wobjectOutput;
# using cache
} elsif (WebGUI::HTTP::getMimeType() ne "text/html") {
$output = $operationOutput.$wobjectOutput;
} elsif ($operationOutput ne "") {
$output = WebGUI::Session::httpHeader()._generatePage($operationOutput);
} elsif ($session{page}{redirectURL} && !$session{var}{adminOn}) {
$output = WebGUI::Session::httpRedirect(WebGUI::Macro::process($session{page}{redirectURL}));
} elsif (exists $session{header}{redirect}) {
$output = $session{header}{redirect};
$output = _generatePage($operationOutput);
} elsif ($wobjectOutput ne "") {
$output = WebGUI::Session::httpHeader()._generatePage($wobjectOutput);
$output = _generatePage($wobjectOutput);
} else {
$output = _generatePage(WebGUI::Page::generate());
my $ttl;
@ -176,10 +173,10 @@ sub page {
$ttl = $session{page}{cacheTimeout};
}
$cache->set($output, $ttl) if ($useCache);
$output = WebGUI::Session::httpHeader().$output;
}
my $httpHeader = WebGUI::HTTP::getHeader();
WebGUI::Session::close();
return $output;
return $httpHeader.$output;
}

View file

@ -28,6 +28,7 @@ use POSIX;
use Storable;
use strict;
use WebGUI::ErrorHandler;
use WebGUI::HTTP;
use WebGUI::Node;
use WebGUI::Session;
use WebGUI::URL;
@ -559,7 +560,7 @@ If a web image (gif, png, jpg, jpeg) is being uploaded it will be resized if it
sub save {
my ($type, $file, $filename, $bytesread, $buffer, $urlizedFilename, $path);
return "" if ($session{header}{status} =~ /^413/);
return "" if (WebGUI::HTTP::getStatus() =~ /^413/);
$filename = $session{cgi}->upload($_[1]);
if (defined $filename) {
if ($filename =~ /([^\/\\]+)$/) {

View file

@ -23,6 +23,7 @@ use WebGUI::ErrorHandler;
use WebGUI::FormProcessor;
use WebGUI::HTML;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Macro;
@ -558,8 +559,8 @@ sub login {
_logLogin($uid,"success");
if ($session{scratch}{redirectAfterLogin}) {
$session{header}{redirect} = WebGUI::Session::httpRedirect($session{scratch}{redirectAfterLogin});
WebGUI::Session::deleteScratch("redirectAfterLogin");
WebGUI::HTTP::setRedirect($session{scratch}{redirectAfterLogin});
WebGUI::Session::deleteScratch("redirectAfterLogin");
}
return "";
}

View file

@ -22,6 +22,7 @@ use WebGUI::Forum;
use WebGUI::Forum::Post;
use WebGUI::Forum::Thread;
use WebGUI::HTML;
use WebGUI::HTTP;
use WebGUI::MessageLog;
use WebGUI::Search;
use WebGUI::Session;
@ -1959,7 +1960,7 @@ sub www_postSave {
}, \%postData);
$thread->subscribe($session{user}{userId}) if ($session{form}{subscribe});
setPostStatus($caller,$thread->getPost($thread->get("rootPostId")));
$session{header}{redirect} = WebGUI::Session::httpRedirect(formatForumURL($caller->{callback}, $forumId));
WebGUI::HTTP::setRedirect(formatForumURL($caller->{callback}, $forumId));
return "";
}
}
@ -2323,7 +2324,7 @@ sub www_viewThread {
# If POST, cause redirect, so new post is displayed using GET instead of POST
if ($session{env}{REQUEST_METHOD} =~ /POST/i) {
my $url= formatThreadURL($caller-> {callback}, $postId);
$session{header}{redirect} = WebGUI::Session::httpRedirect($url);
WebGUI::HTTP::setRedirect($url);
return "";
}
my $post = WebGUI::Forum::Post->new($postId);

240
lib/WebGUI/HTTP.pm Normal file
View file

@ -0,0 +1,240 @@
package WebGUI::HTTP;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2004 Plain Black LLC.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use WebGUI::International;
use WebGUI::Session;
=head1 NAME
Package WebGUI::HTTP
=head1 DESCRIPTION
This package allows the manipulation of HTTP protocol information.
=head1 SYNOPSIS
use WebGUI::HTTP;
$header = WebGUI::HTTP::getHeader();
WebGUI::HTTP::setRedirect($url);
WebGUI::HTTP::setCookie($name,$value);
=head1 METHODS
These subroutines are available from this package:
=cut
#-------------------------------------------------------------------
=head2 getHeader ( )
Generates an HTTP header.
=cut
sub getHeader {
my $header;
unless (exists $session{http}{location}) {
unless ($session{http}{charset}) {
$session{http}{charset} = WebGUI::International::getLanguage($session{page}{languageId},"charset") || "ISO-8859-1";
}
unless ($session{http}{mimetype}) {
$session{http}{mimetype} = "text/html";
}
if ($session{setting}{preventProxyCache}) {
$session{http}{expires} = "-1d";
}
$header = $session{cgi}->header(
-type => $session{http}{mimetype},
-charset => $session{http}{charset},
-cookie => $session{http}{cookie},
-status => $session{http}{status},
-attachment => $session{http}{filename},
-expires => $session{http}{expires}
);
} else {
$header = $session{cgi}->header(
-cookie => $session{http}{cookie},
-location => $session{http}{location},
-status => $session{http}{status}
);
}
return $header;
}
#-------------------------------------------------------------------
=head2 getMimeType ( )
Returns the current mime type of the document to be returned.
=cut
sub getMimeType {
return $session{http}{mimetype} || "text/html";
}
#-------------------------------------------------------------------
=head2 getStatus ( ) {
Returns the current HTTP status code, if one has been set.
=cut
sub getStatus {
return $session{http}{status} || "200 OK";
}
#-------------------------------------------------------------------
=head2 setCookie ( name, value [ , timeToLive ] )
Sends a cookie to the browser.
=over
=item name
The name of the cookie to set. Must be unique from all other cookies from this domain or it will overwrite that cookie.
=item value
The value to set.
=item timeToLive
The time that the cookie should remain in the browser. Defaults to "+10y" (10 years from now).
=back
=cut
sub setCookie {
my $ttl = $_[2] || '+10y';
my $domain;
push @{$session{http}{cookie}}, $session{cgi}->cookie(
-name=>$_[0],
-value=>$_[1],
-expires=>$ttl,
-path=>'/',
-domain=>$domain
);
}
#-------------------------------------------------------------------
=head2 setFilename ( filename [, mimetype] )
Override the default filename for the document, which is usually the page url. Usually used with setMimeType().
=over
=item filename
The filename to set.
=item mimetype
The mimetype for this file. Defaults to "application/octet-stream".
=back
=cut
sub setFilename {
$session{http}{filename} = shift;
my $mimetype = shift || "application/octet-stream";
setMimeType($mimetype);
}
#-------------------------------------------------------------------
=head2 setMimeType ( mimetype )
Override mime type for the document, which is defaultly "text/html". Also see setFilename().
NOTE: By setting the mime type to something other than "text/html" WebGUI will automatically not process the normal page contents. Instead it will return only the content of your Wobject function or Operation.
=over
=item mimetype
The mime type for the document.
=back
=cut
sub setMimeType {
$session{http}{mimetype} = shift;
}
#-------------------------------------------------------------------
=head2 setRedirect ( url )
Sets the necessary information in the HTTP header to redirect to another URL.
=over
=item url
The URL to redirect to.
=back
=cut
sub setRedirect {
$session{http}{location} = shift;
setStatus("302 Redirect");
}
#-------------------------------------------------------------------
=head2 setStatus ( status )
Sets the HTTP status code.
=over
=item status
An HTTP status code. It takes the form of "NNN Message" where NNN is a 3 digit status number and Message is some text explaining the status number.
=back
=cut
sub setStatus {
$session{http}{status} = shift;
}
1;

View file

@ -76,7 +76,7 @@ sub _getBaseURL {
if ($session{user}{toolbar} ne "useLanguageDefault") {
$url .= $session{user}{toolbar};
} else {
$url .= $session{language}{toolbar};
$url .= WebGUI::International::getLanguage($session{user}{language},"toolbar");
}
$url .= '/';
return $url;

View file

@ -31,6 +31,7 @@ This package provides an interface to the internationalization system.
use WebGUI::International;
$string = WebGUI::International::get($internationalId,$namespace);
$hashRef = WebGUI::International::getLanguage($lang);
%languages = WebGUI::International::getLanguages();
This package can also be used in object-oriented (OO) style.
@ -93,6 +94,47 @@ sub get {
}
#-------------------------------------------------------------------
=head2 getLanguage ( [ languageId , propertyName] )
Returns a hash reference to a particular language's properties.
=over
=item languageId
Defaults to "English". The language to retrieve the properties for.
=item propertyName
If this is specified, only the value of the property will be returned, instead of the hash reference to all properties. The valid values are "charset", "toolbar", and "label".
=back
=cut
sub getLanguage {
my $language = shift || "English";
my $property = shift;
my $cmd = "WebGUI::i18n::".$language;
my $load = "use ".$cmd;
eval($load);
unless ($@) {
$cmd = "\$".$cmd."::LANGUAGE";
my $hashRef = eval($cmd);
WebGUI::ErrorHandler::warn("Failed to retrieve language properties because ".$@) if ($@);
if ($property) {
return $hashRef->{$property};
} else {
return $hashRef;
}
} else {
WebGUI::ErrorHandler::warn("Language failed to compile: $language. ".$@);
}
}
#-------------------------------------------------------------------
=head2 getLanguages ( )
@ -110,15 +152,7 @@ sub getLanguages {
foreach my $file (@files) {
if ($file =~ /(.*?)\.pm$/) {
my $language = $1;
my $cmd = "WebGUI::i18n::".$language;
my $load = "use ".$cmd;
eval($load);
unless ($@) {
$cmd = "\$".$cmd."::I18N->{'label'}";
$hashRef->{$language} = eval($cmd);
} else {
WebGUI::ErrorHandler::warn("Language failed to compile: $language. ".$@);
}
$hashRef->{$language} = getLanguage($language,"label");
}
}
return $hashRef;

View file

@ -18,6 +18,7 @@ use WebGUI::Attachment;
use WebGUI::Collateral;
use WebGUI::Grouping;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Node;
@ -301,7 +302,7 @@ sub www_exportTheme {
my $packageName = WebGUI::URL::makeCompliant($theme->{name}).".theme.tar.gz";
$propertyFile->getNode->tar($packageName);
my $export = WebGUI::Attachment->new($packageName,"temp");
$session{header}{redirect} = WebGUI::Session::httpRedirect($export->getURL);
WebGUI::HTTP::setRedirect($export->getURL);
return "";
}

View file

@ -21,7 +21,9 @@ use Tie::IxHash;
use WebGUI::ErrorHandler;
use WebGUI::Grouping;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::Macro;
use WebGUI::Persistent::Tree;
use WebGUI::Session;
use WebGUI::SQL;
@ -386,6 +388,9 @@ Generates the content of the page.
sub generate {
return WebGUI::Privilege::noAccess() unless (canView());
my %var;
if ($session{page}{redirectURL} && !$session{var}{adminOn}) {
WebGUI::HTTP::setRedirect(WebGUI::Macro::process($session{page}{redirectURL}));
}
$var{'page.canEdit'} = canEdit();
$var{'page.controls'} = pageIcon()
.deleteIcon('op=deletePage')

View file

@ -15,6 +15,7 @@ package WebGUI::Privilege;
=cut
use strict;
use WebGUI::HTTP;
use WebGUI::International;
use WebGUI::Session;
@ -50,15 +51,7 @@ Returns a message stating that this functionality can only be used by administra
=cut
sub adminOnly {
if($session{env}{MOD_PERL}) {
my $r = Apache->request;
if(defined($r)) {
$r->custom_response(401, '<!--Admin Only-->' );
$r->status(401);
}
} else {
$session{header}{status} = 401;
}
WebGUI::HTTP::setStatus("401 Admin Only");
my ($output, $sth, @data);
$output = '<h1>'.WebGUI::International::get(35).'</h1>';
$output .= WebGUI::International::get(36);
@ -75,15 +68,7 @@ Returns a message stating that the user does not have the required privileges to
=cut
sub insufficient {
if($session{env}{MOD_PERL}) {
my $r = Apache->request;
if(defined($r)) {
$r->custom_response(401, '<!--Insufficient Privileges-->' );
$r->status(401);
}
} else {
$session{header}{status} = 401;
}
WebGUI::HTTP::setStatus("401 Insufficient Privileges");
my ($output);
$output = '<h1>'.WebGUI::International::get(37).'</h1>';
$output .= WebGUI::International::get(38);
@ -101,24 +86,16 @@ Returns a message stating that the user does not have the privileges necessary t
=cut
sub noAccess {
if($session{env}{MOD_PERL}) {
my $r = Apache->request;
if(defined($r)) {
$r->custom_response(401, '<!--No Access-->' );
$r->status(401);
}
} else {
$session{header}{status} = 401;
}
my ($output);
if ($session{user}{userId} <= 1) {
$output = WebGUI::Operation::Auth::www_auth("init");
} else {
$output = '<h1>'.WebGUI::International::get(37).'</h1>';
$output .= WebGUI::International::get(39);
$output .= '<p>';
}
return $output;
WebGUI::HTTP::setStatus("401 No Access");
my ($output);
if ($session{user}{userId} <= 1) {
$output = WebGUI::Operation::Auth::www_auth("init");
} else {
$output = '<h1>'.WebGUI::International::get(37).'</h1>';
$output .= WebGUI::International::get(39);
$output .= '<p>';
}
return $output;
}
#-------------------------------------------------------------------
@ -130,15 +107,7 @@ Returns a message stating that the user they requested information about is no l
=cut
sub notMember {
if($session{env}{MOD_PERL}) {
my $r = Apache->request;
if(defined($r)) {
$r->custom_response(400, '<!--Not A Member-->' );
$r->status(400);
}
} else {
$session{header}{status} = 400;
}
WebGUI::HTTP::setStatus("400 Not A Member");
my ($output);
$output = '<h1>'.WebGUI::International::get(345).'</h1>';
$output .= WebGUI::International::get(346);
@ -155,15 +124,7 @@ Returns a message stating that the user made a request to delete something that
=cut
sub vitalComponent {
if($session{env}{MOD_PERL}) {
my $r = Apache->request;
if(defined($r)) {
$r->custom_response(403, '<!--Vital Component-->' );
$r->status(403);
}
} else {
$session{header}{status} = 403;
}
WebGUI::HTTP::setStatus("403 Vital Component");
my ($output);
$output = '<h1>'.WebGUI::International::get(40).'</h1>';
$output .= WebGUI::International::get(41);
@ -173,8 +134,5 @@ sub vitalComponent {
1;

View file

@ -51,13 +51,10 @@ TIP: The $session variable is a case-insensitive hash. The contents of the has v
WebGUI::Session::convertVisitorToUser($sessionId,$userId);
WebGUI::Session::deleteScratch($name);
WebGUI::Session::end($sessionId);
$header = WebGUI::Session::httpHeader();
$header = WebGUI::Session::httpRedirect($url);
WebGUI::Session::open($webguiRoot,$configFilename);
WebGUI::Session::refreshPageInfo($pageId);
WebGUI::Session::refreshSessionVars($sessionId);
WebGUI::Session::refreshUserInfo($userId);
WebGUI::Session::setCookie($name,$value);
WebGUI::Session::setScratch($name,$value);
WebGUI::Session::start($userId);
@ -91,7 +88,7 @@ sub _setupPageInfo {
$r->status(404);
}
} else {
$session{header}{status} = '404';
$session{http}{status} = '404';
}
}
} else {
@ -270,53 +267,6 @@ sub end {
}
}
#-------------------------------------------------------------------
=head2 httpHeader ( )
Generates an HTTP header.
=cut
sub httpHeader {
unless ($session{header}{charset}) {
$session{header}{charset} = $session{language}{characterSet} || "ISO-8859-1";
}
if ($session{header}{filename} && $session{header}{mimetype} eq "text/html") {
$session{header}{mimetype} = "application/octet-stream";
}
if ($session{setting}{preventProxyCache}) {
$session{header}{expires} = "-1d";
}
return $session{cgi}->header(
-type => $session{header}{mimetype},
-charset => $session{header}{charset},
-cookie => $session{header}{cookie},
-status => $session{header}{status},
-attachment => $session{header}{filename},
-expires => $session{header}{expires}
);
}
#-------------------------------------------------------------------
=head2 httpRedirect ( url )
Generates an HTTP header for redirect.
=over
=item url
The URL to redirect to.
=back
=cut
sub httpRedirect {
return $session{cgi}->redirect($_[0]);
}
#-------------------------------------------------------------------
@ -393,15 +343,12 @@ sub open {
$CGI::POST_MAX=1024 * $session{setting}{maxAttachmentSize};
$session{cgi} = CGI->new();
if ($session{cgi}->cgi_error =~ /^413/) {
$session{header}{status} = $session{cgi}->cgi_error;
$session{http}{status} = $session{cgi}->cgi_error;
WebGUI::ErrorHandler::warn("File upload too big. May need to adjust Max File Size setting.");
$CGI::POST_MAX=-1;
$session{cgi} = CGI->new();
}
###----------------------------
### header variables
$session{header}{mimetype} = 'text/html';
###----------------------------
### evironment variables from web server
$session{env} = \%ENV;
### check to see if client is proxied and adjust remote_addr as necessary
@ -498,42 +445,6 @@ sub refreshUserInfo {
$session{isInGroup} = ();
}
#-------------------------------------------------------------------
=head2 setCookie ( name, value [ , timeToLive ] )
Sends a cookie to the browser.
=over
=item name
The name of the cookie to set. Must be unique from all other cookies from this domain or it will overwrite that cookie.
=item value
The value to set.
=item timeToLive
The time that the cookie should remain in the browser. Defaults to "+10y" (10 years from now).
=back
=cut
sub setCookie {
my $ttl = $_[2] || '+10y';
#my $domain = $session{env}{SERVER_NAME} if ($session{env}{HTTP_USER_AGENT} =~ m/MSIE/i);
my $domain;
push @{$session{header}{cookie}}, $session{cgi}->cookie(
-name=>$_[0],
-value=>$_[1],
-expires=>$ttl,
-path=>'/',
-domain=>$domain
);
}
#-------------------------------------------------------------------
@ -601,7 +512,12 @@ sub start {
WebGUI::SQL->write("insert into userSession values ('$sessionId', ".
(_time()+$session{setting}{sessionTimeout}).", "._time().", 0, '$ENV{REMOTE_ADDR}', $_[0])");
}
setCookie("wgSession",$sessionId);
push @{$session{http}{cookie}}, $session{cgi}->cookie(
-name=>"wgSession",
-value=>$sessionId,
-expires=>'+10y',
-path=>'/'
);
refreshSessionVars($sessionId);
}

View file

@ -17,6 +17,7 @@ package WebGUI::Style;
use strict;
use Tie::CPHash;
use WebGUI::International;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Template;
@ -102,7 +103,7 @@ sub process {
$type =~ s/.*\.(.*?)$/$1/;
$var{'head.tags'} = '
<meta name="generator" content="WebGUI '.$WebGUI::VERSION.'" />
<meta http-equiv="Content-Type" content="text/html; charset='.($session{header}{charset}||$session{language}{characterSet}||"ISO-8859-1").'" />
<meta http-equiv="Content-Type" content="text/html; charset='.WebGUI::International::getLanguage($session{page}{languageId},"charset").'" />
<link rel="icon" href="'.$session{setting}{siteicon}.'" type="image/'.$type.'" />
<link rel="SHORTCUT ICON" href="'.$session{setting}{favicon}.'" />
'.$session{page}{head}{raw}.'

View file

@ -17,6 +17,7 @@ use WebGUI::DateTime;
use WebGUI::Form;
use WebGUI::FormProcessor;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Macro;
@ -787,8 +788,7 @@ sub www_editTabSave {
#-------------------------------------------------------------------
sub www_exportTab {
return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit);
$session{header}{filename} = WebGUI::URL::urlize($_[0]->get("title")).".tab";
$session{header}{mimetype} = "text/plain";
WebGUI::HTTP::setFilename(WebGUI::URL::urlize($_[0]->get("title")).".tab","text/plain");
my %fields = WebGUI::SQL->buildHash("select DataForm_fieldId,name from DataForm_field where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber");
my $select = "select a.DataForm_entryId as entryId, a.ipAddress, a.username, a.userId, a.submissionDate";
my $from = " from DataForm_entry a";

View file

@ -15,6 +15,7 @@ use Tie::CPHash;
use WebGUI::DateTime;
use WebGUI::Grouping;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Paginator;
@ -175,7 +176,7 @@ sub www_download {
$session{form}{wid},
$session{form}{did});
}
$session{header}{redirect} = WebGUI::Session::httpRedirect($file->getURL);
WebGUI::HTTP::setRedirect($file->getURL);
return "";
} else {
return WebGUI::Privilege::insufficient();

View file

@ -17,6 +17,7 @@ use HTTP::Cookies;
use HTTP::Request::Common;
use HTML::Entities;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Privilege;
@ -297,7 +298,7 @@ sub www_view {
}
if($var{header} ne "text/html") {
$session{header}{mimetype} = $var{header};
WebGUI::HTTP::setMimeType($var{header});
return $var{content};
} else {
return $_[0]->processTemplate($_[0]->get("templateId"),\%var);

View file

@ -15,6 +15,7 @@ use Tie::CPHash;
use WebGUI::DateTime;
use WebGUI::Grouping;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Privilege;
@ -780,16 +781,14 @@ sub www_editQuestionSave {
#-------------------------------------------------------------------
sub www_exportAnswers {
return "" unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToViewReports")));
$session{header}{filename} = WebGUI::URL::escape($_[0]->get("title")."_answers.tab");
$session{header}{mimetype} = "text/tab";
WebGUI::HTTP::setFilename(WebGUI::URL::escape($_[0]->get("title")."_answers.tab"),"text/tab");
return WebGUI::SQL->quickTab("select * from Survey_answer where Survey_id=".$_[0]->get("Survey_id"));
}
#-------------------------------------------------------------------
sub www_exportComposite {
return "" unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToViewReports")));
$session{header}{filename} = WebGUI::URL::escape($_[0]->get("title")."_composite.tab");
$session{header}{mimetype} = "text/tab";
WebGUI::HTTP::setFilename(WebGUI::URL::escape($_[0]->get("title")."_composite.tab"),"text/tab");
return WebGUI::SQL->quickTab("select b.question, c.response, a.userId, a.username, a.ipAddress, c.comment, c.dateOfResponse from Survey_response a
left join Survey_questionResponse c on a.Survey_responseId=c.Survey_responseId
left join Survey_question b on c.Survey_questionId=b.Survey_questionId
@ -799,16 +798,14 @@ sub www_exportComposite {
#-------------------------------------------------------------------
sub www_exportQuestions {
return "" unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToViewReports")));
$session{header}{filename} = WebGUI::URL::escape($_[0]->get("title")."_questions.tab");
$session{header}{mimetype} = "text/tab";
WebGUI::HTTP::setFilename(WebGUI::URL::escape($_[0]->get("title")."_questions.tab"),"text/tab");
return WebGUI::SQL->quickTab("select * from Survey_question where Survey_id=".$_[0]->get("Survey_id"));
}
#-------------------------------------------------------------------
sub www_exportResponses {
return "" unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToViewReports")));
$session{header}{filename} = WebGUI::URL::escape($_[0]->get("title")."_responses.tab");
$session{header}{mimetype} = "text/tab";
WebGUI::HTTP::setFilename(WebGUI::URL::escape($_[0]->get("title")."_responses.tab"),"text/tab");
return WebGUI::SQL->quickTab("select * from Survey_response where Survey_id=".$_[0]->get("Survey_id"));
}

View file

@ -19,6 +19,7 @@ use WebGUI::Forum::UI;
use WebGUI::Grouping;
use WebGUI::HTML;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::MessageLog;
@ -793,9 +794,7 @@ sub www_viewRSS {
</channel>
</rss>
~;
$session{header}{mimetype} = 'text/xml';
WebGUI::HTTP::setMimeType("text/xml");
return $xml;
}

View file

@ -35,7 +35,7 @@ use SOAP::Lite ();
#----------------------------------------
# Database connectivity.
#----------------------------------------
#use Apache::DBI (); # Uncomment if you want to enable connection pooling. Not recommended on low memory - high traffic systems.
#use Apache::DBI (); # Uncomment if you want to enable connection pooling. Not recommended on low memory systems.
use DBI ();
DBI->install_driver("mysql"); # Change to match your database driver.
@ -46,9 +46,7 @@ DBI->install_driver("mysql"); # Change to match your database driver.
#----------------------------------------
#use HTML::Parser (); # commented because it is causing problems with attachments
#use HTML::TagFilter (); # commented because it is causing problems with attachments
use Net::LDAP ();
use Parse::PlainConfig ();
#use Authen::Smb (); #uncomment when using this type of authentication.
use Tie::CPHash ();
use Tie::IxHash ();
use Tree::DAG_Node ();
@ -56,6 +54,8 @@ use Tree::DAG_Node ();
#----------------------------------------
# WebGUI modules.
#----------------------------------------
# core
use WebGUI ();
use WebGUI::Affiliate ();
use WebGUI::Attachment ();
@ -83,6 +83,7 @@ use WebGUI::Mail ();
use WebGUI::MessageLog ();
use WebGUI::Navigation ();
use WebGUI::Node ();
use WebGUI::Operation ();
use WebGUI::Persistent ();
use WebGUI::Persistent::Query ();
use WebGUI::Persistent::Tree ();
@ -90,7 +91,68 @@ use WebGUI::Persistent::Query::Delete ();
use WebGUI::Persistent::Query::Insert ();
use WebGUI::Persistent::Query::Select ();
use WebGUI::Persistent::Query::Update ();
use WebGUI::Operation ();
use WebGUI::Page ();
use WebGUI::Paginator ();
use WebGUI::Privilege ();
use WebGUI::Search ();
use WebGUI::Session ();
use WebGUI::SQL ();
use WebGUI::Style ();
use WebGUI::TabForm ();
use WebGUI::Template ();
use WebGUI::URL ();
use WebGUI::User ();
use WebGUI::Utility ();
use WebGUI::Wobject ();
# help
use WebGUI::Help::Article ();
use WebGUI::Help::AuthLDAP ();
use WebGUI::Help::AuthSMB ();
use WebGUI::Help::AuthWebGUI ();
use WebGUI::Help::DataForm ();
use WebGUI::Help::EventsCalendar ();
use WebGUI::Help::FileManager ();
use WebGUI::Help::HttpProxy ();
use WebGUI::Help::IndexedSearch ();
use WebGUI::Help::MessageBoard ();
use WebGUI::Help::Poll ();
use WebGUI::Help::Product ();
use WebGUI::Help::SiteMap ();
use WebGUI::Help::SQLReport ();
use WebGUI::Help::Survey ();
use WebGUI::Help::SyndicatedContent ();
use WebGUI::Help::USS ();
use WebGUI::Help::WebGUI ();
use WebGUI::Help::WobjectProxy ();
use WebGUI::Help::WSClient ();
# i18n
use WebGUI::i18n::English ();
use WebGUI::i18n::English::Article ();
use WebGUI::i18n::English::AuthLDAP ();
use WebGUI::i18n::English::AuthSMB ();
use WebGUI::i18n::English::AuthWebGUI ();
use WebGUI::i18n::English::DataForm ();
use WebGUI::i18n::English::EventsCalendar ();
use WebGUI::i18n::English::FileManager ();
use WebGUI::i18n::English::HttpProxy ();
use WebGUI::i18n::English::IndexedSearch ();
use WebGUI::i18n::English::MessageBoard ();
use WebGUI::i18n::English::Navigation ();
use WebGUI::i18n::English::Poll ();
use WebGUI::i18n::English::Product ();
use WebGUI::i18n::English::SiteMap ();
use WebGUI::i18n::English::SQLReport ();
use WebGUI::i18n::English::Survey ();
use WebGUI::i18n::English::SyndicatedContent ();
use WebGUI::i18n::English::USS ();
use WebGUI::i18n::English::WebGUI ();
use WebGUI::i18n::English::WebGUIProfile ();
use WebGUI::i18n::English::WobjectProxy ();
use WebGUI::i18n::English::WSClient ();
# operations
use WebGUI::Operation::Auth ();
use WebGUI::Operation::Admin ();
use WebGUI::Operation::Clipboard ();
@ -98,7 +160,6 @@ use WebGUI::Operation::Collateral ();
use WebGUI::Operation::DatabaseLink ();
use WebGUI::Operation::Group ();
use WebGUI::Operation::Help ();
use WebGUI::Operation::International ();
use WebGUI::Operation::MessageLog ();
use WebGUI::Operation::Navigation ();
use WebGUI::Operation::Package ();
@ -117,19 +178,25 @@ use WebGUI::Operation::Theme ();
use WebGUI::Operation::Trash ();
use WebGUI::Operation::User ();
use WebGUI::Operation::WebGUI ();
use WebGUI::Page ();
use WebGUI::Paginator ();
use WebGUI::Privilege ();
use WebGUI::Search ();
use WebGUI::Session ();
use WebGUI::SQL ();
use WebGUI::Style ();
use WebGUI::TabForm ();
use WebGUI::Template ();
use WebGUI::URL ();
use WebGUI::User ();
use WebGUI::Utility ();
use WebGUI::Wobject ();
# you can significantly reduce your memory usage by preloading the plugins used on your sites, only the most commonly used ones are preloaded by default
# wobjects
use WebGUI::Wobject::Article ();
use WebGUI::Wobject::USS ();
# auth methods
use WebGUI::Auth::WebGUI ();
#use WebGUI::Auth::LDAP ();
#use Net::LDAP (); # used by ldap authentication
#use WebGUI::Auth::SMB ();
#use Authen::Smb (); #uncomment when using this type of authentication.
# macros
use WebGUI::Macro::AdminBar ();
use WebGUI::Macro::Navigation ();
print "[ OK ]\n";