--- loncom/interface/lonmsg.pm 2004/09/28 14:12:40 1.109
+++ loncom/interface/lonmsg.pm 2005/01/01 18:36:13 1.128
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.109 2004/09/28 14:12:40 matthew Exp $
+# $Id: lonmsg.pm,v 1.128 2005/01/01 18:36:13 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -523,20 +523,31 @@ 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')).
+ ' '.&mt('Show').
+ ''.
' '.
+ ''.
+ ($folder=~/^(new|critical)/?'':'');
+}
+
+sub scrollbuttons {
+ my ($start,$maxdis,$first,$finish,$total)=@_;
+ unless ($total>0) { return ''; }
+ $start++; $maxdis++;$first++;$finish++;
+ return
''.
''.
- ''.
+ ' of '.$maxdis.
''.
- ''.
- ''.
- &mt('View Critical Messages').''.
- '';
+ ' '.
+ &mt('Messages [_1] through [_2] of [_3]',$first,$finish,$total).'';
}
# =============================================================== Folder suffix
@@ -568,6 +579,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});
}
@@ -575,7 +590,6 @@ sub makefolder {
sub movemsg {
my ($msgid,$srcfolder,$trgfolder)=@_;
- my $unmsgid=&Apache::lonnet::unescape($msgid);
my $srcsuffix=&foldersuffix($srcfolder);
my $trgsuffix=&foldersuffix($trgfolder);
@@ -584,16 +598,13 @@ sub movemsg {
&Apache::lonnet::put('nohist_email'.$trgsuffix,{$msgid => $message{$msgid}});
# Copy status
- my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$unmsgid]);
- &Apache::lonnet::put('email_status'.$trgsuffix,{$unmsgid => $status{$unmsgid}});
-# See if was deleted -> becomes "read" in trash
- my $currentstatus=(&unpackmsgid($status{$unmsgid}),$srcfolder);
- if ($currentstatus eq 'deleted') {
- &statuschange($msgid,'read',$trgfolder);
+ unless ($trgfolder eq 'trash') {
+ my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$msgid]);
+ &Apache::lonnet::put('email_status'.$trgsuffix,{$msgid => $status{$msgid}});
}
# Delete orginals
&Apache::lonnet::del('nohist_email'.$srcsuffix,[$msgid]);
- &Apache::lonnet::del('email_status'.$srcsuffix,[$unmsgid]);
+ &Apache::lonnet::del('email_status'.$srcsuffix,[$msgid]);
}
# ======================================================= Display a course list
@@ -655,7 +666,7 @@ ENDDISHEADER
'
('.$_.'),
'.$role.'
');
}
}
- $r->print('
');
+ $r->print('
');
while (my ($student,$info) = each(%$classlist)) {
my ($sname,$sdom,$status,$fullname,$section) =
(@{$info}[&Apache::loncoursedata::CL_SNAME(),
@@ -663,7 +674,7 @@ ENDDISHEADER
&Apache::loncoursedata::CL_STATUS(),
&Apache::loncoursedata::CL_FULLNAME(),
&Apache::loncoursedata::CL_SECTION()]);
- # next if ($status ne 'Active');
+ next if ($status ne 'Active');
my $key = 'send_to_&&&'.$section.'&&&'.$student;
if (! defined($fullname) || $fullname eq '') { $fullname = $sname; }
$r->print('
'.$sname.'@'.$sdom.'
'.$section.
'
');
}
- $r->print('
');
+ $r->print('');
}
# ==================================================== Display Critical Message
@@ -686,7 +697,6 @@ sub discrit {
foreach (sort keys %what) {
my %content=&unpackagemsg($what{$_});
next if ($content{'senderdomain'} eq '');
- $content{'message'}=~s/\n/\ /g;
$result.=''.&mt('From').': '.
&Apache::loncommon::aboutmewrapper(
&Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('.
@@ -770,10 +780,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");
+