--- loncom/interface/lonmsg.pm 2004/10/26 19:50:15 1.111
+++ loncom/interface/lonmsg.pm 2004/11/13 14:45:57 1.117
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.111 2004/10/26 19:50:15 www Exp $
+# $Id: lonmsg.pm,v 1.117 2004/11/13 14:45:57 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -523,19 +523,20 @@ sub folderlist {
&mt('Folder').': '.
&Apache::loncommon::select_form($folder,'folder',
('' => &mt('INBOX'),'trash' => &mt('TRASH'),
+ 'new' => &mt('New Messages Only'),
+ 'critical' => &mt('Critical'),
'sent' => &mt('Sent Messages'),
map { $_ => $_ } @allfolders)).
' '.&mt('Show').' '.
&Apache::loncommon::select_form($interdis,'interdis',
(' 10' => '10', ' 20' => '20', ' 50' => '50', '100' => '100', '200' => '200')).
'
'.
+ ($folder!~/^(new|critical)/?
''.
''.
- ''.
+ ''.
''.
- ''.
- ''.
- &mt('View Critical Messages').''.
+ '':'').
'';
}
@@ -568,6 +569,10 @@ sub statuschange {
sub makefolder {
my ($newfolder)=@_;
+ if (($newfolder eq 'sent')
+ || ($newfolder eq 'critical')
+ || ($newfolder eq 'trash')
+ || ($newfolder eq 'new')) { return; }
&Apache::lonnet::put('email_folders',{$newfolder => time});
}
@@ -770,10 +775,108 @@ sub sortedmessages {
return @temp;
}
+# ======================================================== Display new messages
+
+
+sub disnew {
+ my $r=shift;
+ my %lt=&Apache::lonlocal::texthash(
+ 'nm' => 'New Messages',
+ 'su' => 'Subject',
+ 'da' => 'Date',
+ 'us' => 'Username',
+ 'op' => 'Open',
+ 'do' => 'Domain'
+ );
+ my @msgids = sort split(/\&/,&Apache::lonnet::reply
+ ('keys:'.$ENV{'user.domain'}.':'.
+ $ENV{'user.name'}.':nohist_email',
+ $ENV{'user.home'}));
+ my @newmsgs;
+ my %setters = ();
+ my $startblock = 0;
+ my $endblock = 0;
+ my %blocked = ();
+ my $numblocked = 0;
+ # Check for blocking of display because of scheduled online exams.
+ &blockcheck(\%setters,\$startblock,\$endblock);
+ foreach (@msgids) {
+ my ($sendtime,$shortsubj,$fromname,$fromdom,$status)=
+ &Apache::lonmsg::unpackmsgid($_);
+ if (defined($sendtime) && $sendtime!~/error/) {
+ my $numsendtime = $sendtime;
+ $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
+ if ($status eq 'new') {
+ if ($numsendtime >= $startblock && ($numsendtime <= $endblock && $endblock > 0) ) {
+ $blocked{$_} = 'ON';
+ $numblocked ++;
+ } else {
+ push @newmsgs, {
+ msgid => $_,
+ sendtime => $sendtime,
+ shortsub => &Apache::lonnet::unescape($shortsubj),
+ from => $fromname,
+ fromdom => $fromdom
+ }
+ }
+ }
+ }
+ }
+ if ($#newmsgs >= 0) {
+ $r->print(<$lt{'nm'}
+  |
+$lt{'da'} | $lt{'us'} | $lt{'do'} | $lt{'su'} |
+TABLEHEAD
+ foreach my $msg (@newmsgs) {
+ $r->print(<<"ENDLINK");
+
+$lt{'op'} |
+ENDLINK
+ foreach ('sendtime','from','fromdom','shortsub') {
+ $r->print("$msg->{$_} | ");
+ }
+ $r->print("
");
+ }
+ $r->print('