--- loncom/xml/lonxml.pm	2001/08/10 15:49:46	1.109
+++ loncom/xml/lonxml.pm	2001/08/15 15:49:14	1.114
@@ -13,7 +13,7 @@
 # 6/12,6/13 H. K. Ng
 # 6/16 Gerd Kortemeyer
 # 7/27 H. K. Ng
-# 8/7,8/9,8/10 Gerd Kortemeyer
+# 8/7,8/9,8/10,8/11,8/15 Gerd Kortemeyer
 
 package Apache::lonxml; 
 use vars 
@@ -113,20 +113,37 @@ sub xmlend {
                   '<address><hr /><h2>Course Discussion of Resource</h2>';
               my $idx;
               for ($idx=1;$idx<=$contrib{'version'};$idx++) {
-                  my $message=$contrib{$idx.':message'};
-                  $message=~s/\n/\<br \/\>/g;
+		my $hidden=($contrib{'hidden'}=~/\.$idx\./);
+		unless (($hidden) && (!$seeid)) {
+                 my $message=$contrib{$idx.':message'};
+                 $message=~s/\n/\<br \/\>/g;
+                 if ($message) {
+                  if ($hidden) {
+		      $message='<font color="#888888">'.$message.'</font>';
+                  }
                   my $sender='Anonymous';
                   if ((!$contrib{$idx.':anonymous'}) || ($seeid)) {
                       $sender=$contrib{$idx.':sendername'}.' at '.
 		      $contrib{$idx.':senderdomain'};
                       if ($contrib{$idx.':anonymous'}) {
 			  $sender.=' (anonymous)';
+                      }
+                      if ($seeid) {
+			  if ($hidden) {
+                             $sender.=' <a href="/adm/feedback?unhide='.
+				 $symb.':::'.$idx.'">Make Visible</a>';
+                          } else {
+                             $sender.=' <a href="/adm/feedback?hide='.
+				 $symb.':::'.$idx.'">Hide</a>';
+			  }
                       }                   
                   }
 		  $discussion.='<p><b>'.$sender.'</b> ('.
                       localtime($contrib{$idx.':timestamp'}).
                       '):<blockquote>'.$message.
-                      '</blockquote></p>'; 
+                      '</blockquote></p>';
+	        }
+               } 
               }
               $discussion.='</address>';
           }
@@ -135,6 +152,65 @@ sub xmlend {
     return $discussion.'</html>';
 }
 
+sub checkout {
+    my ($target,$symb,$tuname,$tudom,$tcrsid)=@_;
+    unless ($symb) {
+	$symb=&Apache::lonnet::symbread();
+    }
+    unless ($tuname) {
+	$tuname=$ENV{'user.name'};
+        $tudom=$ENV{'user.domain'};
+        $tcrsid=$ENV{'request.course.id'};
+    }
+    my $now=time;
+    my $lonhost = $Apache::lonnet::perlvar{'lonHostID'};
+    my $infostr=&Apache::lonnet::escape(
+                 $tuname.'&'.
+                 $tudom.'&'.
+                 $tcrsid.'&'.
+                 $symb.'&'.
+		 $now.'&'.$ENV{'REMOTE_ADDR'});
+    my $token=Apache::lonnet::reply('tmpput:'.$infostr,$lonhost);
+    if ($token=~/^error\:/) { return ''; }
+    $token=~s/^(\d+)\_.*\_(\d+)$/$1\*$2\*$lonhost/;
+    $token=~tr/a-z/A-Z/;
+
+    my %infohash=('token' => $token,
+                  'checktime' => $now,
+                  'remote' => $ENV{'REMOTE_ADDR'});
+
+    unless (
+  &Apache::lonnet::cstore(\%infohash,$symb,$tcrsid,$tudom,$tuname) eq 'ok') {
+       return '';
+    }    
+
+    if (&Apache::lonnet::log($tudom,$tuname,
+                         &Apache::lonnet::homeserver($tuname,$tudom),
+                         &Apache::lonnet::escape('Checkout '.$infostr.' - '.
+                                                 $token)) ne 'ok') {
+	return '';
+    }
+
+    my %reply=&Apache::lonnet::get('environment',
+              ['firstname','middlename','lastname','generation'],
+              $tudom,$tuname);
+    my $plainname=$reply{'firstname'}.' '. 
+                  $reply{'middlename'}.' '.
+                  $reply{'lastname'}.' '.
+		  $reply{'generation'};
+
+    if ($target eq 'web') {
+	return 'Checked out for '.$plainname.
+               '<br />User: '.$tuname.' at '.$tudom.
+	       '<br />CourseID: '.$tcrsid.')'.
+               '<br />DocID: '.$token.
+               '<br />Time: '.localtime($now).
+ '<img align="right" src="/cgi-bin/barcode.gif?encode='.$token.'" /><hr />';
+    } else {
+        return $token;                         
+    }
+}
+
 sub fontsettings() {
     my $headerstring='';
     if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) { 
@@ -308,8 +384,8 @@ sub htmlclean {
 
     my $output= $tree->as_HTML(undef,' ');
      
-    $output=~s/\<(br|hr|img)([^\>\/]*)\>/\<$1$2 \/\>/gis;
-    $output=~s/\<\/(br|hr|img)\>//gis;
+    $output=~s/\<(br|hr|img|meta|allow)([^\>\/]*)\>/\<$1$2 \/\>/gis;
+    $output=~s/\<\/(br|hr|img|meta|allow)\>//gis;
     unless ($full) {
        $output=~s/\<[\/]*(body|head|html)\>//gis;
     }
@@ -760,6 +836,9 @@ sub parstring {
 
 sub writeallows {
     my $thisurl='/res/'.&Apache::lonnet::declutter(shift);
+    if ($ENV{'httpref.'.$thisurl}) {
+	$thisurl=$ENV{'httpref.'.$thisurl};
+    }
     my $thisdir=$thisurl;
     $thisdir=~s/\/[^\/]+$//;
     my %httpref=();