--- loncom/interface/lonmsgdisplay.pm 2006/12/23 18:27:28 1.58
+++ loncom/interface/lonmsgdisplay.pm 2007/12/08 00:25:14 1.83
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.58 2006/12/23 18:27:28 raeburn Exp $
+# $Id: lonmsgdisplay.pm,v 1.83 2007/12/08 00:25:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,12 +33,13 @@ package Apache::lonmsgdisplay;
=head1 NAME
-Apache::lonmsg: supports internal messaging
+Apache::lonmsgdisplay: supports internal messaging
=head1 SYNOPSIS
-lonmsg provides routines for sending messages, receiving messages, and
-a handler to allow users to read, send, and delete messages.
+lonmsgdisplay provides a handler to allow users to read, send,
+and delete messages, and to create and delete message folders,
+and to move messages between folders.
=head1 OVERVIEW
@@ -93,25 +94,6 @@ addresses on their B
'.&mt('Subject').': '.$content{'subject'}.
''.
&Apache::lontexconvert::msgtexconverted($content{'message'}).
- '
'.
-&mt('You have to confirm that you received this message. After confirmation, this message will be moved to your regular inbox').
- '
'.
- ''.
- '';
+ '';
+ my ($rec_button,$reprec_button);
+ $rec_button = &mt('Move to Inbox');
+ if (!$content{'noreplies'}) {
+ $reprec_button = &mt('Move to Inbox/Compose reply');
+ }
+ if ($content{'sendback'}) {
+ $rec_button = &mt('Confirm Receipt');
+ if (!$content{'noreplies'}) {
+ $reprec_button = &mt('Confirm Receipt and Reply');
+ }
+ $result .= &mt('You have to confirm that you have received this message before you can view other pages. After confirmation, this message will be moved to your regular inbox');
+ } else {
+ $result .= &mt('Access to other pages will be prevented until you have moved the message to your inbox.');
+ }
+ $result .= '
'.
+ '';
+ if (!$content{'noreplies'}) {
+ $result .= '';
+ }
}
# Check to see if there were any messages.
if ($result eq '') {
@@ -774,7 +775,6 @@ sub sortedmessages {
my ($blocked,$startblock,$endblock,$numblocked,$folder,$msgstatus) = @_;
my $suffix=&Apache::lonmsg::foldersuffix($folder);
my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix);
-
#unpack the varibles and repack into temp for sorting
my @temp;
my %descriptions;
@@ -789,7 +789,7 @@ sub sortedmessages {
foreach my $msgid (@messages) {
my $esc_msgid=&escape($msgid);
- my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid)=
+ my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid,$processid,$symb,$error) =
&Apache::lonmsg::unpackmsgid($esc_msgid,$folder,undef,
\%status_cache);
next if ($msgstatus ne '' && $msgstatus ne $status);
@@ -892,8 +892,7 @@ sub get_course_desc {
sub disall {
my ($r,$folder,$msgstatus)=@_;
- my %saveable = ('folder' => 'scalar',
- 'msgstatus' => 'scalar',
+ my %saveable = ('msgstatus' => 'scalar',
'sortedby' => 'scalar',
'interdis' => 'scalar',
);
@@ -925,28 +924,10 @@ sub disfolder {
nome => 'No messages have been selected to apply ths action to.',
chec => 'Check the checkbox for at least one message.',
);
+ my $jscript = &Apache::loncommon::check_uncheck_jscript();
$r->print(<'.&mt('There are no '.lc($statushash{$msgstatus}).' messages in this folder.').'
');
}
+ if ($numblocked > 0) {
+ $r->print(&blocked_in_folder($numblocked,$startblock,$endblock,
+ \%setters));
+ }
return;
}
my $interdis = $env{'form.interdis'};
@@ -1053,16 +1044,23 @@ ENDDISHEADER
}
my ($dis_name,$dis_domain) = ($fromname,$fromdomain);
if ($folder eq 'sent') {
- if (defined($recv_name) && !defined($recv_domain)) {
- $dis_name = join('
',@{$recv_name});
- $dis_domain = join('
',@{$recv_domain});
+ if (defined($recv_name) && defined($recv_domain)) {
+ if (ref($recv_name) eq 'ARRAY' &&
+ ref($recv_domain) eq 'ARRAY') {
+ $dis_name = join('
',@{$recv_name});
+ $dis_domain = join('
',@{$recv_domain});
+ }
} else {
my $msg_id = &unescape($origID);
my %message = &Apache::lonnet::get('nohist_email'.$suffix,
[$msg_id]);
my %content = &Apache::lonmsg::unpackagemsg($message{$msg_id});
- $dis_name = join('
',@{$content{'recuser'}});
- $dis_domain = join('
',@{$content{'recdomain'}});
+ if (ref($content{'recuser'}) eq 'ARRAY') {
+ $dis_name = join('
',@{$content{'recuser'}});
+ }
+ if (ref($content{'recdomain'}) eq 'ARRAY') {
+ $dis_domain = join('
',@{$content{'recdomain'}});
+ }
}
}
my $localsenttime = &Apache::lonlocal::locallocaltime($sendtime);
@@ -1073,7 +1071,7 @@ ENDDISHEADER
' value="'.$origID.'" />');
foreach my $item ($localsenttime,$dis_name,$dis_domain,$shortsubj) {
$r->print(''.(($status eq 'new')?'':'').
- ''.
+ ''.
$item.(($status eq 'new')?'':'').' ');
}
my $showstatus;
@@ -1098,11 +1096,11 @@ ENDDISHEADER
$r->print('
');
+ return;
+ }
+ $r->print('
'.
- '
'."\n".
- ''."\n".
+ '
'."\n".
+ ''."\n".
' '."\n".
''.&mt('Action').'
'."\n".
- ' ');
+
+ } else {
+ $r->print(&mt('The sender did not designate a reply to address for this message.').'');
+ return;
+ }
+ } else {
+ $r->print(&Apache::loncommon::aboutmewrapper(
&Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('.
$content{'sendername'}.':'.
- $content{'senderdomain'}.')'.
- ''.
- ''.
- '');
+ $content{'senderdomain'}.')');
+ $r->print(''.
+ '');
+ }
+ if ($content{'recipid'}) {
+ my @ccs = &retrieve_cc_recips('replying',%content);
+ if (@ccs > 0) {
+ my $replyall = qq|
+
+
+
+
+
+|;
+ my $cclist = join(' ',@ccs);
+ $r->print(''.&mt('Replying to').' ');
+ if ($content{'replytoaddr'}) {
+ my ($replytoname,$replytodom) = split(/:/,$content{'replytoaddr'});
+ if ($replytoname ne '' && $replytodom ne '') {
+ $r->print(&Apache::loncommon::plainname($replytoname,
+ $replytodom).' ('.$replytoname.':'.
+ $replytodom.')');
+ $r->print(''.
+ ' ');
+ }
+ }
} else {
$r->print(&recipient_input_row($defdom,%lt));
}
@@ -1338,6 +1407,11 @@ $latexHelp.
} elsif ($broadcast ne 'upload') {
$subj_size = '50';
$r->print(&additional_rec_row(\%lt));
+ if (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
+ || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'})) {
+ $r->print(&reply_to_row(\%lt));
+ }
$r->print(&msg_subject_row($dissub,\%lt,$subj_size));
$r->print(<<"ENDCOMP");
@@ -1412,19 +1486,30 @@ sub recipient_input_row {
&Apache::loncommon::selectstudent_link('compemail','recuname',
'recdomain');
my $output = <<"ENDREC";
-'.&mt('Reply to other recipients').':
'.$replyall.''.$cclist.'
-$lt{'us'}: $selectlink
+$lt{'do'}:
-$domform
ENDREC
return $output;
}
+sub reply_to_row {
+ my ($lt) = @_;
+ my $radioyes = &mt('Yes');
+ my $radiono = &mt('No');
+ my $output = <<"ENDREP";
+$lt{'us'}: $lt{'do'}: $domform $selectlink
+ENDREP
+ return $output;
+}
+
sub additional_rec_row {
my ($lt) = @_;
+ my $cc = &mt('Cc:');
+ my $bcc = &mt('Bcc:');
my $output = <<"ENDADD";
-$lt->{'ar'}:
+$lt->{'ad'}:
username:domain,username:domain, ...
-
-
ENDADD
return $output;
}
@@ -1442,7 +1527,7 @@ sub submit_button_row {
sub msg_subject_row {
my ($dissub,$lt,$subj_size,$extra) = @_;
- my $output = '$lt->{'ad'} :
username:domain,username:domain, ...
+ $cc
+
+$bcc ';
return $output;
@@ -1509,7 +1594,20 @@ sub disfacetoface {
''.&mt('Subject').': '.$content{'subject'}.''.$lt->{'sb'}.': '.$lt->{'sb'}.': '.$extra.
'
'.
$content{'message'};
}
- }
+ }
+ } elsif ($content{'subject'}=~/^Archive/) {
+ $result.=''.&mt('Archived Message').'
';
+ if (defined($content{'coursemsgid'})) {
+ my $crsmsgid = &escape($content{'coursemsgid'});
+ my $archive_message = &general_message($crsmsgid);
+ $content{'message'} = ''.&mt('Subject').': '.$content{'message'}.'
'.$archive_message;
+ } else {
+ %content=&Apache::lonmsg::unpackagemsg($content{'message'});
+ $content{'message'} =
+ ''.&mt('Subject').': '.$content{'subject'}.'
'.&mt('Critical Message').'';
if (defined($content{'coursemsgid'})) {
@@ -1572,7 +1670,7 @@ sub facetoface {
: 'faculty and staff';
&printheader($r,
'/adm/email?recordftf=query',
- "User Notes, Face-to-Face, Critical Messages, Broadcast Messages");
+ "User Notes, Face-to-Face, Critical Messages, Broadcast Messages, Archived Messages");
# from query string
if ($env{'form.recname'}) { $env{'form.recuname'}=$env{'form.recname'}; }
@@ -1587,7 +1685,7 @@ sub facetoface {
('stdselect','recuname','recdomain');
my %lt=&Apache::lonlocal::texthash('user' => 'Username',
'dom' => 'Domain',
- 'head' => "User Notes, Records of Face-To-Face Discussions, Critical Messages, and Broadcast Messages in $crstype",
+ 'head' => "User Notes, Records of Face-To-Face Discussions, Critical Messages, Broadcast Messages and Archived Messages in $crstype",
'subm' => 'Retrieve discussion and message records',
'newr' => 'New Record (record is visible to '.lc($crstype).' '.$leaders.')',
'post' => 'Post this Record');
@@ -1651,8 +1749,8 @@ sub examblock {
'cbds' => 'Communication blocking during scheduled exams',
'desc' => "You can use communication blocking to prevent $usertype enrolled in this course from displaying LON-CAPA messages sent by other $usertype during an online exam. As blocking of communication could potentially interrupt legitimate communication between $usertype who are also both enrolled in a different LON-CAPA course, please be careful that you select the correct start and end times for your scheduled exam when setting or modifying these parameters.",
'mecb' => 'Modify existing communication blocking periods',
- 'ncbc' => 'No communication blocks currently stored',
- 'stor' => 'Store',
+ 'ncbc' => 'No communication blocks currently saved',
+ 'stor' => 'Save',
);
my %ltext = &Apache::lonlocal::texthash(
@@ -1950,10 +2048,11 @@ sub displaymessage {
&build_block_table($r,$startblock,$endblock,\%setters);
return;
}
- &statuschange($msgid,'read',$folder);
+ if ($msgstatus eq '') {
+ &statuschange($msgid,'read',$folder);
+ }
my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
my %content=&Apache::lonmsg::unpackagemsg($message{$msgid});
-
my $counter=0;
$r->print('');
my $escmsgid=&escape($msgid);
@@ -1964,15 +2063,33 @@ sub displaymessage {
$counter++;
}
$r->print('
');
+
+ my $see_anonymous;
+ my $from_student = 0;
+ if ($env{'request.course.id'} eq $content{'courseid'}) {
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $username = $content{'sendername'}.':'.$content{'senderdomain'};
+ my %classlist_entry =
+ &Apache::lonnet::get('classlist',[$username],$cdom,$cnum);
+ if (exists($classlist_entry{$username})) {
+ $from_student = 1;
+ $see_anonymous = &Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
+ }
+ }
+
+
my $number_of_messages = scalar(@messages); #subtract 1 for last index
# start output
&printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',$content{'baseurl'});
my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
# Functions
- $r->print('
');
}
- my $tolist;
- my @recipients = ();
- for (my $i=0; $i<@{$content{'recuser'}}; $i++) {
- $recipients[$i] = &Apache::loncommon::aboutmewrapper(
- &Apache::loncommon::plainname($content{'recuser'}[$i],
+ my ($tolist,$cclist);
+ my (@recipients,@ccs);
+ if (ref($content{'recuser'}) eq 'ARRAY') {
+ for (my $i=0; $i<@{$content{'recuser'}}; $i++) {
+ $recipients[$i] = &Apache::loncommon::aboutmewrapper(
+ &Apache::loncommon::plainname($content{'recuser'}[$i],
$content{'recdomain'}[$i]),
- $content{'recuser'}[$i],$content{'recdomain'}[$i]).
- ' ('.$content{'recuser'}[$i].' at '.$content{'recdomain'}[$i].') ';
+ $content{'recuser'}[$i],$content{'recdomain'}[$i]).
+ ' ('.$content{'recuser'}[$i].' '.&mt('at').' '.$content{'recdomain'}[$i].') ';
+ }
}
$tolist = join(', ',@recipients);
- $r->print(''.&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').' ');
}
@@ -2003,33 +2126,159 @@ sub displaymessage {
}
$r->print('
'.&mt('Subject').': '.$content{'subject'}.
- ($folder ne 'sent'?'
'.&mt('From').': '.
+ if ($content{'recipid'}) {
+ @ccs = &retrieve_cc_recips('display',%content);
+ $cclist = join(', ',@ccs);
+ }
+ my ($restitle,$baseurl,$refers_to);
+ if (defined($content{'resource_title'})) {
+ $restitle = $content{'resource_title'};
+ } else {
+ if (defined($content{'baseurl'})) {
+ $restitle = &Apache::lonnet::gettitle($content{'baseurl'});
+ }
+ }
+ if (defined($content{'baseurl'})) {
+ $baseurl = &Apache::lonenc::check_encrypt($content{'baseurl'});
+ }
+ if ($from_student && $see_anonymous ) {
+ $r->print(&Apache::loncommon::student_image_tag($content{'senderdomain'},$content{'sendername'}));
+ }
+
+ $r->print('
'.&mt('Subject').': '.$content{'subject'});
+ if ($folder eq 'sent') {
+ $r->print('
'.&mt('To').': '.$tolist);
+ if ($content{'replytoaddr'}) {
+ my ($replytoname,$replytodom) = split(/:/,$content{'replytoaddr'});
+ if ($replytoname ne '' && $replytodom ne '') {
+ $r->print('
'.&mt('Reply To').': '.
+ $replytoname.' '.&mt('at').' '.$replytodom);
+ }
+ }
+ } else {
+ $r->print('
'.&mt('From').': '.
&Apache::loncommon::aboutmewrapper(
&Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),
- $content{'sendername'},$content{'senderdomain'}).' ('.
- $content{'sendername'}.' at '.
- $content{'senderdomain'}.') ':'
'.&mt('To').': '.
- $tolist).
- ($content{'courseid'}?'
'.&mt($crstype).': '.$courseinfo{'description'}.
- ($content{'coursesec'}?' ('.&mt('Section').': '.$content{'coursesec'}.')':''):'').
- '
'.&mt('Time').': '.$content{'time'}.
- ($content{'baseurl'}?'
'.&mt('Refers to').': '.
- $content{'baseurl'}.' ('.&Apache::lonnet::gettitle($content{'baseurl'}).')':'').
- ''.
+ $content{'sendername'},$content{'senderdomain'}));
+ if ($content{'noreplies'}) {
+ $r->print(' ('.&mt('No replies to sender').')');
+ } else {
+ if ($content{'replytoaddr'}) {
+ my ($replytoname,$replytodom) = split(/:/,$content{'replytoaddr'});
+ if ($replytoname ne '' && $replytodom ne '') {
+ $r->print('
'.&mt('Reply To').': '.
+ $replytoname.' '.&mt('at').' '.$replytodom);
+ }
+ } else {
+ $r->print(' ('.$content{'sendername'}.' '.&mt('at').' '.
+ $content{'senderdomain'}.') ');
+ }
+ if ($cclist) {
+ $r->print('
'.&mt('Cc').': '.$cclist);
+ }
+ }
+ }
+ if ($content{'courseid'}) {
+ $r->print('
'.&mt($crstype).': '.$courseinfo{'description'});
+ if ($content{'coursesec'}) {
+ $r->print(' ('.&mt('Section').': '.$content{'coursesec'}.')');
+ }
+ }
+ $r->print('
'.&mt('Time').': '.$content{'time'});
+ if ($baseurl) {
+ if (defined($content{'courseid'}) && defined($env{'request.course.id'})) {
+ if ($content{'courseid'} eq $env{'request.course.id'}) {
+ my $symblink;
+ my $showsymb = &Apache::lonenc::check_decrypt($symb);
+ my $showurl = &Apache::lonenc::check_decrypt($baseurl);
+ my $encrypturl = &Apache::lonnet::EXT('resource.0.encrypturl',
+ $showsymb,$env{'user.domain'},$env{'user.name'});
+ if ($symb) {
+ if ($encrypturl =~ /^yes$/i && !$env{'request.role.adv'}) {
+ $showsymb = &Apache::lonenc::check_encrypt($symb);
+ }
+ $symblink = '?symb='.$showsymb;
+ }
+ if ($encrypturl =~ /^yes$/i && !$env{'request.role.adv'}) {
+ $showurl = $baseurl;
+ }
+ $r->print('
'.&mt('Refers to').': '.$restitle.'');
+ $refers_to = 1;
+ }
+ }
+ if (!$refers_to) {
+ if ($baseurl =~ m-^/enc/-) {
+ if (defined($content{'courseid'})) {
+ if (!$env{'request.course.id'}) {
+ my $unencurl =
+ &Apache::lonenc::unencrypted($baseurl,
+ $content{'courseid'});
+ if ($unencurl ne '') {
+ if (&Apache::lonnet::allowed('bre',$unencurl)) {
+ $r->print('
'.&mt('Refers to').
+ ': '.
+ $restitle.'');
+ }
+ }
+ }
+ }
+ } else {
+ if (&Apache::lonnet::allowed('bre',$baseurl)) {
+ $r->print('
'.&mt('Refers to').
+ ': '.$restitle.'');
+ }
+ }
+ }
+ }
+ $r->print(''.
&Apache::lontexconvert::msgtexconverted($content{'message'},1).
'
'.&displayresource(%content).'
'.&mt('Could not deliver message').' '. + &mt('Please use the browser "Back" button and correct the recipient addresses '."($sendstatus)").'
'); } - if ($group ne '') { - $r->print(&groupmail_sent($group,$cdom,$cnum)); - } else { - &Apache::loncommunicate::menu($r); - } - } else { - $r->print(''.&mt('Could not deliver message').' '. - &mt('Please use the browser "Back" button and correct the recipient addresses '."($sendstatus)").'
'); } } return $sendstatus; @@ -2431,16 +2718,19 @@ sub handler { &printheader($r,'','Confirmed Receipt'); my $replying = 0; foreach my $envkey (keys(%env)) { - if ($envkey=~/^form\.rec\_(.*)$/) { - $r->print(''.&mt('Confirming Receipt').': '. - &Apache::lonmsg::user_crit_received($1).'