--- loncom/interface/loncommon.pm	2009/08/08 19:55:04	1.882
+++ loncom/interface/loncommon.pm	2009/09/25 13:51:58	1.890
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.882 2009/08/08 19:55:04 raeburn Exp $
+# $Id: loncommon.pm,v 1.890 2009/09/25 13:51:58 droeschl Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -483,7 +483,7 @@ ENDAUTHORBRW
 
 sub coursebrowser_javascript {
     my ($domainfilter,$sec_element,$formname)=@_;
-    my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Community - for which you wish to add/modify a user role');
+    my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Community - for which you wish to add/modify a user role.');
     my $id_functions = &javascript_index_functions();
     my $output = '
 <script type="text/javascript" language="JavaScript">
@@ -602,7 +602,7 @@ sub userbrowser_javascript {
     my $id_functions = &javascript_index_functions();
     return <<"ENDUSERBRW";
 
-function openuserbrowser(formname,uname,udom,ulast,ufirst,uemail,hideudom,crsdom) {
+function openuserbrowser(formname,uname,udom,ulast,ufirst,uemail,hideudom,crsdom,caller) {
     var url = '/adm/pickuser?';
     var userdom = getDomainFromSelectbox(formname,udom);
     if (userdom != null) {
@@ -617,6 +617,9 @@ function openuserbrowser(formname,uname,
                                 '&uemailelement='+uemail+
                                 '&hideudomelement='+hideudom+
                                 '&coursedom='+crsdom;
+    if ((caller != null) && (caller != undefined)) {
+        url += '&caller='+caller;
+    }
     var title = 'User_Browser';
     var options = 'scrollbars=1,resizable=1,menubar=0';
     options += ',width=700,height=600';
@@ -624,23 +627,27 @@ function openuserbrowser(formname,uname,
     stdeditbrowser.focus();
 }
 
-function fix_domain (formname,udom,origdom) {
+function fix_domain (formname,udom,origdom,uname) {
     var formid = getFormIdByName(formname);
     if (formid > -1) {
+        var unameid = getIndexByName(formid,uname);
         var domid = getIndexByName(formid,udom);
         var hidedomid = getIndexByName(formid,origdom);
         if (hidedomid > -1) {
             var fixeddom = document.forms[formid].elements[hidedomid].value;
-            if (domid > -1) {
-                var slct = document.forms[formid].elements[domid];
-                if (slct.type == 'select-one') {
-                    var i;
-                    for (i=0;i<slct.length;i++) {
-                        if (slct.options[i].value==fixeddom) { slct.selectedIndex=i; }
+            var unameval = document.forms[formid].elements[unameid].value;
+            if ((fixeddom != '') && (fixeddom != undefined) && (fixeddom != null) && (unameval != '') && (unameval != undefined) && (unameval != null)) {
+                if (domid > -1) {
+                    var slct = document.forms[formid].elements[domid];
+                    if (slct.type == 'select-one') {
+                        var i;
+                        for (i=0;i<slct.length;i++) {
+                            if (slct.options[i].value==fixeddom) { slct.selectedIndex=i; }
+                        }
+                    }
+                    if (slct.type == 'hidden') {
+                        slct.value = fixeddom;
                     }
-                }
-                if (slct.type == 'hidden') {
-                    slct.value = fixeddom;
                 }
             }
         }
@@ -715,9 +722,9 @@ sub selectauthor_link {
 
 sub selectuser_link {
     my ($form,$unameelem,$domelem,$lastelem,$firstelem,$emailelem,$hdomelem,
-        $coursedom,$linktext) = @_;
+        $coursedom,$linktext,$caller) = @_;
     return '<a href="javascript:openuserbrowser('."'$form','$unameelem','$domelem',".
-           "'$lastelem','$firstelem','$emailelem','$hdomelem','$coursedom'".
+           "'$lastelem','$firstelem','$emailelem','$hdomelem','$coursedom','$caller'".
            ');">'.$linktext.'</a>';
 }
 
@@ -2971,7 +2978,7 @@ sub syllabuswrapper {
 # -----------------------------------------------------------------------------
 
 sub track_student_link {
-    my ($linktext,$sname,$sdom,$target,$start) = @_;
+    my ($linktext,$sname,$sdom,$target,$start,$only_body) = @_;
     my $link ="/adm/trackstudent?";
     my $title = 'View recent activity';
     if (defined($sname) && $sname !~ /^\s*$/ &&
@@ -2985,6 +2992,7 @@ sub track_student_link {
         $target = '';
     }
     if ($start) { $link.='&amp;start='.$start; }
+    if ($only_body) { $link .= '&amp;only_body=1'; }
     $title = &mt($title);
     $linktext = &mt($linktext);
     return qq{<a href="$link" title="$title" $target>$linktext</a>}.
@@ -3917,23 +3925,24 @@ sub parse_block_record {
 }
 
 sub blocking_status {
-  my $blocked;
   my ($activity,$uname,$udom) = @_;
   my %setters;
+
+  # check for active blocking
   my ($startblock,$endblock)=&blockcheck(\%setters,$activity,$uname,$udom);
-  if ($startblock && $endblock) {
-    $blocked = 1;
-  }
-  if(!wantarray) {
-    return $blocked;
-  }
-  my $output;
-  my $querystring;
-  $querystring = "?activity=$activity";
 
-      $output .= <<"END_MYBLOCK";
-<script type="text/javascript">
-// <![CDATA[
+  my $blocked = $startblock && $endblock ? 1 : 0;
+
+  # caller just wants to know whether a block is active
+  if (!wantarray) { return $blocked; }
+
+  # build a link to a popup window containing the details
+  my $querystring  = "?activity=$activity";
+  # $uname and $udom decide whose portfolio the user is trying to look at
+     $querystring .= "&amp;udom=$udom"      if $udom;
+     $querystring .= "&amp;uname=$uname"    if $uname;
+
+  my $output .= <<'END_MYBLOCK';
     function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
         var options = "width=" + w + ",height=" + h + ",";
         options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
@@ -3941,18 +3950,20 @@ sub blocking_status {
         var newWin = window.open(url, wdwName, options);
         newWin.focus();
     }
-
-// ]]>
-</script>
 END_MYBLOCK
+
+  $output = Apache::lonhtmlcommon::scripttag($output);
+  
   my $popupUrl = "/adm/blockingstatus/$querystring";
+  my $text = mt('Communication Blocked');
+
   $output .= <<"END_BLOCK";
 <div class='LC_comblock'>
   <a onclick='openWindow("$popupUrl","Blocking Table",600,300,"no","no");return false;' href='/adm/blockingstatus/$querystring'
-  title='Communication Blocked'>
-  <img class='LC_noBorder LC_middle' title='Communication Blocked' src='/res/adm/pages/comblock.png' alt='Communication Blocked'/></a>
+  title='$text'>
+  <img class='LC_noBorder LC_middle' title='$text' src='/res/adm/pages/comblock.png' alt='$text'/></a>
   <a onclick='openWindow("$popupUrl","Blocking Table",600,300,"no","no");return false;' href='/adm/blockingstatus/$querystring' 
-  title='Communication Blocked'>Communication Blocked</a>
+  title='$text'>$text</a>
 </div>
 
 END_BLOCK
@@ -4468,7 +4479,7 @@ sub bodytag {
 
     # Explicit link to get inline menu
     my $menu= ($no_inline_link?''
-	       :'<a href="/adm/remote?action=collapse">'.&mt('Switch to Inline Menu Mode').'</a>');
+	       :'<a href="/adm/remote?action=collapse" target="_top">'.&mt('Switch to Inline Menu Mode').'</a>');
     $bodytag .= qq|<div id="LC_nav_bar">$name $role
             <em>$realm</em> $dc_info </div>
             <ol class="LC_smallMenu LC_right">
@@ -4994,6 +5005,9 @@ table.LC_nested tr.LC_empty_row td {
   padding: 8px;
 }
 
+table.LC_caption {
+}
+
 table.LC_nested tr.LC_empty_row td {
   padding: 4ex
 }
@@ -6763,6 +6777,11 @@ sub simple_error_page {
     sub end_data_table_header_row {
 	return '</tr>'."\n";;
     }
+
+    sub data_table_caption {
+        my $caption = shift;
+        return "<caption class=\"LC_caption\">$caption</caption>";
+    }
 }
 
 =pod
@@ -9284,10 +9303,11 @@ sub restore_settings {
 
 =item * &build_recipient_list()
 
-Build recipient lists for four types of e-mail:
+Build recipient lists for five types of e-mail:
 (a) Error Reports, (b) Package Updates, (c) lonstatus warnings/errors
-(d) Help requests, generated by
-lonerrorhandler.pm, CHECKRPMS, loncron, and lonsupportreq.pm respectively.
+(d) Help requests, (e) Course requests needing approval,  generated by
+lonerrorhandler.pm, CHECKRPMS, loncron, lonsupportreq.pm and
+loncoursequeueadmin.pm respectively.
 
 Inputs:
 defmail (scalar - email address of default recipient), 
@@ -9889,7 +9909,7 @@ sub check_clone {
 }
 
 sub construct_course {
-    my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context,$cnum) = @_;
+    my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context,$cnum,$category) = @_;
     my $outcome;
     my $linefeed =  '<br />'."\n";
     if ($context eq 'auto') {
@@ -9928,7 +9948,7 @@ sub construct_course {
                                              $args->{'ccuname'}.':'.
                                              $args->{'ccdomain'},
                                              $args->{'crstype'},
-                                             $cnum);
+                                             $cnum,$context,$category);
 
     # Note: The testing routines depend on this being output; see 
     # Utils::Course. This needs to at least be output as a comment