--- loncom/interface/lonmsgdisplay.pm	2012/02/14 17:28:25	1.157.4.1
+++ loncom/interface/lonmsgdisplay.pm	2013/09/04 14:21:30	1.169
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging display
 #
-# $Id: lonmsgdisplay.pm,v 1.157.4.1 2012/02/14 17:28:25 raeburn Exp $
+# $Id: lonmsgdisplay.pm,v 1.169 2013/09/04 14:21:30 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -128,11 +128,8 @@ sub folderlist {
                 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',
+                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.',
 
     );
 
@@ -182,7 +179,7 @@ function folder_choice(targetform,caller
         if (targetform.folderaction.options[targetform.folderaction.selectedIndex].value == 'rename') {
             for (var i=0; i<permfolders_keys.length; i++) {
                 if (permfolders_keys[i] == targetform.folder.value) {
-                    alert("$lt{'the'} '"+permfolders_vals[i]+"' $lt{'fmnb'}");
+                    alert("'"+permfolders_vals[i]+"' -- $lt{'fmnb'}");
                     return;
                 }
             }
@@ -191,7 +188,7 @@ function folder_choice(targetform,caller
                 targetform.renamed.value=foldername;
                 for (var i=0; i<allfolders.length; i++) {
                     if (allfolders[i] == foldername) {
-                        alert("$lt{'thfm'} '"+foldername+"' $lt{'asth'}");
+                        alert("'"+foldername+"' $lt{'asth'}");
                         return;
                     }
                 }
@@ -207,7 +204,7 @@ function folder_choice(targetform,caller
         if (newname) {
             for (var i=0; i<allfolders.length; i++) {
                 if (allfolders[i] == newname) {
-                    alert("$lt{'tnfm'} '"+newname+"' $lt{'asth'}");
+                    alert("'"+newname+"' -- $lt{'asth'}");
                     return;
                 }
             }
@@ -222,6 +219,8 @@ function folder_choice(targetform,caller
 
     $output .= '
 <form method="post" action="/adm/email" name="folderlist">
+   <div class="LC_columnSection"><fieldset>
+   <legend>'.&mt('Folder Actions').'</legend>
    <table border="0" cellspacing="2" cellpadding="8">
     <tr>
      <td><b>'.$lt{'fold'}.'</b><br />'."\n".
@@ -234,14 +233,16 @@ function folder_choice(targetform,caller
      <td><b>'.$lt{'status'}.'</b><br />'."\n".
        &Apache::loncommon::select_form($msgstatus,'msgstatus',\%statushash).'
      </td>
-     <td><b>'.$lt{'actn'}.'</b><br />'."\n".'
+     <td style="padding-right: 40px;">
+         <b>'.$lt{'actn'}.'</b><br />'."\n".'
          <span class="LC_nobreak">'.
          &Apache::loncommon::select_form('view','folderaction',\%actions).
          ' <input type="button" value="'.$lt{'go'}.
          '" onclick="javascript:folder_choice(this.form,'."'change'".');" />
          </span>
      </td>
-     <td><b>'.&mt('New Folder').'</b><br />'."\n".'
+     <td style="border-left: 1px solid;padding-left: 40px;">
+         <b>'.&mt('New Folder').'</b><br />'."\n".'
          <span class="LC_nobreak">
          <input type="text" size="15" name="newfolder" value="" />
          <input type="button" value="'.$lt{'go'}.
@@ -250,6 +251,7 @@ function folder_choice(targetform,caller
      </td>
     </tr>
    </table>
+   </fieldset></div>
 '."\n".
     '<input type="hidden" name="sortedby" value="'.$env{'form.sortedby'}.'" />'.
     '<input type="hidden" name="renamed" value="" />'.
@@ -543,7 +545,7 @@ sub discourse {
        $result .= '<fieldset id="LC_activeusers"><legend>'
                  .$bcc_curr_hdr
                  .'</legend>'
-                 .'<form name="activeusers">';
+                 .'<form name="activeusers" action="">';
        $result .= $tmptext.'</form></fieldset><br />';
        if (ref($statushash) eq 'HASH') {
            $statushash->{'active'} = 1;
@@ -564,7 +566,7 @@ sub discourse {
        $result .= '<fieldset id="LC_previoususers"><legend>'
                  .$bcc_prev_hdr
                  .'</legend>'
-                 .'<form name="previoususers">';
+                 .'<form name="previoususers" action="">';
        $result .= $tmptext.'</form></fieldset><br />';
        if (ref($statushash) eq 'HASH') {
            $statushash->{'previous'} = 1;
@@ -587,7 +589,7 @@ sub discourse {
        $result .= '<fieldset id="LC_futureusers"><legend>'
                  .$bcc_future_hdr
                  .'</legend>'
-                 .'<form name="futureusers">';
+                 .'<form name="futureusers" action="">';
        $result .= $tmptext.'</form></fieldset>';
        if (ref($statushash) eq 'HASH') {
            $statushash->{'future'} = 1;
@@ -662,7 +664,7 @@ sub disgroup {
                     }
                     $r->print('<fieldset>'.
                               '<legend>'.$lt{$status}.'</legend>'.
-                              '<form name="'.$formname.'">'.
+                              '<form name="'.$formname.'" action="">'.
                               '<span class="LC_nobreak">'.
                               '<input type="button" value="'.&mt('Check All').'" '.
                               'onclick="javascript:toggleAll('."this.form,'check'".')" />'.
@@ -877,8 +879,9 @@ sub discrit {
             '<p class="LC_info">'.
             &mt('You have no critical messages.').
             '</p>'.
-            '<a href="/adm/roles">'.&mt('Select a course').'</a><br />'.
-            '<a href="/adm/email">'.&mt('Communicate').'</a>';
+            &Apache::lonhtmlcommon::actionbox(
+                ['<a href="/adm/roles">'.&mt('Select a course').'</a>',
+                 '<a href="/adm/email">'.&mt('Communicate').'</a>']);
     } else {
         $r->print($header);
     }
@@ -1232,17 +1235,17 @@ ENDDISHEADER
 
 
     # Bottom Functions
-    $r->print('<table border="0" cellspacing="2" cellpadding="8">
+    $r->print('
+<div class="LC_columnSection"><fieldset>
+<legend>'.&mt('Message Actions').'</legend>
+<table border="0" cellspacing="2" cellpadding="8">
  <tr>
-  <td>
-   <fieldset>
-   <legend>'.&mt('Select').'</legend>
+  <td><b>'.&mt('Select Messages').'</b><br />
    <span class="LC_nobreak">
    <input type="button" onclick="javascript:checkAll(document.disall.delmark)" value="'.&mt('Check All').'" />'."\n".
   ' <input type="button" onclick="javascript:uncheckAll(document.disall.delmark)" value="'.&mt('Uncheck All').'" />'."\n".
   '<input type="hidden" name="sortedby" value="'.$env{'form.sortedby'}.'" />
   </span>
-  </fieldset>
   </td>'."\n".
   '<td><b>'.&mt('Action').'</b><br />'."\n".
   '  <select name="checkedaction">'."\n");
@@ -1266,7 +1269,7 @@ ENDDISHEADER
     $r->print("\n".'</select></td>'."\n");
 
     if (keys(%gotfolders) > 0) {
-        $r->print('<td><b>'.&mt('Destination folder').'<b><br />');
+        $r->print('<td><b>'.&mt('Destination folder').'</b><br />');
 	my %userfolders;
         foreach my $key (keys(%gotfolders)) {
             $userfolders{$key} = $key;
@@ -1275,10 +1278,12 @@ ENDDISHEADER
         $r->print(&Apache::loncommon::select_form('','movetofolder',\%userfolders).
                   '</td>');
     }
-    $r->print('<td>'.
+    $r->print('<td style="vertical-align:bottom;">'.
               '<input type="button" name="go" value="'.&mt('Go').
               '" onclick="javascript:validate_checkedaction()"/></td>'."\n".
-              '</tr></table>');
+              '</tr></table>'."\n".
+              '</fieldset></div>'."\n"
+    );
     my $postedstartdis=$startdis+1;
     $r->print('<input type="hidden" name="folder" value="'.$folder.'" /><input type="hidden" name="startdis" value="'.$postedstartdis.'" /><input type="hidden" name="interdis" value="'.$env{'form.interdis'}.'" /><input type="hidden" name="msgstatus" value="'.$msgstatus.'" /><input type="hidden" name="markedaction" value="" /></form>');
     if ($numblocked > 0) {
@@ -1462,9 +1467,12 @@ function courseRecipients() {
                     document.compemail.groupmail.value = document.$formname.groupmail[document.$formname.groupmail.selectedIndex].value;
 |;
                 }
+                #typeof(...forminput.length) returns 'undefined' if only one entry exists
                 $broadcast_js .= qq|
     if (typeof(document.$formname.selectedusers_forminput.length)=="undefined") {
-        document.compemail.courserecips.value += '_&&&_'+document.$formname.selectedusers_forminput.value;
+        if (document.$formname.selectedusers_forminput.checked) {
+            document.compemail.courserecips.value += '_&&&_'+document.$formname.selectedusers_forminput.value;
+        }
     } else {
         for (var i=0; i<document.$formname.selectedusers_forminput.length; i++) {
             if (document.$formname.selectedusers_forminput[i].checked) {
@@ -1654,8 +1662,8 @@ ENDREPSCRIPT
         $r->print(&additional_rec_row(\%lt));
         $r->print('<tr><td colspan="2">'.
                   &mt('Unless you choose otherwise:').'<ul><li>'.
-        &mt("The subject in each forwarded message will be <i>'Forwarding:'</i> followed by the original subject.").'</li><li>'.
-        &mt("The message itself will begin with a first line: <i>'Forwarded message from'</i> followed by the original sender's name.").'</li></ul></td></tr>');
+        &mt("The subject in each forwarded message will be [_1]'Forwarding:'[_2] followed by the original subject.",'<i>','</i>').'</li><li>'.
+        &mt("The message itself will begin with a first line: [_1]'Forwarded message from'[_2] followed by the original sender's name.",'<i>','</i>').'</li></ul></td></tr>');
         $func1='Forward'; # do not translate here!
         $dissub = &mt('Forwarding').': ';
         $subj_size = '10';
@@ -1730,7 +1738,7 @@ ENDBLOCK
 '</pre>
 </p>
 <p>
-'.&mt('The messages will be assembled from all lines with the respective'."\n".'<tt>username:domain</tt>, 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.','<br />','<tt>','</tt>'));
         $r->print(<<ENDUPLOAD);
 </p>
 <p>
@@ -1765,18 +1773,12 @@ sub check_group_priv {
 
 sub recipient_input_row {
     my ($dom,%lt) = @_;
-    my $domform;
-    if (($dom eq 'relate') && (!$env{'user.adv'})) {
-        $domform = '<span class="LC_cusr_emph">'.$dom.'</span>'.
-                   '<input type="hidden" name="recdomain" value="'.$dom.'" />';  
-    } else {
-        $domform = &Apache::loncommon::select_dom_form($dom,'recdomain');
-    }
+    my $domform = &Apache::loncommon::select_dom_form($dom,'recdomain');
     my $selectlink=
       &Apache::loncommon::selectstudent_link('compemail','recuname',
                                              'recdomain');
     my $output = <<"ENDREC";
-<tr><td colspan="3"><span class="LC_nobreak"><b>$lt{'to'}</b> $lt{'us'}:&nbsp;<input type="text" size="15" name="recuname" value="$env{'form.recname'}" />&nbsp;$lt{'do'}:&nbsp;$domform&nbsp;&nbsp;$selectlink</span></td></tr>
+<tr><td colspan="3"><span class="LC_nobreak"><b>$lt{'to'}</b> $lt{'us'}:&nbsp;<input type="text" size="12" name="recuname" value="$env{'form.recname'}" />&nbsp;$lt{'do'}:&nbsp;$domform&nbsp;&nbsp;$selectlink</span></td></tr>
 ENDREC
     return $output;
 }
@@ -2044,7 +2046,7 @@ sub facetoface {
                  .&mt('Discussion and message records for [_1] ([_2])'
                      ,$aboutmelink
                      ,$env{'form.recuname'}.':'.$env{'form.recdomain'})
-                 .'<h2>'
+                 .'</h2>'
        );
         &disfacetoface($r,$env{'form.recuname'},$env{'form.recdomain'});
 	$r->print(<<ENDRHEAD);
@@ -2063,317 +2065,6 @@ ENDBFORM
     }
 }
 
-# ----------------------------------------------------------- Blocking during exams
-
-sub examblock {
-    my ($r,$action) = @_;
-    unless ($env{'request.course.id'}) { return;}
-    if (!&Apache::lonnet::allowed('dcm',$env{'request.course.id'})
-	&& ! &Apache::lonnet::allowed('dcm',$env{'request.course.id'}.
-				      '/'.$env{'request.course.sec'})) {
-	$r->print('Not allowed');
-	return;
-    }
-    my $usertype;
-    my $crstype = &Apache::loncommon::course_type();
-    if ($crstype eq 'Community') {
-        $usertype = 'members';
-    } else {
-	$usertype = 'students';
-    }
-    my $lctype = lc($crstype);
-    my %lt=&Apache::lonlocal::texthash(
-            'comb' => 'Communication Blocking',
-            'cbds' => 'Communication blocking during scheduled exams',
-            'desc' => "You can use communication blocking to prevent $usertype enrolled in this $lctype 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 or community, 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 saved',
-             'stor' => 'Save',
-    );
-
-    my %ltext = &Apache::lonlocal::texthash(
-            'dura' => 'Duration',
-            'setb' => 'Set by',
-            'even' => 'Event',
-            'blck' => 'Blocked?',
-            'actn' => 'Action',
-            'star' => 'Start',
-            'endd' => 'End'
-    );
-
-    &printheader($r,'/adm/email?block=display',$lt{'comb'});
-    $r->print('<h3>'.$lt{'cbds'}.'</h3>');
-
-    if ($action eq 'store') {
-        &blockstore($r);
-    }
-
-    $r->print($lt{'desc'}.'<br /><br />
-               <form name="blockform" method="post" action="/adm/email?block=store">
-             ');
-
-    $r->print('<h4>'.$lt{'mecb'}.'</h4>');
-    my %records = ();
-    my $blockcount = 0;
-    my $parmcount = 0;
-    &get_blockdates(\%records,\$blockcount);
-    if ($blockcount > 0) {
-        $parmcount = &display_blocker_status($r,\%records,\%ltext);
-    } else {
-        $r->print($lt{'ncbc'}.'<br /><br />');
-    }
-    &display_addblocker_table($r,$parmcount,\%ltext);
-    my $end_page=&Apache::loncommon::end_page();
-    $r->print(<<"END");
-<br />
-<input type="hidden" name="blocktotal" value="$blockcount" />
-<input type ="submit" value="$lt{'stor'}" />
-</form>
-$end_page
-END
-    return;
-}
-
-sub blockstore {
-    my $r = shift;
-    my %lt=&Apache::lonlocal::texthash(
-            'tfcm' => 'The following changes were made',
-            'ncwm' => 'No changes were made.' 
-    );
-    my %adds = ();
-    my %removals = ();
-    my %cancels = ();
-    my $modtotal = 0;
-    my $canceltotal = 0;
-    my $addtotal = 0;
-    my %blocking = ();
-    $r->print('<h3>'.$lt{'head'}.'</h3>');
-    foreach my $envkey (keys(%env)) {
-        if ($envkey =~ m/^form\.modify_(\d+)$/) {
-            $adds{$1} = $1;
-            $removals{$1} = $1;
-            $modtotal ++;
-        } elsif ($envkey =~ m/^form\.cancel_(\d+)$/) {
-            $cancels{$1} = $1;
-            unless ( defined($removals{$1}) ) {
-                $removals{$1} = $1;
-                $canceltotal ++;
-            }
-        } elsif ($envkey =~ m/^form\.add_(\d+)$/) {
-            $adds{$1} = $1;
-            $addtotal ++;
-        } 
-    }
-
-    foreach my $key (keys(%removals)) {
-        my $hashkey = $env{'form.key_'.$key};
-        &Apache::lonnet::del('comm_block',["$hashkey"],
-                         $env{'course.'.$env{'request.course.id'}.'.domain'},
-                         $env{'course.'.$env{'request.course.id'}.'.num'}
-                         );
-    }
-    foreach my $key (keys(%adds)) {
-        unless ( defined($cancels{$key}) ) {
-            my ($newstart,$newend) = &get_dates_from_form($key);
-            my $newkey = $newstart.'____'.$newend;
-            my $blocktypes = &get_block_choices($key);
-            $blocking{$newkey} = {
-                          setter => $env{'user.name'}.':'.$env{'user.domain'},
-                          event  => &escape($env{'form.title_'.$key}),
-                          blocks => $blocktypes,
-                        };
-        }
-    }
-    if ($addtotal + $modtotal > 0) {
-        &Apache::lonnet::put('comm_block',\%blocking,
-                     $env{'course.'.$env{'request.course.id'}.'.domain'},
-                     $env{'course.'.$env{'request.course.id'}.'.num'}
-                     );
-    }
-    my $chgestotal = $canceltotal + $modtotal + $addtotal;
-    if ($chgestotal > 0) {
-        $r->print($lt{'tfcm'}.'<ul>');
-        if ($canceltotal > 0) {
-            $r->print('<li>'.&mt('[quant,_1,communication blocking period was,communication blocking periods were] removed.',$canceltotal).'</li>');
-        }
-        if ($modtotal > 0) {
-            $r->print('<li>'.&mt('[quant,_1,communication blocking period was,communication blocking periods were] modified.',$modtotal).'</li>');
-        }
-        if ($addtotal > 0) {
-            $r->print('<li>'.&mt('[quant,_1,communication blocking period was,communication blocking periods were] added.',$addtotal).'</li>');
-        }
-        $r->print('</ul>');
-    } else {
-        $r->print($lt{'ncwm'});
-    }
-    $r->print('<br />');
-    return;
-}
-
-sub get_dates_from_form {
-    my $item = shift;
-    my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate_'.$item);
-    my $enddate   = &Apache::lonhtmlcommon::get_date_from_form('enddate_'.$item);
-    return ($startdate,$enddate);
-}
-
-sub get_blockdates {
-    my ($records,$blockcount) = @_;
-    $$blockcount = 0;
-    %{$records} = &Apache::lonnet::dump('comm_block',
-                         $env{'course.'.$env{'request.course.id'}.'.domain'},
-                         $env{'course.'.$env{'request.course.id'}.'.num'}
-                         );
-    $$blockcount = keys(%{$records});
-
-    if ((keys(%{$records}))[0] =~ /^error: 2 /) {
-	$records = {};
-	$$blockcount = 0;
-    }
-}
-
-sub get_block_choices {
-    my $item = shift;
-    my $blocklist;
-    my ($typeorder,$types) = &blocktype_text();
-    foreach my $type (@{$typeorder}) {
-        if ($env{'form.'.$type.'_'.$item}) {
-            $blocklist->{$type} = 'on'; 
-        } else {
-            $blocklist->{$type} = 'off';
-        }
-    }
-    return $blocklist;
-}
-
-sub display_blocker_status {
-    my ($r,$records,$ltext) = @_;
-    my $parmcount = 0;
-  
-    my %lt = &Apache::lonlocal::texthash(
-        'modi' => 'Modify',
-        'canc' => 'Cancel',
-    );
-    my ($typeorder,$types) = &blocktype_text();
-    $r->print(&Apache::loncommon::start_data_table());
-    $r->print(<<"END");
-  <tr>
-    <th>$ltext->{'dura'}</th>
-    <th>$ltext->{'setb'}</th>
-    <th>$ltext->{'even'}</th>
-    <th>$ltext->{'blck'}</th>
-    <th>$ltext->{'actn'}</th>
-  </tr>
-END
-    foreach my $record (sort(keys(%{$records}))) {
-        my $onchange = 'onFocus="javascript:window.document.forms['.
-                       "'blockform'].elements['modify_".$parmcount."'].".
-                       'checked=true;"';
-        my ($start,$end) = split(/____/,$record);
-        my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);
-        my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);
-	
-	my ($setuname,$setudom,$title,$blocks) = 
-	    &Apache::loncommon::parse_block_record($$records{$record});
-	$title = &HTML::Entities::encode($title,'"<>&');
-        my $settername = 
-           &Apache::loncommon::aboutmewrapper(
-                           &Apache::loncommon::plainname($setuname,$setudom),
-                           $setuname,$setudom);
-        $r->print(&Apache::loncommon::start_data_table_row());
-        $r->print(<<"END");
-        <td>$ltext->{'star'}:&nbsp;$startform<br />$ltext->{'endd'}:&nbsp;&nbsp;$endform</td>
-        <td>$settername</td>
-        <td><input type="text" name="title_$parmcount" size="15" value="$title" /><input type="hidden" name="key_$parmcount" value="$record" /></td>
-        <td>
-END
-        foreach my $block (@{$typeorder}) {
-            my $blockstatus = '';
-            if ($blocks->{$block} eq 'on') {
-                $blockstatus = 'checked="checked"';
-            }
-            $r->print('<span class="LC_nobreak"><label><input type="checkbox" name="'.$block.'_'.$parmcount.'" '.$blockstatus.' value="1" />'.$types->{$block}.'</label></span><br />');
-        }
-        $r->print(<<"END");
-        </td>      
-        <td><span class="LC_nobreak"><label>
-        <input type="checkbox" name="modify_$parmcount" />$lt{'modi'}
-        </label></span><br /><span class="LC_nobreak">
-        <label>
-        <input type="checkbox" name="cancel_$parmcount" />$lt{'canc'}
-        </label></span>
-END
-        $r->print(&Apache::loncommon::end_data_table_row());
-        $parmcount++;
-    }
-    $r->print(<<"END");
-</table>
-<br />
-<br />
-END
-    return $parmcount;
-}
-
-sub display_addblocker_table {
-    my ($r,$parmcount,$ltext) = @_;
-    my $start = time;
-    my $end = $start + (60 * 60 * 2); #Default is an exam of 2 hours duration.
-    my $onchange = 'onFocus="javascript:window.document.forms['.
-                   "'blockform'].elements['add_".$parmcount."'].".
-                   'checked=true;"';
-    my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);
-    my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);
-    my %lt = &Apache::lonlocal::texthash(
-        'addb' => 'Add block',
-        'exam' => 'e.g., Exam 1',
-        'addn' => 'Add new communication blocking periods'
-    );
-    my ($typeorder,$types) = &blocktype_text();
-    $r->print(<<"END");
-<h4>$lt{'addn'}</h4> 
-END
-    $r->print(&Apache::loncommon::start_data_table());
-    $r->print(<<"END");
-   <tr>
-     <th>$ltext->{'dura'}</th>
-     <th>$ltext->{'even'} $lt{'exam'}</th>
-     <th>$ltext->{'blck'}</th>
-     <th>$ltext->{'actn'}</th>
-   </tr>
-END
-    $r->print(&Apache::loncommon::start_data_table_row());
-    $r->print(<<"END");
-     <td>$ltext->{'star'}:&nbsp;$startform<br />$ltext->{'endd'}:&nbsp;&nbsp;$endform</td>
-     <td><input type="text" name="title_$parmcount" size="15" value="" /></td>
-     <td>
-END
-    foreach my $block (@{$typeorder}) {
-        $r->print('<span class="LC_nobreak"><label><input type="checkbox" name="'.$block.'_'.$parmcount.'" value="1" />'.$types->{$block}.'</label></span><br />');
-     }
-     $r->print(<<"END");
-     </td>
-     <td><span class="LC_nobreak"><label>
-     <input type="checkbox" name="add_$parmcount" value="1" />$lt{'addb'}
-     </label></span></td>
-END
-    $r->print(&Apache::loncommon::end_data_table_row());
-    $r->print(&Apache::loncommon::end_data_table());
-    return;
-}
-
-sub blocktype_text {
-    my %types = &Apache::lonlocal::texthash(
-        'com' => 'Messaging',
-        'chat' => 'Chat Room',
-        'boards' => 'Discussion',
-        'port' => 'Portfolio',
-        'groups' => 'Groups',
-        'blogs' => 'Blogs',
-    );
-    my $typeorder = ['com','chat','boards','port','groups','blogs'];
-    return ($typeorder,\%types);
-}
-
 # ----------------------------------------------------------- Display a message
 
 sub displaymessage {
@@ -2390,7 +2081,6 @@ sub displaymessage {
     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);
         my($blocked, $blocktext) = &Apache::loncommon::blocking_status("com");
         $r->print("<br />".$blocktext);
         return;
@@ -2444,19 +2134,22 @@ sub displaymessage {
     push(@functionlist,'<a href="/adm/email?markdel='.&escape($msgid).$sqs.'">'
                   .&mt('Delete')
                   .'</a>');
-    push(@functionlist,'<a href="/adm/email?'.$sqs.'">'
-                  .&mt('Back to Folder Display')
-                  .'</a>');
+
+# Prepare available navigation
+    my @navigationlist;
     if ($counter > 0){
-        push(@functionlist,'<a href="/adm/email?display='.$messages[$counter-1]->[5].$sqs.'">'
+        push(@navigationlist,'<a href="/adm/email?display='.$messages[$counter-1]->[5].$sqs.'">'
                           .&mt('Previous')
                           .'</a>');
     }
     if ($counter < $number_of_messages - 1){
-        push(@functionlist,'<a href="/adm/email?display='.$messages[$counter+1]->[5].$sqs.'">'
+        push(@navigationlist,'<a href="/adm/email?display='.$messages[$counter+1]->[5].$sqs.'">'
                           .&mt('Next')
                           .'</a>');
     }
+    push(@navigationlist,'<a href="/adm/email?'.$sqs.'">'
+                  .&mt('Back to Folder Display')
+                  .'</a>');
 
 # Prepare available actions
     my $symb;
@@ -2465,7 +2158,7 @@ sub displaymessage {
     } elsif (defined($content{'baseurl'})) {
         $symb=&Apache::lonnet::symbread($content{'baseurl'});
     }
-        my @actionlist;
+    my @actionlist;
     if ($env{'user.adv'}) {
 
 	if (&Apache::lonnet::allowed('vgr',$env{'request.course.id'})) {
@@ -2493,7 +2186,7 @@ sub displaymessage {
 	}
     }
 
-# Print functionlist and actionlist in page header
+# Print functionlist, navigationlist, and actionlist in page header
         my $functions='<div class="LC_columnSection">';
 
         # Functionlist
@@ -2503,10 +2196,18 @@ sub displaymessage {
         }
         $functions .= &Apache::lonhtmlcommon::end_funclist();
 
+        # Navigationlist
+        $functions.=&Apache::lonhtmlcommon::start_funclist(
+                    &mt('Navigation'));
+        foreach my $item (@navigationlist) {
+            $functions.=&Apache::lonhtmlcommon::add_item_funclist($item);
+        }
+        $functions .= &Apache::lonhtmlcommon::end_funclist();
+
         # Actionlist
         if (@actionlist) {
-            my $legendtext=&mt('Currently available actions (will open extra window)');
-            $functions.=&Apache::lonhtmlcommon::start_funclist($legendtext);
+            $functions.=&Apache::lonhtmlcommon::start_funclist(
+                            &mt('Currently available actions (will open extra window)'));
             foreach my $item (@actionlist) {
                 $functions.=&Apache::lonhtmlcommon::add_item_funclist($item);
             }
@@ -3357,15 +3058,13 @@ sub handler {
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
         ['display','replyto','forward','markread','markdel','markunread',
          'sendreply','compose','sendmail','critical','recname','recdom',
-         'recordftf','sortedby','block','folder','startdis','interdis',
+         'recordftf','sortedby','folder','startdis','interdis',
 	 'showcommentbaseurl','dismode','group','subject','text','ref',
          'msgstatus']);
     $sqs='&amp;sortedby='.$env{'form.sortedby'};
 
 # ------------------------------------------------------ They checked for email
-    unless ($env{'form.block'}) {
-        &Apache::lonnet::put('email_status',{'recnewemail'=>0});
-    }
+    &Apache::lonnet::put('email_status',{'recnewemail'=>0});
 
 # ----------------------------------------------------------------- Breadcrumbs
 
@@ -3568,8 +3267,6 @@ sub handler {
 	&compout($r,'','',$env{'form.compose'});
     } elsif ($env{'form.recordftf'}) {
 	&facetoface($r,$env{'form.recordftf'});
-    } elsif ($env{'form.block'}) {
-        &examblock($r,$env{'form.block'});
     } elsif ($env{'form.sendmail'}) {
         if ($env{'form.multiforward'}) {
             &printheader($r,'','Messages being sent.');