--- loncom/interface/lonmsg.pm 2005/05/20 17:00:40 1.143
+++ loncom/interface/lonmsg.pm 2005/11/28 20:14:43 1.158
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.143 2005/05/20 17:00:40 albertel Exp $
+# $Id: lonmsg.pm,v 1.158 2005/11/28 20:14:43 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -114,6 +114,8 @@ use HTML::Entities();
use Mail::Send;
use Apache::lonlocal;
use Apache::loncommunicate;
+use Apache::lonfeedback;
+use Apache::lonrss();
# Querystring component with sorting type
my $sqs;
@@ -124,7 +126,7 @@ my $interdis;
sub packagemsg {
my ($subject,$message,$citation,$baseurl,$attachmenturl,
- $recuser,$recdomain)=@_;
+ $recuser,$recdomain,$msgid)=@_;
$message =&HTML::Entities::encode($message,'<>&"');
$citation=&HTML::Entities::encode($citation,'<>&"');
$subject =&HTML::Entities::encode($subject,'<>&"');
@@ -134,15 +136,25 @@ sub packagemsg {
#remove machine specification
$attachmenturl =~ s|^http://[^/]+/|/|;
$attachmenturl =&HTML::Entities::encode($attachmenturl,'<>&"');
-
+ my $course_context;
+ if (defined($env{'form.replyid'})) {
+ my ($sendtime,$shortsubj,$fromname,$fromdomain,$count,$origcid)=
+ split(/\:/,&Apache::lonnet::unescape($env{'form.replyid'}));
+ $course_context = $origcid;
+ }
+ unless(defined($course_context)) {
+ $course_context = $env{'request.course.id'};
+ }
my $now=time;
$msgcount++;
my $partsubj=$subject;
$partsubj=&Apache::lonnet::escape($partsubj);
- my $msgid=&Apache::lonnet::escape(
+ unless(defined($msgid)) {
+ $msgid=&Apache::lonnet::escape(
$now.':'.$partsubj.':'.$env{'user.name'}.':'.
$env{'user.domain'}.':'.$msgcount.':'.
- $env{'request.course.id'}.':'.$$);
+ $course_context.':'.$$);
+ }
my $result='
'.
- &mt('Messages [_1] through [_2] of [_3]',$first,$finish,$total).'';
+ &mt('Showing messages [_1] through [_2] of [_3]',$first,$finish,$total).'';
}
# =============================================================== Folder suffix
@@ -596,6 +643,9 @@ sub statuschange {
if (($newstatus eq 'deleted') || ($newstatus eq 'new')) {
&Apache::lonnet::put('email_status'.$suffix,{$msgid => $newstatus});
}
+ if ($newstatus eq 'deleted') {
+ &movemsg(&Apache::lonnet::unescape($msgid),$folder,'trash');
+ }
}
# ============================================================= Make new folder
@@ -768,8 +818,9 @@ sub sortedmessages {
my $msgid=&Apache::lonnet::escape($_);
my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid)=
&Apache::lonmsg::unpackmsgid($msgid,$folder);
+ my $description = &get_course_desc($fromcid);
my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status,
- $msgid);
+ $msgid,$description);
# Check whether message was sent during blocking period.
if ($sendtime >= $startblock && ($sendtime <= $endblock && $endblock > 0) ) {
my $escid = &Apache::lonnet::unescape($msgid);
@@ -805,6 +856,12 @@ sub sortedmessages {
if ($env{'form.sortedby'} eq "revsubject"){
@temp = sort {lc($b->[1]) cmp lc($a->[1])} @temp;
}
+ if ($env{'form.sortedby'} eq "course"){
+ @temp = sort {lc($a->[6]) cmp lc($b->[6])} @temp;
+ }
+ if ($env{'form.sortedby'} eq "revcourse"){
+ @temp = sort {lc($b->[6]) cmp lc($a->[6])} @temp;
+ }
if ($env{'form.sortedby'} eq "status"){
@temp = sort {$a->[4] cmp $b->[4]} @temp;
}
@@ -814,6 +871,18 @@ sub sortedmessages {
return @temp;
}
+sub get_course_desc {
+ my ($fromcid) = @_;
+ my $description;
+ if (defined($env{'course.'.$fromcid.'.description'})) {
+ $description = $env{'course.'.$fromcid.'.description'};
+ } else {
+ my %courseinfo=&Apache::lonnet::coursedescription($fromcid);
+ $description = $courseinfo{'description'};
+ }
+ return $description;
+}
+
# ======================================================== Display new messages
@@ -822,6 +891,7 @@ sub disnew {
my %lt=&Apache::lonlocal::texthash(
'nm' => 'New Messages',
'su' => 'Subject',
+ 'co' => 'Course',
'da' => 'Date',
'us' => 'Username',
'op' => 'Open',
@@ -843,6 +913,7 @@ sub disnew {
my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
&Apache::lonmsg::unpackmsgid($_);
if (defined($sendtime) && $sendtime!~/error/) {
+ my $description = &get_course_desc($fromcid);
my $numsendtime = $sendtime;
$sendtime = &Apache::lonlocal::locallocaltime($sendtime);
if ($status eq 'new') {
@@ -855,7 +926,8 @@ sub disnew {
sendtime => $sendtime,
shortsub => &Apache::lonnet::unescape($shortsubj),
from => $fromname,
- fromdom => $fromdom
+ fromdom => $fromdom,
+ course => $description
}
}
}
@@ -865,14 +937,15 @@ sub disnew {
$r->print(<
$latexHelp
-
+ 
-$lt{'da'} $lt{'us'} $lt{'do'} $lt{'su'} $lt{'da'} $lt{'us'} $lt{'do'} $lt{'su'} $lt{'co'}
TABLEHEAD
foreach my $msg (@newmsgs) {
$r->print(<<"ENDLINK");
-
+
");
@@ -986,6 +1059,12 @@ ENDDISHEADER
$r->print(''.&mt('Subject').'');
}
$r->print('$lt{'op'}
ENDLINK
- foreach ('sendtime','from','fromdom','shortsub') {
+ foreach ('sendtime','from','fromdom','shortsub','course') {
$r->print("$msg->{$_} ");
}
$r->print("');
+ if ($env{'form.sortedby'} eq "revcourse") {
+ $r->print(''.&mt('Course').'');
+ } else {
+ $r->print(''.&mt('Course').'');
+ }
+ $r->print(' ');
if ($env{'form.sortedby'} eq "revstatus") {
$r->print(''.&mt('Status').' ');
} else {
@@ -993,16 +1072,16 @@ ENDDISHEADER
}
$r->print("\n");
for (my $n=$firstdis;$n<=$lastdis;$n++) {
- my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID)= @{$temp[$n]};
+ my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID,$description)= @{$temp[$n]};
if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) {
if ($status eq 'new') {
- $r->print('');
+ $r->print(' ');
} elsif ($status eq 'read') {
- $r->print(' ');
+ $r->print(' ');
} elsif ($status eq 'replied') {
- $r->print(' ');
+ $r->print(' ');
} else {
- $r->print(' ');
+ $r->print(' ');
}
$r->print(' \n");
+ $description.''.&mt('Open').' '.
@@ -1011,7 +1090,7 @@ ENDDISHEADER
' '.&Apache::lonlocal::locallocaltime($sendtime).' '.
$fromname.' '.$fromdomain.' '.
&Apache::lonnet::unescape($shortsubj).' '.
- $status." '.$status.' '."\n");
} elsif ($status eq 'deleted') {
# purge
&movemsg(&Apache::lonnet::unescape($origID),$folder,'trash');
@@ -1095,8 +1174,9 @@ sub compout {
'' . $crithelp .
'';
- }
+&mt('Send copy to permanent email address (if known)').''.
+''; }
my %message;
my %content;
my $defdom=$env{'user.domain'};
@@ -1173,7 +1253,7 @@ ENDREC
$lt{'sb'}:
General message text
-
The file format for the uploaded portion of the message is:
@@ -1214,7 +1294,9 @@ ENDUPLOAD
if ($broadcast eq 'group') {
&discourse;
}
- $r->print('');
+ $r->print(''.
+ &Apache::lonfeedback::generate_preview_button('compemail','message').
+ &Apache::lonhtmlcommon::htmlareaselectactive('message'));
}
# ---------------------------------------------------- Display all face to face
@@ -1235,8 +1317,8 @@ sub retrieve_instructor_comments {
my %content=&unpackagemsg($records{$_});
next if ($content{'senderdomain'} eq '');
next if ($content{'subject'} !~ /^Record/);
- # $content{'message'}=~s/\n/\
/g;
- $result.='Recorded by '.
+ # &Apache::lonfeedback::newline_to_br(\$content{'message'});
+ $result.='Recorded by '.
$content{'sendername'}.'@'.$content{'senderdomain'}."\n";
$result.=
&Apache::lontexconvert::msgtexconverted($content{'message'})."\n";
@@ -1259,7 +1341,7 @@ sub disfacetoface {
foreach (sort keys %records) {
my %content=&unpackagemsg($records{$_});
next if ($content{'senderdomain'} eq '');
- $content{'message'}=~s/\n/\
/g;
+ &Apache::lonfeedback::newline_to_br(\$content{'message'});
if ($content{'subject'}=~/^Record/) {
$result.='
'.&mt('Currently available actions (will open extra window)').': | '); + my $symb=&Apache::lonnet::symbread($content{'baseurl'}); + if (&Apache::lonnet::allowed('vgr',$env{'request.course.id'})) { + $r->print(''.&Apache::loncommon::track_student_link(&mt('View recent activity'),$content{'sendername'},$content{'senderdomain'},'check').' | '); + } + if (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) && $symb) { + $r->print(''.&Apache::loncommon::pprmlink(&mt('Set/Change parameters'),$content{'sendername'},$content{'senderdomain'},$symb,'check').' | '); + } + if (&Apache::lonnet::allowed('mgr',$env{'request.course.id'}) && $symb) { + $r->print(''.&Apache::loncommon::pgrdlink(&mt('Set/Change grades'),$content{'sendername'},$content{'senderdomain'},$symb,'check').' | '); + } + $r->print('