From d95a076ac51ee5c68aed5416966631f80d25bf42 Mon Sep 17 00:00:00 2001 From: Patrick Donelan Date: Sun, 15 Mar 2009 06:34:15 +0000 Subject: [PATCH] Add optional userId param to Survey::responseId so that you can create a response for a specific user (not just current user bound to session) --- lib/WebGUI/Asset/Wobject/Survey.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index ae65c3f5a..8792acc00 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -1293,7 +1293,7 @@ sub responseIdCookies { #------------------------------------------------------------------- -=head2 responseId +=head2 responseId( [userId] ) Accessor for the responseId property, which is the unique identifier for a single L instance. See also L<"responseJSON">. @@ -1301,15 +1301,20 @@ L instance. See also L<"responseJS The responseId of the current user is returned, or created if one does not already exist. If the user is anonymous, the IP is used. Or an emailed or linked code can be used. +=head3 userId (optional) + +If specified, this user is used rather than the current user + =cut sub responseId { my $self = shift; + my ($userId) = validate_pos(@_, {type => SCALAR, optional => 1}); if (!defined $self->{responseId}) { my $ip = $self->session->env->getIp; - my $id = $self->session->user->userId; + my $id = $userId || $self->session->user->userId; my $anonId = $self->session->form->process('userid'); if ($self->responseIdCookies) { $anonId ||= $self->session->http->getCookies->{Survey2AnonId}; ## no critic