[LON-CAPA-cvs] cvs: loncom /homework grades.pm /interface londocs.pm /lonnet/perl lonnet.pm rat lonratsrv.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 13 Jun 2005 20:23:57 -0000


This is a MIME encoded message

--albertel1118694237
Content-Type: text/plain

albertel		Mon Jun 13 16:23:57 2005 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
    /rat	lonratsrv.pm 
    /loncom/homework	grades.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - eliminating $home from that args to finishuserfileupload it shoudn't have had it in the first place
  
  
--albertel1118694237
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20050613162357.txt"

Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.188 loncom/interface/londocs.pm:1.189
--- loncom/interface/londocs.pm:1.188	Sat Jun 11 09:38:47 2005
+++ loncom/interface/londocs.pm	Mon Jun 13 16:23:53 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.188 2005/06/11 13:38:47 raeburn Exp $
+# $Id: londocs.pm,v 1.189 2005/06/13 20:23:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -840,8 +840,7 @@
                             '<resource id="2" src="" type="finish"></resource>'."\n".
                             '</map>';
             $env{'form.output'}=$newmapstr;
-            my $home=&Apache::lonnet::homeserver($coursenum,$coursedom);
-            my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$home,
+            my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
                                                 'output',$1.$2);
             if ($result != m|^/uploaded/|) {
                 $errtext.='Map not saved: A network error occured when trying to save the new map. ';
Index: rat/lonratsrv.pm
diff -u rat/lonratsrv.pm:1.31 rat/lonratsrv.pm:1.32
--- rat/lonratsrv.pm:1.31	Wed Jun  8 11:18:28 2005
+++ rat/lonratsrv.pm	Mon Jun 13 16:23:53 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Server for RAT Maps
 #
-# $Id: lonratsrv.pm,v 1.31 2005/06/08 15:18:28 www Exp $
+# $Id: lonratsrv.pm,v 1.32 2005/06/13 20:23:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -292,9 +292,8 @@
         $outstr.="</map>\n";
 	if ($fn=~/^\/*uploaded\/(\w+)\/(\w+)\/(.*)$/) {
 	    $env{'form.output'}=$outstr;
-            my $home=&Apache::lonnet::homeserver($2,$1);
-            my $result=&Apache::lonnet::finishuserfileupload($2,$1,$home,
-						'output',$3);
+            my $result=&Apache::lonnet::finishuserfileupload($2,$1,
+							     'output',$3);
 	    if ($result != m|^/uploaded/|) {
 		$errtext.='Map not saved: A network error occured when trying to save the map. ';
 	    }
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.274 loncom/homework/grades.pm:1.275
--- loncom/homework/grades.pm:1.274	Sun Jun  5 02:12:16 2005
+++ loncom/homework/grades.pm	Mon Jun 13 16:23:54 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.274 2005/06/05 06:12:16 albertel Exp $
+# $Id: grades.pm,v 1.275 2005/06/13 20:23:54 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2321,12 +2321,11 @@
                     }
                 }
                 $version++;
-                my $home_server = &Apache::lonnet::homeserver($stuname,$domain,undef);
                 $env{'form.copy'} = &Apache::lonnet::getfile("/uploaded/$domain/$stuname/portfolio$directory$answer_file");
                 if($env{'form.copy'} eq '-1') {
                     &Apache::lonnet::logthis('problem getting file '.$directory.$answer_file);
                 } else {
-                   my $copy_result = &Apache::lonnet::finishuserfileupload($stuname,$domain,$home_server,'copy',
+                   my $copy_result = &Apache::lonnet::finishuserfileupload($stuname,$domain,'copy',
                                     '/portfolio'.$directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]);
                     push(@v_portfiles, $answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]);
                     &Apache::lonnet::mark_as_readonly($domain,$stuname,
@@ -4580,9 +4579,8 @@
     my ($contents,$filename)=@_;
     my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
     my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
-    my $docuhome=$env{'course.'.$env{'request.course.id'}.'.home'};
     $env{'form.sillywaytopassafilearound'}=$contents;
-    &Apache::lonnet::finishuserfileupload($docuname,$docudom,$docuhome,'sillywaytopassafilearound',$filename);
+    &Apache::lonnet::finishuserfileupload($docuname,$docudom,'sillywaytopassafilearound',$filename);
 
 }
 
@@ -5158,8 +5156,6 @@
     }
     my %coursedata=&Apache::lonnet::coursedescription($env{'form.domainid'}.'_'.$env{'form.courseid'});
     $r->print("Doing upload to ".$coursedata{'description'}." <br />");
-    my $home=&Apache::lonnet::homeserver($env{'form.courseid'},
-					 $env{'form.domainid'});
     my $fname=$env{'form.upfile.filename'};
     #FIXME
     #copied from lonnet::userfileupload()
@@ -5179,7 +5175,7 @@
     if (length($env{'form.upfile'}) < 2) {
 	$r->print("<font color='red'>Error:</font> The file you attempted to upload, <tt>".&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"')."</tt>, contained no information. Please check that you entered the correct filename.");
     } else {
-	my $result=&Apache::lonnet::finishuserfileupload($env{'form.courseid'},$env{'form.domainid'},$home,'upfile',$fname);
+	my $result=&Apache::lonnet::finishuserfileupload($env{'form.courseid'},$env{'form.domainid'},'upfile',$fname);
 	if ($result =~ m|^/uploaded/|) {
 	    $r->print("<font color='green'>Success:</font> Successfully uploaded ".(length($env{'form.upfile'})-1)." bytes of data into location <tt>".$result."</tt>");
 	} else {
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.637 loncom/lonnet/perl/lonnet.pm:1.638
--- loncom/lonnet/perl/lonnet.pm:1.637	Sat Jun 11 09:38:47 2005
+++ loncom/lonnet/perl/lonnet.pm	Mon Jun 13 16:23:54 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.637 2005/06/11 13:38:47 raeburn Exp $
+# $Id: lonnet.pm,v 1.638 2005/06/13 20:23:54 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1132,7 +1132,7 @@
 }
 
 # --------- File operations in /home/httpd/html/userfiles/$domain/1/2/3/$course
-# input: action, courseID, current domain, home server for course, intended
+# input: action, courseID, current domain, intended
 #        path to file, source of file, instruction to parse file for objects,
 #        ref to hash for embedded objects,
 #        ref to hash for codebase of java objects.
@@ -1162,11 +1162,12 @@
 #
 
 sub process_coursefile {
-    my ($action,$docuname,$docudom,$docuhome,$file,$source,$parser,$allfiles,$codebase)=@_;
+    my ($action,$docuname,$docudom,$file,$source,$parser,$allfiles,$codebase)=@_;
     my $fetchresult;
+    my $home=&homeserver($docuname,$docudom);
     if ($action eq 'propagate') {
-        $fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$file
-                            ,$docuhome);
+        $fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$file,
+			     $home);
     } else {
         my $fetchresult = '';
         my $fpath = '';
@@ -1182,7 +1183,7 @@
                 my $destination = $filepath.'/'.$fname;
                 rename($source,$destination);
                 $fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$file,
-                                 $docuhome);
+                                 $home);
             }
         } elsif ($action eq 'uploaddoc') {
             open(my $fh,'>'.$filepath.'/'.$fname);
@@ -1195,19 +1196,19 @@
                 }
             }
             $fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$file,
-                                 $docuhome);
+                                 $home);
             if ($fetchresult eq 'ok') {
                 return '/uploaded/'.$fpath.'/'.$fname;
             } else {
                 &logthis('Failed to transfer '.$docudom.'/'.$docuname.'/'.$file.
-                        ' to host '.$docuhome.': '.$fetchresult);
+                        ' to host '.$home.': '.$fetchresult);
                 return '/adm/notfound.html';
             }
         }
     }
     unless ( $fetchresult eq 'ok') {
         &logthis('Failed to transfer '.$docudom.'/'.$docuname.'/'.$file.
-             ' to host '.$docuhome.': '.$fetchresult);
+             ' to host '.$home.': '.$fetchresult);
     }
     return $fetchresult;
 }
@@ -1228,7 +1229,7 @@
 }
 
 sub store_edited_file {
-    my ($primary_url,$content,$docudom,$docuname,$docuhome,$fetchresult) = @_;
+    my ($primary_url,$content,$docudom,$docuname,$fetchresult) = @_;
     my $file = $primary_url;
     $file =~ s#^/uploaded/$docudom/$docuname/##;
     my $fpath = '';
@@ -1239,12 +1240,14 @@
     open(my $fh,'>'.$filepath.'/'.$fname);
     print $fh $content;
     close($fh);
+    my $home=&homeserver($docuname,$docudom);
     $$fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$file,
-                                 $docuhome);
+			  $home);
     if ($$fetchresult eq 'ok') {
         return '/uploaded/'.$fpath.'/'.$fname;
     } else {
-        &logthis('Failed to transfer '.$docudom.'/'.$docuname.'/'.$file.                        ' to host '.$docuhome.': '.$$fetchresult);
+        &logthis('Failed to transfer '.$docudom.'/'.$docuname.'/'.$file.
+		 ' to host '.$home.': '.$$fetchresult);
         return '/adm/notfound.html';
     }
 }
@@ -1295,30 +1298,30 @@
         return $fullpath.'/'.$fname; 
     }
 # Create the directory if not present
-    my $docuname='';
-    my $docudom='';
-    my $docuhome='';
     $fname="$subdir/$fname";
     if ($coursedoc) {
-	$docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
-	$docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
-	$docuhome=$env{'course.'.$env{'request.course.id'}.'.home'};
+	my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
+	my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
         if ($env{'form.folder'} =~ m/^default/) {
-            return &finishuserfileupload($docuname,$docudom,$docuhome,$formname,$fname,$parser,$allfiles,$codebase);
+            return &finishuserfileupload($docuname,$docudom,
+					 $formname,$fname,$parser,$allfiles,
+					 $codebase);
         } else {
             $fname=$env{'form.folder'}.'/'.$fname;
-            return &process_coursefile('uploaddoc',$docuname,$docudom,$docuhome,$fname,$formname,$parser,$allfiles,$codebase);
+            return &process_coursefile('uploaddoc',$docuname,$docudom,
+				       $fname,$formname,$parser,
+				       $allfiles,$codebase);
         }
     } else {
-        $docuname=$env{'user.name'};
-        $docudom=$env{'user.domain'};
-        $docuhome=$env{'user.home'};
-        return &finishuserfileupload($docuname,$docudom,$docuhome,$formname,$fname,$parser,$allfiles,$codebase);
+        my $docuname=$env{'user.name'};
+        my $docudom=$env{'user.domain'};
+	return &finishuserfileupload($docuname,$docudom,$formname,
+				     $fname,$parser,$allfiles,$codebase);
     }
 }
 
 sub finishuserfileupload {
-    my ($docuname,$docudom,$docuhome,$formname,$fname,$parser,$allfiles,$codebase) = @_;
+    my ($docuname,$docudom,$formname,$fname,$parser,$allfiles,$codebase) = @_;
     my $path=$docudom.'/'.$docuname.'/';
     my $filepath=$perlvar{'lonDocRoot'};
     my ($fnamepath,$file);
@@ -1342,13 +1345,16 @@
 	close(FH);
     }
     if ($parser eq 'parse') {
-        my $parse_result = &extract_embedded_items($filepath,$file,$allfiles,$codebase);
+        my $parse_result = &extract_embedded_items($filepath,$file,$allfiles,
+						   $codebase);
         unless ($parse_result eq 'ok') {
-            &logthis('Failed to parse '.$filepath.$file.' for embedded media: '.$parse_result); 
+            &logthis('Failed to parse '.$filepath.$file.
+		     ' for embedded media: '.$parse_result); 
         }
     }
 # Notify homeserver to grep it
 #
+    my $docuhome=&homeserver($docuname,$docudom);
     my $fetchresult= &reply('fetchuserfile:'.$path.$file,$docuhome);
     if ($fetchresult eq 'ok') {
 #
@@ -1471,17 +1477,17 @@
 
 sub extract_java_items {
     my ($javafiles,$allfiles,$codebase) = @_;
-    foreach my $item (keys (%{$javafiles})) {
-        unless ($item eq 'codebase') {
+    foreach my $item (keys(%{$javafiles})) {
+        if ($item ne 'codebase') {
             if ($$javafiles{$item} ne '') {
-                if (exists($$allfiles{$$javafiles{'codebase'}.$$javafiles{$item}})) {
-                    unless (grep/^$item$/,@{$$allfiles{$$javafiles{'codebase'}.$$javafiles{$item}}}) {
-                        push(@{$$allfiles{$$javafiles{'codebase'}.$$javafiles{$item}}},&escape($item));
-                    }
-                } else {
-                    @{$$allfiles{$$javafiles{'codebase'}.$$javafiles{$item}}} = (&escape($item));
-                    $$codebase{$$javafiles{'codebase'}.$$javafiles{$item}} = $$javafiles{'codebase'};
-                                                                                
+		my $file=$javafiles->{'codebase'}.$javafiles->{$item};
+                if (exists($allfiles->{$file})) {
+                    unless (scalar(grep(/^$item$/, @{$allfiles->{$file}}))) {
+                        push(@{$allfiles->{$file}}, &escape($item));
+		    }
+		} else {
+                    @{$allfiles->{$file}} = (&escape($item));
+                    $codebase->{$file} = $javafiles->{'codebase'};
                 }
             }
         }
@@ -3875,7 +3881,7 @@
 </map>
 ENDINITMAP
         $topurl=&declutter(
-        &finishuserfileupload($uname,$udom,$uhome,'initmap','default.sequence')
+        &finishuserfileupload($uname,$udom,'initmap','default.sequence')
                           );
     }
 # ----------------------------------------------------------- Write preferences
@@ -6798,7 +6804,6 @@
 
   docuname: username or courseid of destination for the file
   docudom: domain of user/course of destination for the file
-  docuhome: loncapa id of the library server that is getting the file
   formname: same as for userfileupload()
   fname: filename (inculding subdirectories) for the file
 

--albertel1118694237--