Diff for /loncom/interface/lonchatfetch.pm between versions 1.8 and 1.13

version 1.8, 2003/03/28 23:16:25 version 1.13, 2004/06/27 17:14:28
Line 29 Line 29
 package Apache::lonchatfetch;  package Apache::lonchatfetch;
   
 use strict;  use strict;
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common :http);
 use Apache::lontexconvert;  use Apache::lontexconvert;
 use Apache::loncommon;  use Apache::loncommon;
 use Apache::lonnet;  use Apache::lonnet;
Line 37  use Apache::lonnet; Line 37  use Apache::lonnet;
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
   
       if (! &Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
                ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))
           ) {
           return HTTP_NOT_ACCEPTABLE;
       }
   
     my $loaderror=&Apache::lonnet::overloaderror($r);      my $loaderror=&Apache::lonnet::overloaderror($r);
     if ($loaderror) { return $loaderror; }      if ($loaderror) { return $loaderror; }
     $loaderror=      $loaderror=
Line 57  sub handler { Line 63  sub handler {
     my @entries=split(/\:/,      my @entries=split(/\:/,
        &Apache::lonnet::reply(         &Apache::lonnet::reply(
         "chatretr:$cdom:$cnum:$ENV{'user.domain'}:$ENV{'user.name'}",$chome));          "chatretr:$cdom:$cnum:$ENV{'user.domain'}:$ENV{'user.name'}",$chome));
     my ($lastid)=($entries[$#entries]=~/^(\w+)/);  # Figure out what the last valid entry-id is
     my ($thentime,$idnum)=split(/\_/,$lastid);      my ($lastid,$thentime,$idnum);
       foreach (@entries) {
    $_=~/^(\w+)/;
           if ($1 ne 'active_participant') {
       $lastid=$1;
               ($thentime,$idnum)=split(/\_/,$lastid);
    }
       }
 # ----------------------------------------------------------- Can see identity?  # ----------------------------------------------------------- Can see identity?
     my $crs='/'.$ENV{'request.course.id'};      my $crs='/'.$ENV{'request.course.id'};
     if ($ENV{'request.course.sec'}) {      if ($ENV{'request.course.sec'}) {
Line 75  sub handler { Line 88  sub handler {
        $include=1;          $include=1; 
        $newstuff='<html><body bgcolor="#FFFFFF">';         $newstuff='<html><body bgcolor="#FFFFFF">';
     }      }
       my @participants=();
     foreach (@entries) {      foreach (@entries) {
  if ($include) {   my ($id,$msg,$udom)=split(/\:/,&Apache::lonnet::unescape($_));
     my ($id,$msg,$uname)=split(/\:/,&Apache::lonnet::unescape($_));    if ($id eq 'active_participant') {
     if ($id eq 'active_participant') {             chomp($udom);
 # $newstuff.='participant: '.$msg.' '.$uname;     $participants[$#participants+1]=
     } else {             &Apache::loncommon::nickname($msg,$udom);
  chomp($msg);   } elsif ($include) {
  my ($msgtime,$msgnum)=split(/\_/,$id);      chomp($msg);
  my ($sdom,$snum,$anon,$contrib)=split(/\:/,      my ($msgtime,$msgnum)=split(/\_/,$id);
                                               &Apache::lonnet::unescape($msg));      my ($sdom,$snum,$anon,$contrib)=split(/\:/,
  $contrib=&Apache::lonnet::unescape($contrib);       &Apache::lonnet::unescape($msg));
  $contrib=~s/\n/\<br \/\>/g;      $contrib=&Apache::lonnet::unescape($contrib);
  $contrib=&Apache::lontexconvert::msgtexconverted($contrib);      $contrib=~s/\n/\<br \/\>/g;
  $contrib=~s/\n/ /g;      ($contrib,my $errors)=&Apache::lontexconvert::msgtexconverted($contrib);
  $contrib=~s/\'/\&\#39\;/g;      if ($errors) { $contrib.="[Message not fully displayed due to incorrect embedded TeX]"; }
  my $sender='';      if ($errors && $snum eq $ENV{'user.name'} &&
  if ($seeid) {   $sdom eq $ENV{'user.domain'} ) {
     $sender=&Apache::loncommon::plainname($snum,$sdom);   $contrib.="<br />[TeX error message: $errors]";
     my $nick=&Apache::loncommon::nickname($snum,$sdom);      }
     if (($nick) && ($nick ne $sender)) {      $contrib=~s/\n/ /g;
  $sender.=' '.$nick;      $contrib=~s/\'/\&\#39\;/g;
     }      my $sender='';
     if ($anon) { $sender.=' [Anon]' };      if ($seeid) {
  } elsif (!$anon) {   $sender=&Apache::loncommon::plainname($snum,$sdom);
     $sender=&Apache::loncommon::nickname($snum,$sdom);   my $nick=&Apache::loncommon::nickname($snum,$sdom);
  } else {   if (($nick) && ($nick ne $sender)) {
     $sender=&Apache::loncommon::screenname($snum,$sdom);      $sender.=' '.$nick;
     unless ($sender) { $sender="Anonymous"; }  
  }   }
  $sender=~s/\'/\"/g;   if ($anon) { $sender.=' [Anon]' };
  my $color=$sender;      } elsif (!$anon) {
  $color=~tr/a-j/0-9/;   $sender=&Apache::loncommon::nickname($snum,$sdom);
  $color=~tr/A-J/0-9/;      } else {
  $color=~tr/k-t/0-9/;   $sender=&Apache::loncommon::screenname($snum,$sdom);
  $color=~tr/K-T/0-9/;   unless ($sender) { $sender="Anonymous"; }
  $color=~tr/u-z/0-5/;  
  $color=~tr/U-Z/0-5/;  
  $color=~s/\D//g;  
  $color=substr($color,0,6);  
  my $timestamp=localtime($msgtime);  
  my ($mhour,$mmin,$msec)=($timestamp=~/(\d\d)\:(\d\d)\:(\d\d)/);  
  $newstuff.='<font color="#'.$color.'"><a name="'.$id.'"><b>'.  
     $sender.'</b> ('.$mhour.':'.$mmin.':'.$msec.'): '.  
     $contrib."</font><br>";  
  $bottomid=$id;  
     }      }
         } else {      $sender=~s/\'/\&\#39\;/g;
             $_=~/^(\w+)/;      my $color=$sender;
             if ($1 eq $ENV{'form.lastid'}) { $include=1; }      $color=~tr/a-j/0-9/;
         }      $color=~tr/A-J/0-9/;
       $color=~tr/k-t/0-9/;
       $color=~tr/K-T/0-9/;
       $color=~tr/u-z/0-5/;
       $color=~tr/U-Z/0-5/;
       $color=~s/\D//g;
       $color=substr($color,0,6);
       my $timestamp=localtime($msgtime);
       my ($mhour,$mmin,$msec)=($timestamp=~/(\d\d)\:(\d\d)\:(\d\d)/);
       $newstuff.='<font color="#'.$color.'"><a name="'.$id.'"><b>'.
    $sender.'</b> ('.$mhour.':'.$mmin.':'.$msec.'): '.
    $contrib."</font><br>";
       $bottomid=$id;
    } else {
       $_=~/^(\w+)/;
       if ($1 eq $ENV{'form.lastid'}) { $include=1; }
    }
     }      }
       my $participant_output=join('<br />',sort @participants);
     $r->print(<<ENDDOCUMENT);      $r->print(<<ENDDOCUMENT);
 <html>  <html>
 <head>  <head>
Line 137  sub handler { Line 157  sub handler {
 parent.chatout.document.writeln('$newstuff');  parent.chatout.document.writeln('$newstuff');
 parent.chatout.scroll(0,10000000);  parent.chatout.scroll(0,10000000);
 </script>  </script>
   $participant_output
 </body>  </body>
 </html>  </html>
 ENDDOCUMENT  ENDDOCUMENT

Removed from v.1.8  
changed lines
  Added in v.1.13


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>