--- loncom/interface/lonmsgdisplay.pm 2006/12/23 18:27:28 1.58
+++ loncom/interface/lonmsgdisplay.pm 2007/05/05 02:50:27 1.77
@@ -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.77 2007/05/05 02:50:27 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 = &mt('Move to Inbox');
+ my $reprec_button = &mt('Move to Inbox/Compose reply');
+ if ($content{'sendback'}) {
+ $rec_button = &mt('Confirm Receipt');
+ $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('Click one of the buttons below to move the message to your inbox').' '.&mt('Access to other pages will be prevented until you have done this.');
+ }
+ $result .= '
'.
+ ''.
'';
+ 'value="'.$reprec_button.'" />';
}
# Check to see if there were any messages.
if ($result eq '') {
@@ -774,7 +768,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 +782,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);
@@ -925,19 +918,11 @@ 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 +1048,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 +1075,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,8 +1100,8 @@ ENDDISHEADER
$r->print('
');
+ my $symb;
+ if (defined($content{'symb'})) {
+ $symb = $content{'symb'};
+ } elsif (defined($content{'baseurl'})) {
+ $symb=&Apache::lonnet::symbread($content{'baseurl'});
+ }
if ($env{'user.adv'}) {
$r->print('
');
+ if ($content{'recipid'}) {
+ my @ccs = &retrieve_cc_recips('replying',%content);
+ if (@ccs > 0) {
+ my $replyall = qq|
+
+
+
+
+
+|;
+ my $cclist = join(' ',@ccs);
+ $r->print(''.
- '
'."\n".
- ''."\n".
+ '
'."\n".
+ ''."\n".
' '."\n".
''.&mt('Action').'
'."\n".
' ');
+ }
+ }
} else {
$r->print(&recipient_input_row($defdom,%lt));
}
@@ -1421,10 +1470,13 @@ ENDREC
sub additional_rec_row {
my ($lt) = @_;
+ my $cc = &mt('Cc:');
+ my $bcc = &mt('Bcc:');
my $output = <<"ENDADD";
-'.&mt('Reply to other recipients').':
'.$replyall.''.$cclist.'
+$lt->{'ad'}:
username:domain,username:domain, ...
-
-
ENDADD
return $output;
}
@@ -1509,7 +1561,20 @@ sub disfacetoface {
''.&mt('Subject').': '.$content{'subject'}.'$lt->{'ad'} :
username:domain,username:domain, ...
+ $cc
+
+$bcc
'.
$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 +1637,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 +1652,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 +1716,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 +2015,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);
@@ -1989,9 +2055,14 @@ sub displaymessage {
'">'.&mt('Next').'');
}
$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].' 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 +2074,137 @@ 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'});
+ }
+ $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);
+ } 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{'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 +2644,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).'