--- loncom/interface/lonmsgdisplay.pm 2006/12/07 21:21:04 1.49 +++ loncom/interface/lonmsgdisplay.pm 2007/01/04 02:02:36 1.61 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging display # -# $Id: lonmsgdisplay.pm,v 1.49 2006/12/07 21:21:04 albertel Exp $ +# $Id: lonmsgdisplay.pm,v 1.61 2007/01/04 02:02:36 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -74,8 +74,8 @@ email program, so they have full access interface, or other features they may wish to use in response to the student's query. -=item * B: LON-CAPA can block display of e-mails that are -sent to a student during an online exam. A course coordinator or +=item * B: LON-CAPA can block selected communication +features for students during an online exam. A course coordinator or instructor can set an open and close date/time for scheduled online exams in a course. If a user uses the LON-CAPA internal messaging system to display e-mails during the scheduled blocking event, @@ -132,17 +132,25 @@ use LONCAPA; # Querystring component with sorting type my $sqs; my $startdis; -my $interdis; # ============================================================ List all folders sub folderlist { - my $folder=shift; + my ($folder,$msgstatus) = @_; my %lt = &Apache::lonlocal::texthash( actn => 'Action', fold => 'Folder', show => 'Show', + status => 'Message Status', go => 'Go', + nnff => 'New Name for Folder', + newn => 'New Name', + thfm => 'The folder may not be renamed', + fmnb => 'folder may not be renamed as it is a folder provided by the system.', + asth => 'as this name is already in use for a system-provided or user-defined folder.', + the => 'The', + tnfm => 'The new folder may not be named', + ); my %actions = &Apache::lonlocal::texthash( @@ -152,6 +160,10 @@ sub folderlist { ); $actions{'select_form_order'} = ['view','rename','delete']; + my %statushash = &get_msgstatus_types(); + + $statushash{'select_form_order'} = ['','new','read','replied','forwarded']; + my %permfolders = &get_permanent_folders(); my $permlist = join("','",sort(keys(%permfolders))); my ($permlistkeys,$permlistvals); @@ -165,6 +177,7 @@ sub folderlist { my %userfolders; foreach my $key (keys(%gotfolders)) { + $key =~ s/(['"])/\$1/g; #' stupid emacs $userfolders{$key} = $key; } my @userorder = sort(keys(%userfolders)); @@ -172,7 +185,7 @@ sub folderlist { my $folderlist = join("','",@userorder); $folderlist .= "','".$permlistvals; - $formhash{'select_form_order'} = ['','critical','new',@userorder,'sent','trash']; + $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 .= '
@@ -226,12 +243,12 @@ 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).'
'.$lt{'actn'}.'
'. &Apache::loncommon::select_form('view','folderaction',%actions).' @@ -253,7 +270,7 @@ function folder_choice(targetform,caller
'."\n". ''. ''. - ($folder=~/^(new|critical)/?'
':''); + ($folder=~/^critical/?'':''); return $output; } @@ -261,25 +278,43 @@ sub get_permanent_folders { my %permfolders = &Apache::lonlocal::texthash('' => 'INBOX', 'trash' => 'TRASH', - 'new' => 'New Messages Only', 'critical' => 'Critical', 'sent' => 'Sent Messages', ); return %permfolders; } +sub get_msgstatus_types { + my %statushash = &Apache::lonlocal::texthash( + '' => 'Any', + new => 'Unread', + read => 'Read', + replied => 'Replied to', + forwarded => 'Forwarded', + ); + return %statushash; +} + sub scrollbuttons { - my ($start,$maxdis,$first,$finish,$total)=@_; + my ($start,$maxdis,$first,$finish,$total,$msgstatus)=@_; unless ($total>0) { return ''; } $start++; $maxdis++;$first++;$finish++; + + my %statushash = &get_msgstatus_types(); + my $status; + if ($msgstatus eq '') { + $status = &mt('All'); + } else { + $status = $statushash{$msgstatus}; + } return - &mt('Page').': '. + ''.&mt('Page').': '. ''. ''. ' of '.$maxdis. ''. '
'. - &mt('Showing messages [_1] through [_2] of [_3]',$first,$finish,$total).''; + &mt('[_1] messages: showing messages [_2] through [_3] of [_4].',$status,$first,$finish,$total).''; } # =============================================================== Status Change @@ -346,18 +381,18 @@ sub deletefolder { my ($folder)=@_; my %permfolders = &get_permanent_folders(); if (defined($permfolders{$folder})) { - return &mt('The folder [_1] may not be deleted',$folder); + return &mt('The folder "[_1]" may not be deleted',$folder); } my %userfolders = &Apache::lonmsg::get_user_folders(); if (!defined($userfolders{$folder})) { - return &mt('The folder [_1] does not exist so deletion is not required.', + return &mt('The folder "[_1]" does not exist so deletion is not required.', $folder); } # check folder is empty; my $suffix=&Apache::lonmsg::foldersuffix($folder); my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix); if (@messages > 0) { - return &mt('The folder [_1] contains messages so it may not be deleted.'). + 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.'); } @@ -569,10 +604,10 @@ sub disgroup { $result.=''. '
'.$lt{$status}. ''. - ''. '  '. - ''. '

'. &Apache::loncommon::start_data_table(). @@ -736,10 +771,9 @@ $content{'sendername'}.':'. } sub sortedmessages { - my ($blocked,$startblock,$endblock,$numblocked,$folder) = @_; + 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; @@ -754,9 +788,10 @@ 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); my $description = &get_course_desc($fromcid,\%descriptions); my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status, $esc_msgid,$description); @@ -852,148 +887,117 @@ sub get_course_desc { } } -# ======================================================== Display new messages - - -sub disnew { - my $r=shift; - my %lt=&Apache::lonlocal::texthash( - 'nm' => 'New Messages', - 'su' => 'Subject', - 'co' => 'Course', - 'da' => 'Date', - 'us' => 'Username', - 'op' => 'Open', - 'do' => 'Domain' - ); - my @msgids = sort(&Apache::lonnet::getkeys('nohist_email')); - my @newmsgs; - my %setters = (); - my %blocked = (); - my $numblocked = 0; - # Check for blocking of display because of scheduled online exams. - my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com'); - my %status_cache = - &Apache::lonnet::get('email_status',\@msgids); - my %descriptions; - foreach my $id (@msgids) { - my $msgid=&escape($id); - my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)= - &Apache::lonmsg::unpackmsgid($msgid,undef,undef,\%status_cache); - if (defined($sendtime) && $sendtime!~/error/) { - my $description = &get_course_desc($fromcid,\%descriptions); - my $numsendtime = $sendtime; - $sendtime = &Apache::lonlocal::locallocaltime($sendtime); - if ($status eq 'new') { - if ($numsendtime >= $startblock && ($numsendtime <= $endblock && $endblock > 0) ) { - $blocked{$id} = 'ON'; - $numblocked ++; - } else { - push(@newmsgs, { - msgid => $msgid, - sendtime => $sendtime, - shortsub => $shortsubj, - from => $fromname, - fromdom => $fromdom, - course => $description, - }); - } - } - } - } - if ($#newmsgs >= 0) { - $r->print(<$lt{'nm'} - - -TABLEHEAD - foreach my $msg (@newmsgs) { - $r->print(<<"ENDLINK"); - - -ENDLINK - foreach my $item ('sendtime','from','fromdom','shortsub','course') { - $r->print(""); - } - $r->print(""); - } - $r->print('
 $lt{'da'}$lt{'us'}$lt{'do'}$lt{'su'}$lt{'co'}
$lt{'op'}$msg->{$item}
'); - } elsif ($numblocked == 0) { - $r->print("

".&mt('You have no unread messages')."

"); - } - if ($numblocked > 0) { - my $beginblock = &Apache::lonlocal::locallocaltime($startblock); - my $finishblock = &Apache::lonlocal::locallocaltime($endblock); - $r->print('

'.&mt('You have [quant,_1,blocked unread message,blocked unread messages].',$numblocked).'

'."\n". - &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).'
'."\n". - &Apache::loncommon::build_block_table($startblock,$endblock, - \%setters)); - } -} - - # ======================================================== Display all messages sub disall { - my ($r,$folder)=@_; - $r->print(&folderlist($folder)); - if ($folder eq 'new') { - &disnew($r); - } elsif ($folder eq 'critical') { + my ($r,$folder,$msgstatus)=@_; + my %saveable = ('folder' => 'scalar', + '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); } else { - &disfolder($r,$folder); + &disfolder($r,$folder,$msgstatus); } } # ============================================================ Display a folder sub disfolder { - my ($r,$folder)=@_; + my ($r,$folder,$msgstatus)=@_; + my %statushash = &get_msgstatus_types(); my %blocked = (); my %setters = (); my $numblocked = 0; my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com'); + my %lt = &Apache::lonlocal::texthash( + sede => 'Select a destination folder to which the messages will be moved.', + nome => 'No messages have been selected to apply ths action to.', + chec => 'Check the checkbox for at least one message.', + ); $r->print(< function checkall() { - for (i=0; i ENDDISHEADER + my $fsqs='&folder='.$folder; - my @temp=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder); + my @temp=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder,$msgstatus); my $totalnumber=$#temp+1; - unless ($totalnumber>0) { - $r->print('

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

'); + if ($totalnumber < 1) { + 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.').'

'); + } return; } - unless ($interdis) { - $interdis=20; - } + my $interdis = $env{'form.interdis'}; my $number=int($totalnumber/$interdis); + if ($totalnumber%$interdis == 0) { + $number--; + } + if (($startdis<0) || ($startdis>$number)) { $startdis=$number; } my $firstdis=$interdis*$startdis; if ($firstdis>$#temp) { $firstdis=$#temp-$interdis+1; } my $lastdis=$firstdis+$interdis-1; if ($lastdis>$#temp) { $lastdis=$#temp; } - $r->print(&scrollbuttons($startdis,$number,$firstdis,$lastdis,$totalnumber)); + $r->print(&scrollbuttons($startdis,$number,$firstdis,$lastdis,$totalnumber,$msgstatus)); $r->print('
'. - '
 '); + ''); } else { @@ -1060,14 +1064,28 @@ ENDDISHEADER $dis_domain = join('
',@{$content{'recdomain'}}); } } - $r->print(''. - ''."\n"); + my $localsenttime = &Apache::lonlocal::locallocaltime($sendtime); + my $count = $n +1; + $r->print(''); + foreach my $item ($localsenttime,$dis_name,$dis_domain,$shortsubj) { + $r->print(''); + } + my $showstatus; + my %statushash = &get_msgstatus_types(); + if ($status eq '') { + $showstatus = ''; + } else { + $showstatus = $statushash{$status}; + } + $r->print(''."\n"); } elsif ($status eq 'deleted') { # purge my ($result,$msg) = @@ -1075,30 +1093,55 @@ ENDDISHEADER } } - $r->print("
 '); if ($env{'form.sortedby'} eq "revdate") { $r->print(''.&mt('Date').''.&mt('Open').''. - ($folder ne 'trash'?''.&mt('Delete'):' ').''.&Apache::lonlocal::locallocaltime($sendtime).''. - $dis_name.''.$dis_domain.''. - $shortsubj.''. - $description.''.$status.'
'.(($status eq 'new')?'':''). + $count.'.'.(($status eq 'new')?'':'').' '. + ''.(($status eq 'new')?'':''). + ''. + $item.(($status eq 'new')?'':'').''.(($status eq 'new')?'':'').$description. + (($status eq 'new')?'':'').''. + (($status eq 'new')?'':'').$showstatus. + (($status eq 'new')?'':'').'
\n

". - ''.&mt('Check All').' '. - ''.&mt('Uncheck All').'

'. - ''); + $r->print("
\n"); + $r->print(' + + '."\n". + ''."\n"); + + if (keys(%gotfolders) > 0) { + $r->print(''); + } + $r->print(''."\n". + '
'. + '
'."\n". + ''."\n". + '
 '.&mt('Action').'
'."\n". + '

'); + $r->print(' '."\n"); } - $r->print('

'); - my %gotfolders = &Apache::lonmsg::get_user_folders(); - my %userfolders; - foreach my $key (keys(%gotfolders)) { - $userfolders{$key} = $key; + if ($msgstatus ne 'read') { + $r->print(' ."\n"'); } - $r->print( - &Apache::loncommon::select_form('','movetofolder', - %userfolders)); + if ($msgstatus ne 'unread') { + $r->print(' '."\n"); + } + $r->print(' '."\n"); + + my %gotfolders = &Apache::lonmsg::get_user_folders(); + if (keys(%gotfolders) > 0) { + $r->print(' '); + } + $r->print("\n".'

'.&mt('Destination folder').'
'); + my %userfolders; + foreach my $key (keys(%gotfolders)) { + $userfolders{$key} = $key; + } + $userfolders{''} = ""; + $r->print(&Apache::loncommon::select_form('','movetofolder',%userfolders). + '
   '. + '
'); 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('[_1,quant,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)); + &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)); } @@ -1107,7 +1150,8 @@ ENDDISHEADER # ============================================================== Compose output sub compout { - my ($r,$forwarding,$replying,$broadcast,$replycrit,$folder,$dismode)=@_; + my ($r,$forwarding,$replying,$broadcast,$replycrit,$folder,$dismode, + $multiforward)=@_; my $suffix=&Apache::lonmsg::foldersuffix($folder); my ($cdom,$cnum,$group,$refarg); if (exists($env{'form.group'})) { @@ -1137,6 +1181,13 @@ sub compout { } elsif ($replycrit) { $r->print('

'.&mt('Replying to a Critical Message').'

'); $replying=$replycrit; + } elsif ($multiforward) { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>"/adm/email?folder=".&escape($folder), + 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).'
'); } else { &printheader($r,'/adm/email?compose=upload', 'Distribute from Uploaded File'); @@ -1147,13 +1198,18 @@ sub compout { my $dismsg=''; my $disbase=''; my $func=&mt('Send New'); - my %lt=&Apache::lonlocal::texthash('us' => 'Username', - 'do' => 'Domain', - 'ad' => 'Additional Recipients', - 'sb' => 'Subject', - 'ca' => 'Cancel', - 'ma' => 'Mail'); - + my %lt=&Apache::lonlocal::texthash('us' => 'Username', + 'do' => 'Domain', + 'ad' => 'Additional Recipients', + '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', + ); if (&Apache::lonnet::allowed('srm',$env{'request.course.id'}) || &Apache::lonnet::allowed('srm',$env{'request.course.id'}. '/'.$env{'request.course.sec'})) { @@ -1250,24 +1306,49 @@ sub compout { } } my $latexHelp = Apache::loncommon::helpLatexCheatsheet(); - if ($broadcast ne 'upload') { - $r->print(<<"ENDCOMP"); -$lt{'ad'}
username:domain,username:domain, ... - - -$lt{'sb'}: - + my $subj_size; + if ($multiforward) { + $r->print(&additional_rec_row(\%lt)); + $r->print(''. + &mt('Unless you choose otherwise:').'
  • '. + &mt("The subject in each forwarded message will be 'Forwarding:' followed by the original subject.").'
  • '. + &mt("The message itself will begin with a first line: 'Forwarded message from' followed by the original sender's name.").'
'); + $func=&mt('Forward'); + $dissub = &mt('Forwarding').': '; + $subj_size = '10'; + my $extra = '<'.&mt('original subject').'>   '. + ''.&mt('Yes').' '.&mt('No'); + $dismsg = &mt('Forwarded message from ').' '; + my $sender = &mt("sender's name"); + $r->print(&msg_subject_row($dissub,\%lt,$subj_size,$extra)); + $r->print(''.&mt('Message begins with:').' '.$sender.'   '.&mt('Yes').' '.&mt('No').' + +
'. +$latexHelp. +&mt("Any new text to display before the text of the original messages:").'
+


'); + my @to_forward = &Apache::loncommon::get_env_multiple('form.delmark'); + foreach my $msg (@to_forward) { + $r->print(''); + } + $r->print(&submit_button_row($folder,$dismode,$func.' '.$lt{'msg'}, + \%lt)); + } elsif ($broadcast ne 'upload') { + $subj_size = '50'; + $r->print(&additional_rec_row(\%lt)); + $r->print(&msg_subject_row($dissub,\%lt,$subj_size)); + $r->print(<<"ENDCOMP"); + $latexHelp


$dispcrit $disbase - - - -
-$citation ENDCOMP + $r->print(&submit_button_row($folder,$dismode,$func.' '.$lt{'ma'}, + \%lt)); + $r->print($citation); if (exists($env{'form.ref'})) { $r->print(''); @@ -1277,31 +1358,34 @@ ENDCOMP $env{'form.group'}.'" />'); } } else { # $broadcast is 'upload' - $r->print(<print(< -

Generate messages from a file

+

$lt{'gen'}

Subject:

-

General message text
+

$lt{'gmt'}:

-The file format for the uploaded portion of the message is: -

-username1:domain1: text
-username2:domain2: text
-username3:domain1: text
-
+$lt{'tff'}: +ENDBLOCK + $r->print(' +
'."\n".
+&mt('username1:domain1: text')."\n".
+&mt('username2:domain2: text')."\n".
+&mt('username3:domain1: text')."\n".
+'

-The messages will be assembled from all lines with the respective -username:domain, and appended to the general message text.

+'.&mt('The messages will be assembled from all lines with the respective'."\n".'username:domain, and appended to the general message text.')); + $r->print(<

$dispcrit -

+

ENDUPLOAD } if ($broadcast eq 'group') { @@ -1334,6 +1418,35 @@ ENDREC return $output; } +sub additional_rec_row { + my ($lt) = @_; + my $output = <<"ENDADD"; +$lt->{'ad'}:
username:domain,username:domain, ... + + +ENDADD + return $output; +} + +sub submit_button_row { + my ($folder,$dismode,$sendtext,$lt) = @_; + my $output = qq| + + + +
+|; + return $output; +} + +sub msg_subject_row { + my ($dissub,$lt,$subj_size,$extra) = @_; + my $output = ''.$lt->{'sb'}.':'.$extra. + ''; + return $output; +} + sub retrieve_instructor_comments { my ($user,$domain)=@_; my $target=$env{'form.grade_target'}; @@ -1368,7 +1481,7 @@ sub disfacetoface { if (!&Apache::lonnet::allowed('dff',$env{'request.course.id'}) && ! &Apache::lonnet::allowed('dff',$env{'request.course.id'}. '/'.$env{'request.course.sec'})) { - $r->print('Not allowed'); + $r->print(&mt('Not allowed')); return; } my %records=&Apache::lonnet::dump('nohist_email', @@ -1450,7 +1563,7 @@ sub facetoface { if (!&Apache::lonnet::allowed('dff',$env{'request.course.id'}) && ! &Apache::lonnet::allowed('dff',$env{'request.course.id'}. '/'.$env{'request.course.sec'})) { - $r->print('Not allowed'); + $r->print(&mt('Not allowed')); return; } my $crstype = &Apache::loncommon::course_type(); @@ -1537,7 +1650,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' + 'ncbc' => 'No communication blocks currently stored', + 'stor' => 'Store', ); my %ltext = &Apache::lonlocal::texthash( @@ -1576,7 +1690,7 @@ sub examblock { $r->print(<<"END");
- + $end_page END @@ -1587,10 +1701,6 @@ sub blockstore { my $r = shift; my %lt=&Apache::lonlocal::texthash( 'tfcm' => 'The following changes were made', - 'cbps' => 'communication blocking period(s)', - 'werm' => 'was/were removed', - 'wemo' => 'was/were modified', - 'wead' => 'was/were added', 'ncwm' => 'No changes were made.' ); my %adds = (); @@ -1647,13 +1757,13 @@ sub blockstore { if ($chgestotal > 0) { $r->print($lt{'tfcm'}.'
    '); if ($canceltotal > 0) { - $r->print('
  • '.$canceltotal.' '.$lt{'cbps'},' '.$lt{'werm'}.'
  • '); + $r->print('
  • '.&mt('[quant,_1,communication blocking period was,communication blocking periods were] removed.',$canceltotal).'
  • '); } if ($modtotal > 0) { - $r->print('
  • '.$modtotal.' '.$lt{'cbps'},' '.$lt{'wemo'}.'
  • '); + $r->print('
  • '.&mt('[quant,_1,communication blocking period was,communication blocking periods were] modified.',$modtotal).'
  • '); } if ($addtotal > 0) { - $r->print('
  • '.$addtotal.' '.$lt{'cbps'},' '.$lt{'wead'}.'
  • '); + $r->print('
  • '.&mt('[quant,_1,communication blocking period was,communication blocking periods were] added.',$addtotal).'
  • '); } $r->print('
'); } else { @@ -1823,7 +1933,7 @@ sub blocktype_text { # ----------------------------------------------------------- Display a message sub displaymessage { - my ($r,$msgid,$folder)=@_; + my ($r,$msgid,$folder,$msgstatus)=@_; my $suffix=&Apache::lonmsg::foldersuffix($folder); my %blocked = (); my %setters = (); @@ -1832,14 +1942,16 @@ sub displaymessage { # info to generate "next" and "previous" buttons and check if message is blocked my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com'); - my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder); + my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder,$msgstatus); if ( $blocked{$msgid} eq 'ON' ) { &printheader($r,'/adm/email',&mt('Display a Message')); $r->print(&mt('You attempted to display a message that is currently blocked because you are enrolled in one or more courses for which there is an ongoing online exam.')); &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}); @@ -1868,7 +1980,6 @@ sub displaymessage { ''.&mt('Delete').''. ''.&mt('Back to Folder Display').''); if ($counter > 0){ $r->print(''.&mt('Next').''); } $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(''); - my $symb=&Apache::lonnet::symbread($content{'baseurl'}); if (&Apache::lonnet::allowed('vgr',$env{'request.course.id'})) { $r->print(''); } @@ -1903,6 +2019,17 @@ sub displaymessage { ' ('.$content{'recuser'}[$i].' at '.$content{'recdomain'}[$i].') '; } $tolist = join(', ',@recipients); + 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('
'.&mt('Subject').': '.$content{'subject'}. ($folder ne 'sent'?'
'.&mt('From').': '. &Apache::loncommon::aboutmewrapper( @@ -1913,13 +2040,46 @@ sub displaymessage { $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'}).')':''). - '

'.
+	      '
'.&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; + if ($symb) { + &Apache::lonenc::check_decrypt(\$symb); + $symblink = '?symb='.$symb; + } + &Apache::lonenc::check_decrypt(\$baseurl); + $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.''); + } + } + } + } else { + if (&Apache::lonnet::allowed('bre',$baseurl)) { + $r->print('
'.&mt('Refers to'). + ': '.$restitle.''); + } + } + } + } + $r->print('

'.
 	      &Apache::lontexconvert::msgtexconverted($content{'message'},1).
 	      '

'.&displayresource(%content).'

'); - return; + return; } # =========================================================== Show the citation @@ -1932,7 +2092,12 @@ sub displayresource { # if (($env{'request.course.id'} eq $content{'courseid'}) && (&Apache::lonnet::allowed('vgr',$content{'courseid'}))) { - my $symb=&Apache::lonnet::symbread($content{'baseurl'}); + my $symb; + if (defined($content{'symb'})) { + $symb = $content{'symb'}; + } else { + $symb=&Apache::lonnet::symbread($content{'baseurl'}); + } # Could not get a symb, give up unless ($symb) { return $content{'citation'}; } # Have a symb, can render @@ -2034,10 +2199,12 @@ sub sendoffmail { $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; } if ($env{'form.send'}) { - if ($group eq '') { - &printheader($r,'','Messages being sent.'); - } else { - $r->print(&groupmail_header('sending',$group)); + if (!$env{'form.multiforward'}) { + if ($group eq '') { + &printheader($r,'','Messages being sent.'); + } else { + $r->print(&groupmail_header('sending',$group)); + } } $r->rflush(); my %content=(); @@ -2122,11 +2289,9 @@ sub sendoffmail { my $msgtxt = $savemsg; if ($toaddr{$address}) { $msgtxt.='
'.$toaddr{$address}; } my @thismsg; - if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) && - (&Apache::lonnet::allowed('srm',$env{'request.course.id'}) - || &Apache::lonnet::allowed('srm',$env{'request.course.id'}. - '/'.$env{'request.course.sec'}))) { - $r->print(&mt('Sending critical message').' '.$recuname.':'.$recdomain.': '); + if ($msgtype eq 'critical') { + $r->print(&mt('Sending critical message').' '. + $recuname.':'.$recdomain.': '); @thismsg= &Apache::lonmsg::user_crit_msg($recuname,$recdomain, $msgsubj,$msgtxt, @@ -2148,7 +2313,7 @@ sub sendoffmail { $specialmsg_status{$recuname.':'.$recdomain} = join(' ',@thismsg); foreach my $result (@thismsg) { - if ($result eq 'ok') { + if ($result eq 'ok' || $result eq 'con_delayed') { $numspecial++; } } @@ -2215,20 +2380,24 @@ sub sendoffmail { } else { &printheader($r,'','No messages sent.'); } - if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) { - $r->print('
'.&mt('Completed.').''); - if ($env{'form.displayedcrit'}) { - &discrit($r); - } - if ($group ne '') { - $r->print(&groupmail_sent($group,$cdom,$cnum)); - } else { - &Apache::loncommunicate::menu($r); - } - } else { - $r->print('

'.&mt('Could not deliver message').' '. + if (!$env{'form.multiforward'}) { + if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) { + $r->print('
'.&mt('Completed.'). + ''); + if ($env{'form.displayedcrit'}) { + &discrit($r); + } + 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; } # ===================================================================== Handler @@ -2248,7 +2417,8 @@ sub handler { ['display','replyto','forward','markread','markdel','markunread', 'sendreply','compose','sendmail','critical','recname','recdom', 'recordftf','sortedby','block','folder','startdis','interdis', - 'showcommentbaseurl','dismode','group','subject','text','ref']); + 'showcommentbaseurl','dismode','group','subject','text','ref', + 'msgstatus']); $sqs='&sortedby='.$env{'form.sortedby'}; # ------------------------------------------------------ They checked for email @@ -2282,15 +2452,13 @@ sub handler { } # --------------------------------------------------------------------- Display - + my $msgstatus = $env{'form.msgstatus'}; $startdis=$env{'form.startdis'}; - $startdis--; + if ($startdis ne '') { + $startdis--; + } unless ($startdis) { $startdis=0; } - $interdis=$env{'form.interdis'}; - unless ($interdis) { $interdis=20; } - $sqs.='&interdis='.$interdis; - if ($env{'form.firstview'}) { $startdis=0; } @@ -2309,7 +2477,7 @@ sub handler { # --------------------------------------------------------------- Render Output if ($env{'form.display'}) { - &displaymessage($r,$env{'form.display'},$folder); + &displaymessage($r,$env{'form.display'},$folder,$msgstatus); } elsif ($env{'form.replyto'}) { &compout($r,'',$env{'form.replyto'},undef,undef,$folder,$dismode); } elsif ($env{'form.confirm'}) { @@ -2346,47 +2514,82 @@ sub handler { '

'.$msg."

\n"); } &Apache::loncommunicate::menu($r); - &disall($r,($folder?$folder:$dismode)); - } elsif ($env{'form.markedmove'}) { - my ($total,$failed,@failed_msg)=(0,0); - foreach my $key (keys(%env)) { - if ($key=~/^form\.delmark_(.*)$/) { - my ($result,$msg) = - &movemsg(&unescape($1),$folder, - $env{'form.movetofolder'}); - if ($result) { + &disall($r,($folder?$folder:$dismode),$msgstatus); + } elsif ($env{'form.markedaction'} eq 'markedforward') { + my $total = 0; + my @to_forward = &Apache::loncommon::get_env_multiple('form.delmark'); + foreach my $msgid (@to_forward) { + &statuschange(&unescape($msgid),'forwarded',$folder); + $total ++; + } + if ($total > 0) { + &compout($r,undef,undef,undef,undef,$folder,$dismode,$total); + } + } elsif ($env{'form.markedaction'} eq 'markedread') { + my $total = 0; + my @to_markread = &Apache::loncommon::get_env_multiple('form.delmark'); + foreach my $msgid (@to_markread) { + &statuschange(&unescape($msgid),'read',$folder); + $total ++; + } + &printheader($r,'','Marked Messages Read'); + $r->print(&mt('Marked [_1] message(s) read',$total).'

'); + &Apache::loncommunicate::menu($r); + &disall($r,($folder?$folder:$dismode),$msgstatus); + } elsif ($env{'form.markedaction'} eq 'markedunread') { + my $total = 0; + my @to_markunread = &Apache::loncommon::get_env_multiple('form.delmark'); + foreach my $msgid (@to_markunread) { + &statuschange(&unescape($msgid),'new',$folder); + $total ++; + } + &printheader($r,'','Marked Messages Unread'); + $r->print(&mt('Marked [_1] message(s) unread',$total).'

'); + &Apache::loncommunicate::menu($r); + &disall($r,($folder?$folder:$dismode),$msgstatus); + } elsif ($env{'form.markedaction'} eq 'markedmove') { + my $destfolder = $env{'form.movetofolder'}; + my %gotfolders = &Apache::lonmsg::get_user_folders(); + &printheader($r,'','Moved Messages'); + if (!defined($gotfolders{$destfolder})) { + $r->print(&mt('Destination folder [_1] is not a valid folder', + $destfolder)); + } else { + my ($total,$failed,@failed_msg)=(0,0); + my @to_move = &Apache::loncommon::get_env_multiple('form.delmark'); + foreach my $msgid (@to_move) { + my ($result,$msg) = &movemsg(&unescape($msgid),$folder, + $env{'form.movetofolder'}); + if ($result) { $total++; - } else { + } else { $failed++; push(@failed_msg,$msg); - } + } } - } - &printheader($r,'','Moved Messages'); - if ($failed) { - $r->print('

+ if ($failed) { + $r->print('

'.&mt('Failed to move [_1] message(s)',$failed). '

'); - $r->print('

'. - join("

\n

",@failed_msg). - "

\n"); - } - $r->print(&mt('Moved [_1] message(s)',$total).'

'); + $r->print('

'. + join("

\n

",@failed_msg). + "

\n"); + } + $r->print(&mt('Moved [_1] message(s)',$total).'

'); + } &Apache::loncommunicate::menu($r); - &disall($r,($folder?$folder:$dismode)); - } elsif ($env{'form.markeddel'}) { + &disall($r,($folder?$folder:$dismode),$msgstatus); + } elsif ($env{'form.markedaction'} eq 'markeddel') { my ($total,$failed,@failed_msg)=(0,0); - foreach my $key (keys(%env)) { - if ($key=~/^form\.delmark_(.*)$/) { - my ($result,$msg) = - &statuschange(&unescape($1),'deleted', - $folder); - if ($result) { - $total++; - } else { - $failed++; - push(@failed_msg,$msg); - } + my @to_delete = &Apache::loncommon::get_env_multiple('form.delmark'); + foreach my $msgid (@to_delete) { + my ($result,$msg) = &statuschange(&unescape($msgid),'deleted', + $folder); + if ($result) { + $total++; + } else { + $failed++; + push(@failed_msg,$msg); } } &printheader($r,'','Deleted Messages'); @@ -2400,12 +2603,12 @@ sub handler { } $r->print(&mt('Deleted [_1] message(s)',$total).'

'); &Apache::loncommunicate::menu($r); - &disall($r,($folder?$folder:$dismode)); + &disall($r,($folder?$folder:$dismode),$msgstatus); } elsif ($env{'form.markunread'}) { &printheader($r,'','Marked Message as Unread'); &statuschange($env{'form.markunread'},'new'); &Apache::loncommunicate::menu($r); - &disall($r,($folder?$folder:$dismode)); + &disall($r,($folder?$folder:$dismode),$msgstatus); } elsif ($env{'form.compose'}) { &compout($r,'','',$env{'form.compose'}); } elsif ($env{'form.recordftf'}) { @@ -2413,7 +2616,63 @@ sub handler { } elsif ($env{'form.block'}) { &examblock($r,$env{'form.block'}); } elsif ($env{'form.sendmail'}) { - &sendoffmail($r,$folder); + if ($env{'form.multiforward'}) { + &printheader($r,'','Messages being sent.'); + my $fixed_subj = $env{'form.subject'}; + my $suffix=&Apache::lonmsg::foldersuffix($folder); + my (%sendresult,%forwardok,%forwardfail,$fwdcount); + my @to_forward = &Apache::loncommon::get_env_multiple('form.delmark'); + foreach my $item (@to_forward) { + my $msgid=&unescape($item); + my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]); + my %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1); + if ($env{'form.showorigsubj'}) { + $env{'form.subject'} = $fixed_subj.$content{'subject'}; + } else { + $env{'form.subject'} = ''; + } + my $uname = $content{'sendername'}; + my $udom = $content{'senderdomain'}; + &statuschange($msgid,'forwarded',$folder); + if ($env{'form.showorigsender'}) { + $env{'form.message'} = $env{'form.msgheader'}.' '. + &Apache::loncommon::plainname($uname,$udom).' ('. + $uname.':'.$udom.')'; + } + $env{'form.message'} .= "\n\n-- Forwarded message --\n\n". + $content{'message'}; + $fwdcount ++; + $r->print($fwdcount.': '); + $sendresult{$msgid} = &sendoffmail($r,$folder); + $r->print('
'); + } + foreach my $key (keys(%sendresult)) { + if ($sendresult{$key} =~/^(\s*(?:ok|con_delayed)\s*)*$/) { + $forwardok{$key} = $sendresult{$key}; + } else { + $forwardfail{$key} = $sendresult{$key}; + } + } + if (keys(%forwardok) > 0) { + my $count = keys(%forwardok); + $r->print('
'. + &mt('[quant,_1,message] forwarded.',$count). + ''); + } + if (keys(%forwardfail) > 0) { + my $count = keys(%forwardfail); + $r->print('

'. + &mt('Could not forward [quant,_1,message].',$count). + ' '); + foreach my $key (keys(%forwardfail)) { + $r->print(&mt('Could not deliver forwarded message.').' '. + &mt('The recipient addresses may need to be corrected').' ('.$forwardfail{$key}.').

'); + } + } + &Apache::loncommunicate::menu($r); + } else { + &sendoffmail($r,$folder); + } if ($env{'form.storebasecomment'}) { &storecomment($r); } @@ -2425,7 +2684,7 @@ sub handler { $env{'form.message'},'/adm/communicate','public'); } if ((!exists($env{'form.group'})) && (!$env{'form.displayedcrit'})) { - &disall($r,($folder?$folder:$dismode)); + &disall($r,($folder?$folder:$dismode),$msgstatus); } } elsif ($env{'form.newfolder'}) { &printheader($r,'','New Folder'); @@ -2439,7 +2698,7 @@ sub handler { $showfolder = $folder; } &Apache::loncommunicate::menu($r); - &disall($r,$showfolder); + &disall($r,$showfolder,$msgstatus); } elsif ($env{'form.showcommentbaseurl'}) { &storedcommentlisting($r); } elsif ($env{'form.folderaction'} eq 'delete') { @@ -2453,7 +2712,7 @@ sub handler { $showfolder = $folder; } &Apache::loncommunicate::menu($r); - &disall($r,$showfolder); + &disall($r,$showfolder,$msgstatus); } elsif ($env{'form.folderaction'} eq 'rename') { &printheader($r,'','Renamed Folder'); my $showfolder = $env{'form.renamed'}; @@ -2465,11 +2724,11 @@ sub handler { $showfolder = $folder; } &Apache::loncommunicate::menu($r); - &disall($r,$showfolder); + &disall($r,$showfolder,$msgstatus); } else { &printheader($r,'','Display All Messages'); &Apache::loncommunicate::menu($r); - &disall($r,($folder?$folder:$dismode)); + &disall($r,($folder?$folder:$dismode),$msgstatus); } $r->print(&Apache::loncommon::end_page()); return OK;

'.&mt('Currently available actions (will open extra window)').':'.&Apache::loncommon::track_student_link(&mt('View recent activity'),$content{'sendername'},$content{'senderdomain'},'check').'