--- loncom/lonnet/perl/lonnet.pm 2006/03/05 01:54:50 1.718 +++ loncom/lonnet/perl/lonnet.pm 2006/04/06 18:04:23 1.725 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.718 2006/03/05 01:54:50 www Exp $ +# $Id: lonnet.pm,v 1.725 2006/04/06 18:04:23 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -260,6 +260,13 @@ sub critical { sub transfer_profile_to_env { my ($lonidsdir,$handle)=@_; + if (!defined($lonidsdir)) { + $lonidsdir = $perlvar{'lonIDsDir'}; + } + if (!defined($handle)) { + ($handle) = ($env{'user.environment'} =~m|/([^/]+)\.id$| ); + } + my @profile; { open(my $idf,"$lonidsdir/$handle.id"); @@ -843,6 +850,7 @@ sub save_cache { my ($r)=@_; if (! $r->is_initial_req()) { return DECLINED; } &purge_remembered(); + #&Apache::loncommon::validate_page(); undef(%env); return OK; } @@ -996,13 +1004,13 @@ sub retrievestudentphoto { # -------------------------------------------------------------------- New chat sub chatsend { - my ($newentry,$anon)=@_; + my ($newentry,$anon,$group)=@_; my $cnum=$env{'course.'.$env{'request.course.id'}.'.num'}; my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'}; my $chome=$env{'course.'.$env{'request.course.id'}.'.home'}; &reply('chatsend:'.$cdom.':'.$cnum.':'. &escape($env{'user.domain'}.':'.$env{'user.name'}.':'.$anon.':'. - &escape($newentry)),$chome); + &escape($newentry)).':'.$group,$chome); } # ------------------------------------------ Find current version of a resource @@ -1320,7 +1328,7 @@ sub clean_filename { # --------------- Take an uploaded file and put it into the userfiles directory # input: $formname - the contents of the file are in $env{"form.$formname"} -# the desired filenam is in $env{"form.$formname"} +# the desired filenam is in $env{"form.$formname.filename"} # $coursedoc - if true up to the current course # if false # $subdir - directory in userfile to store the file into @@ -1331,7 +1339,7 @@ sub clean_filename { sub userfileupload { - my ($formname,$coursedoc,$subdir,$parser,$allfiles,$codebase)=@_; + my ($formname,$coursedoc,$subdir,$parser,$allfiles,$codebase,$destuname,$destudom)=@_; if (!defined($subdir)) { $subdir='unknown'; } my $fname=$env{'form.'.$formname.'.filename'}; $fname=&clean_filename($fname); @@ -1354,6 +1362,7 @@ sub userfileupload { close($fh); return $fullpath.'/'.$fname; } + # Create the directory if not present $fname="$subdir/$fname"; if ($coursedoc) { @@ -1369,6 +1378,12 @@ sub userfileupload { $fname,$formname,$parser, $allfiles,$codebase); } + } elsif (defined($destuname)) { + my $docuname=$destuname; + my $docudom=$destudom; + return &finishuserfileupload($docuname,$docudom,$formname, + $fname,$parser,$allfiles,$codebase); + } else { my $docuname=$env{'user.name'}; my $docudom=$env{'user.domain'}; @@ -4726,6 +4741,12 @@ sub GetFileTimestamp { sub stat_file { my ($uri) = @_; $uri = &clutter($uri); + + # we want just the url part without the unneeded accessor url bits + if ($uri =~ m-^/adm/-) { + $uri=~s-^/adm/wrapper/-/-; + $uri=~s-^/adm/coursedocs/showdoc/-/-; + } my ($udom,$uname,$file,$dir); if ($uri =~ m-^/(uploaded|editupload)/-) { ($udom,$uname,$file) = @@ -4746,6 +4767,7 @@ sub stat_file { my ($result) = &dirlist($file,$udom,$uname,$dir); my @stats = split('&', $result); + if($stats[0] ne 'empty' && $stats[0] ne 'no_such_dir') { shift(@stats); #filename is first return @stats; @@ -5092,9 +5114,6 @@ sub EXT { ($env{'user.domain'} eq $udom)) { $section=$env{'request.course.sec'}; @groups=&sort_course_groups($env{'request.course.groups'},$courseid); - if (@groups > 0) { - @groups = sort(@groups); - } } else { if (! defined($usection)) { $section=&getsection($udom,$uname,$courseid); @@ -5229,10 +5248,7 @@ sub check_group_parms { sub sort_course_groups { # Sort groups based on defined rankings. Default is sort(). my ($grouplist,$courseid) = @_; - my @groups = split/:/,$grouplist; - if (@groups > 1) { - @groups = sort(@groups); - } + my @groups = sort(split(/:/,$grouplist)); return @groups; }