diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index bc2a48035..84a87d01f 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -83,7 +83,7 @@ sub _setupSessionVars { WebGUI::SQL->write("update userSession set lastPageView="._time().", lastIP='$session{env}{REMOTE_ADDR}', expires=".(_time()+$session{setting}{sessionTimeout})." where sessionId='$_[0]'"); } else { - start(1,$_[0]); + $vars{sessionId} = start(1,$_[0]); } } $session{var} = \%vars; @@ -474,6 +474,7 @@ sub start { -path=>'/' ); refreshSessionVars($sessionId); + return $sessionId; } 1; diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index e7f44131e..60aee579f 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -59,8 +59,7 @@ These methods are available from this class: #------------------------------------------------------------------- sub _create { - my ($userId); - $userId = WebGUI::Id::generate(); + my $userId = shift || WebGUI::Id::generate(); WebGUI::SQL->write("insert into users (userId,dateCreated) values (".quote($userId).",".time().")"); WebGUI::Grouping::addUsersToGroups([$userId],[2,7]); return $userId; @@ -218,13 +217,17 @@ sub lastUpdated { #------------------------------------------------------------------- -=head2 new ( userId ) +=head2 new ( userId [, overrideId ] ) Constructor. =head3 userId -The userId of the user you're creating an object reference for. If left blank it will default to "1" (Visitor). If specified as "new" then a new user account will be created and assigned the next available userId. +The userId of the user you're creating an object reference for. If left blank it will default to "1" (Visitor). If specified as "new" then a new user account will be created and assigned the next available userId. + +=head3 overrideId + +A unique ID to use instead of the ID that WebGUI will generate for you. It must be absolutely unique and can be up to 22 alpha numeric characters long. =cut @@ -233,7 +236,8 @@ sub new { tie %user, 'Tie::CPHash'; $class = shift; $userId = shift || 1; - $userId = _create() if ($userId eq "new"); + my $overrideId = shift; + $userId = _create($overrideId) if ($userId eq "new"); %user = WebGUI::SQL->quickHash("select * from users where userId=".quote($userId)); %profile = WebGUI::SQL->buildHash("select userProfileField.fieldName, userProfileData.fieldData from userProfileField, userProfileData where userProfileField.fieldName=userProfileData.fieldName and diff --git a/lib/WebGUI/Wobject/WSClient.pm b/lib/WebGUI/Wobject/WSClient.pm index 795867973..b0f2a609a 100644 --- a/lib/WebGUI/Wobject/WSClient.pm +++ b/lib/WebGUI/Wobject/WSClient.pm @@ -264,6 +264,9 @@ sub www_view { if ($self->get('preprocessMacros')) { $call = WebGUI::Macro::process($self->get("callMethod")); $param_str = WebGUI::Macro::process($self->get("params")); + } else { + $call = $self->get('callMethod'); + $param_str = $self->get('params'); } # see if we can shortcircuit this whole process diff --git a/sbin/userImport.pl b/sbin/userImport.pl index bc76698e7..2008bf6f0 100644 --- a/sbin/userImport.pl +++ b/sbin/userImport.pl @@ -157,6 +157,9 @@ Special Cases: -Blank lines will be ignored. + -If userId is specified for an import record, that userId + be used instead of generating one. + STOP exit; } @@ -222,13 +225,16 @@ while() { # process user my ($duplicate) = WebGUI::SQL->quickArray("select count(*) from users where username=".quote($user{username})); + my ($duplicateId) = WebGUI::SQL->quickArray("select count(*) from users where userId=".quote($user{userId})) if $user{userId}; if ($user{username} eq "") { print "Skipping line $lineNumber.\n" unless ($quiet); } elsif ($duplicate) { print "User $user{username} already exists. Skipping.\n" unless ($quiet); + } elsif ($duplicateId) { + print "ID $user{userId} already exists. Skipping.\n" unless ($quiet); } else { print "Adding user $user{username}\n" unless ($quiet); - my $u = WebGUI::User->new("new"); + my $u = WebGUI::User->new("new", $user{userId}); $u->username($user{username}); $u->authMethod($user{authMethod}); $u->status($user{status});