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

banghart lon-capa-cvs@mail.lon-capa.org
Wed, 10 Nov 2004 06:02:12 -0000


banghart		Wed Nov 10 01:02:12 2004 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  	Added is_locked(file, domain, user) subroutine
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.565 loncom/lonnet/perl/lonnet.pm:1.566
--- loncom/lonnet/perl/lonnet.pm:1.565	Mon Nov  8 18:08:46 2004
+++ loncom/lonnet/perl/lonnet.pm	Wed Nov 10 01:02:11 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.565 2004/11/08 23:08:46 albertel Exp $
+# $Id: lonnet.pm,v 1.566 2004/11/10 06:02:11 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3780,6 +3780,20 @@
     return $listing;
 }
 
+sub is_locked {
+    my ($file_name, $domain, $user) = @_;
+    my @check;
+    my $is_locked;
+    push @check, $file_name;
+    my %locked = &Apache::lonnet::get('file_permissions',\@check,
+                                        $ENV{'user.domain'},$ENV{'user.name'});
+    if (ref($locked{$file_name}) eq 'ARRAY') {
+        $is_locked = 'true';
+    } else {
+        $is_locked = 'false';
+    }
+}
+
 # ------------------------------------------------------------- Mark as Read Only
 
 sub mark_as_readonly {
@@ -3799,16 +3813,12 @@
     my %current_permissions = &Apache::lonnet::dump('file_permissions',$domain,$user);
     my @readonly_files;
     while (my ($file_name,$value) = each(%current_permissions)) {
-        &logthis("found $file_name");
         if (ref($value) eq "ARRAY"){
-            &logthis("found array");
             foreach my $stored_what (@{$value}) {
                 if ($stored_what eq $what) {
                     push(@readonly_files, $file_name);
-                    &logthis("defined pushed $file_name");
                 } elsif (!defined($what)) {
                     push(@readonly_files, $file_name);
-                    &logthis("undef pushed $file_name");
                 }
             }
         }