From 263bb9bbdfb36969b7f1a73b039b01690b746110 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 7 Apr 2009 13:00:53 -0700 Subject: [PATCH] Handle the uid parameter, easily. Add the getUser method, to return the right user, based on the uid URL parameter. Change appendCommonVars to use getUser so that it always dispays the correct username. --- lib/WebGUI/Account.pm | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/WebGUI/Account.pm b/lib/WebGUI/Account.pm index bae617837..ee5ffd194 100644 --- a/lib/WebGUI/Account.pm +++ b/lib/WebGUI/Account.pm @@ -53,7 +53,7 @@ sub appendCommonVars { my $self = shift; my $var = shift; my $session = $self->session; - my $user = $session->user; + my $user = $self->getUser; $var->{'user_full_name' } = $user->getWholeName; $var->{'user_member_since'} = $user->dateCreated; @@ -314,6 +314,25 @@ sub getUrl { #------------------------------------------------------------------- +=head2 getUser + +Gets the user, either specified by the uid URL parameter, or the +session user. + +=cut + +sub getUser { + my $self = shift; + if ($self->uid) { + return WebGUI::User->new($self->session, $self->uid); + } + else { + return $self->session->user; + } +} + +#------------------------------------------------------------------- + =head2 new ( session, module [,method ,uid] ) Constructor.