[LON-CAPA-cvs] cvs: loncom / lonenc.pm /auth lonroles.pm /interface lonsearchcat.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 17 Dec 2004 21:44:20 -0000


albertel		Fri Dec 17 16:44:20 2004 EDT

  Modified files:              
    /loncom	lonenc.pm 
    /loncom/auth	lonroles.pm 
    /loncom/interface	lonsearchcat.pm 
  Log:
  BUG#3736
  
  
Index: loncom/lonenc.pm
diff -u loncom/lonenc.pm:1.7 loncom/lonenc.pm:1.8
--- loncom/lonenc.pm:1.7	Tue Nov 16 10:26:36 2004
+++ loncom/lonenc.pm	Fri Dec 17 16:44:19 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # URL translation for encrypted filenames
 #
-# $Id: lonenc.pm,v 1.7 2004/11/16 15:26:36 albertel Exp $
+# $Id: lonenc.pm,v 1.8 2004/12/17 21:44:19 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -49,9 +49,9 @@
 # Initialize Environment
             &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
 # Decrypt URL and redirect
-	    &Apache::lonnet::logthis("args ".$r->args);
-	    &Apache::lonnet::logthis("uri ".$r->uri);
-	    $r->internal_redirect(&unencrypted($r->uri).'?'.$r->args);
+	    my $redirect=&unencrypted($r->uri);
+	    if ($r->args) { $redirect.='?'.$r->args; }
+	    $r->internal_redirect($redirect);
 	    return OK;
 	} 
     }
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.114 loncom/auth/lonroles.pm:1.115
--- loncom/auth/lonroles.pm:1.114	Fri Dec  3 00:34:04 2004
+++ loncom/auth/lonroles.pm	Fri Dec 17 16:44:19 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.114 2004/12/03 05:34:04 raeburn Exp $
+# $Id: lonroles.pm,v 1.115 2004/12/17 21:44:19 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -339,7 +339,7 @@
 	$r->print("<h1>LON-CAPA Access Control</h1>");
         $r->print("<hr><pre>Access  : ".
                   Apache::lonnet::plaintext($priv)."\n");
-        $r->print("Resource: $fn\n");
+        $r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n");
         $r->print("Action  : $msg\n</pre><hr>");
     } else {
         if ($ENV{'user.error.msg'}) {
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.234 loncom/interface/lonsearchcat.pm:1.235
--- loncom/interface/lonsearchcat.pm:1.234	Mon Sep 27 10:58:01 2004
+++ loncom/interface/lonsearchcat.pm	Fri Dec 17 16:44:19 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.234 2004/09/27 14:58:01 matthew Exp $
+# $Id: lonsearchcat.pm,v 1.235 2004/12/17 21:44:19 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -445,10 +445,18 @@
 {   # Scope the course search to avoid global variables
 #
 # Variables For course search
-my %alreadyseen;
 my %hash;
 my $totalfound;
 
+sub make_symb {
+    my ($id)=@_;
+    my ($mapid,$resid)=split(/\./,$id);
+    my $map=$hash{'map_id_'.$mapid};
+    my $res=$hash{'src_'.$id};
+    my $symb=&Apache::lonnet::encode_symb($map,$resid,$res);
+    return $symb;
+}
+
 sub course_search {
     my $r=shift;
     my $bodytag=&Apache::loncommon::bodytag('Course Search');
@@ -471,16 +479,18 @@
 	      $bodytag.'<hr /><center><font size="+2" face="arial">'.$pretty_search_string.'</font></center><hr /><b>'.&mt('Course content').':</b><br />');
     $r->rflush();
 # ======================================================= Go through the course
-    undef %alreadyseen;
-    %alreadyseen=();
     my $c=$r->connection;
     if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
             &GDBM_READER(),0640)) {
-        foreach (keys %hash) {
+        foreach (sort(keys(%hash))) {
             if ($c->aborted()) { last; }
-            if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
-                &checkonthis($r,$hash{$_},0,$hash{'title_'.$1},$fulltext,
-                             @allwords);
+            if (($_=~/^src\_(.+)$/)) {
+		if ($hash{'randomout_'.$1} & !$ENV{'request.role.adv'}) {
+		    next; 
+		}
+		my $symb=&make_symb($1);
+                &checkonthis($r,$1,$hash{$_},0,&Apache::lonnet::gettitle($symb),
+			     $fulltext,$symb,@allwords);
             }
         }
         untie(%hash);
@@ -570,15 +580,20 @@
 # =============================== This pulls up a resource and its dependencies
 
 sub checkonthis {
-    my ($r,$url,$level,$title,$fulltext,@allwords)=@_;
-    $alreadyseen{$url}=1;
+    my ($r,$id,$url,$level,$title,$fulltext,$symb,@allwords)=@_;
     $r->rflush();
-    my $result=&Apache::lonnet::metadata($url,'title').' '.
-               &Apache::lonnet::metadata($url,'subject').' '.
-               &Apache::lonnet::metadata($url,'abstract').' '.
-               &Apache::lonnet::metadata($url,'keywords');
-    if (($url) && ($fulltext)) {
-	$result.=&Apache::lonnet::ssi_body($url);
+    
+    my $result=$title.' ';
+    if ($ENV{'request.role.adv'} || !$hash{'encrypted_'.$id}) {
+	$result.=&Apache::lonnet::metadata($url,'title').' '.
+	    &Apache::lonnet::metadata($url,'subject').' '.
+	    &Apache::lonnet::metadata($url,'abstract').' '.
+	    &Apache::lonnet::metadata($url,'keywords');
+    }
+    my ($extension)=($url=~/\.(\w+)$/);
+    if (&Apache::loncommon::fileembstyle($extension) eq 'ssi' &&
+	($url) && ($fulltext)) {
+	$result.=&Apache::lonnet::ssi_body($url.'?symb='.&Apache::lonnet::escape($symb));
     }
     $result=~s/\s+/ /gs;
     my $applies = 0;
@@ -589,8 +604,15 @@
        for (my $i=0;$i<=$level*5;$i++) {
            $r->print('&nbsp;');
        }
-       $r->print('<a href="'.$url.'" target="cat">'.
-		 ($title?$title:$url).'</a><br />');
+       my $href=$url;
+       if ($hash{'encrypted_'.$id} && !$ENV{'request.role.adv'}) {
+	   $href=&Apache::lonenc::encrypted($href)
+	       .'?symb='.&Apache::lonenc::encrypted($symb);
+       } else {
+	   $href.='?symb='.&Apache::lonnet::escape($symb);
+       }
+       $r->print('<a href="'.$href.'" target="cat">'.($title?$title:$url).
+		 '</a><br />');
        $totalfound++;
     } elsif ($fulltext) {
        $r->print(' .');
@@ -600,8 +622,8 @@
     my $dependencies=
                 &Apache::lonnet::metadata($url,'dependencies');
     foreach (split(/\,/,$dependencies)) {
-       if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
-          &checkonthis($r,$_,$level+1,'',$fulltext,@allwords);
+       if (($_=~/^\/res\//)) {
+          &checkonthis($r,$id,$_,$level+1,'',$fulltext,undef,@allwords);
        }
     }
 }