[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

banghart lon-capa-cvs@mail.lon-capa.org
Sat, 04 Dec 2004 02:14:20 -0000


banghart		Fri Dec  3 21:14:20 2004 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  	Saving work in progress. Not tested, much not completed.
  	Routines to save and retrieve information about files
  	selected for essay submission.
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.571 loncom/lonnet/perl/lonnet.pm:1.572
--- loncom/lonnet/perl/lonnet.pm:1.571	Sat Nov 27 12:23:08 2004
+++ loncom/lonnet/perl/lonnet.pm	Fri Dec  3 21:14:19 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.571 2004/11/27 17:23:08 raeburn Exp $
+# $Id: lonnet.pm,v 1.572 2004/12/04 02:14:19 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3812,6 +3812,52 @@
     return;
 }
 
+# ------------------------------------------------------------Save Selected Files
+
+sub save_selected_files {
+    my ($user, $path, @files) = @_;
+    my $filename = $user."savedfiles";
+    open OUT, '>'.$Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/'.$filename;
+    foreach (@files) {
+        print OUT $ENV{'form.currentpath'}.$_."\n";
+    }
+    close OUT;
+    return 'ok';
+}
+
+sub files_in_path {
+    my ($user, $path) = @_;
+    my $filename = $user."savedfiles";
+    my %return_files;
+    open IN, '<'.$Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/'.$filename;
+    return \%return_files;
+}
+
+# called in portfolio select mode, to show files selected NOT in current directory
+sub files_not_in_path {
+    my ($user, $path) = @_;
+    my $filename = $user."savedfiles";
+    my @return_files;
+    my $path_part;
+    open IN, '<'.$Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/'.$filename;
+    while (<IN>) {
+        #ok, I know it's clunky, but I want it to work
+        my @paths_and_file = split m!/!, $_;
+        my $file_part = pop @paths_and_file;
+        my $path_part = join '/', @paths_and_file;
+        $path_part .= '/';
+        my $path_and_file = $path_part.$file_part;
+        if ($path_part ne $path) {
+            push @return_files, ($path_and_file);
+            &logthis("path part is $path_part file is $file_part");
+        } else {
+            &logthis("path part is $path_part file is $file_part");
+        }
+    }
+    close OUT;
+    return @return_files;
+}
+
 #--------------------------------------------------------------Get Marked as Read Only
 
 sub get_marked_as_readonly {