--- loncom/interface/lonmsgdisplay.pm 2013/07/15 16:13:21 1.163 +++ loncom/interface/lonmsgdisplay.pm 2017/04/02 13:31:48 1.181.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging display # -# $Id: lonmsgdisplay.pm,v 1.163 2013/07/15 16:13:21 bisitz Exp $ +# $Id: lonmsgdisplay.pm,v 1.181.2.1 2017/04/02 13:31:48 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -120,21 +120,23 @@ my $startdis=''; sub folderlist { my ($folder,$msgstatus) = @_; - my %lt = &Apache::lonlocal::texthash( + my %html_lt = &Apache::lonlocal::texthash( actn => 'Action', fold => 'Folder', show => 'Show', status => 'Message Status', go => 'Go', + + ); + &html_escape(\%html_lt); + my %js_lt = &Apache::lonlocal::texthash( 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', + fmnb => 'Folder may not be renamed as it is a folder provided by the system.', + asth => 'Requested name already in use for a system-provided or user-defined folder.', ); + &js_escape(\%js_lt); # set se lastvisit for the new mail check in the toplevel menu &Apache::lonnet::appenv({'user.mailcheck.lastvisit'=>time}); @@ -182,16 +184,16 @@ function folder_choice(targetform,caller if (targetform.folderaction.options[targetform.folderaction.selectedIndex].value == 'rename') { for (var i=0; i'.&mt('Folder Actions').' - - - - - - - @@ -266,8 +268,8 @@ sub get_permanent_folders { my %permfolders = &Apache::lonlocal::texthash('' => 'INBOX', 'trash' => 'TRASH', - 'critical' => 'Critical', - 'sent' => 'Sent Messages', + 'critical' => 'CRITICAL', + 'sent' => 'SENT MESSAGES', ); return %permfolders; } @@ -383,7 +385,7 @@ 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.',$permfolders{$folder}); } my %userfolders = &Apache::lonmsg::get_user_folders(); if (!defined($userfolders{$folder})) { @@ -816,7 +818,8 @@ sub discrit { .''; my %what=&Apache::lonnet::dump('critical'); my $result = ''; - foreach my $key (sort(keys(%what))) { + # Sort by date in descending order + foreach my $key (sort{$b <=> $a}(keys(%what))) { my %content=&Apache::lonmsg::unpackagemsg($what{$key}); next if ($content{'senderdomain'} eq ''); my $description; @@ -1026,6 +1029,13 @@ sub disall { &Apache::loncommon::store_settings('user','mail',\%saveable); &Apache::loncommon::restore_settings('user','mail',\%saveable); $folder ||= $env{'form.folder'}; + # Always show critical messages if present + my @what=&Apache::lonnet::dump('critical',$env{'user.domain'},$env{'user.name'}); + if ($what[0]) { + if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) { + $folder = 'critical'; + } + } $msgstatus ||= $env{'form.msgstatus'}; $env{'form.interdis'} ||= 20; @@ -1046,11 +1056,12 @@ sub disfolder { my %setters = (); my $numblocked = 0; my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com'); - my %lt = &Apache::lonlocal::texthash( + my %js_lt = &Apache::lonlocal::texthash( sede => 'Select a destination folder to which the messages will be moved.', nome => 'No messages have been selected to apply this action to.', chec => 'Check the checkbox for at least one message.', ); + &js_escape(\%js_lt); my $jscript = &Apache::loncommon::check_uncheck_jscript(); $r->print(< @@ -1061,7 +1072,7 @@ sub disfolder { document.disall.markedaction.value = document.disall.checkedaction.options[document.disall.checkedaction.selectedIndex].value; if (document.disall.checkedaction.options[document.disall.checkedaction.selectedIndex].value == 'markedmove') { if (document.disall.movetofolder.options[document.disall.movetofolder.selectedIndex].value == "") { - alert("$lt{'sede'}"); + alert("$js_lt{'sede'}"); return; } } @@ -1078,7 +1089,7 @@ sub disfolder { } } if (checktotal == 0) { - alert("$lt{'nome'}\\n$lt{'chec'}"); + alert("$js_lt{'nome'}\\n$js_lt{'chec'}"); return; } document.disall.submit(); @@ -1207,7 +1218,7 @@ ENDDISHEADER foreach my $item ($localsenttime,$dis_name,$dis_domain,$shortsubj) { $r->print(''); + $item.''.(($status eq 'new')?'':'').''); } # Description and Status my $showstatus; @@ -1257,7 +1268,7 @@ ENDDISHEADER $r->print(' '."\n"); } if ($msgstatus ne 'read') { - $r->print(' ."\n"'); + $r->print(' '."\n"); } if ($msgstatus ne 'unread') { $r->print(' '."\n"); @@ -1665,8 +1676,8 @@ ENDREPSCRIPT $r->print(&additional_rec_row(\%lt)); $r->print(''); + &mt("The subject in each forwarded message will be [_1]'Forwarding:'[_2] followed by the original subject.",'','').'
  • '. + &mt("The message itself will begin with a first line: [_1]'Forwarded message from'[_2] followed by the original sender's name.",'','').'
  • '); $func1='Forward'; # do not translate here! $dissub = &mt('Forwarding').': '; $subj_size = '10'; @@ -1741,7 +1752,7 @@ ENDBLOCK '

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

    @@ -1895,7 +1906,7 @@ sub disfacetoface { $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}, '%255b'.$user.'%253a'.$domain.'%255d'); - my $result='

    '; + my $result=''; foreach my $key (sort(keys(%records))) { my %content=&Apache::lonmsg::unpackagemsg($records{$key}); next if ($content{'senderdomain'} eq ''); @@ -1927,8 +1938,7 @@ sub disfacetoface { } else { %content=&Apache::lonmsg::unpackagemsg($content{'message'}); $content{'message'} = - ''.&mt('Subject').': '.$content{'subject'}.'
    '.&mt('Subject').': '.$content{'subject'}.'
    '. $content{'message'}; } } else { @@ -1957,15 +1967,15 @@ $content{'sendername'}.':'. if ($result eq '') { my $lctype = &mt(lc(&Apache::loncommon::course_type())); if ($target ne 'tex') { - $r->print("

    ".&mt('No notes, face-to-face discussion records, critical messages, or broadcast messages in this [_1].',$lctype)."

    "); + $r->print("

    ".&mt('No notes, face-to-face discussion records, critical messages or broadcast messages in this '.$lctype.'.')."

    "); } else { - $r->print('\textbf{'.&mt('No notes, face-to-face discussion records, critical messages or broadcast messages in this [_1].',$lctype).'}\\\\'); + $r->print('\textbf{'.&mt('No notes, face-to-face discussion records, critical messages or broadcast messages in this '.$lctype.'.').'}\\\\'); } - } elsif ($target ne 'tex') { - $r->print($result.'
    '); + } elsif ($target eq 'tex') { + $r->print(&Apache::lonxml::xmlparse($r,$target,$result)); } else { - $r->print(&Apache::lonxml::xmlparse($r, 'tex', $result)); - } + $r->print('
    '.$result.'
    '); + } } sub general_message { @@ -2164,9 +2174,10 @@ sub displaymessage { my @actionlist; if ($env{'user.adv'}) { - if (&Apache::lonnet::allowed('vgr',$env{'request.course.id'})) { + if (($env{'request.course.id'}) && ($from_student) && + (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) { push(@actionlist,&Apache::loncommon::track_student_link( - &mt('View recent activity') + 'View recent activity' ,$content{'sendername'} ,$content{'senderdomain'} ,'check')); @@ -2694,7 +2705,7 @@ sub storedcommentlisting { '^'.&escape(&escape($env{'form.showcommentbaseurl'}))); $r->print(&Apache::loncommon::start_page('Saved Comment Listing',undef, {'onlybody' => 1})); - if ((keys %msgs)[0]=~/^error\:/) { + if ((keys(%msgs))[0]=~/^error\:/) { $r->print(&mt('No saved comments yet.')); } else { my $found=0; @@ -2909,6 +2920,7 @@ sub sendoffmail { } my @recusers; my @recudoms; + my %permresults; foreach my $address (sort(keys(%toaddr))) { my ($recuname,$recdomain)=split(/\:/,$address); my $msgtxt = $savemsg; @@ -2925,7 +2937,8 @@ sub sendoffmail { $env{'form.sendbck'}, $env{'form.permanent'}, \$sentmessage{$address}, - $nosentstore,$recipid); + $nosentstore,$recipid, + $attachmenturl,\%permresults); } else { $r->print(&mt('Sending').' '.$recuname.':'.$recdomain.': '); @thismsg= @@ -2936,13 +2949,20 @@ sub sendoffmail { $env{'form.permanent'}, \$sentmessage{$address}, undef,undef,undef, - $nosentstore,$recipid); + $nosentstore,$recipid, + \%permresults); } $msg_status{$recuname.':'.$recdomain}=join(' ',@thismsg); if ($msg_status{$recuname.':'.$recdomain} =~ /(ok|con_delayed)/) { $numsent++; push(@recusers,$recuname); push(@recudoms,$recdomain); + if ($1 eq 'ok') { + $r->print('ok '); + } + if ($permresults{$recuname.':'.$recdomain}) { + $r->print(' (email) '); + } } $sendstatus.=' '.join(' ',@thismsg); }
    '.$lt{'fold'}.'
    '."\n". +
    '.$html_lt{'fold'}.'
    '."\n". &Apache::loncommon::select_form($folder,'folder',\%formhash).'
    '.$lt{'show'}.'
    '."\n". +
    '.$html_lt{'show'}.'
    '."\n". &Apache::loncommon::select_form($env{'form.interdis'},'interdis', \%show).'
    '.$lt{'status'}.'
    '."\n". +
    '.$html_lt{'status'}.'
    '."\n". &Apache::loncommon::select_form($msgstatus,'msgstatus',\%statushash).'
    '.$lt{'actn'}.'
    '."\n".' +
    + '.$html_lt{'actn'}.'
    '."\n".' '. &Apache::loncommon::select_form('view','folderaction',\%actions). - '
    '.&mt('New Folder').'
    '."\n".' +
    + '.&mt('New Folder').'
    '."\n".' -
    '.(($status eq 'new')?'':''). ''. - $item.(($status eq 'new')?'':'').'
    '. &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.").'