[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm /lonnet/perl lonnet.pm rat lonuserstate.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 10 Feb 2006 22:33:48 -0000


albertel		Fri Feb 10 17:33:48 2006 EDT

  Modified files:              
    /rat	lonuserstate.pm 
    /loncom/interface	lonnavmaps.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - BUG#4635 ext resources that ended in / caused oddities
  
  
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.99 rat/lonuserstate.pm:1.100
--- rat/lonuserstate.pm:1.99	Tue Jan 10 16:41:29 2006
+++ rat/lonuserstate.pm	Fri Feb 10 17:33:42 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construct and maintain state and binary representation of course for user
 #
-# $Id: lonuserstate.pm,v 1.99 2006/01/10 21:41:29 albertel Exp $
+# $Id: lonuserstate.pm,v 1.100 2006/02/10 22:33:42 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -443,12 +443,8 @@
 	    foreach (split(/\,/,$hash{$_})) {
 		my $resid=$_;
 		my $uri=$hash{'src_'.$resid};
-		$uri=~s/^\/adm\/wrapper//;
-		$uri=&Apache::lonnet::declutter($uri);
-		my @uriparts=split(/\//,$uri);
-		my $urifile=$uriparts[$#uriparts];
-		$#uriparts--;
-		my $uripath=join('/',@uriparts);
+		my ($uripath,$urifile) =
+		    &Apache::lonnet::split_uri_for_cond($uri);
 		if ($uripath) {
 		    my $uricond='0';
 		    if (defined($hash{'conditions_'.$resid})) {
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.358 loncom/interface/lonnavmaps.pm:1.359
--- loncom/interface/lonnavmaps.pm:1.358	Thu Jan 12 18:35:55 2006
+++ loncom/interface/lonnavmaps.pm	Fri Feb 10 17:33:45 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.358 2006/01/12 23:35:55 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.359 2006/02/10 22:33:45 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3658,9 +3658,8 @@
 }
 sub condval {
     my $self=shift;
-    my $uri=&Apache::lonnet::deversion(&Apache::lonnet::declutter($self->src()));
-    my ($pathname,$filename)=($uri=~m|(.*)/([^/]*)|);
-    $pathname=~s/^adm\/wrapper\///;    
+    my ($pathname,$filename) = 
+	&Apache::lonnet::split_uri_for_cond($self->src());
 
     my $match=($env{'acc.res.'.$env{'request.course.id'}.'.'.$pathname}=~
 	       /\&\Q$filename\E\:([\d\|]+)\&/);
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.709 loncom/lonnet/perl/lonnet.pm:1.710
--- loncom/lonnet/perl/lonnet.pm:1.709	Fri Feb 10 05:01:32 2006
+++ loncom/lonnet/perl/lonnet.pm	Fri Feb 10 17:33:48 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.709 2006/02/10 10:01:32 albertel Exp $
+# $Id: lonnet.pm,v 1.710 2006/02/10 22:33:48 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3450,16 +3450,17 @@
    return 'F';
 }
 
+sub split_uri_for_cond {
+    my $uri=&deversion(&declutter(shift));
+    my @uriparts=split(/\//,$uri);
+    my $filename=pop(@uriparts);
+    my $pathname=join('/',@uriparts);
+    return ($pathname,$filename);
+}
 # --------------------------------------------------- Is a resource on the map?
 
 sub is_on_map {
-    my $uri=&deversion(&declutter(shift));
-    my @uriparts=split(/\//,$uri);
-    my $filename=$uriparts[$#uriparts];
-    my $pathname=$uri;
-    $pathname=~s|/\Q$filename\E$||;
-    $pathname=~s/^adm\/wrapper\///;
-    $pathname=~s/^adm\/coursedocs\/showdoc\///;
+    my ($pathname,$filename) = &split_uri_for_cond(shift);
     #Trying to find the conditional for the file
     my $match=($env{'acc.res.'.$env{'request.course.id'}.'.'.$pathname}=~
 	       /\&\Q$filename\E\:([\d\|]+)\&/);