Annotation of loncom/interface/lonchatfetch.pm, revision 1.2

1.1       www         1: # The LearningOnline Network
                      2: # Chat Fetching
                      3: #
1.2     ! www         4: # $Id: lonchatfetch.pm,v 1.1 2002/08/08 13:44:17 www Exp $
1.1       www         5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
                     29: package Apache::lonchatfetch;
                     30: 
                     31: use strict;
                     32: use Apache::Constants qw(:common);
                     33: use Apache::lontexconvert;
                     34: 
                     35: sub handler {
                     36:     my $r = shift;
                     37:     $r->content_type('text/html');
                     38:     $r->send_http_header;
                     39:     return OK if $r->header_only;
                     40: 
                     41: # ------------------------------------------------------------ retrieve entries
                     42: 
                     43:     my $cnum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
                     44:     my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
                     45:     my $chome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'};
                     46:     my @entries=split(/\:/,
                     47:                        &Apache::lonnet::reply("chatretr:$cdom:$cnum",$chome));
                     48:     my ($lastid)=($entries[$#entries]=~/^(\w+)/);
                     49:     my ($thentime,$idnum)=split(/\_/,$lastid);
                     50: # -------------------------------------------------------- see which ones apply
                     51:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['lastid']);
                     52:     my $include=0;
                     53:     my $newstuff='';
1.2     ! www        54:     unless ($ENV{'form.lastid'}) { 
        !            55:        $include=1; 
        !            56:        $newstuff='<html><body bgcolor="#FFFFFF">';
        !            57:     }
1.1       www        58:     foreach (@entries) {
                     59: 	if ($include) {
                     60:             my ($id,$msg)=split(/\:/,&Apache::lonnet::unescape($_));
                     61:             chomp($msg);
                     62:             my ($msgtime,$msgnum)=split(/\_/,$id);
                     63:             my ($sdom,$snum,$anon,$contrib)=split(/\:/,
                     64:                                               &Apache::lonnet::unescape($msg));
                     65:             $contrib=&Apache::lonnet::unescape($contrib);
                     66:             $contrib=~s/\n/\<br \/\>/g;
                     67: 	    $contrib=&Apache::lontexconvert::msgtexconverted($contrib);
                     68:             $contrib=~s/\n/ /g;
                     69:             $contrib=~s/\'/\&\#39\;/g;
                     70:             my $sender=$snum.' at '.$sdom;
                     71:             if ($anon) {
                     72:             }
1.2     ! www        73: 	    $newstuff.='<a name="'.$id.'"><b>'.
        !            74:                        $sender.'</b> ('.localtime($msgtime).'): '.
1.1       www        75:                        $contrib."<br>";
                     76:         } else {
                     77:             $_=~/^(\w+)/;
                     78:             if ($1 eq $ENV{'form.lastid'}) { $include=1; }
                     79:         }
                     80:     }
                     81:     $r->print(<<ENDDOCUMENT);
                     82: <html>
                     83: <head>
                     84: <title>The LearningOnline Network with CAPA</title>
                     85:   <meta HTTP-EQUIV="Refresh" CONTENT="5; url=/adm/chatfetch?lastid=$lastid">
                     86: </head>
                     87: <body bgcolor="#FFFFFF">
                     88: <script>
                     89: parent.chatout.document.writeln('$newstuff');
                     90: </script>
                     91: </body>
                     92: </html>
                     93: ENDDOCUMENT
                     94:     return OK;
                     95: } 
                     96: 
                     97: 1;
                     98: __END__

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