From 35c4ad353d8aadfcfc646173d8077f95fc12e54c Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 16 Jan 2006 21:55:39 +0000 Subject: [PATCH] missing session variables from ->new found via code analysis --- lib/WebGUI/Asset/Event.pm | 2 +- lib/WebGUI/Asset/Post.pm | 8 ++++---- lib/WebGUI/Asset/Post/Thread.pm | 12 ++++++------ lib/WebGUI/Asset/Redirect.pm | 2 +- lib/WebGUI/Asset/Shortcut.pm | 12 +++++++----- lib/WebGUI/Asset/Wobject/Collaboration.pm | 6 +++--- lib/WebGUI/Asset/Wobject/Dashboard.pm | 6 +++--- lib/WebGUI/Asset/Wobject/HttpProxy.pm | 2 +- lib/WebGUI/Asset/Wobject/HttpProxy/Parse.pm | 5 +++++ lib/WebGUI/Asset/Wobject/Matrix.pm | 6 +++--- lib/WebGUI/Asset/Wobject/MessageBoard.pm | 2 +- lib/WebGUI/Session.pm | 1 + 12 files changed, 36 insertions(+), 28 deletions(-) diff --git a/lib/WebGUI/Asset/Event.pm b/lib/WebGUI/Asset/Event.pm index 46060710b..f0bbdf717 100644 --- a/lib/WebGUI/Asset/Event.pm +++ b/lib/WebGUI/Asset/Event.pm @@ -218,7 +218,7 @@ sub view { my ($garbage, $end) = $self->session->datetime->dayStartEnd($self->get("eventEndDate")); my $sth = $self->session->db->read("select assetId from EventsCalendar_event where ((eventStartDate >= $start and eventStartDate <= $end) or (eventEndDate >= $start and eventEndDate <= $end)) and assetId<>".$self->session->db->quote($self->getId)); while (my ($assetId) = $sth->array) { - my $asset = WebGUI::Asset::Event->new($assetId); + my $asset = WebGUI::Asset::Event->new($self->session, $assetId); # deal with multiple versions of the same event with conflicting dates next unless (($asset->get("eventStartDate") >= $start && $asset->get("eventStartDate") <= $end) || ($asset->get("eventEndDate") >= $start && $asset->get("eventEndDate") <= $end)); push(@others,{ diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index 4419029c0..24650b752 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -241,7 +241,7 @@ sub getAvatarUrl { my $avatarUrl; return $avatarUrl unless $self->getThread->getParent->getValue("avatarsEnabled"); - my $user = WebGUI::User->new($self->get('ownerUserId')); + my $user = WebGUI::User->new($self->session, $self->get('ownerUserId')); #Get avatar field, storage Id. my $storageId = $user->profileField("avatar"); my $avatar = WebGUI::Storage::Image->get($self->session,$storageId); @@ -468,7 +468,7 @@ sub getTemplateVars { sub getThread { my $self = shift; unless (exists $self->{_thread}) { - $self->{_thread} = WebGUI::Asset::Post::Thread->new($self->get("threadId")); + $self->{_thread} = WebGUI::Asset::Post::Thread->new($self->session, $self->get("threadId")); } return $self->{_thread}; } @@ -617,14 +617,14 @@ sub notifySubscribers { foreach my $userId (@{$group->getUsers(undef,1)}) { $subscribers{$userId} = $userId unless ($userId eq $self->get("ownerUserId")); } - $group = WebGUI::Group->new($self->getThread->getParent->get("subscriptionGroupId")); + $group = WebGUI::Group->new($self->session, $self->getThread->getParent->get("subscriptionGroupId")); foreach my $userId (@{$group->getUsers(undef,1)}) { $subscribers{$userId} = $userId unless ($userId eq $self->get("ownerUserId")); } my %lang; my $i18n = WebGUI::International->new($self->session); foreach my $userId (keys %subscribers) { - my $u = WebGUI::User->new($userId); + my $u = WebGUI::User->new($self->session, $userId); if ($lang{$u->profileField("language")}{message} eq "") { $lang{$u->profileField("language")}{var} = $self->getTemplateVars(); $self->getThread->getParent->appendTemplateLabels($lang{$u->profileField("language")}{var}); diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index f5334e483..16c0f95f2 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -39,7 +39,7 @@ sub canSubscribe { sub createSubscriptionGroup { my $self = shift; return if ($self->get("subscriptionGroupId")); - my $group = WebGUI::Group->new("new"); + my $group = WebGUI::Group->new($self->session, "new"); $group->name($self->getId); $group->description("The group to store subscriptions for the thread ".$self->getId); $group->isEditable(0); @@ -127,7 +127,7 @@ sub getLastPost { my $lastPostId = $self->get("lastPostId"); my $lastPost; if ($lastPostId) { - $lastPost = WebGUI::Asset::Post->new($lastPostId); + $lastPost = WebGUI::Asset::Post->new($self->session, $lastPostId); } return $lastPost if (defined $lastPost); return $self; @@ -196,7 +196,7 @@ sub getNextThread { group by assetData.assetId order by ".$sortBy." asc ",$self->session->dbSlave); - $self->{_next} = WebGUI::Asset->new($id,$class,$version); + $self->{_next} = WebGUI::Asset->new($self->session, $id,$class,$version); # delete $self->{_next} unless ($self->{_next}->{_properties}{className} =~ /Thread/); }; return $self->{_next}; @@ -233,7 +233,7 @@ sub getPreviousThread { ) group by assetData.assetId order by ".$sortBy." desc, assetData.revisionDate desc ",$self->session->dbSlave); - $self->{_previous} = WebGUI::Asset::Post::Thread->new($id,$class,$version); + $self->{_previous} = WebGUI::Asset::Post::Thread->new($self->session, $id,$class,$version); # delete $self->{_previous} unless ($self->{_previous}->{_properties}{className} =~ /Thread/); }; return $self->{_previous}; @@ -454,7 +454,7 @@ sub rate { my $average = round($sum/$count); $self->update({rating=>$average}); if ($self->session->setting->get("useKarma")) { - my $poster = WebGUI::User->new($self->get("ownerUserId")); + my $poster = WebGUI::User->new($self->session, $self->get("ownerUserId")); $poster->karma($rating*$self->getParent->get("karmaRatingMultiplier"),"collaboration rating","someone rated post ".$self->getId); my $rater = WebGUI::User->new($self->session->user->userId); $rater->karma(-$self->getParent->get("karmaSpentToRate"),"collaboration rating","spent karma to rate post ".$self->getId); @@ -672,7 +672,7 @@ sub view { $p->setDataByQuery($sql, undef, undef, undef, "url", $currentPageUrl); foreach my $dataSet (@{$p->getPageData()}) { next unless ($dataSet->{className} eq "WebGUI::Asset::Post" || $dataSet->{className} eq "WebGUI::Asset::Post::Thread"); #handle non posts! - my $reply = WebGUI::Asset::Post->new($dataSet->{assetId}, $dataSet->{className}, $dataSet->{revisionDate}); + my $reply = WebGUI::Asset::Post->new($self->session, $dataSet->{assetId}, $dataSet->{className}, $dataSet->{revisionDate}); $reply->{_thread} = $self; # caching thread for better performance my %replyVars = %{$reply->getTemplateVars}; $replyVars{isCurrent} = ($reply->get("url") eq $currentPageUrl); diff --git a/lib/WebGUI/Asset/Redirect.pm b/lib/WebGUI/Asset/Redirect.pm index 870d4205a..9779ebe31 100644 --- a/lib/WebGUI/Asset/Redirect.pm +++ b/lib/WebGUI/Asset/Redirect.pm @@ -120,7 +120,7 @@ sub www_view { my $self = shift; return $self->session->privilege->noAccess() unless $self->canView; if ($self->session->var->isAdminOn() && $self->canEdit) { - my $i18n = WebGUI::International->new("Asset_Redirect"); + my $i18n = WebGUI::International->new($self->session, "Asset_Redirect"); return $self->getAdminConsole->render($i18n->get("what do you want to do with this redirect").'