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

raeburn raeburn@source.lon-capa.org
Thu, 30 Dec 2010 19:35:38 -0000


raeburn		Thu Dec 30 19:35:38 2010 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Portfolio files can be overwritten in course context, if locked file is 
    locked for an assignment with access controlled by a slot which is 
    currently open for user (i.e., slot status: RESERVED_LOCATION or RESERVED).
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.990 loncom/interface/loncommon.pm:1.991
--- loncom/interface/loncommon.pm:1.990	Fri Dec 24 07:58:04 2010
+++ loncom/interface/loncommon.pm	Thu Dec 30 19:35:28 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.990 2010/12/24 07:58:04 raeburn Exp $
+# $Id: loncommon.pm,v 1.991 2010/12/30 19:35:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -8957,6 +8957,11 @@
                                             $getpropath);
     my $found_file = 0;
     my $locked_file = 0;
+    my @lockers;
+    my $navmap;
+    if ($env{'request.course.id'}) {
+        $navmap = Apache::lonnavmaps::navmap->new();
+    }
     foreach my $line (@dir_list) {
         my ($file_name,$rest)=split(/\&/,$line,2);
         if ($file_name eq $fname){
@@ -8965,8 +8970,28 @@
                 $file_name = $group.$file_name;
             }
             $found_file = 1;
-            if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') {
-                $locked_file = 1;
+            if (&Apache::lonnet::is_locked($file_name,$udom,$uname,\@lockers) eq 'true') {
+                foreach my $lock (@lockers) {
+                    if (ref($lock) eq 'ARRAY') {
+                        my ($symb,$crsid) = @{$lock};
+                        if ($crsid eq $env{'request.course.id'}) {
+                            if (ref($navmap)) {
+                                my $res = $navmap->getBySymb($symb);
+                                foreach my $part (@{$res->parts()}) { 
+                                    my ($slot_status,$slot_time,$slot_name)=$res->check_for_slot($part);
+                                    unless (($slot_status == $res->RESERVED) ||
+                                            ($slot_status == $res->RESERVED_LOCATION)) {
+                                        $locked_file = 1;
+                                    }
+                                }
+                            } else {
+                                $locked_file = 1;
+                            }
+                        } else {
+                            $locked_file = 1;
+                        }
+                    }
+                }
             } else {
                 my @info = split(/\&/,$rest);
                 my $currsize = $info[6]/1000;
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1095 loncom/lonnet/perl/lonnet.pm:1.1096
--- loncom/lonnet/perl/lonnet.pm:1.1095	Sat Nov 27 23:32:08 2010
+++ loncom/lonnet/perl/lonnet.pm	Thu Dec 30 19:35:37 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1095 2010/11/27 23:32:08 raeburn Exp $
+# $Id: lonnet.pm,v 1.1096 2010/12/30 19:35:37 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -7295,7 +7295,7 @@
 }
 
 sub is_locked {
-    my ($file_name, $domain, $user) = @_;
+    my ($file_name, $domain, $user, $which) = @_;
     my @check;
     my $is_locked;
     push (@check,$file_name);
@@ -7307,9 +7307,13 @@
     if (ref($locked{$file_name}) eq 'ARRAY') {
         $is_locked = 'false';
         foreach my $entry (@{$locked{$file_name}}) {
-           if (ref($entry) eq 'ARRAY') { 
+           if (ref($entry) eq 'ARRAY') {
                $is_locked = 'true';
-               last;
+               if (ref($which) eq 'ARRAY') {
+                   push(@{$which},$entry);
+               } else {
+                   last;
+               }
            }
        }
     } else {