lots o' fixes.

This commit is contained in:
Matthew Wilson 2006-01-15 04:25:33 +00:00
parent adce5c8094
commit 250d8ff944
16 changed files with 64 additions and 53 deletions

View file

@ -58,10 +58,6 @@ sub contentHandler {
my $s = Apache2::ServerUtil->server;
### 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);
### form variables
# foreach ($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
$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);

View file

@ -1032,7 +1032,7 @@ sub new {
}
$class = $className;
}
my $cache = WebGUI::Cache->new($session,$session, ["asset",$assetId,$revisionDate]);
my $cache = WebGUI::Cache->new($session, ["asset",$assetId,$revisionDate]);
my $properties = $cache->get;
if (exists $properties->{assetId}) {
# got properties from cache

View file

@ -25,8 +25,9 @@ our @ISA = qw(WebGUI::Asset);
#-------------------------------------------------------------------
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($self->session,"Asset_Event");
my $i18n = WebGUI::International->new($session,"Asset_Event");
push(@{$definition}, {
assetName=>$i18n->get('assetName'),
icon=>'calendar.gif',
@ -59,7 +60,7 @@ sub definition {
}
}
});
return $class->SUPER::definition($definition);
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------

View file

@ -102,8 +102,9 @@ sub chopTitle {
#-------------------------------------------------------------------
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($self->session,"Asset_Post");
my $i18n = WebGUI::International->new($session,"Asset_Post");
push(@{$definition}, {
assetName=>$i18n->get('assetName'),
icon=>'post.gif',
@ -173,7 +174,7 @@ sub definition {
}
},
});
return $class->SUPER::definition($definition);
return $class->SUPER::definition($session,$definition);
}

View file

@ -58,9 +58,9 @@ sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session);
my $i18n = WebGUI::International->new($session,"Asset_Redirect");
push(@{$definition}, {
assetName=>$i18n->get('assetName',"Asset_Redirect"),
assetName=>$i18n->get('assetName'),
uiLevel => 9,
icon=>'redirect.gif',
tableName=>'redirect',
@ -72,7 +72,7 @@ sub definition {
}
}
});
return $class->SUPER::definition($definition);
return $class->SUPER::definition($session,$definition);
}

View file

@ -155,8 +155,9 @@ sub canManage {
#-------------------------------------------------------------------
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($self->session,"Asset_Shortcut");
my $i18n = WebGUI::International->new($session,"Asset_Shortcut");
push(@{$definition}, {
assetName=>$i18n->get('assetName'),
icon=>'shortcut.gif',
@ -206,7 +207,7 @@ sub definition {
}
}
});
return $class->SUPER::definition($definition);
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------

View file

@ -57,8 +57,9 @@ A hash reference passed in from a subclass definition.
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($self->session,"Asset_Snippet");
my $i18n = WebGUI::International->new($session,"Asset_Snippet");
push(@{$definition}, {
assetName=>$i18n->get('assetName'),
uiLevel => 5,
@ -81,7 +82,7 @@ sub definition {
}
});
return $class->SUPER::definition($definition);
return $class->SUPER::definition($session,$definition);
}

View file

@ -60,8 +60,9 @@ An array of hashes to prepend to the list
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($self->session,'Wobject');
my $i18n = WebGUI::International->new($session,'Wobject');
my %properties;
tie %properties, 'Tie::IxHash';
%properties = (
@ -119,7 +120,7 @@ sub definition {
autoGenerateForms=>1,
properties => \%properties
});
return $class->SUPER::definition($definition);
return $class->SUPER::definition($session,$definition);
}
@ -191,6 +192,7 @@ A comparison expression to be used when checking whether the action should be al
=cut
sub confirm {
my $self = shift;
return $self->session->privilege->vitalComponent() if ($_[4]);
my $noURL = $_[3] || $_[0]->getUrl;
my $i18n = WebGUI::International->new($self->session,'Wobject');
@ -278,8 +280,8 @@ Logs the view of the wobject to the passive profiling mechanism.
sub logView {
my $self = shift;
if ($self->session->setting->get("passiveProfilingEnabled")) {
WebGUI::PassiveProfiling::add($session,$self->get("assetId"));
WebGUI::PassiveProfiling::addPage($session,$self->get("assetId")); # add wobjects on asset to passive profile log
WebGUI::PassiveProfiling::add($self->session,$self->get("assetId"));
WebGUI::PassiveProfiling::addPage($self->session,$self->get("assetId")); # add wobjects on asset to passive profile log
}
return;
}

View file

@ -117,7 +117,7 @@ sub new {
my $cache;
my $class = shift;
my $session = shift;
if($session->config->get("memcached_servers")) {
if ($session->config->get("memcached_servers")) {
require WebGUI::Cache::Memcached;
return WebGUI::Cache::Memcached->new($session,@_);
} else {

View file

@ -97,7 +97,7 @@ Renders an email address field.
sub toHtml {
my $self = shift;
$self->session->style->setScript($self->session->config->get("extrasURL").'/emailCheck.js',{ type=>'text/javascript' });
$self->get("extras") .= ' onchange="emailCheck(this.value)" ';
$self->{_params}{extras} .= ' onchange="emailCheck(this.value)" ';
return $self->SUPER::toHtml;
}

View file

@ -69,7 +69,7 @@ sub toHtml {
my $self = shift;
my $value = $self->fixQuotes($self->get("value"));
my $i18n = WebGUI::International->new($self->session);
$self->get("extras") ||= 'onclick="this.value=\''.$i18n->get(452).'\'"';
$self->{_params}{extras}; ||= 'onclick="this.value=\''.$i18n->get(452).'\'"';
my $html = '<input type="submit" ';
$html .= 'name="'.$self->get("name").'" ' if ($self->get("name"));
$html .= 'id="'.$self->{id}.'" ' unless ($self->{id} eq "_formId");

View file

@ -90,7 +90,7 @@ sub AUTOLOAD {
return undef;
}
my $class = "WebGUI::Form::".$name;
$self->{_data} .= $class->new(%params)->toHtmlWithWrapper;
$self->{_data} .= $class->new($self->session,%params)->toHtmlWithWrapper;
}
#-------------------------------------------------------------------

View file

@ -52,6 +52,7 @@ password and email address, as well as some other WebGUI settings.
#-------------------------------------------------------------------
sub www_setup {
my $session = shift;
$session->http->setMimeType("text/html");
return "" unless ($session->setting->get("specialState") eq "init");
my $i18n = WebGUI::International->new($session, "WebGUI");
my $output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
@ -101,15 +102,15 @@ sub www_setup {
$f->submit;
$output .= $f->print;
} elsif ($session->form->process("step") eq "3") {
WebGUI::Setting::remove('specialState');
WebGUI::Setting::set('companyName',$session->form->text("companyName"));
WebGUI::Setting::set('companyURL',$session->form->url("companyURL"));
WebGUI::Setting::set('companyEmail',$session->form->email("companyEmail"));
WebGUI::HTTP::setRedirect($session->url->gateway());
$session->setting->remove('specialState');
$session->setting->set('companyName',$session->form->text("companyName"));
$session->setting->set('companyURL',$session->form->url("companyURL"));
$session->setting->set('companyEmail',$session->form->email("companyEmail"));
$session->setting->setRedirect($session->url->gateway());
return "";
} else {
$output .= '<legend align="left">Admin Account</legend>';
my $u = WebGUI::User->new('3');
my $u = WebGUI::User->new($session,'3');
my $f = WebGUI::HTMLForm->new($session,action=>$session->url->gateway());
$f->hidden(
-name=>"op",

View file

@ -114,10 +114,8 @@ Cleans up a WebGUI session information from memory and disconnects from any reso
sub close {
my $self = shift;
##Must destroy the logger last!
my %keys = grep { $_ ne '_errorHandler' } keys %{ $self };
foreach my $object (keys %{$self}) {
next if ($object eq '_request' || $object eq '_sessionId' || $object eq '_server');
##Don't destroy things that don's exist
my %mykeys = grep { ($_ ne '_errorHandler' && $_ ne '_request' && $_ eq '_sessionId' && $_ eq '_server') } keys %{ $self };
foreach my $object (keys %mykeys) {
$self->{$object} and $self->{$object}->DESTROY;
}
$self->{_errorHandler} and $self->{_errorHandler}->DESTROY;
@ -359,8 +357,9 @@ sub open {
my $server = shift;
my $sessionId = shift;
my $config = WebGUI::Config->new($webguiRoot,$configFile);
my $self = {_sessionId=>$sessionId, _config=>$config, _server=>$server};
my $self = {_config=>$config, _server=>$server};
bless $self , $class;
$self->{_var} = WebGUI::Session::Var->new($self,$sessionId);
$self->{_request} = Apache2::Request->new($request, POST_MAX => 1024 * $self->setting->get("maxAttachmentSize")) if (defined $request);
return $self;
}
@ -422,7 +421,7 @@ Returns a WebGUI::Session::Scratch object.
sub scratch {
my $self = shift;
unless (exists $self->{_scratch}) {
$self->{_scratch} = WebGUI::Session::Scratch->new($self->getId, $self->db);
$self->{_scratch} = WebGUI::Session::Scratch->new($self);
}
return $self->{_scratch};
}

View file

@ -26,7 +26,7 @@ This package allows you to attach arbitrary data to the session that lasts until
=head1 SYNOPSIS
$scratch = WebGUI::Session::Scratch->new($sessionId, $db);
$scratch = WebGUI::Session::Scratch->new($session);
$scratch->delete('temp');
$scratch->set('temp',$value);
@ -61,7 +61,7 @@ sub delete {
my $name = shift;
return undef unless ($name);
delete $self->{_data}{$name};
$self->{_db}->deleteRow("userSessionScratch","sessionId",$self->{_sessionId});
$self->session->db->deleteRow("userSessionScratch","sessionId",$self->{_sessionId});
}
@ -76,7 +76,7 @@ Deletes all scratch variables for this session.
sub deleteAll {
my $self = shift;
delete $self->{_data};
$self->session->db->write("delete from userSessionScratch where sessionId=".quote($self->{_sessionId}));
$self->session->db->write("delete from userSessionScratch where sessionId=".quote($self->{_sessionId}));
}
@ -97,7 +97,7 @@ sub deleteName {
my $name = shift;
return undef unless ($name);
delete $self->{_data}{$name};
$self->session->db->write("delete from userSessionScratch where name=".quote($name));
$self->session->db->write("delete from userSessionScratch where name=".quote($name));
}
@ -136,26 +136,35 @@ sub get {
#-------------------------------------------------------------------
=head2 new ( sessionId, db )
=head2 new ( session )
Constructor. Returns a scratch object.
=head3 sessionId
=head3 session
The unique id of the current session.
=head3 db
An active WebGUI::SQL database handler.
The current session.
=cut
sub new {
my $class = shift;
my $sessionId = shift;
my $db = shift;
my $data = $db->buildHashRef("select name,value from userSessionScratch where sessionId=".$db->quote($sessionId));
bless {_sessionId=>$sessionId, _db=>$db, _data=>$data}, $class;
my $session = shift;
my $data = $session->db->buildHashRef("select name,value from userSessionScratch where sessionId=".$session->db->quote($session->getId));
bless {_session=>$session,_sessionId=>$session->getId, _data=>$data}, $class;
}
#-------------------------------------------------------------------
=head2 session ( )
Returns a reference to the WebGUI::Session object.
=cut
sub session {
my $self = shift;
return $self->{_session};
}
@ -181,7 +190,7 @@ sub set {
my $value = shift;
return undef unless ($name);
$self->{_data}{$name} = $value;
$self->{_db}->write("replace into userSessionScratch (sessionId, name, value) values (".$self->{_db}->quoteAndJoin([$self->{_sessionId}, $name, $value]).")");
$self->session->db->write("replace into userSessionScratch (sessionId, name, value) values (".$self->session->db->quoteAndJoin([$self->{_sessionId}, $name, $value]).")");
}

View file

@ -170,7 +170,7 @@ sub new {
$self->end;
}
if ($self->{_var}{sessionId} ne "") {
$self->{_var}{lastPageView} =$session->datetime->time();
$self->{_var}{lastPageView} = $session->datetime->time();
$self->{_var}{lastIP} = $session->env("REMOTE_ADDR");
$self->{_var}{expires} = $session->datetime->time() + $session->setting->get("sessionTimeout");
$session->db->setRow("userSession","sessionId",$self->{_var});