misc. syntax fixes.

This commit is contained in:
Matthew Wilson 2006-01-14 20:01:41 +00:00
parent 4f582e5853
commit 6009ead286
5 changed files with 26 additions and 27 deletions

View file

@ -21,7 +21,6 @@ use WebGUI::Cache;
use WebGUI::Config; use WebGUI::Config;
use WebGUI::International; use WebGUI::International;
use WebGUI::Operation; use WebGUI::Operation;
use WebGUI::Privilege;
use WebGUI::Session; use WebGUI::Session;
use WebGUI::Utility; use WebGUI::Utility;
use WebGUI::PassiveProfiling; use WebGUI::PassiveProfiling;
@ -36,7 +35,7 @@ sub handler {
my $r = shift; my $r = shift;
my $s = Apache2::ServerUtil->server; my $s = Apache2::ServerUtil->server;
$s->add_version_component("WebGUI/".$WebGUI::VERSION); $s->add_version_component("WebGUI/".$WebGUI::VERSION);
$config = WebGUI::Config->new($s->dir_config('WebguiRoot'),$r->dir_config('WebguiConfig')); my $config = WebGUI::Config->new($s->dir_config('WebguiRoot'),$r->dir_config('WebguiConfig'));
foreach my $url ($config->get("extrasURL"), @{$config->get("passthruUrls")}) { foreach my $url ($config->get("extrasURL"), @{$config->get("passthruUrls")}) {
return Apache2::Const::DECLINED if ($r->uri =~ m/^$url/); return Apache2::Const::DECLINED if ($r->uri =~ m/^$url/);
} }
@ -60,9 +59,9 @@ sub contentHandler {
### Open new or existing user session based on user-agent's cookie. ### Open new or existing user session based on user-agent's cookie.
my $session = WebGUI::Session->open($s->dir_config('WebguiRoot'),$r->dir_config('WebguiConfig'),$r, $s); my $session = WebGUI::Session->open($s->dir_config('WebguiRoot'),$r->dir_config('WebguiConfig'),$r, $s);
### form variables ### form variables
foreach ($session->{_request}->param) { # foreach ($session->{_request}->param) {
$session{form}{$_} = $session->{_request}->body($_) || $session->{_request}->param($_); # $session{form}{$_} = $session->{_request}->body($_) || $session->{_request}->param($_);
} # }
if ($session->env->get("HTTP_X_MOZ") eq "prefetch") { # browser prefetch is a bad thing if ($session->env->get("HTTP_X_MOZ") eq "prefetch") { # browser prefetch is a bad thing
$session->http->setStatus("403","We don't allow prefetch, because it increases bandwidth, hurts stats, and can break web sites."); $session->http->setStatus("403","We don't allow prefetch, because it increases bandwidth, hurts stats, and can break web sites.");
$r->print($session->http->getHeader); $r->print($session->http->getHeader);
@ -94,14 +93,14 @@ sub page {
my $assetUrl = shift; my $assetUrl = shift;
my $output = processOperations($session); my $output = processOperations($session);
if ($output eq "") { if ($output eq "") {
my $asset = eval{WebGUI::Asset->newByUrl($session,$assetUrl,$session{form}{revision})}; my $asset = eval{WebGUI::Asset->newByUrl($session,$assetUrl,$session->form->process("revision"))};
if ($@) { if ($@) {
$session->errorHandler->warn("Couldn't instantiate asset for url: ".$session->url->getRequestedUrl." Root cause: ".$@); $session->errorHandler->warn("Couldn't instantiate asset for url: ".$session->url->getRequestedUrl." Root cause: ".$@);
} }
if (defined $asset) { if (defined $asset) {
my $method = "view"; my $method = "view";
if (exists $session{form}{func}) { if ($session->form->process("func")) {
$method = $session{form}{func}; $method = $session->form->process("func");
unless ($method =~ /^[A-Za-z]+$/) { unless ($method =~ /^[A-Za-z]+$/) {
$session->security("tried to call a non-existent method $method on $assetUrl"); $session->security("tried to call a non-existent method $method on $assetUrl");
$method = "view"; $method = "view";
@ -130,23 +129,23 @@ sub page {
sub processOperations { sub processOperations {
my $session = shift; my $session = shift;
my ($cmd, $output); my ($cmd, $output);
my $op = $session{form}{op}; my $op = $session->form->process("op");
my $opNumber = shift || 1; # my $opNumber = shift || 1;
if ($op) { if ($op) {
$output = WebGUI::Operation::execute($session,$op); $output = WebGUI::Operation::execute($session,$op);
} }
$opNumber++; # $opNumber++;
if ($output eq "" && exists $session{form}{"op".$opNumber}) { # if ($output eq "" && $session->form->process("op".$opNumber)) {
my $urlString = $session->url->unescape($session->form->get("op".$opNumber)); # my $urlString = $session->url->unescape($session->form->process("op".$opNumber));
my @pairs = split(/\;/,$urlString); # my @pairs = split(/\;/,$urlString);
my %form; # my %form;
foreach my $pair (@pairs) { # foreach my $pair (@pairs) {
my @param = split(/\=/,$pair); # my @param = split(/\=/,$pair);
$form{$param[0]} = $param[1]; # $form{$param[0]} = $param[1];
} # }
$session{form} = \%form; # $session{form} = \%form;
$output = processOperations($session,$opNumber); # $output = processOperations($session,$opNumber);
} # }
return $output; return $output;
} }
@ -168,7 +167,7 @@ sub tryAssetMethod {
my $methodToTry = "www_".$method; my $methodToTry = "www_".$method;
my $output = eval{$asset->$methodToTry()}; my $output = eval{$asset->$methodToTry()};
if ($@) { if ($@) {
$session->errorHandler->warn("Couldn't call method ".$method." on asset for url: ".$session{requestedUrl}." Root cause: ".$@); $session->errorHandler->warn("Couldn't call method ".$method." on asset for url: ".$session->url->getRequestedUrl." Root cause: ".$@);
$output = tryAssetMethod($session,$asset,'view') if ($method ne "view"); $output = tryAssetMethod($session,$asset,'view') if ($method ne "view");
} }
return $output; return $output;

View file

@ -618,7 +618,7 @@ Array reference of methods allowed to be called externally;
sub new { sub new {
my $self = {}; my $self = {};
my $class = shift; my $class = shift;
my $self->{_session} = shift; $self->{_session} = shift;
$self->{authMethod} = shift; $self->{authMethod} = shift;
my $userId = shift || $self->{_session}->user->userId; my $userId = shift || $self->{_session}->user->userId;
$self->{user} = $self->{_session}->user; $self->{user} = $self->{_session}->user;

View file

@ -530,7 +530,7 @@ sub user {
my $option = shift; my $option = shift;
if (defined $option) { if (defined $option) {
$self->{_var}{userId} = $option->{userId} || $option->{user}->userId; $self->{_var}{userId} = $option->{userId} || $option->{user}->userId;
$self->db-setRow("userSession","sessionId", $self->{_var}); $self->db->setRow("userSession","sessionId", $self->{_var});
if ($self->setting("passiveProfilingEnabled")) { if ($self->setting("passiveProfilingEnabled")) {
$self->db->write("update passiveProfileLog set userId = ".$self->db->quote($self->{_var}{userId})." where sessionId = ".$self->db->quote($self->getId)); $self->db->write("update passiveProfileLog set userId = ".$self->db->quote($self->{_var}{userId})." where sessionId = ".$self->db->quote($self->getId));
} }

View file

@ -176,7 +176,7 @@ Adds a FATAL type message to the log, outputs an error message to the user, and
sub fatal { sub fatal {
my $self = shift; my $self = shift;
my $message = shift; my $message = shift;
my $self->{_session}->http->setStatus("500","Server Error"); $self->{_session}->http->setStatus("500","Server Error");
Apache2::RequestUtil->request->content_type('text/html') if ($self->{_session}->request); Apache2::RequestUtil->request->content_type('text/html') if ($self->{_session}->request);
$self->getLogger->fatal($message); $self->getLogger->fatal($message);
$self->getLogger->debug("Stack trace for FATAL ".$message."\n".$self->getStackTrace()); $self->getLogger->debug("Stack trace for FATAL ".$message."\n".$self->getStackTrace());

View file

@ -267,7 +267,7 @@ sub help {
my $urlParams = shift; my $urlParams = shift;
my $pageURL = shift || $self->session->url->getRequestedUrl; my $pageURL = shift || $self->session->url->getRequestedUrl;
my ($output, $namespace); my ($output, $namespace);
my $output = '<a href="'.$self->session->url->page('op=viewHelp;hid='.$urlParams.';namespace='.$namespace). $output = '<a href="'.$self->session->url->page('op=viewHelp;hid='.$urlParams.';namespace='.$namespace).
'" target="_blank"><img src="'.$self->_getBaseURL().'help.gif" border="0" align="right" title="'.WebGUI::International->new($self->session,'Icon')->get('Help').'" Alt="'.WebGUI::International->new($self->session,'Icon')->get('Help').'"></a>'; '" target="_blank"><img src="'.$self->_getBaseURL().'help.gif" border="0" align="right" title="'.WebGUI::International->new($self->session,'Icon')->get('Help').'" Alt="'.WebGUI::International->new($self->session,'Icon')->get('Help').'"></a>';
return $output; return $output;
} }