--- loncom/xml/lonxml.pm	2001/08/11 20:16:10	1.111
+++ loncom/xml/lonxml.pm	2001/08/15 14:03:03	1.112
@@ -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,8/11 Gerd Kortemeyer
+# 8/7,8/9,8/10,8/11,8/15 Gerd Kortemeyer
 
 package Apache::lonxml; 
 use vars 
@@ -152,6 +152,39 @@ 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 $lonhost = $Apache::lonnet::perlvar{'lonHostID'};
+    my $infostr=&Apache::lonnet::escape(
+                 $tuname.'&'.
+                 $tudom.'&'.
+                 $tcrsid.'&'.
+                 $symb.'&'.
+		 time.'&'.$ENV{'REMOTE_ADDR'});
+    my $token=Apache::lonnet::reply('tmpput:'.$infostr,$lonhost);
+    if ($token=~/^error\:/) { return ''; }
+    $token=~s/^(\d+)\_.*\_(\d+)$/$1\_$2\_$lonhost/;
+    if (&Apache::lonnet::log($tudom,$tuname,
+                         &Apache::lonnet::homeserver($tuname,$tudom),
+                         &Apache::lonnet::escape('Checkout '.$infostr.' - '.
+                                                 $token)) ne 'ok') {
+	return '';
+    }
+    if ($target eq 'web') {
+	return '<img src="/cgi-bin/barcode.gif?encode='.$token.'" />';
+    } else {
+        return $token;                         
+    }
+}
+
 sub fontsettings() {
     my $headerstring='';
     if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) {