--- loncom/interface/loncommon.pm	2009/07/31 03:14:20	1.873
+++ loncom/interface/loncommon.pm	2009/10/24 03:24:13	1.902
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.873 2009/07/31 03:14:20 raeburn Exp $
+# $Id: loncommon.pm,v 1.902 2009/10/24 03:24:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -483,27 +483,18 @@ 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 $output = '
+    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">
 // <![CDATA[
     var stdeditbrowser;'."\n";
-   $output .= <<"ENDSTDBRW";
+
+    $output .= <<"ENDSTDBRW";
     function opencrsbrowser(formname,uname,udom,desc,extra_element,multflag,crstype) {
         var url = '/adm/pickcourse?';
-        var domainfilter = '';
         var formid = getFormIdByName(formname);
-        if (formid > -1) {
-            var domid = getIndexByName(formid,udom);
-            if (domid > -1) {
-                if (document.forms[formid].elements[domid].type == 'select-one') {
-                    domainfilter=document.forms[formid].elements[domid].options[document.forms[formid].elements[domid].selectedIndex].value;
-                }
-                if (document.forms[formid].elements[domid].type == 'hidden') {
-                    domainfilter=document.forms[formid].elements[domid].value;
-                }
-            }
-        }
+        var domainfilter = getDomainFromSelectbox(formname,udom);
         if (domainfilter != null) {
            if (domainfilter != '') {
                url += 'domainfilter='+domainfilter+'&';
@@ -555,24 +546,7 @@ sub coursebrowser_javascript {
         stdeditbrowser = open(url,title,options,'1');
         stdeditbrowser.focus();
     }
-
-    function getFormIdByName(formname) {
-        for (var i=0;i<document.forms.length;i++) {
-            if (document.forms[i].name == formname) {
-                return i;
-            }
-        }
-        return -1; 
-    }
-
-    function getIndexByName(formid,item) {
-        for (var i=0;i<document.forms[formid].elements.length;i++) {
-            if (document.forms[formid].elements[i].name == item) {
-                return i;
-            }
-        }
-        return -1;
-    }
+$id_functions
 ENDSTDBRW
     if ($sec_element ne '') {
         $output .= &setsec_javascript($sec_element,$formname);
@@ -583,6 +557,109 @@ ENDSTDBRW
     return $output;
 }
 
+sub javascript_index_functions {
+    return <<"ENDJS";
+
+function getFormIdByName(formname) {
+    for (var i=0;i<document.forms.length;i++) {
+        if (document.forms[i].name == formname) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+function getIndexByName(formid,item) {
+    for (var i=0;i<document.forms[formid].elements.length;i++) {
+        if (document.forms[formid].elements[i].name == item) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+function getDomainFromSelectbox(formname,udom) {
+    var userdom;
+    var formid = getFormIdByName(formname);
+    if (formid > -1) {
+        var domid = getIndexByName(formid,udom);
+        if (domid > -1) {
+            if (document.forms[formid].elements[domid].type == 'select-one') {
+                userdom=document.forms[formid].elements[domid].options[document.forms[formid].elements[domid].selectedIndex].value;
+            }
+            if (document.forms[formid].elements[domid].type == 'hidden') {
+                userdom=document.forms[formid].elements[domid].value;
+            }
+        }
+    }
+    return userdom;
+}
+
+ENDJS
+
+}
+
+sub userbrowser_javascript {
+    my $id_functions = &javascript_index_functions();
+    return <<"ENDUSERBRW";
+
+function openuserbrowser(formname,uname,udom,ulast,ufirst,uemail,hideudom,crsdom,caller) {
+    var url = '/adm/pickuser?';
+    var userdom = getDomainFromSelectbox(formname,udom);
+    if (userdom != null) {
+       if (userdom != '') {
+           url += 'srchdom='+userdom+'&';
+       }
+    }
+    url += 'form=' + formname + '&unameelement='+uname+
+                                '&udomelement='+udom+
+                                '&ulastelement='+ulast+
+                                '&ufirstelement='+ufirst+
+                                '&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';
+    var stdeditbrowser = open(url,title,options,'1');
+    stdeditbrowser.focus();
+}
+
+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;
+            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;
+                    }
+                }
+            }
+        }
+    }
+    return;
+}
+
+$id_functions
+ENDUSERBRW
+}
+
 sub setsec_javascript {
     my ($sec_element,$formname) = @_;
     my $setsections = qq|
@@ -644,6 +721,14 @@ sub selectauthor_link {
           &mt('Select Author').'</a>';
 }
 
+sub selectuser_link {
+    my ($form,$unameelem,$domelem,$lastelem,$firstelem,$emailelem,$hdomelem,
+        $coursedom,$linktext,$caller) = @_;
+    return '<a href="javascript:openuserbrowser('."'$form','$unameelem','$domelem',".
+           "'$lastelem','$firstelem','$emailelem','$hdomelem','$coursedom','$caller'".
+           ');">'.$linktext.'</a>';
+}
+
 sub check_uncheck_jscript {
     my $jscript = <<"ENDSCRT";
 function checkAll(field) {
@@ -1120,8 +1205,8 @@ sub help_menu_js {
 
     my $template .= <<"ENDTEMPLATE";
 <script type="text/javascript">
-// <!-- BEGIN LON-CAPA Internal
 // <![CDATA[
+// <!-- BEGIN LON-CAPA Internal
 var banner_link = '';
 function helpMenu(target) {
     var caller = this;
@@ -1146,8 +1231,8 @@ function writeHelp(caller) {
     caller.document.close()
     caller.focus()
 }
-// ]]>
 // END LON-CAPA Internal -->
+// ]]>
 </script>
 ENDTEMPLATE
     return $template;
@@ -1815,7 +1900,7 @@ The optional $onchange argumnet specifie
 sub select_dom_form {
     my ($defdom,$name,$includeempty,$showdomdesc,$onchange) = @_;
     if ($onchange) {
-        ' onchange="'.$onchange.'"';
+        $onchange = ' onchange="'.$onchange.'"';
     }
     my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains());
     if ($includeempty) { @domains=('',@domains); }
@@ -2870,7 +2955,7 @@ sub messagewrapper {
 sub noteswrapper {
     my ($link,$un,$do)=@_;
     return 
-"<a href='/adm/email?recordftf=retrieve&recname=$un&recdom=$do'>$link</a>";
+"<a href='/adm/email?recordftf=retrieve&amp;recname=$un&amp;recdom=$do'>$link</a>";
 }
 
 # ------------------------------------------------------------- Aboutme Wrapper
@@ -2880,7 +2965,7 @@ sub aboutmewrapper {
     if (!defined($username)  && !defined($domain)) {
         return;
     }
-    return '<a href="/adm/'.$domain.'/'.$username.'/aboutme"'.
+    return '<a href="/adm/'.$domain.'/'.$username.'/aboutme?forcestudent=1"'.
 	($target?' target="$target"':'').' title="'.&mt("View this user's personal information page").'">'.$link.'</a>';
 }
 
@@ -2894,7 +2979,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*$/ &&
@@ -2908,6 +2993,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>}.
@@ -3840,23 +3926,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,";
@@ -3864,18 +3951,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
@@ -3958,7 +4047,7 @@ sub determinedomain {
     my $domain=shift;
     if (! $domain) {
         # Determine domain if we have not been given one
-        $domain = $Apache::lonnet::perlvar{'lonDefDomain'};
+        $domain = &Apache::lonnet::default_login_domain();
         if ($env{'user.domain'}) { $domain=$env{'user.domain'}; }
         if ($env{'request.role.domain'}) { 
             $domain=$env{'request.role.domain'}; 
@@ -4308,6 +4397,9 @@ sub bodytag {
         if ($env{'request.role'} !~ /^cr/) {
             $role = &Apache::lonnet::plaintext($role,&course_type());
         }
+        if ($env{'request.course.sec'}) {
+            $role .= ('&nbsp;'x2).'-&nbsp;'.&mt('section:').'&nbsp;'.$env{'request.course.sec'};
+        }   
 	$realm = $env{'course.'.$env{'request.course.id'}.'.description'};
     } else {
         $role = &Apache::lonnet::plaintext($role);
@@ -4347,34 +4439,52 @@ sub bodytag {
         $dc_info = '('.$dc_info.')';
     }
 
-    $role = "($role)" if $role;
+    $role = '<span class="LC_nobreak">('.$role.')</span>' if $role;
     &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']);
 
     if ($env{'environment.remote'} eq 'off') {
         # No Remote
-	if ($env{'request.state'} eq 'construct') {
-	    $forcereg=1;
-	}
+        if ($env{'request.state'} eq 'construct') {
+            $forcereg=1;
+        }
 
-#    if ($env{'request.state'} eq 'construct') {
-#        $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls
-#    }
+    #    if ($env{'request.state'} eq 'construct') {
+    #        $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls
+    #    }
 
         my $titletable = '<table id="LC_title_bar">'
-                        ."<tr><td> $titleinfo $dc_info</td>"
-                        .'</tr></table>';
+                            ."<tr><td> $titleinfo $dc_info</td>"
+                            .'</tr></table>';
 
-	if ($no_nav_bar) {
-	    $bodytag .= $titletable;
-	} else {
-        $bodytag .= qq|<div id="LC_nav_bar">$name $role<br />
-            <em>$realm</em> $dc_info</div>| unless $env{'form.inhibitmenu'};
+        if ($no_nav_bar) {
+            $bodytag .= $titletable;
+        } else {
+            $bodytag .= qq|<div id="LC_nav_bar">$name $role<br />
+                <em>$realm</em> $dc_info</div>| unless $env{'form.inhibitmenu'};
 
-	    if ($env{'request.state'} eq 'construct') {
-                $bodytag .= &Apache::lonmenu::menubuttons($forcereg,$titletable);
-            } else {
-                $bodytag .= &Apache::lonmenu::menubuttons($forcereg).$titletable;
-            }
+#SD $titletable is obsolete
+#SD            if ($env{'request.state'} eq 'construct') {
+#SD                $bodytag .= &Apache::lonmenu::menubuttons($forcereg,$titletable);
+#SD            } else {
+#SD                $bodytag .= &Apache::lonmenu::menubuttons($forcereg).$titletable;
+#SD            }
+               if (   $env{'form.inhibitmenu'} eq 'yes' 
+                   || $ENV{'REQUEST_URI'} eq '/adm/logout'
+                   || $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) {
+                   
+                   return $bodytag;
+               }
+
+               $bodytag .= Apache::lonhtmlcommon::scripttag(
+                                Apache::lonmenu::utilityfunctions(),
+                                'start');
+               $bodytag .= Apache::lonmenu::primary_menu();
+               $bodytag .= Apache::lonmenu::secondary_menu();
+               #SD remove next line
+               #$bodytag .= Apache::lonmenu::menubuttons($forcereg);
+               $bodytag .= Apache::lonmenu::serverform();
+               $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); 
+               $bodytag .= Apache::lonmenu::innerregister($forcereg) if $forcereg;
         }
         return $bodytag;
     }
@@ -4391,10 +4501,10 @@ 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">
+            <ol class="LC_primary_menu LC_right">
                 <li>$menu</li>
             </ol>| unless $env{'form.inhibitmenu'};
     #
@@ -4565,14 +4675,6 @@ a:focus {
   background: yellow 
 }
 
-hr {
-  clear: both;
-  color: $tabbg;
-  background-color: $tabbg;
-  height: 3px;
-  border: none;
-}
-
 form, .inline { 
    display: inline; 
 }
@@ -4838,10 +4940,6 @@ td.LC_menubuttons_text {
   font-weight: bold;
 }
 
-.LC_roleslog_note {
-  font-size: small;
-}
-
 table.LC_data_table,
 table.LC_mail_list {
   border: 1px solid #000000;
@@ -4861,6 +4959,7 @@ table.LC_nested_outer {
   width: 100%;
 }
 
+table.LC_innerpickbox,
 table.LC_nested {
   border: none;
   border-collapse: collapse;
@@ -4871,13 +4970,19 @@ table.LC_nested {
 table.LC_data_table tr th, 
 table.LC_calendar tr th, 
 table.LC_mail_list tr th,
-table.LC_prior_tries tr th {
+table.LC_prior_tries tr th,
+table.LC_innerpickbox tr th {
   font-weight: bold;
   background-color: $data_table_head;
   color:$fontmenu;
   font-size:90%;
 }
 
+table.LC_innerpickbox tr th,
+table.LC_innerpickbox tr td {
+  vertical-align: top;
+}
+
 table.LC_data_table tr.LC_info_row > td {
   background-color: #CCCCCC;
   font-weight: bold;
@@ -4888,12 +4993,14 @@ table.LC_data_table tr.LC_odd_row > td,
 table.LC_pick_box tr > td.LC_odd_row {
   background-color: $data_table_light;
   padding: 2px;
+  vertical-align: top;
 }
 
 table.LC_data_table tr.LC_even_row > td,
 table.LC_pick_box tr > td.LC_even_row {
   background-color: $data_table_dark;
   padding: 2px;
+  vertical-align: top;
 }
 
 table.LC_data_table tr.LC_data_table_highlight td {
@@ -4914,6 +5021,9 @@ table.LC_nested tr.LC_empty_row td {
   padding: 8px;
 }
 
+table.LC_caption {
+}
+
 table.LC_nested tr.LC_empty_row td {
   padding: 4ex
 }
@@ -5037,7 +5147,7 @@ table.LC_mail_list tr.LC_mail_other:hove
 
 table.LC_data_table tr > td.LC_browser_file,
 table.LC_data_table tr > td.LC_browser_file_published {
-  background: #CCFF88;
+  background: #AAEE77;
 }
 
 table.LC_data_table tr > td.LC_browser_file_locked,
@@ -5046,16 +5156,16 @@ table.LC_data_table tr > td.LC_browser_f
 }
 
 table.LC_data_table tr > td.LC_browser_file_obsolete {
-  background: #AAAAAA;
+  background: #888888;
 }
 
 table.LC_data_table tr > td.LC_browser_file_modified,
 table.LC_data_table tr > td.LC_browser_file_metamodified {
-  background: #FFFF77;
+  background: #F8F866;
 }
 
 table.LC_data_table tr.LC_browser_folder > td {
-  background: #CCCCFF;
+  background: #E0E8FF;
 }
 
 table.LC_data_table tr > td.LC_roles_is {
@@ -5197,7 +5307,7 @@ table.LC_pick_box {
 table.LC_pick_box td.LC_pick_box_title {
   background: $sidebg;
   font-weight: bold;
-  text-align: right;
+  text-align: left;
   vertical-align: top;
   width: 184px;
   padding: 8px;
@@ -5235,40 +5345,6 @@ table.LC_pick_box td.LC_oddrow_value {
   background-color: $data_table_light;
 }
 
-table.LC_helpform_receipt {
-  width: 620px;
-  border-collapse: separate;
-  background: white;
-  border: 1px solid black;
-  border-spacing: 1px;
-}
-
-table.LC_helpform_receipt td.LC_pick_box_title {
-  background: $tabbg;
-  font-weight: bold;
-  text-align: right;
-  width: 184px;
-  padding: 8px;
-}
-
-table.LC_helpform_receipt td.LC_evenrow_value {
-  text-align: left;
-  padding: 8px;
-  background-color: $data_table_light;
-}
-
-table.LC_helpform_receipt td.LC_oddrow_value {
-  text-align: left;
-  padding: 8px;
-  background-color: $data_table_light;
-}
-
-table.LC_helpform_receipt td.LC_pick_box_separator {
-  padding: 0;
-  height: 1px;
-  background: black;
-}
-
 span.LC_helpform_receipt_cat {
   font-weight: bold;
 }
@@ -5571,10 +5647,6 @@ table.LC_double_column tr td.LC_right_co
   vertical-align: top;
 }
 
-span.LC_role_level {
-  font-weight: bold;
-}
-
 div.LC_left_float {
   float: left;
   padding-right: 5%;
@@ -5729,10 +5801,10 @@ div.LC_createcourse {
 # --------------------------*/
 
 a:hover,
-ol.LC_smallMenu a:hover,
+ol.LC_primary_menu a:hover,
 ol#LC_MenuBreadcrumbs a:hover,
 ol#LC_PathBreadcrumbs a:hover,
-ul#LC_TabMainMenuContent a:hover,
+ul#LC_secondary_menu a:hover,
 .LC_FormSectionClearButton input:hover
 ul.LC_TabContent   li:hover a {
 	color:#BF2317;
@@ -5809,7 +5881,7 @@ fieldset > legend {
     font-style: normal;
 }
 
-ol.LC_smallMenu {
+ol.LC_primary_menu {
     float: right;
     margin: 0.2em 0 0 0;
 }
@@ -5818,23 +5890,23 @@ ol#LC_PathBreadcrumbs {
 	margin: 0;
 }
 
-ol.LC_smallMenu li {
+ol.LC_primary_menu li {
 	display: inline;
 	padding: 5px 5px 0 10px;
 	vertical-align: top;
 }
 
-ol.LC_smallMenu li img {
+ol.LC_primary_menu li img {
 	vertical-align: bottom;
 }
 
-ol.LC_smallMenu a {
+ol.LC_primary_menu a {
 	font-size: 90%;
 	color: RGB(80, 80, 80);
 	text-decoration: none;
 }
 
-ul#LC_TabMainMenuContent {
+ul#LC_secondary_menu {
     clear: both;
     color: $fontmenu;
     background: $tabbg;
@@ -5844,7 +5916,7 @@ ul#LC_TabMainMenuContent {
     width: 100%;
 }
 
-ul#LC_TabMainMenuContent li {
+ul#LC_secondary_menu li {
     font-weight: bold;
     line-height: 1.8em;
     padding: 0 0.8em; 
@@ -5867,7 +5939,7 @@ ul.LC_TabContentBigger li {
 	float:left;
 }
 
-ul#LC_TabMainMenuContent li a {
+ul#LC_secondary_menu li a {
     color: $fontmenu;
 	text-decoration: none;
 }
@@ -6656,14 +6728,14 @@ sub simple_error_page {
 	my ($add_class) = @_;
 	$row_count[0]++;
 	my $css_class = ($row_count[0] % 2)?'LC_odd_row':'LC_even_row';
-	$css_class = (join(' ',$css_class,$add_class));
+	$css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
 	return  '<tr class="'.$css_class.'">'."\n";;
     }
     
     sub continue_data_table_row {
 	my ($add_class) = @_;
 	my $css_class = ($row_count[0] % 2)?'LC_odd_row':'LC_even_row';
-	$css_class = (join(' ',$css_class,$add_class));
+	$css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');;
 	return  '<tr class="'.$css_class.'">'."\n";;
     }
 
@@ -6687,6 +6759,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
@@ -7459,6 +7536,7 @@ sub user_picker {
         #       loncreateuser::print_user_query_page()
         #       has been completed.
         next if ($option eq 'alc');
+        next if (($option eq 'crs') && ($env{'form.form'} eq 'requestcrs'));  
         next if ($option eq 'crs' && !$env{'request.course.id'});
         if ($curr_selected{'srchin'} eq $option) {
             $srchinsel .= ' 
@@ -7623,24 +7701,20 @@ $newuserscript
 
 $new_user_create
 
-<table>
- <tr>
-  <td>$lt{'doma'}:</td>
-  <td>$domform</td>
-  </td>
- </tr>
- <tr>
-  <td>$lt{'usr'}:</td>
-  <td>$srchbysel
-      $srchtypesel 
-      <input type="text" size="15" name="srchterm" value="$srchterm" />
-      $srchinsel 
-  </td>
- </tr>
-</table>
-<br />
 END_BLOCK
 
+    $output .= &Apache::lonhtmlcommon::start_pick_box().
+               &Apache::lonhtmlcommon::row_title($lt{'doma'}).
+               $domform.
+               &Apache::lonhtmlcommon::row_closure().
+               &Apache::lonhtmlcommon::row_title($lt{'usr'}).
+               $srchbysel.
+               $srchtypesel. 
+               '<input type="text" size="15" name="srchterm" value="'.$srchterm.'" />'.
+               $srchinsel.
+               &Apache::lonhtmlcommon::row_closure(1). 
+               &Apache::lonhtmlcommon::end_pick_box().
+               '<br />';
     return $output;
 }
 
@@ -8557,7 +8631,7 @@ sub csv_print_select_table {
 	my ($value,$display,$defaultcol)=@{ $array_ref };
 	$r->print(&start_data_table_row().'<td>'.$display.'</td>');
 
-	$r->print('<td><select name=f'.$i.
+	$r->print('<td><select name="f'.$i.'"'.
 		  ' onchange="javascript:flip(this.form,'.$i.');">');
 	$r->print('<option value="none"></option>');
 	foreach my $sample (sort({$a <=> $b} keys(%{ $samples->[0] }))) {
@@ -9211,10 +9285,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), 
@@ -9787,7 +9862,8 @@ sub check_clone {
         $clonemsg = &mt('No new course created.').$linefeed.&mt('A new course could not be cloned from the specified original - [_1] - because it is a non-existent course.',$args->{'clonecourse'}.':'.$args->{'clonedomain'});     
     } else {
 	my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1});
-	if ($env{'request.role.domain'} eq $args->{'clonedomain'}) {
+	if (($env{'request.role.domain'} eq $args->{'clonedomain'}) && 
+            (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
 	    $can_clone = 1;
 	} else {
 	    my %clonehash = &Apache::lonnet::get('environment',['cloners'],
@@ -9815,7 +9891,7 @@ sub check_clone {
 }
 
 sub construct_course {
-    my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context) = @_;
+    my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context,$cnum,$category) = @_;
     my $outcome;
     my $linefeed =  '<br />'."\n";
     if ($context eq 'auto') {
@@ -9853,7 +9929,8 @@ sub construct_course {
                                              $args->{'crscode'},
                                              $args->{'ccuname'}.':'.
                                              $args->{'ccdomain'},
-                                             $args->{'crstype'});
+                                             $args->{'crstype'},
+                                             $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
@@ -10167,6 +10244,16 @@ sub group_term {
     return $names{$crstype};
 }
 
+sub course_types {
+    my @types = ('official','unofficial','community');
+    my %typename = (
+                         official   => 'Official course',
+                         unofficial => 'Unofficial course',
+                         community  => 'Community',
+                   );
+    return (\@types,\%typename);
+}
+
 sub icon {
     my ($file)=@_;
     my $curfext = lc((split(/\./,$file))[-1]);