[LON-CAPA-cvs] cvs: loncom /xml londefdef.pm

raeburn raeburn@source.lon-capa.org
Sat, 11 Apr 2009 01:11:02 -0000


raeburn		Sat Apr 11 01:11:02 2009 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
  Log:
  - Side effect of change in lonnet.pm 1.886 -- to address bug 5290 (portfolio).
     - HTML parsing code is also used when uploading to DOCS.
     - Need to add httpref entry for any files linked to in uploaded file (not these types of file do not appear in the course map).
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.399 loncom/xml/londefdef.pm:1.400
--- loncom/xml/londefdef.pm:1.399	Tue Mar 31 10:12:45 2009
+++ loncom/xml/londefdef.pm	Sat Apr 11 01:11:02 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.399 2009/03/31 10:12:45 foxr Exp $
+# $Id: londefdef.pm,v 1.400 2009/04/11 01:11:02 raeburn Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -1612,6 +1612,26 @@
 	my $href=&Apache::lonxml::get_param('href',$parstack,$safeeval,
 					    undef,1);
 	$currentstring=&Apache::lonenc::encrypt_ref($token,{'href'=>$href});
+        if ($href =~ /\S/) {
+            if ($href !~ m{^https?://}) {
+                my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
+                my $linkurl;
+                if ($href =~ m{^/uploaded/}) {
+                    $linkurl = $href;
+                } elsif ($href =~ m{^[^/]}) {
+                    my $path = $url;
+                    $path  =~ s{[^/]*$}{};
+                    $linkurl = $path.$href;
+                }
+                if ($linkurl =~ m{^/uploaded/}) {
+                    if (!&Apache::lonnet::allowed('bre',$linkurl)) {
+                        if (&Apache::lonnet::is_on_map($url)) {
+                            &Apache::lonxml::extlink($linkurl);
+                        }
+                    }
+                }
+            }
+        }
     }
     return $currentstring;
 }