--- loncom/interface/loncommon.pm 2006/10/10 21:57:31 1.462 +++ loncom/interface/loncommon.pm 2006/11/01 22:22:31 1.467 @@ -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.467 2006/11/01 22:22:31 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2067,6 +2067,27 @@ sub getnames { } } +sub getemails { + my ($uname,$udom)=@_; + if ($udom eq 'public' && $uname eq 'public') { + return; + } + if (!$udom) { $udom=$env{'user.domain'}; } + if (!$uname) { $uname=$env{'user.name'}; } + my $id=$uname.':'.$udom; + my ($names,$cached)=&Apache::lonnet::is_cached_new('emailscache',$id); + if ($cached) { + return %{$names}; + } else { + my %loadnames=&Apache::lonnet::get('environment', + ['notification','critnotification', + 'permanentemail'], + $udom,$uname); + &Apache::lonnet::do_cache_new('emailscache',$id,\%loadnames); + return %loadnames; + } +} + # ------------------------------------------------------------------ Screenname =pod @@ -2596,7 +2617,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 +2663,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(); } @@ -3388,6 +3409,10 @@ table.LC_whatsnew tr.LC_empty_row td { text-align: center; padding: 8px; } +table.LC_whatsnew tr.LC_empty_row td { + padding: 4ex +} + table.LC_whatsnew { } @@ -3728,6 +3753,7 @@ Inputs: $title - optional title for the bgcolor -> override the default page bgcolor no_auto_mt_title -> prevent &mt()ing the title arg + =back =cut @@ -4676,7 +4702,7 @@ sub get_env_multiple { =pod -=back +=back =head1 CSV Upload/Handling functions @@ -6004,7 +6030,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 +6058,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 +6165,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: ".