version 1.7, 2001/12/19 17:17:46
|
version 1.17, 2003/10/04 20:49:40
|
Line 41 package Apache::loncommunicate;
|
Line 41 package Apache::loncommunicate;
|
use strict; |
use strict; |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::lonmsg(); |
use Apache::lonmsg(); |
|
use Apache::loncommon; |
|
use Apache::lonlocal; |
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
$r->content_type('text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
return OK if $r->header_only; |
return OK if $r->header_only; |
# |
# |
# Start document |
# Start document |
# |
# |
$r->print(<<ENDDOCUMENT); |
$r->print(<<END); |
<html> |
<html> |
<head> |
<head> |
<title>The LearningOnline Network with CAPA</title> |
<title>The LearningOnline Network with CAPA</title> |
</head> |
</head> |
<body bgcolor="#FFFFFF"> |
END |
<img align=right src=/adm/lonIcons/lonlogos.gif> |
my %lt=&Apache::lonlocal::texthash( |
<h1>Communicate</h1> |
'vam' => 'View All Messages', |
ENDDOCUMENT |
'vcm' => 'View Critical Messages', |
my $st='<table><tr><td bgcolor="#FFFFAA"><b>'; |
'smu' => 'Send Message to User(s)', |
my $en='</b></td><tr></table>'; |
'bmc' => 'Broadcast Message to Course', |
$r->print('<p>'. |
'dmu' => 'Distribute Messages from Uploaded File to Course', |
$st.'<a href="/adm/email/">All Messages</a>'.$en.'<p>'. |
'unr' => |
$st.'<a href="/adm/email?critical=display">Critical Messages</a>'.$en.'<p>'. |
'User Notes, Records of Face-to-Face Discussions, and Critical Messages', |
$st.'<a href="/adm/email?compose=individual">Send message to user(s)</a>'.$en |
'nm' => 'New Messages', |
); |
'su' => 'Subject', |
|
'da' => 'Date', |
|
'us' => 'Username', |
|
'op' => 'Open', |
|
'do' => 'Domain' |
|
); |
|
|
|
$r->print(&Apache::loncommon::bodytag("Communication and Messages")); |
|
$r->print(<<END); |
|
<table cellspacing="10" cellpadding="2"> |
|
<tr><td bgcolor="#FFFFAA"> |
|
<b><a href="/adm/email/">$lt{'vam'}</a></b> |
|
</td></tr> |
|
<tr><td bgcolor="#FFFFAA"> |
|
<b><a href="/adm/email?critical=display">$lt{'vcm'}</a></b> |
|
</td></tr> |
|
<tr><td bgcolor="#FFFFAA"> |
|
<b><a href="/adm/email?compose=individual">$lt{'smu'}</a></b> |
|
</td></tr> |
|
END |
if (($ENV{'request.course.id'}) && |
if (($ENV{'request.course.id'}) && |
(&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { |
(&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { |
$r->print( |
$r->print(<<END); |
'<p>'.$st. |
<tr><td bgcolor="#FFFFAA"> |
'<a href="/adm/email?compose=group">Broadcast message to course</a>'.$en. |
<b><a href="/adm/email?compose=group">$lt{'bmc'}</a></b> |
'<p>'.$st. |
</td></tr> |
'<a href="/adm/email?compose=upload">Upload messages to course</a>'.$en); |
<tr><td bgcolor="#FFFFAA"> |
|
<b><a href="/adm/email?compose=upload">$lt{'dmu'}</a></b> |
|
</td></tr> |
|
<tr><td bgcolor="#FFFFAA"> |
|
<b><a href="/adm/email?recordftf=query">$lt{'unr'}</a></b> |
|
</td></tr> |
|
|
|
END |
} |
} |
$r->print(<<ENDTABLE); |
$r->print('</table>'); |
<h3>New Messages</h3> |
my @msgids = sort split(/\&/,&Apache::lonnet::reply |
<table border=2><tr><th> </th> |
('keys:'.$ENV{'user.domain'}.':'. |
<th>Date</th><th>Username</th><th>Domain</th><th>Subject</th></tr> |
$ENV{'user.name'}.':nohist_email', |
ENDTABLE |
$ENV{'user.home'})); |
map { |
my @newmsgs; |
my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)= |
foreach (@msgids) { |
|
my ($sendtime,$shortsubj,$fromname,$fromdom,$status)= |
&Apache::lonmsg::unpackmsgid($_); |
&Apache::lonmsg::unpackmsgid($_); |
|
if (defined($sendtime) && $sendtime!~/error/) { |
|
$sendtime = &Apache::lonlocal::locallocaltime($sendtime); |
if ($status eq 'new') { |
if ($status eq 'new') { |
$r->print( |
push @newmsgs, { |
'<tr bgcolor="#FFBB77"><td><a href="/adm/email?display='.$_. |
msgid => $_, |
'">Open</a></td><td>'.localtime($sendtime).'</td><td>'. |
sendtime => $sendtime, |
$fromname.'</td><td>'.$fromdomain.'</td><td>'. |
shortsub => &Apache::lonnet::unescape($shortsubj), |
&Apache::lonnet::unescape($shortsubj).'</td></tr>'); |
from => $fromname, |
|
fromdom => $fromdom |
|
} |
} |
} |
} sort split(/\&/,&Apache::lonnet::reply('keys:'. |
} |
$ENV{'user.domain'}.':'. |
} |
$ENV{'user.name'}.':nohist_email', |
if ($#newmsgs >= 0) { |
$ENV{'user.home'})); |
$r->print(<<TABLEHEAD); |
$r->print('</table></body></html>'); |
<h3>$lt{'nm'}</h3> |
|
<table border=2><tr><th> </th> |
|
<th>$lt{'da'}</th><th>$lt{'us'}</th><th>$lt{'do'}</th><th>$lt{'su'}</th></tr> |
|
TABLEHEAD |
|
foreach my $msg (@newmsgs) { |
|
$r->print(<<"ENDLINK"); |
|
<tr bgcolor="#FFBB77"> |
|
<td><a href="/adm/email?display=$msg->{'msgid'}">$lt{'op'}</a></td> |
|
ENDLINK |
|
foreach ('sendtime','from','fromdom','shortsub') { |
|
$r->print("<td>$msg->{$_}</td>"); |
|
} |
|
$r->print("</td></tr>"); |
|
} |
|
$r->print('</table></body></html>'); |
|
} else { |
|
$r->print("<h3>".&mt('You have no unread messages')."</h3>"); |
|
} |
return OK; |
return OK; |
} |
} |
|
|