[LON-CAPA-cvs] cvs: rat / lonambiguous.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 17 Dec 2004 22:40:25 -0000


albertel		Fri Dec 17 17:40:25 2004 EDT

  Modified files:              
    /rat	lonambiguous.pm 
  Log:
   BUG# 3714
  
  
Index: rat/lonambiguous.pm
diff -u rat/lonambiguous.pm:1.10 rat/lonambiguous.pm:1.11
--- rat/lonambiguous.pm:1.10	Sun Sep 21 23:02:06 2003
+++ rat/lonambiguous.pm	Fri Dec 17 17:40:24 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to resolve ambiguous file locations
 #
-# $Id: lonambiguous.pm,v 1.10 2003/09/22 03:02:06 www Exp $
+# $Id: lonambiguous.pm,v 1.11 2004/12/17 22:40:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -67,6 +67,15 @@
 
 # ================================================================ Main Handler
 
+sub make_symb {
+    my ($id)=@_;
+    my ($mapid,$resid)=split(/\./,$id);
+    my $map=$bighash{'map_id_'.$mapid};
+    my $res=$bighash{'src_'.$id};
+    my $symb=&Apache::lonnet::encode_symb($map,$resid,$res);
+    return $symb;
+}
+
 sub handler {
    my $r=shift;
 
@@ -151,15 +160,17 @@
 # ------------------------------------------------------------------- Has ID(s)
          my @possibilities=split(/\,/,$ids);
          my $couldbe='';
-         map {
-             if (&Apache::lonnet::allowed('bre',$bighash{'src_'.$_})) {
+         foreach (@possibilities) {
+             if ($bighash{'encrypted_'.$_}) { next; }
+	     my $symb=&make_symb($_);
+             if (&Apache::lonnet::allowed('bre',$bighash{'src_'.$_},$symb)) {
 	         if ($couldbe) {
 		     $couldbe.=','.$_;
                  } else {
                      $couldbe=$_;
                  }
              }
-	 } @possibilities;
+	 }
          if ($couldbe) {
             @possibilities=split(/\,/,$couldbe);
             if ($#possibilities>0) {
@@ -176,24 +187,21 @@
 of the resource you meant.
 <p>
 Please click on the instance of the resource you intended to access:
-<p>
-<form action="/adm/ambiguous" method=post>
-<input type=hidden name=orgurl value="$thisfn">
-<input type=hidden name=selecturl value=1>
-<table border=2>
-<tr><th>&nbsp;</th><th>Title</th><th>Type</th><th>Part of ...</th></tr>
+</p>
+<table border="2">
+<tr><th>Title</th><th>Part of ...</th></tr>
 ENDSTART
                map {
+		   my $resurl=$bighash{'src_'.$_};
                    my $mapurl=$bighash{'map_id_'.(split(/\./,$_))[0]};
-                   $r->print('<tr><td><input type=submit value=Select name="'.
-                              $_.'"></td><td>'.$bighash{'title_'.$_}.
-                              '</td><td>'.$bighash{'type_'.$_}.
-                              '</td><td>'.
-                              ($mapurl=~/^\/uploaded\//?'':'<a href="'.$mapurl.'">').
-                              &Apache::lonnet::gettitle($mapurl).'&nbsp;'.
-			      ($mapurl=~/^\/uploaded\//?'':'</a>').'</td></tr>');
+		   my $symb=&make_symb($_);
+		   $r->print('<tr><td><a href="'.$resurl.'?symb='.$symb.'">'.
+			     &Apache::lonnet::gettitle($symb).
+			     '</a></td><td>'.
+			     &Apache::lonnet::gettitle($mapurl).'&nbsp;'.
+			     '</td></tr>');
                } @possibilities;
-               $r->print('</table></form></body></html>');
+               $r->print('</table></body></html>');
 	       untie(%bighash);
                return OK;
             }