[LON-CAPA-cvs] cvs: loncom /interface londocs.pm

raeburn raeburn at source.lon-capa.org
Sun Nov 11 12:37:17 EST 2012


raeburn		Sun Nov 11 17:37:17 2012 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - Bug 6619. Use lonnet::get_timebased_id() when attempting to get a unique
    identifier for a folder or composite page in a course.
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.503 loncom/interface/londocs.pm:1.504
--- loncom/interface/londocs.pm:1.503	Thu Nov  8 20:51:40 2012
+++ loncom/interface/londocs.pm	Sun Nov 11 17:37:17 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.503 2012/11/08 20:51:40 raeburn Exp $
+# $Id: londocs.pm,v 1.504 2012/11/11 17:37:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1828,6 +1828,18 @@
 		if (defined($item)) {
 		    my ($name,$url,$residx)=
 			map {&unescape($_)} split(/\=/,$item);
+                    if ($url=~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
+                        my ($suffix,$errortxt,$locknotfreed) = 
+                            &newmap_suffix($1,$2,$coursedom,$coursenum);
+                        if ($locknotfreed) {
+                            $r->print($locknotfreed);
+                        }
+                        if ($suffix) {
+                            $url =~ s/_new\./_$suffix./; 
+                        } else {
+                            return $errortxt;
+                        }
+                    }
 		    push(@imports, [$name, $url, $residx]);
 		}
 	    }
@@ -2537,6 +2549,30 @@
     return $line;
 }
 
+sub newmap_suffix {
+    my ($area,$container,$coursedom,$coursenum) = @_;
+    my ($prefix,$idtype,$errtext,$locknotfreed);
+    $prefix = 'docs';
+    if ($area eq 'supplemental') {
+        $prefix = 'supp';
+    }
+    $prefix .= $container;
+    $idtype = 'concat';
+    my ($suffix,$freedlock,$error) =
+        &Apache::lonnet::get_timebased_id($prefix,'num','uploadedmaps',
+                                          $coursedom,$coursenum);
+    if (!$suffix) {
+        $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
+        if ($error) {
+            $errtext .= '<br />'.$error;
+        }
+    }
+    if ($freedlock ne 'ok') {
+        $locknotfreed = '<div class="LC_error">'.&mt('There was a problem removing a lockfile. This will prevent creation of additional folders or composite pages in this course.  Please contact the domain coordinator for your LON-CAPA domain.').'</div>';
+    }
+    return ($suffix,$errtext,$locknotfreed);
+}
+
 =pod
 
 =item tiehash()
@@ -3736,10 +3772,8 @@
        } else {
            #$postexec='self.close();';
        }
-       my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
-                     '.sequence';
-       my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
-                     '.page';
+       my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
+       my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
 	my $container='sequence';
 	if ($env{'form.pagepath'}) {
 	    $container='page';
@@ -3965,8 +3999,7 @@
        $env{'form.pagepath'} = '';
        if ($allowed) {
 	   my $folderseq=
-	       '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
-	       '.sequence';
+	       '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
 
 	   my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
 




More information about the LON-CAPA-cvs mailing list