--- loncom/interface/lonmsg.pm 2003/07/25 01:18:04 1.58
+++ loncom/interface/lonmsg.pm 2004/04/06 15:56:37 1.97
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.58 2003/07/25 01:18:04 bowersj2 Exp $
+# $Id: lonmsg.pm,v 1.97 2004/04/06 15:56:37 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,23 +25,8 @@
#
# http://www.lon-capa.org/
#
-#
-# (Routines to control the menu
-#
-# (TeX Conversion Module
-#
-# 05/29/00,05/30 Gerd Kortemeyer)
-#
-# 10/05 Gerd Kortemeyer)
-#
-# 10/19,10/20,10/30,
-# 02/06/01 Gerd Kortemeyer
-# 07/27 Guy Albertelli
-# 07/27,07/28,07/30,08/03,08/06,08/08,08/09,08/10,8/13,8/15,
-# 10/1,11/5 Gerd Kortemeyer
-# YEAR=2002
-# 1/1,3/18 Gerd Kortemeyer
-#
+
+
package Apache::lonmsg;
=pod
@@ -115,20 +100,25 @@ use Apache::loncommon();
use Apache::lontexconvert();
use HTML::Entities();
use Mail::Send;
+use Apache::lonlocal;
+use Apache::loncommunicate;
+
+# Querystring component with sorting type
+my $sqs;
# ===================================================================== Package
sub packagemsg {
my ($subject,$message,$citation,$baseurl,$attachmenturl)=@_;
- $message =&HTML::Entities::encode($message);
- $citation=&HTML::Entities::encode($citation);
- $subject =&HTML::Entities::encode($subject);
+ $message =&HTML::Entities::encode($message,'<>&"');
+ $citation=&HTML::Entities::encode($citation,'<>&"');
+ $subject =&HTML::Entities::encode($subject,'<>&"');
#remove machine specification
$baseurl =~ s|^http://[^/]+/|/|;
- $baseurl =&HTML::Entities::encode($baseurl);
+ $baseurl =&HTML::Entities::encode($baseurl,'<>&"');
#remove machine specification
$attachmenturl =~ s|^http://[^/]+/|/|;
- $attachmenturl =&HTML::Entities::encode($attachmenturl);
+ $attachmenturl =&HTML::Entities::encode($attachmenturl,'<>&"');
my $now=time;
$msgcount++;
@@ -140,7 +130,7 @@ sub packagemsg {
my $result='
Attachment: '.$fname.'.'.$ft.''; + $content{'message'}.='
'.&mt('Attachment').': '.$fname.'.'.$ft.''; } else { - $content{'message'}.='
Attachment: '.$fname.'.'.$ft.''; } @@ -209,14 +200,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()) { + print $fh $body; + $fh->close; + } } # ==================================================== Send notification emails @@ -279,6 +271,53 @@ sub author_res_msg { return 'no_host'; } +# =========================================== Retrieve author resource messages + +sub retrieve_author_res_msg { + my $url=shift; + $url=&Apache::lonnet::declutter($url); + my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//); + my %errormsgs=&Apache::lonnet::dump('nohist_res_msgs',$domain,$author); + my $msgs=''; + foreach (keys %errormsgs) { + if ($_=~/^\Q$url\E\_\d+$/) { + my %content=&unpackagemsg($errormsgs{$_}); + $msgs.='
'.
+ $content{'time'}.': '.$content{'message'}.
+ '
ENDDISHEADER
+ my %coursepersonnel=
+ &Apache::lonnet::get_course_adv_roles();
+ foreach my $role (sort keys %coursepersonnel) {
+ foreach (split(/\,/,$coursepersonnel{$role})) {
+ my ($puname,$pudom)=split(/\:/,$_);
+ $r->print(
+ '
'.
+ &Apache::loncommon::plainname($puname,
+ $pudom).' ('.$_.'), '.$role.'');
+ }
+ }
+
foreach (sort keys %courselist) {
my ($end,$start)=split(/\:/,$courselist{$_});
my $active=1;
@@ -529,7 +584,7 @@ ENDDISHEADER
sub discrit {
my $r=shift;
- my $header = '
'; - } - $r->print(<<"ENDREPLY"); -
-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 @@ -624,111 +691,198 @@ sub disall { } ENDDISHEADER - $r->print( - '