--- loncom/interface/loncommon.pm 2006/10/10 21:57:31 1.462 +++ loncom/interface/loncommon.pm 2006/10/12 18:17:57 1.463 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.462 2006/10/10 21:57:31 albertel Exp $ +# $Id: loncommon.pm,v 1.463 2006/10/12 18:17:57 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2596,7 +2596,7 @@ sub submlink { my ($text,$uname,$udom,$symb,$target)=@_; if (!($uname && $udom)) { (my $cursymb, my $courseid,$udom,$uname)= - &Apache::lonxml::whichuser($symb); + &Apache::lonnet::whichuser($symb); if (!$symb) { $symb=$cursymb; } } if (!$symb) { $symb=&Apache::lonnet::symbread(); } @@ -2642,7 +2642,7 @@ sub pprmlink { my ($text,$uname,$udom,$symb,$target)=@_; if (!($uname && $udom)) { (my $cursymb, my $courseid,$udom,$uname)= - &Apache::lonxml::whichuser($symb); + &Apache::lonnet::whichuser($symb); if (!$symb) { $symb=$cursymb; } } if (!$symb) { $symb=&Apache::lonnet::symbread(); } @@ -6004,7 +6004,7 @@ sub escape_url { # -------------------------------------------------------- Initliaze user login sub init_user_environment { - my ($r, $username, $domain, $authhost, $form, $extra_env) = @_; + my ($r, $username, $domain, $authhost, $form, $args) = @_; my $lonids=$Apache::lonnet::perlvar{'lonIDsDir'}; my $public=($username eq 'public' && $domain eq 'public'); @@ -6032,17 +6032,20 @@ sub init_user_environment { } if (!$cookie) { $cookie="publicuser_$oldest"; } } else { - opendir(DIR,$lonids); - while ($filename=readdir(DIR)) { - if ($filename=~/^$username\_\d+\_$domain\_$authhost\.id$/) { - unlink($lonids.'/'.$filename); + # if this isn't a robot, kill any existing non-robot sessions + if (!$args->{'robot'}) { + opendir(DIR,$lonids); + while ($filename=readdir(DIR)) { + if ($filename=~/^$username\_\d+\_$domain\_$authhost\.id$/) { + unlink($lonids.'/'.$filename); + } } + closedir(DIR); } - closedir(DIR); - # Give them a new cookie - - $cookie="$username\_$now\_$domain\_$authhost"; + my $id = ($args->{'robot'} ? 'robot'.$args->{'robot'} + : $now); + $cookie="$username\_$id\_$domain\_$authhost"; # Initialize roles @@ -6136,7 +6139,9 @@ sub init_user_environment { &_add_to_env(\%disk_env,\%initial_env); &_add_to_env(\%disk_env,\%userenv,'environment.'); &_add_to_env(\%disk_env,$userroles); - &_add_to_env(\%disk_env,$extra_env); + if (ref($args->{'extra_env'})) { + &_add_to_env(\%disk_env,$args->{'extra_env'}); + } untie(%disk_env); } else { &Apache::lonnet::logthis("WARNING: ".