--- loncom/interface/lonmsg.pm 2003/08/18 17:37:42 1.64
+++ loncom/interface/lonmsg.pm 2003/10/15 21:10:24 1.69
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.64 2003/08/18 17:37:42 www Exp $
+# $Id: lonmsg.pm,v 1.69 2003/10/15 21:10:24 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -115,6 +115,10 @@ use Apache::loncommon();
use Apache::lontexconvert();
use HTML::Entities();
use Mail::Send;
+use Apache::lonlocal;
+
+# Querystring component with sorting type
+my $sqs;
# ===================================================================== Package
@@ -140,7 +144,7 @@ sub packagemsg {
my $result='
Attachment: '.$fname.'.'.$ft.''; + $content{'message'}.='
'.&mt('Attachment').': '.$fname.'.'.$ft.''; } else { - $content{'message'}.='
Attachment: '.$fname.'.'.$ft.'';
}
@@ -209,14 +213,15 @@ sub unpackmsgid {
sub sendemail {
my ($to,$subject,$body)=@_;
$body=
- "*** This is an automatic message generated by the LON-CAPA system.\n".
- "*** Please do not reply to this address.\n\n".$body;
+ "*** ".&mt('This is an automatic message generated by the LON-CAPA system.')."\n".
+ "*** ".&mt('Please do not reply to this address.')."\n\n".$body;
my $msg = new Mail::Send;
$msg->to($to);
$msg->subject('[LON-CAPA] '.$subject);
- my $fh = $msg->open('smtp',Server => 'localhost');
- print $fh $body;
- $fh->close;
+ if (my $fh = $msg->open('smtp',Server => 'localhost')) {
+ print $fh $body;
+ $fh->close;
+ }
}
# ==================================================== Send notification emails
@@ -359,10 +364,10 @@ sub user_crit_received {
my %contents=&unpackagemsg($message{$msgid},1);
my $status='rec: '.($contents{'sendback'}?
&user_normal_msg($contents{'sendername'},$contents{'senderdomain'},
- 'Receipt: '.$ENV{'user.name'}.' at '.$ENV{'user.domain'},
- 'User '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+ &mt('Receipt').': '.$ENV{'user.name'}.' at '.$ENV{'user.domain'},
+ &mt('User').' '.$ENV{'user.name'}.' '.&mt('at').' '.$ENV{'user.domain'}.
' acknowledged receipt of message'."\n".' "'.
- $contents{'subject'}.'"'."\n".'dated '.
+ $contents{'subject'}.'"'."\n".&mt('dated').' '.
$contents{'time'}.".\n"
):'no msg req');
$status.=' trans: '.
@@ -466,6 +471,9 @@ sub discourse {
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
$ENV{'course.'.$ENV{'request.course.id'}.'.num'});
my $now=time;
+ my %lt=&Apache::lonlocal::texthash('cfa' => 'Check for All',
+ 'cfs' => 'Check for Section/Group',
+ 'cfn' => 'Check for None');
$r->print(<
ENDDISHEADER
my %coursepersonnel=
@@ -542,7 +550,7 @@ ENDDISHEADER
sub discrit {
my $r=shift;
- my $header = ' '.
- 'Check All '.
- 'Uncheck All '.
- ''.
+ ''.&mt('Check All').' '.
+ ''.&mt('Uncheck All').' '.
+ ''.
+ ''.
'Critical Messages
'.
+ my $header = ''.&mt('Critical Messages').'
'.
'
ENDREPLY
}
+sub sortedmessages {
+ my @messages = &Apache::lonnet::getkeys('nohist_email');
+ #unpack the varibles and repack into temp for sorting
+ my @temp;
+ foreach (@messages) {
+ my $msgid=&Apache::lonnet::escape($_);
+ my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)=
+ &Apache::lonmsg::unpackmsgid($msgid);
+ my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status,
+ $msgid);
+ push @temp ,\@temp1;
+ }
+ #default sort
+ @temp = sort {$a->[0] <=> $b->[0]} @temp;
+ if ($ENV{'form.sortedby'} eq "date"){
+ @temp = sort {$a->[0] <=> $b->[0]} @temp;
+ }
+ if ($ENV{'form.sortedby'} eq "revdate"){
+ @temp = sort {$b->[0] <=> $a->[0]} @temp;
+ }
+ if ($ENV{'form.sortedby'} eq "user"){
+ @temp = sort {lc($a->[2]) cmp lc($b->[2])} @temp;
+ }
+ if ($ENV{'form.sortedby'} eq "revuser"){
+ @temp = sort {lc($b->[2]) cmp lc($a->[2])} @temp;
+ }
+ if ($ENV{'form.sortedby'} eq "domain"){
+ @temp = sort {$a->[3] cmp $b->[3]} @temp;
+ }
+ if ($ENV{'form.sortedby'} eq "revdomain"){
+ @temp = sort {$b->[3] cmp $a->[3]} @temp;
+ }
+ if ($ENV{'form.sortedby'} eq "subject"){
+ @temp = sort {lc($a->[1]) cmp lc($b->[1])} @temp;
+ }
+ if ($ENV{'form.sortedby'} eq "revsubject"){
+ @temp = sort {lc($b->[1]) cmp lc($a->[1])} @temp;
+ }
+ if ($ENV{'form.sortedby'} eq "status"){
+ @temp = sort {$a->[4] cmp $b->[4]} @temp;
+ }
+ if ($ENV{'form.sortedby'} eq "revstatus"){
+ @temp = sort {$b->[4] cmp $a->[4]} @temp;
+ }
+ return @temp;
+}
+
# ======================================================== Display all messages
sub disall {
@@ -638,80 +700,40 @@ sub disall {
}
ENDDISHEADER
- $r->print('Display All Messages
'.&mt('Display All Messages').'
');
- my @messages = split(/\&/,&Apache::lonnet::reply('keys:'.$ENV{'user.domain'}.':'.$ENV{'user.name'}.':nohist_email',$ENV{'user.home'}));
- #unpack the varibles and repack into temp for sorting
- my @temp;
- foreach (@messages) {
- my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)=
- &Apache::lonmsg::unpackmsgid($_);
- my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$_);
- push @temp ,\@temp1;
- }
- #default sort
- @temp = sort {$a->[0] <=> $b->[0]} @temp;
- if ($ENV{'form.sortedby'} eq "date"){
- @temp = sort {$a->[0] <=> $b->[0]} @temp;
- }
- if ($ENV{'form.sortedby'} eq "revdate"){
- @temp = sort {$b->[0] <=> $a->[0]} @temp;
- }
- if ($ENV{'form.sortedby'} eq "user"){
- @temp = sort {lc($a->[2]) cmp lc($b->[2])} @temp;
- }
- if ($ENV{'form.sortedby'} eq "revuser"){
- @temp = sort {lc($b->[2]) cmp lc($a->[2])} @temp;
- }
- if ($ENV{'form.sortedby'} eq "domain"){
- @temp = sort {$a->[3] cmp $b->[3]} @temp;
- }
- if ($ENV{'form.sortedby'} eq "revdomain"){
- @temp = sort {$b->[3] cmp $a->[3]} @temp;
- }
- if ($ENV{'form.sortedby'} eq "subject"){
- @temp = sort {lc($a->[1]) cmp lc($b->[1])} @temp;
- }
- if ($ENV{'form.sortedby'} eq "revsubject"){
- @temp = sort {lc($b->[1]) cmp lc($a->[1])} @temp;
- }
- if ($ENV{'form.sortedby'} eq "status"){
- @temp = sort {$a->[4] cmp $b->[4]} @temp;
- }
- if ($ENV{'form.sortedby'} eq "revstatus"){
- @temp = sort {$b->[4] cmp $a->[4]} @temp;
- }
+ my @temp=sortedmessages();
foreach (@temp){
my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID)= @$_;
if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) {
@@ -724,19 +746,20 @@ ENDDISHEADER
} else {
$r->print('  ');
if ($ENV{'form.sortedby'} eq "revdate") {
- $r->print('Date ');
+ $r->print(''.&mt('Date').'');
} else {
- $r->print('Date');
+ $r->print(''.&mt('Date').'');
}
$r->print('');
if ($ENV{'form.sortedby'} eq "revuser") {
- $r->print('Username');
+ $r->print(''.&mt('Username').'');
} else {
- $r->print('Username');
+ $r->print(''.&mt('Username').'');
}
$r->print(' ');
if ($ENV{'form.sortedby'} eq "revdomain") {
- $r->print('Domain');
+ $r->print(''.&mt('Domain').'');
} else {
- $r->print('Domain');
+ $r->print(''.&mt('Domain').'');
}
$r->print(' ');
if ($ENV{'form.sortedby'} eq "revsubject") {
- $r->print('Subject');
+ $r->print(''.&mt('Subject').'');
} else {
- $r->print('Subject');
+ $r->print(''.&mt('Subject').'');
}
$r->print(' ');
if ($ENV{'form.sortedby'} eq "revstatus") {
- $r->print('Status ');
+ $r->print(''.&mt('Status').'');
} else {
- $r->print('Status');
+ $r->print(''.&mt('Status').'');
}
$r->print('');
}
- $r->print(' ');
}
}
$r->print('Open Delete '.
- ''.localtime($sendtime).' '.
+ $r->print(' '.&mt('Open').' '.&mt('Delete').' '.
+ ''.&Apache::lonlocal::locallocaltime($sendtime).' '.
$fromname.' '.$fromdomain.' '.
&Apache::lonnet::unescape($shortsubj).' '.
$status.'