--- loncom/interface/lonmsgdisplay.pm 2007/05/14 13:22:47 1.80 +++ loncom/interface/lonmsgdisplay.pm 2010/01/25 18:09:42 1.145 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging display # -# $Id: lonmsgdisplay.pm,v 1.80 2007/05/14 13:22:47 raeburn Exp $ +# $Id: lonmsgdisplay.pm,v 1.145 2010/01/25 18:09:42 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -113,8 +113,8 @@ use lib '/home/httpd/lib/perl/'; use LONCAPA; # Querystring component with sorting type -my $sqs; -my $startdis; +my $sqs=''; +my $startdis=''; # ============================================================ List all folders @@ -136,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', @@ -143,7 +146,7 @@ sub folderlist { ); $actions{'select_form_order'} = ['view','rename','delete']; - my %statushash = &get_msgstatus_types(); + my %statushash = &Apache::lonlocal::texthash(&get_msgstatus_types()); $statushash{'select_form_order'} = ['','new','read','replied','forwarded']; @@ -170,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 .= '
'; + my $output = ''.&mt('Page:').' '; + if ($maxdis == 1) { + # No buttons if only one page is displayed + $output .= '1/1'; + } else { + $output .= + ''. + ''. + ' / '.$maxdis.' '. + ''. + ''; + } + $output .= + ''.
- ' '. - &Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row(); - $result .= " | $lt{'name'} | ". - "$lt{'usnm'} | ". - "$lt{'doma'} | ". - &Apache::loncommon::end_data_table_header_row(); + my $formname = $status.'users'; + if (ref($access_status) eq 'HASH') { + $access_status->{$status} = $$numitems{$status}; + } + $r->print(''; } - $result .= ' |
---|
' . $crithelp . - '
'. - '' . $crithelp . - '
'. -''; + ''.$crithelp.' '.&mt('Require return receipt?').''.&mt('This message was designated by the sender not to allow replies.').' |
'.&mt('[_1]Send reply[_2] to other recipients','','').': '.$replyall.' | '.$tolist.' |
'.&mt('[_1]Cc[_2] to other copied recipients','','').': '.$replyall.' | '.$cclist.' |
'.&mt('[_1]Cc[_2] to other copied group members','','').': '.$replyall.' | '.$groupcclist.' |
'."\n".
+$latexHelp." \n". +&mt("Any new text to display before the text of the original messages:").' '."\n". +''. +$wysiwyglink); 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'}, + $r->print(&submit_button_row($folder,$dismode,&mt($func1.' '.$func2{'msg'}), \%lt)); } elsif ($broadcast ne 'upload') { $subj_size = '50'; @@ -1425,15 +1660,17 @@ $latexHelp. } $r->print(&msg_subject_row($dissub,\%lt,$subj_size)); $r->print(<<"ENDCOMP"); - |
$lt{'gmt'}:
$lt{'tff'}: ENDBLOCK @@ -1474,22 +1711,32 @@ $dispcrit
ENDUPLOAD } - if ($broadcast eq 'group') { - if ($group eq '') { - my $studentsel = &discourse(); - $r->print($studentsel); - } - } if ($env{'form.displayedcrit'}) { $r->print(''); } - $r->print('+ + + | $prevbutton |
".&mt('No notes, face-to-face discussion records, critical messages, or broadcast messages in this [_1].',$lctype)."
"); } else { $r->print('\textbf{'.&mt('No notes, face-to-face discussion records, critical messages or broadcast messages in this [_1].',$lctype).'}\\\\'); } + } elsif ($target ne 'tex') { + $r->print($result.'$lt{'user'}: | - | -$stdbrws - | -
$lt{'dom'}: | -$domform |
'); my $escmsgid=&escape($msgid); foreach (@messages) { if ($_->[5] eq $escmsgid){ @@ -2073,68 +2375,148 @@ 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('
'.&mt('Functions').': | '); + +# Prepare available functions + my @functionlist; if (!$content{'noreplies'}) { - $r->print(''.&mt('Reply').' | '); - } - $r->print(''.&mt('Forward').' | '. - ''.&mt('Mark Unread').' | '. - ''.&mt('Delete').' | '. - ''.&mt('Back to Folder Display').' | '); + push(@functionlist,'' + .&mt('Reply') + .''); + } + push(@functionlist,'' + .&mt('Forward') + .''); + push(@functionlist,'' + .&mt('Mark Unread') + .''); + push(@functionlist,'' + .&mt('Delete') + .''); + push(@functionlist,'' + .&mt('Back to Folder Display') + .''); if ($counter > 0){ - $r->print(''.&mt('Previous').' | '); + push(@functionlist,'' + .&mt('Previous') + .''); } if ($counter < $number_of_messages - 1){ - $r->print(''.&mt('Next').' | '); + push(@functionlist,'' + .&mt('Next') + .''); } - $r->print('
'.&mt('Currently available actions (will open extra window)').': | '); + 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').' | '); - } + push(@actionlist,&Apache::loncommon::track_student_link( + &mt('View recent activity') + ,$content{'sendername'} + ,$content{'senderdomain'} + ,'check')); + } if (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) && $symb) { - $r->print(''.&Apache::loncommon::pprmlink(&mt('Set/Change parameters'),$content{'sendername'},$content{'senderdomain'},$symb,'check').' | '); + push(@actionlist,&Apache::loncommon::pprmlink( + &mt('Set/Change parameters') + ,$content{'sendername'} + ,$content{'senderdomain'} + ,$symb + ,'check')); } if (&Apache::lonnet::allowed('mgr',$env{'request.course.id'}) && $symb) { - $r->print(''.&Apache::loncommon::pgrdlink(&mt('Set/Change grades'),$content{'sendername'},$content{'senderdomain'},$symb,'check').' | '); + push(@actionlist,&Apache::loncommon::pgrdlink( + &mt('Set/Change grades') + ,$content{'sendername'} + ,$content{'senderdomain'} + ,$symb + ,'check')); } - $r->print('
'. - &Apache::lontexconvert::msgtexconverted($content{'message'},1). - '
' + .&Apache::lontexconvert::msgtexconverted($content{'message'},1) + .'' + ); + if (&displayresource(%content)) { + $r->print(&Apache::lonhtmlcommon::row_closure() + .&Apache::lonhtmlcommon::row_title(&mt('Resource Details')) + .&displayresource(%content) + ); + } + $r->print(&Apache::lonhtmlcommon::row_closure(1). + &Apache::lonhtmlcommon::end_pick_box()); + # Display LON-CAPA Message (End) return; } -sub retrieve_cc_recips { - my ($context,%content) = @_; - my %reciphash = - &Apache::lonnet::get('nohist_emailrecip',[$content{'recipid'}], - $content{'senderdomain'},$content{'sendername'}); - my $recipinfo = $reciphash{$content{'recipid'}}; - my @ccs; - if (ref($recipinfo) eq 'HASH') { - if (ref($recipinfo->{'cc'}) eq 'HASH') { - foreach my $cc (sort(keys(%{$recipinfo->{'cc'}}))) { - my ($ccname,$ccdom) = split(/:/,$cc); - if (!(($ccname eq $env{'user.name'}) && - ($ccdom eq $env{'user.domain'}))) { - my $showcc =''; - if ($context eq 'replying') { - $showcc = '
'.&mt('Attachment not included - exceeded permitted length').'
'.&mt('Could not deliver message').' '. - &mt('Please use the browser "Back" button and correct the recipient addresses '."($sendstatus)").'
'); + my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Could not deliver message'),1); + $message .= ''. - &mt('Failed to delete the message.').'
'. - ''.$msg."
\n"); + my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Failed to delete the message.'),1); + $message .= ''.$msg.'
'; + $message = &Apache::loncommon::confirmwrapper($message); + $r->print($message); } &Apache::loncommunicate::menu($r); &disall($r,($folder?$folder:$dismode),$msgstatus); @@ -2761,7 +3433,10 @@ sub handler { $total ++; } &printheader($r,'','Marked Messages Read'); - $r->print(&mt('Marked [_1] message(s) read',$total).''); + my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Marked [quant,_1,message] read',$total)); + $message = &Apache::loncommon::confirmwrapper($message); + $r->print($message); + # $r->print('
'); &Apache::loncommunicate::menu($r); &disall($r,($folder?$folder:$dismode),$msgstatus); } elsif ($env{'form.markedaction'} eq 'markedunread') { @@ -2772,7 +3447,10 @@ sub handler { $total ++; } &printheader($r,'','Marked Messages Unread'); - $r->print(&mt('Marked [_1] message(s) unread',$total).'
'); + my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Marked [quant,_1,message] unread',$total)); + $message = &Apache::loncommon::confirmwrapper($message); + $r->print($message); + # $r->print('
'); &Apache::loncommunicate::menu($r); &disall($r,($folder?$folder:$dismode),$msgstatus); } elsif ($env{'form.markedaction'} eq 'markedmove') { @@ -2795,15 +3473,17 @@ sub handler { push(@failed_msg,$msg); } } - 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).''); + my $message = ''; + if ($failed) { + $message .= &Apache::lonhtmlcommon::confirm_success(&mt('Failed to move [quant,_1,message]',$failed),1); + $message .= '
'. + join("
\n",@failed_msg). + "
\n"; + } + $message .= &Apache::lonhtmlcommon::confirm_success(&mt('Moved [quant,_1,message]',$total)); + $message = &Apache::loncommon::confirmwrapper($message); + $r->print($message); + # $r->print(''); } &Apache::loncommunicate::menu($r); &disall($r,($folder?$folder:$dismode),$msgstatus); @@ -2821,15 +3501,17 @@ sub handler { } } &printheader($r,'','Deleted Messages'); + my $message = ''; if ($failed) { - $r->print('
- '.&mt('Failed to delete [_1] message(s)',$failed). - '
'); - $r->print(''. + $message .= &Apache::lonhtmlcommon::confirm_success(&mt('Failed to delete [quant,_1,message]',$failed),1); + $message .= '
'. join("
\n",@failed_msg). - "
\n"); + "\n"; } - $r->print(&mt('Deleted [_1] message(s)',$total).''); + $message .= &Apache::lonhtmlcommon::confirm_success(&mt('Deleted [quant,_1,message]',$total)); + $message = &Apache::loncommon::confirmwrapper($message); + $r->print($message); + # $r->print('
');
&Apache::loncommunicate::menu($r);
&disall($r,($folder?$folder:$dismode),$msgstatus);
} elsif ($env{'form.markunread'}) {
@@ -2853,7 +3535,7 @@ sub handler {
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);
+ my %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1,1);
if ($env{'form.showorigsubj'}) {
$env{'form.subject'} = $fixed_subj.$content{'subject'};
} else {
@@ -2867,8 +3549,10 @@ sub handler {
&Apache::loncommon::plainname($uname,$udom).' ('.
$uname.':'.$udom.')';
}
- $env{'form.message'} .= "\n\n-- Forwarded message --\n\n".
- $content{'message'};
+ $env{'form.message'}.="\n\n-- Forwarded message --\n\n".
+ $content{'message'};
+ $env{'form.attachmenturl'} = $content{'attachmenturl'};
+ $env{'form.multiforwid'} = $item;
$fwdcount ++;
$r->print($fwdcount.': ');
$sendresult{$msgid} = &sendoffmail($r,$folder);
@@ -2883,19 +3567,19 @@ sub handler {
}
if (keys(%forwardok) > 0) {
my $count = keys(%forwardok);
- $r->print('
'.
- &mt('[quant,_1,message] forwarded.',$count).
- '');
+ my $message = &Apache::lonhtmlcommon::confirm_success(&mt('[quant,_1,message] forwarded.',$count));
+ $message = &Apache::loncommon::confirmwrapper($message);
+ $r->print($message);
}
if (keys(%forwardfail) > 0) {
my $count = keys(%forwardfail);
- $r->print('
'.
- &mt('Could not forward [quant,_1,message].',$count).
- ' ');
+ my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Could not forward [quant,_1,message].',$count),1);
foreach my $key (keys(%forwardfail)) {
- $r->print(&mt('Could not deliver forwarded message.').' '.
- &mt('The recipient addresses may need to be corrected').' ('.$forwardfail{$key}.').
');
+ $message .= '
'.&mt('Could not deliver forwarded message.').' '.
+ &mt('The recipient addresses may need to be corrected').' ('.$forwardfail{$key}.')';
}
+ $message = &Apache::loncommon::confirmwrapper($message);
+ $r->print($message);
}
&Apache::loncommunicate::menu($r);
} else {
@@ -2919,10 +3603,13 @@ sub handler {
my $showfolder = $env{'form.newfolder'};
my ($makeresult,$warning) = &makefolder($env{'form.newfolder'});
if ($makeresult eq 'ok') {
- $r->print(&mt('Mail folder "[_1]" created.',$showfolder).'
');
+ my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Folder "[_1]" created.',$showfolder));
+ $message = &Apache::loncommon::confirmwrapper($message);
+ $r->print($message);
} else {
- $r->print(&mt('Creation failed.').' '.$makeresult.'
'.
- $warning);
+ my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Creation failed.').' '.$makeresult.'
'.$warning,1);
+ $message = &Apache::loncommon::confirmwrapper($message);
+ $r->print($message);
$showfolder = $folder;
}
&Apache::loncommunicate::menu($r);
@@ -2934,10 +3621,14 @@ sub handler {
my $showfolder = '';
my $delresult = &deletefolder($folder);
if ($delresult eq 'ok') {
- $r->print(&mt('Mail folder "[_1]" deleted.',$folder).'
');
+ my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Folder "[_1]" deleted.',$folder));
+ $message = &Apache::loncommon::confirmwrapper($message);
+ $r->print($message);
$env{'form.folder'} = '';
} else {
- $r->print(&mt('Deletion failed.').' '.$delresult.'
');
+ my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Deletion failed.').' '.$delresult,1);
+ $message = &Apache::loncommon::confirmwrapper($message);
+ $r->print($message);
$showfolder = $folder;
}
&Apache::loncommunicate::menu($r);
@@ -2947,9 +3638,13 @@ sub handler {
my $showfolder = $env{'form.renamed'};
my $renresult = &renamefolder($folder);
if ($renresult eq 'ok') {
- $r->print(&mt('Mail folder "[_1]" renamed "[_2]".',$folder,$showfolder).'
');
+ my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Folder "[_1]" renamed to "[_2]".',$folder,$showfolder));
+ $message = &Apache::loncommon::confirmwrapper($message);
+ $r->print($message);
} else {
- $r->print(&mt('Renaming failed.').' '.$renresult.'
');
+ my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Renaming failed.').' '.$renresult,1);
+ $message = &Apache::loncommon::confirmwrapper($message);
+ $r->print($message);
$showfolder = $folder;
}
&Apache::loncommunicate::menu($r);