--- loncom/interface/lonmsgdisplay.pm 2007/01/04 02:02:36 1.61 +++ loncom/interface/lonmsgdisplay.pm 2007/04/22 02:25:36 1.69 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging display # -# $Id: lonmsgdisplay.pm,v 1.61 2007/01/04 02:02:36 raeburn Exp $ +# $Id: lonmsgdisplay.pm,v 1.69 2007/04/22 02:25:36 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 screen, but g are much more useful than traditional email can be made to be, even with HTML support. -Right now, this document will cover just how to send a message, since -it is likely you will not need to programmatically read messages, -since lonmsg already implements that functionality. - -The routines used to package messages and unpackage messages are not -only used by lonmsg when creating/extracting messages for LON-CAPA's -internal messaging system, but also by lonnotify.pm which is available -for use by Domain Coordinators to broadcast standard e-mail to specified -users in their domain. The XML packaging used in the two cases is very -similar. The differences are the use of $uname and -$udom in stored internal messages, compared -with $email in stored -Domain Coordinator e-mail for the storage of information about -recipients of the message/e-mail. - -=head1 FUNCTIONS - -=over 4 - =cut use strict; @@ -119,6 +101,7 @@ use Apache::lonnet; use HTML::TokeParser(); use Apache::Constants qw(:common); use Apache::loncommon(); +use Apache::lonhtmlcommon(); use Apache::lontexconvert(); use HTML::Entities(); use Apache::lonlocal; @@ -924,19 +907,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(< - function checkall() { - for (i=0; i 0) { + for (var i=0; iprint('

'.&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'}; @@ -1052,16 +1037,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); @@ -1097,8 +1089,8 @@ ENDDISHEADER $r->print(''."\n". '
'. - '
'."\n". - ''."\n". + '
'."\n". + ''."\n". '
 '.&mt('Action').'
'."\n". ' '); if ($numblocked > 0) { - my $beginblock = &Apache::lonlocal::locallocaltime($startblock); - my $finishblock = &Apache::lonlocal::locallocaltime($endblock); - $r->print('

'. - &mt('[quant,_1,message is, messages are] not viewable because display of LON-CAPA messages sent to you by other students between [_2] and [_3] is currently being blocked because of online exams.',$numblocked,$beginblock,$finishblock)); - $r->print(&Apache::loncommon::build_block_table($startblock,$endblock, - \%setters)); + $r->print(&blocked_in_folder($numblocked,$startblock,$endblock, + \%setters)); } } +sub blocked_in_folder { + my ($numblocked,$startblock,$endblock,$setters) = @_; + my $beginblock = &Apache::lonlocal::locallocaltime($startblock); + my $finishblock = &Apache::lonlocal::locallocaltime($endblock); + my $output = '

'. + &mt('[quant,_1,message is, messages are] not viewable because display of LON-CAPA messages sent to you by other students between [_2] and [_3] is currently being blocked because of online exams.',$numblocked,$beginblock,$finishblock); + $output .= &Apache::loncommon::build_block_table($startblock,$endblock, + $setters); + return $output; +} + # ============================================================== Compose output sub compout { @@ -2030,6 +2029,7 @@ sub displaymessage { 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'}. ($folder ne 'sent'?'
'.&mt('From').': '. &Apache::loncommon::aboutmewrapper( @@ -2045,25 +2045,36 @@ sub displaymessage { 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) { - &Apache::lonenc::check_decrypt(\$symb); - $symblink = '?symb='.$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; } - &Apache::lonenc::check_decrypt(\$baseurl); - $r->print('
'.&mt('Refers to').': '.$restitle.''); + $r->print('
'.&mt('Refers to').': '.$restitle.''); $refers_to = 1; } } if (!$refers_to) { if ($baseurl =~ m-^/enc/-) { if (defined($content{'courseid'})) { - my $unencurl = - &Apache::lonenc::unencrypted($baseurl, - $content{'courseid'}); - if (defined($unencurl)) { - if (&Apache::lonnet::allowed('bre',$unencurl)) { - $r->print('
'.&mt('Refers to'). - ': '.$restitle.''); + 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.''); + } } } } @@ -2260,7 +2271,7 @@ sub sendoffmail { } } if ($env{'form.additionalrec'}) { - foreach my $rec (split(/\,/,$env{'form.additionalrec'})) { + foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec'})) { my ($auname,$audom)=split(/:/,$rec); if (($auname ne "") && ($audom ne "")) { $toaddr{$auname.':'.$audom}=''; @@ -2345,7 +2356,7 @@ sub sendoffmail { split(/\:/,&unescape($specialmsgid)); foreach my $recipient (sort(keys(%toaddr))) { - if ($specialmsg_status{$recipient} eq 'ok') { + if ($specialmsg_status{$recipient} =~ /\s*(ok|con_delayed)\s*/) { my $usersubj = $subj_prefix.'['.$recipient.']'; my $usermsgid = &Apache::lonmsg::buildmsgid($stamp,$usersubj, @@ -2707,6 +2718,7 @@ sub handler { my $delresult = &deletefolder($folder); if ($delresult eq 'ok') { $r->print(&mt('Mail folder "[_1]" deleted.',$folder).'
'); + $env{'form.folder'} = ''; } else { $r->print(&mt('Deletion failed.').' '.$delresult.'
'); $showfolder = $folder; @@ -2737,8 +2749,6 @@ sub handler { =pod -=back - =cut 1;