--- loncom/interface/lonmsgdisplay.pm 2006/12/23 06:22:36 1.56.2.1 +++ loncom/interface/lonmsgdisplay.pm 2009/11/26 05:21:43 1.139 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging display # -# $Id: lonmsgdisplay.pm,v 1.56.2.1 2006/12/23 06:22:36 albertel Exp $ +# $Id: lonmsgdisplay.pm,v 1.139 2009/11/26 05:21:43 faziophi 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; @@ -130,9 +113,8 @@ use lib '/home/httpd/lib/perl/'; use LONCAPA; # Querystring component with sorting type -my $sqs; -my $startdis; -my $interdis; +my $sqs=''; +my $startdis=''; # ============================================================ List all folders @@ -154,6 +136,9 @@ sub folderlist { ); + # set se lastvisit for the new mail check in the toplevel menu + &Apache::lonnet::appenv({'user.mailcheck.lastvisit'=>time}); + my %actions = &Apache::lonlocal::texthash( view => 'View Folder', rename => 'Rename Folder', @@ -188,6 +173,7 @@ sub folderlist { $formhash{'select_form_order'} = ['','critical',@userorder,'sent','trash']; my $output = qq||; + my %show = ('select_form_order' => [10,20,50,100,200], + map {$_=>$_} (10,20,50,100,200)); + + $output .= '
@@ -240,12 +231,9 @@ function folder_choice(targetform,caller -
'.$lt{'fold'}.'
'."\n". &Apache::loncommon::select_form($folder,'folder',%formhash).'
'.$lt{'show'}.'
- +
'.$lt{'show'}.'
'."\n". + &Apache::loncommon::select_form($env{'form.interdis'},'interdis', + %show).'
'.$lt{'status'}.'
'."\n". &Apache::loncommon::select_form($msgstatus,'msgstatus',%statushash).' @@ -253,16 +241,16 @@ function folder_choice(targetform,caller
'.$lt{'actn'}.'
'. &Apache::loncommon::select_form('view','folderaction',%actions).'

'. - ' + '
     '. - ''. + '

-
'.&mt('New Folder').'
'. +
'.&mt('Name').'
'. '
@@ -301,16 +289,20 @@ sub scrollbuttons { $start++; $maxdis++;$first++;$finish++; my %statushash = &get_msgstatus_types(); - + my $status; + if ($msgstatus eq '') { + $status = &mt('All'); + } else { + $status = $statushash{$msgstatus}; + } return - ''.&mt('Page').': '. - ''. - ''. - ' of '.$maxdis. - ''. - '
'. - &mt('_location_in_mail_folder',$msgstatus,$statushash{$msgstatus}, - $first,$finish,$total).'
'; + ''.&mt('Page').': '. + ''. + ''. + ' / '.$maxdis.' '. + ''. + '
'. + &mt('[_1] messages: showing messages [_2] through [_3] of [_4].',$status,$first,$finish,$total).''; } # =============================================================== Status Change @@ -366,7 +358,7 @@ sub makefolder { } } else { $outcome = - &mt('Error - could not obtain lock on email folders record.'); + &mt('Error - could not obtain lock on message folders record.'); } return ($outcome,$warning); } @@ -389,8 +381,8 @@ sub deletefolder { my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix); if (@messages > 0) { return &mt('The folder "[_1]" contains messages so it may not be deleted.',$folder). - '
'. - &mt('Delete or move the messages to a different folder first.'); + '
'. + &mt('Delete or move the messages to a different folder first.'); } my $delresult = &Apache::lonnet::del('email_folders',[$folder]); return $delresult; @@ -403,6 +395,9 @@ sub renamefolder { if ($env{'form.renamed'} eq '') { return &mt('The folder "[_1]" may not be renamed to "[_2]" as the new name you requested is an invalid name.',$folder,$newname); } + if (defined($permfolders{$folder})) { + return &mt('The folder "[_1]" may not be renamed as it is a folder provided by the system.',$folder); + } if (defined($permfolders{$newname})) { return &mt('The folder "[_1]" may not be renamed to "[_2]" as the new name you requested is reserved for folders provided automatically by the system.',$folder,$newname); } @@ -512,7 +507,9 @@ sub movemsg { # ======================================================= Display a course list sub discourse { - my $result; + my ($statushash) = @_; + my ($result,$active,$previous,$future); + my $crstype = &Apache::loncommon::course_type(); my ($course_personnel, $current_members, $expired_members, @@ -521,51 +518,108 @@ sub discourse { unshift @$current_members, (@$course_personnel); my %defaultUsers; - $result .= ''."\n"; + my $tmptext; + if ($tmptext = &Apache::lonselstudent::render_student_list($current_members, + "activeusers", + "current", + \%defaultUsers, + 1,"selectedusers",1,'email') + ) { + my $bcc_curr_hdr; + if ($crstype eq 'Community') { + $bcc_curr_hdr = &mt('Bcc: community participants with current access'); + } else { + $bcc_curr_hdr = &mt('Bcc: course members with current access'); + } + $result .= '
' + .$bcc_curr_hdr + .'' + .'
'; + $result .= $tmptext.'

'; + if (ref($statushash) eq 'HASH') { + $statushash->{'active'} = 1; + } + } + if ($tmptext = &Apache::lonselstudent::render_student_list($expired_members, + "previoususers", + "expired", + \%defaultUsers, + 1, "selectedusers",0,'email') + ) { + my $bcc_prev_hdr; + if ($crstype eq 'Community') { + $bcc_prev_hdr = &mt('Bcc: community participants with expired access'); + } else { + $bcc_prev_hdr = &mt('Bcc: course members with expired access'); + } + $result .= '
' + .$bcc_prev_hdr + .'' + .'
'; + $result .= $tmptext.'

'; + if (ref($statushash) eq 'HASH') { + $statushash->{'previous'} = 1; + } - $result .= &Apache::lonselstudent::render_student_list($current_members, - "compemail", - "current", - \%defaultUsers, - 1,"selectedusers",1); - - $result .= &Apache::lonselstudent::render_student_list($expired_members, - "compemail", - "expired", - \%defaultUsers, - 1, "selectedusers",0); - $result .= &Apache::lonselstudent::render_student_list($future_members, - "compemail", - "future", - \%defaultUsers, - 1, "selectedusers", 0); + } + if ($tmptext = &Apache::lonselstudent::render_student_list($future_members, + "futureusers", + "future", + \%defaultUsers, + 1, "selectedusers",0,'email') + ) { + my $bcc_future_hdr; + if ($crstype eq 'Community') { + $bcc_future_hdr = &mt('Bcc: community participants with future access'); + } else { + $bcc_future_hdr = &mt('Bcc: course members with future access'); + } + + $result .= '
' + .$bcc_future_hdr + .'' + .'
'; + $result .= $tmptext.'
'; + if (ref($statushash) eq 'HASH') { + $statushash->{'future'} = 1; + } + + } return $result; } sub disgroup { - my ($cdom,$cnum,$group,$viewgrps,$editgrps) = @_; - my $result; + my ($r,$cdom,$cnum,$group,$access_status) = @_; + my $hasfloat; # Needs to be in a course if (!($env{'request.course.fn'})) { - $result = &mt('Error: you must have a course role selected to be able to send a broadcast message to a group in the course.'); - return $result; + $r->print(''.&mt('Error: you must have a course role selected to be able to send a broadcast message to a group in the course.').''); + return; } if ($cdom eq '' || $cnum eq '') { - $result = &mt('Error: could not determine domain or number of course'); - return $result; + $r->print(''.&mt('Error: could not determine domain or number of course').''); + return; } my ($memberinfo,$numitems) = &Apache::longroup::group_memberlist($cdom,$cnum,$group,{},[]); my @statustypes = ('active'); + my $viewgrps = &Apache::lonnet::allowed('vcg',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); + my $editgrps = &Apache::lonnet::allowed('mdg',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); if ($viewgrps || $editgrps) { push(@statustypes,('future','previous')); } if (keys(%{$memberinfo}) == 0) { - $result = &mt('As this group has no members, there are no '. - 'recipients to select.'); - return $result; + $r->print(''. + &mt('As this group has no members, there are no recipients to select'). + ''); + return; } else { - $result = &mt('Select message recipients from the group members listed below.
'); + $hasfloat = 1; + unless($env{'environment.wysiwygeditor'} eq 'on') { + $r->print('
'); + } my %Sortby = ( active => {}, previous => {}, @@ -575,9 +629,9 @@ sub disgroup { 'name' => 'Name', 'usnm' => 'Username', 'doma' => 'Domain', - 'active' => 'Active Members', - 'previous' => 'Former Members', - 'future' => 'Future Members', + 'active' => 'Broadcast to Active Members', + 'previous' => 'Broadcast (Bcc) to Former Members', + 'future' => 'Broadcast (Bcc) to Future Members', ); foreach my $user (sort(keys(%{$memberinfo}))) { my $status = $$memberinfo{$user}{status}; @@ -591,75 +645,82 @@ sub disgroup { push(@{$Sortby{$status}{$$memberinfo{$user}{fullname}}},$user); } } - $result .= &group_check_uncheck(); - $result .= ''. - ''; + $r->print(&group_check_uncheck()); foreach my $status (@statustypes) { if (ref($numitems) eq 'HASH') { if ((defined($$numitems{$status})) && ($$numitems{$status})) { - $result.='". - "". - "". - &Apache::loncommon::end_data_table_header_row(); + my $formname = $status.'users'; + if (ref($access_status) eq 'HASH') { + $access_status->{$status} = $$numitems{$status}; + } + $r->print('
'. + ''.$lt{$status}.''. + '
'. + ''. + ''. + '  '. + ''. + ''); + if ($status eq 'active') { + $r->print((' 'x3).''); + } + $r->print('
'.&Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + "
". + "". + "". + &Apache::loncommon::end_data_table_header_row()); foreach my $key (sort(keys(%{$Sortby{$status}}))) { foreach my $user (@{$Sortby{$status}{$key}}) { - $result .= - &Apache::loncommon::start_data_table_row(). - ''. + $$memberinfo{$user}{'fullname'}.''. ''. ''. - &Apache::loncommon::end_data_table_row(); + &Apache::loncommon::end_data_table_row()); } } - $result .= &Apache::loncommon::end_data_table(); + $r->print(&Apache::loncommon::end_data_table().''. + '
'); } } - $result .= ''; } - $result .= '
'. - '
'.$lt{$status}. - ''. - ''. - '  '. - ''. - '

'. - &Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row(); - $result .= "
$lt{'name'}$lt{'usnm'}$lt{'doma'}$lt{'name'}$lt{'usnm'}$lt{'doma'}print(&Apache::loncommon::start_data_table_row(). + ''. - $$memberinfo{$user}{'fullname'}.''.$$memberinfo{$user}{'uname'}.''.$$memberinfo{$user}{'udom'}.'  
'; + unless($env{'environment.wysiwygeditor'} eq 'on') { + $r->print('
'); + } } - return $result; + return $hasfloat; } sub group_check_uncheck { my $output = qq| |; } @@ -689,10 +750,16 @@ sub groupmail_header { } &Apache::lonhtmlcommon::clear_breadcrumbs(); if ($refarg) { + my $brtitle; + if (&Apache::loncommon::course_type() eq 'Community') { + $brtitle = 'View community groups'; + } else { + $brtitle = 'View course groups'; + } &Apache::lonhtmlcommon::add_breadcrumb ({href=>"/adm/coursegroups", text=>"Groups", - title=>"View course groups"}); + title=>$brtitle}); } &Apache::lonhtmlcommon::add_breadcrumb ({href=>"/adm/$cdom/$cnum/$group/smppg?$refarg", @@ -701,13 +768,13 @@ sub groupmail_header { {href=>"/adm/email?compose=group&group=". "$env{'form.group'}&$refarg", text=>"Send a Message in a Group", - title=>"Compose Group Email Message"},); + title=>"Compose Group Message"},); if ($action eq 'sending') { &Apache::lonhtmlcommon::add_breadcrumb ({text=>"Messages being sent.", - title=>"Messages sent"},); + title=>"E-mails sent"},); } - my $groupheader = &Apache::loncommon::start_page('Group Email'); + my $groupheader = &Apache::loncommon::start_page('Group Message'); $groupheader .= &Apache::lonhtmlcommon::breadcrumbs ('Group - '.$env{'form.group'}.' Email'); return $groupheader; @@ -721,7 +788,7 @@ sub groupmail_sent { } my $output .= '

'. - &mt('Send another group email').''.'   '. + &mt('Send another group message').''.'   '. ''. &mt('Return to group page').''; return $output; @@ -731,28 +798,59 @@ sub groupmail_sent { sub discrit { my $r=shift; - my $header = '

'.&mt('Critical Messages').'

'. - '
'. - ''; + my $header = '

'.&mt('Critical Messages').'

' + .'
' + .&mt('Access to other pages will be prevented until you have moved all critical messages to your inbox.') + .'

' + .'' + .''; my %what=&Apache::lonnet::dump('critical'); my $result = ''; foreach my $key (sort(keys(%what))) { my %content=&Apache::lonmsg::unpackagemsg($what{$key}); next if ($content{'senderdomain'} eq ''); - $result.='
'.&mt('From').': '. -&Apache::loncommon::aboutmewrapper( - &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('. -$content{'sendername'}.':'. - $content{'senderdomain'}.') '.$content{'time'}. - '
'.&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'). - '
'. - ''. - ''; + $result .= &Apache::lonhtmlcommon::start_pick_box() + .&Apache::lonhtmlcommon::row_title(&mt('From'),undef,'LC_oddrow_value') + .''.&Apache::loncommon::aboutmewrapper( + &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).'' + .' ('.$content{'sendername'}.':'.$content{'senderdomain'}.')' + .&Apache::lonhtmlcommon::row_closure(1) + .&Apache::lonhtmlcommon::row_title(&mt('Date'),undef,'LC_evenrow_value') + .$content{'time'} + .&Apache::lonhtmlcommon::row_closure(1) + .&Apache::lonhtmlcommon::row_title(&mt('Subject'),undef,'LC_oddrow_value') + .$content{'subject'} + .&Apache::lonhtmlcommon::row_closure(1) + .&Apache::lonhtmlcommon::row_title(&mt('Message'),undef,'LC_evenrow_value') + .'
'.&Apache::lontexconvert::msgtexconverted($content{'message'}).'
' + .&Apache::lonhtmlcommon::row_closure() + .&Apache::lonhtmlcommon::row_title('',undef,'LC_oddrow_value') + .'
'; + 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 .= '
' + .&Apache::lonhtmlcommon::row_closure(1) + .&Apache::lonhtmlcommon::row_title('',undef,'LC_evenrow_value') + .''; + if (!$content{'noreplies'}) { + $result .= '' + } + $result .= &Apache::lonhtmlcommon::row_closure(1) + .&Apache::lonhtmlcommon::end_pick_box() + .'
'; } # Check to see if there were any messages. if ($result eq '') { @@ -770,7 +868,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; @@ -784,8 +881,9 @@ sub sortedmessages { } foreach my $msgid (@messages) { + next if ($msgid eq ''); 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); @@ -888,6 +986,16 @@ sub get_course_desc { sub disall { my ($r,$folder,$msgstatus)=@_; + my %saveable = ('msgstatus' => 'scalar', + 'sortedby' => 'scalar', + 'interdis' => 'scalar', + ); + &Apache::loncommon::store_settings('user','mail',\%saveable); + &Apache::loncommon::restore_settings('user','mail',\%saveable); + $folder ||= $env{'form.folder'}; + $msgstatus ||= $env{'form.msgstatus'}; + $env{'form.interdis'} ||= 20; + $r->print(&folderlist($folder,$msgstatus)); if ($folder eq 'critical') { &discrit($r); @@ -910,28 +1018,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; i ENDDISHEADER - my $fsqs='&folder='.$folder; + my $fsqs='&folder='.$folder; my @temp=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder,$msgstatus); my $totalnumber=$#temp+1; if ($totalnumber < 1) { - $r->print('

'.&mt('_empty_mail_folder', - $msgstatus, - $statushash{$msgstatus}).'

'); + if ($msgstatus eq '') { + $r->print('

'.&mt('Empty Folder').'

'); + } elsif ($msgstatus eq 'replied') { + $r->print('

'.&mt('You have not replied to any messages in this folder.').'

'); + } else { + $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; } - unless ($interdis) { - $interdis=20; - } + my $interdis = $env{'form.interdis'}; my $number=int($totalnumber/$interdis); - if ($interdis) { - if ($totalnumber%$interdis == 0) { - $number--; - } + if ($totalnumber%$interdis == 0) { + $number--; } if (($startdis<0) || ($startdis>$number)) { $startdis=$number; } @@ -985,48 +1086,50 @@ ENDDISHEADER $r->print(''. ''); + $r->print(''.&mt('Date').''); } else { - $r->print(''.&mt('Date').''); + $r->print(''.&mt('Date').''); } $r->print(''); + $r->print(''.&mt('Status').''); } else { - $r->print(''.&mt('Status').''); + $r->print(''.&mt('Status').''); } $r->print("\n"); my $suffix = &Apache::lonmsg::foldersuffix($folder); + my $count = $firstdis; for (my $n=$firstdis;$n<=$lastdis;$n++) { my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID, $description,$recv_name,$recv_domain)= @{$temp[$n]}; if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) { + $count ++; if ($status eq 'new') { $r->print(''); } elsif ($status eq 'read') { @@ -1038,28 +1141,34 @@ 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); - my $count = $n +1; - $r->print(''); + ' value="'.$origID.'" />'); foreach my $item ($localsenttime,$dis_name,$dis_domain,$shortsubj) { $r->print(''); + $item.(($status eq 'new')?'':'').''); } my $showstatus; my %statushash = &get_msgstatus_types(); @@ -1083,11 +1192,11 @@ ENDDISHEADER $r->print('
 '); if ($env{'form.sortedby'} eq "revdate") { - $r->print(''.&mt('Date').''); if ($env{'form.sortedby'} eq "revuser") { - $r->print(''.&mt('Username').''); + $r->print(''.&mt('Username').''); } else { - $r->print(''.&mt('Username').''); + $r->print(''.&mt('Username').''); } $r->print(''); if ($env{'form.sortedby'} eq "revdomain") { - $r->print(''.&mt('Domain').''); + $r->print(''.&mt('Domain').''); } else { - $r->print(''.&mt('Domain').''); + $r->print(''.&mt('Domain').''); } $r->print(''); if ($env{'form.sortedby'} eq "revsubject") { - $r->print(''.&mt('Subject').''); + $r->print(''.&mt('Subject').''); } else { - $r->print(''.&mt('Subject').''); + $r->print(''.&mt('Subject').''); } $r->print(''); if ($env{'form.sortedby'} eq "revcourse") { - $r->print(''.&mt('Course').''); + $r->print(''.&mt('Course').''); } else { - $r->print(''.&mt('Course').''); + $r->print(''.&mt('Course').''); } $r->print(''); if ($env{'form.sortedby'} eq "revstatus") { - $r->print(''.&mt('Status').'
'.(($status eq 'new')?'':''). + $r->print(''.(($status eq 'new')?'':''). $count.'.'.(($status eq 'new')?'':'').' '. ''.(($status eq 'new')?'':''). ''. - $item.(($status eq 'new')?'':'').'
'."\n". ''."\n". '
'. - '
'."\n". - ''."\n". + '
'."\n". + ''."\n". '
 '.&mt('Action').'
'."\n". - ' '."\n"); if ($folder ne 'trash') { $r->print(' '."\n"); @@ -1122,17 +1231,28 @@ ENDDISHEADER '" onclick="javascript:validate_checkedaction()"/>
'); my $postedstartdis=$startdis+1; - $r->print(''); + $r->print(''); 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); + + my ($blocked, $blocktext) = &Apache::loncommon::blocking_status("com"); + $output .="

".$blocktext; + + return $output; +} + # ============================================================== Compose output sub compout { @@ -1173,7 +1293,15 @@ sub compout { text=>"Display All Messages"}); &printheader($r,'/adm/email?compose=multiforward', 'Forwarding Multiple Messages'); - $r->print(&mt('Each of the [quant,_1,message] you checked will be forwarded to the recipient(s) you select below.',$multiforward).'
'); + if ($multiforward > 1) { + $r->print(&mt('Each of the [quant,_1,message] you checked' + .' will be forwarded to the recipient(s) you select below.' + ,''.$multiforward.'') + .'
'); + } else { + $r->print(&mt('The message you checked will be forwarded to the recipient(s) you select below.').'
'); + } + } else { &printheader($r,'/adm/email?compose=upload', 'Distribute from Uploaded File'); @@ -1183,42 +1311,140 @@ sub compout { my $dissub=''; my $dismsg=''; my $disbase=''; - my $func=&mt('Send New'); + my $attachrow; + my $func1='Send'; # do not translate here! + my %func2=( # do not translate here! + 'ma' => 'Message', + 'msg' => 'Messages', + ); my %lt=&Apache::lonlocal::texthash('us' => 'Username', 'do' => 'Domain', 'ad' => 'Additional Recipients', + 'rt' => 'Reply to', + 'ar' => 'Allow replies', 'sb' => 'Subject', 'ca' => 'Cancel', - 'ma' => 'Mail', - 'msg' => 'Messages', 'gen' => 'Generate messages from a file', 'gmt' => 'General message text', 'tff' => 'The file format for the uploaded portion of the message is', 'uas' => 'Upload and Send', + 'atta' => 'Attachment', + 'to' => 'To:', ); + my %attachmax = ( + text => &mt('(128 KB max size)'), + num => 131072, + ); + if (!$forwarding && !$multiforward) { + $attachrow = ''.$lt{'atta'}.' '.$attachmax{'text'}.': '; + } if (&Apache::lonnet::allowed('srm',$env{'request.course.id'}) || &Apache::lonnet::allowed('srm',$env{'request.course.id'}. '/'.$env{'request.course.sec'})) { + my $crstype = &Apache::loncommon::course_type(); my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message"); + my $rsstxt; + if (&Apache::loncommon::course_type() eq 'Community') { + $rsstxt = &mt('Include in community RSS newsfeed'); + } else { + $rsstxt = &mt('Include in course RSS newsfeed'); + } $dispcrit= - '

' . $crithelp . - '

'. - '' . $crithelp . - '

'. -'

'; - } + ''.$crithelp.'  '.&mt('Require return receipt?').'  
'. + '
'. +'
'; + } + if ($broadcast ne 'group') { + if (&Apache::lonnet::allowed('dff',$env{'request.course.id'}) || + &Apache::lonnet::allowed('dff',$env{'request.course.id'}. + '/'.$env{'request.course.sec'})) { + + my $rectxt; + if (&Apache::loncommon::course_type() eq 'Community') { + $rectxt = &mt("Include in community's 'User records' for recipient(s)"); + } else { + $rectxt = &mt("Include in course's 'User records' for recipient(s)"); + } + + $dispcrit.='
'; + } + } + my %message; my %content; + my ($hasfloat,$broadcast_js,$sendmode,$can_grp_broadcast); my $defdom=$env{'user.domain'}; + if ($broadcast eq 'group') { + my %access_status = ( + active => 0, + previous => 0, + future => 0, + ); + + if ($group eq '') { + my $studentsel = &discourse(\%access_status); + if ($studentsel) { + if ($env{'environment.wysiwygeditor'} eq 'on') { + $r->print($studentsel); + } else { + $r->print('
'.$studentsel.'
'); + } + $hasfloat = 1; + } + } else { + $can_grp_broadcast = &check_group_priv($group); + if ($can_grp_broadcast) { + $hasfloat = &disgroup($r,$cdom,$cnum,$group,\%access_status); + } + } + if ($hasfloat) { + $sendmode = ''."\n"; + $broadcast_js = qq| + + +|; + } + } if ($forwarding) { %message=&Apache::lonnet::get('nohist_email'.$suffix,[$forwarding]); %content=&Apache::lonmsg::unpackagemsg($message{$forwarding},$folder); $dispcrit.=''; - $func=&mt('Forward'); + $func1='Forward'; # do not translate here! $dissub=&mt('Forwarding').': '.$content{'subject'}; $dismsg=&mt('Forwarded message from').' '. @@ -1232,7 +1458,7 @@ sub compout { %content=&Apache::lonmsg::unpackagemsg($message{$replying},$folder); $dispcrit.=''; - $func=&mt('Send Reply to'); + $func1='Send Reply to'; # do not translate here! $dissub=&mt('Reply').': '.$content{'subject'}; $dismsg='> '.$content{'message'}; @@ -1242,56 +1468,142 @@ sub compout { if ($content{'baseurl'}) { $disbase=''; if ($env{'user.adv'}) { - $disbase.='