--- loncom/interface/loncommon.pm	2006/07/19 10:58:31	1.433
+++ loncom/interface/loncommon.pm	2006/08/04 18:56:20	1.442
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.433 2006/07/19 10:58:31 albertel Exp $
+# $Id: loncommon.pm,v 1.442 2006/08/04 18:56:20 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -285,7 +285,7 @@ sub browser_and_searcher_javascript {
 	}
         url += 'element=' + elementname + '';
         var title = 'Browser';
-        var options = 'scrollbars=1,resizable=1,menubar=1,location=1';
+        var options = 'scrollbars=1,resizable=1,menubar=0,toolbar=1,location=1';
         options += ',width=700,height=600';
         editbrowser = open(url,title,options,'1');
         editbrowser.focus();
@@ -306,7 +306,7 @@ sub browser_and_searcher_javascript {
 	}
         url += 'element=' + elementname + '';
         var title = 'Search';
-        var options = 'scrollbars=1,resizable=1,menubar=0';
+        var options = 'scrollbars=1,resizable=1,menubar=0,toolbar=1,location=1';
         options += ',width=700,height=600';
         editsearcher = open(url,title,options,'1');
         editsearcher.focus();
@@ -672,14 +672,14 @@ sub help_open_topic {
     {
 	$template .= 
   "<table bgcolor='#3333AA' cellspacing='1' cellpadding='1' border='0'><tr>".
-  "<td bgcolor='#5555FF'><a href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";
+  "<td bgcolor='#5555FF'><a target=\"_top\" href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";
     }
 
     # Add the graphic
     my $title = &mt('Online Help');
     my $helpicon=&lonhttpdurl("/adm/help/gif/smallHelp.gif");
     $template .= <<"ENDTEMPLATE";
- <a href="$link" title="$title"><img src="$helpicon" border="0" alt="(Help: $topic)" /></a>
+ <a target="_top" href="$link" title="$title"><img src="$helpicon" border="0" alt="(Help: $topic)" /></a>
 ENDTEMPLATE
     if ($text ne '') { $template.='</td></tr></table>' };
     return $template;
@@ -766,29 +766,35 @@ sub help_open_menu {
 sub top_nav_help {
     my ($text) = @_;
 
-    my ($topic,$component_help,$faq,$bug,$stayOnPage,$width,$height);
-   
-    $text = "" if (not defined $text);
-    $stayOnPage = 0 if (not defined $stayOnPage);
-    if ($env{'browser.interface'} eq 'textual' ||
-        $env{'environment.remote'} eq 'off' ) {
-        $stayOnPage=1;
-    }
-    $width = 620 if (not defined $width);
-    $height = 600 if (not defined $height);
-    my $link='';
+    $text = &mt($text);
+
+    my $stayOnPage = 
+	($env{'browser.interface'}  eq 'textual' ||
+	 $env{'environment.remote'} eq 'off' );
+    my $link=  ($stayOnPage) ? "javascript:helpMenu('display')"
+	                     : "javascript:helpMenu('open')";
+    my $banner_link = &update_help_link(undef,undef,undef,undef,$stayOnPage);
+
     my $title = &mt('Get help');
-    if ($stayOnPage) {
-	$link = "javascript:helpMenu('display')";
-    } else {
-        $link = "javascript:helpMenu('open')";
-    }
+
+    return <<"END";
+$banner_link
+ <a href="$link" title="$title">$text</a>
+END
+}
+
+sub help_menu_js {
+    my ($text) = @_;
+
+    my $stayOnPage = 
+	($env{'browser.interface'}  eq 'textual' ||
+	 $env{'environment.remote'} eq 'off' );
+
+    my $width = 620;
+    my $height = 600;
     my $helptopic=&general_help();
-    my $banner_link = &update_help_link($topic,$component_help,$faq,$bug,$stayOnPage);
     my $details_link = '/adm/help/'.$helptopic.'.hlp';
-    my $template;
     my $nothing=&Apache::lonhtmlcommon::javascript_nothing();
-    my $helpicon=&lonhttpdurl("/adm/lonIcons/helpgateway.gif");
     my $start_page =
         &Apache::loncommon::start_page('Help Menu', undef,
 				       {'frameset'    => 1,
@@ -800,8 +806,8 @@ sub top_nav_help {
         &Apache::loncommon::end_page({'frameset' => 1,
 				      'js_ready' => 1,});
 
-    $template .= <<"ENDTEMPLATE";
- <script type="text/javascript">
+    my $template .= <<"ENDTEMPLATE";
+<script type="text/javascript">
 // <!-- BEGIN LON-CAPA Internal
 // <![CDATA[
 var banner_link = '';
@@ -830,9 +836,7 @@ function writeHelp(caller) {
 }
 // ]]>
 // END LON-CAPA Internal -->
- </script>
-$banner_link
- <a href="$link" title="$title">$text</a>
+</script>
 ENDTEMPLATE
     return $template;
 }
@@ -868,14 +872,14 @@ sub help_open_bug {
     {
 	$template .= 
   "<table bgcolor='#AA3333' cellspacing='1' cellpadding='1' border='0'><tr>".
-  "<td bgcolor='#FF5555'><a href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";
+  "<td bgcolor='#FF5555'><a target=\"_top\" href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";
     }
 
     # Add the graphic
     my $title = &mt('Report a Bug');
     my $bugicon=&lonhttpdurl("/adm/lonMisc/smallBug.gif");
     $template .= <<"ENDTEMPLATE";
- <a href="$link" title="$title"><img src="$bugicon" border="0" alt="(Bug: $topic)" /></a>
+ <a target="_top" href="$link" title="$title"><img src="$bugicon" border="0" alt="(Bug: $topic)" /></a>
 ENDTEMPLATE
     if ($text ne '') { $template.='</td></tr></table>' };
     return $template;
@@ -913,14 +917,14 @@ sub help_open_faq {
     {
 	$template .= 
   "<table bgcolor='#337733' cellspacing='1' cellpadding='1' border='0'><tr>".
-  "<td bgcolor='#448844'><a href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";
+  "<td bgcolor='#448844'><a target=\"_top\" href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";
     }
 
     # Add the graphic
     my $title = &mt('View the FAQ');
     my $faqicon=&lonhttpdurl("/adm/lonMisc/smallFAQ.gif");
     $template .= <<"ENDTEMPLATE";
- <a href="$link" title="$title"><img src="$faqicon" border="0" alt="(FAQ: $topic)" /></a>
+ <a target="_top" href="$link" title="$title"><img src="$faqicon" border="0" alt="(FAQ: $topic)" /></a>
 ENDTEMPLATE
     if ($text ne '') { $template.='</td></tr></table>' };
     return $template;
@@ -2088,9 +2092,9 @@ sub screenname {
 sub messagewrapper {
     my ($link,$username,$domain,$subject,$text)=@_;
     return 
-        '<a href="/adm/email?compose=individual&'.
-        'recname='.$username.'&recdom='.$domain.
-	'&subject='.&escape($subject).'&text='.&escape($text).'" '.
+        '<a href="/adm/email?compose=individual&amp;'.
+        'recname='.$username.'&amp;recdom='.$domain.
+	'&amp;subject='.&escape($subject).'&amp;text='.&escape($text).'" '.
         'title="'.&mt('Send message').'">'.$link.'</a>';
 }
 # --------------------------------------------------------------- Notes Wrapper
@@ -2871,7 +2875,7 @@ sub bodytag {
                    'alink'   => &designparm($function.'.alink',$domain),
 		   'vlink'   => &designparm($function.'.vlink',$domain),
 		   'link'    => &designparm($function.'.link',$domain),);
-    @$addentries{keys(%design)} = @design{keys(%design)};
+    @design{keys(%$addentries)} = @$addentries{keys(%$addentries)}; 
 
  # role and realm
     my ($role,$realm) = split(/\./,$env{'request.role'},2);
@@ -2896,7 +2900,7 @@ sub bodytag {
     my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
     if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
 
-    my $extra_body_attr = &make_attr_string($forcereg,$addentries);
+    my $extra_body_attr = &make_attr_string($forcereg,\%design);
 
 # construct main body tag
     my $bodytag = "<body $extra_body_attr>".
@@ -2919,6 +2923,8 @@ sub bodytag {
     my $name = &plainname($env{'user.name'},$env{'user.domain'});
     if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
 	undef($role);
+    } else {
+	$name = &aboutmewrapper($name,$env{'user.name'},$env{'user.domain'});
     }
     
     my $roleinfo=(<<ENDROLE);
@@ -3194,6 +3200,9 @@ form, .inline { display: inline; }
 .LC_success {
   color: green;
 }
+.LC_icon {
+  border: 0px;
+}
 
 table#LC_top_nav, table#LC_menubuttons {
   width: 100%;
@@ -3281,6 +3290,10 @@ table#LC_top_nav td.LC_top_nav_exit,
 table#LC_top_nav td.LC_top_nav_help {
   width: 2.0em;
 }
+table#LC_top_nav td.LC_top_nav_login {
+  width: 4.0em;
+  text-align: center;
+}
 table.LC_breadcrumbs td, table.LC_docs_path td  {
   background: $tabbg;
   color: $font;
@@ -3321,6 +3334,11 @@ td.LC_menubuttons_img {
   font-weight: bold;
 }
 
+table.LC_aboutme_port {
+  border: 0px;
+  border-collapse: collapse;
+  border-spacing: 0px;
+}
 table.LC_data_table, table.LC_mail_list {
   border: 1px solid #000000;
   border-collapse: separate;
@@ -3334,11 +3352,13 @@ table.LC_data_table tr th, table.LC_cale
   background-color: $data_table_head;
   font-size: smaller;
 }
-table.LC_data_table tr td {
+table.LC_data_table tr td, 
+table.LC_aboutme_port tr td {
   background-color: $data_table_light;
   padding: 2px;
 }
-table.LC_data_table tr.LC_even_row td {
+table.LC_data_table tr.LC_even_row td,
+table.LC_aboutme_port tr.LC_even_row td {
   background-color: $data_table_dark;
 }
 table.LC_data_table tr.LC_data_table_highlight td {
@@ -3691,6 +3711,11 @@ sub headtag {
     if ($args->{'force_register'}) {
 	$result .= &Apache::lonmenu::registerurl(1);
     }
+    if (!$args->{'no_nav_bar'} 
+	&& !$args->{'only_body'}
+	&& !$args->{'frameset'}) {
+	$result .= &help_menu_js();
+    }
 
     if (ref($args->{'redirect'})) {
 	my ($time,$url,$inhibit_continue) = @{$args->{'redirect'}};
@@ -3860,7 +3885,7 @@ sub start_page {
     #&Apache::lonnet::logthis("start_page ".join(':',caller(0)));
     my %head_args;
     foreach my $arg ('redirect','force_register','domain','function',
-		     'bgcolor') {
+		     'bgcolor','frameset','no_nav_bar','only_body') {
 	if (defined($args->{$arg})) {
 	    $head_args{$arg} = $args->{$arg};
 	}
@@ -4331,13 +4356,20 @@ sub get_course_users {
         }
     }
     if ((@{$roles} > 1) || ((@{$roles} == 1) && ($$roles[0] ne "st"))) {
-        my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$cdom,$cnum);
-        foreach my $person (@coursepersonnel) {
+        my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
+        my $now = time;
+        foreach my $person (sort(keys(%coursepersonnel))) {
             my $match = 0;
             my $secmatch = 0;
+            my $status;
             my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/);
             $user =~ s/:$//;
-            if (($role) && (grep(/^\Q$role\E$/,@{$roles}))) {
+            my ($end,$start) = split(/:/,$coursepersonnel{$person});
+            if ($end == -1 || $start == -1) {
+                next;
+            }
+            if (($role) && ((grep(/^\Q$role\E$/,@{$roles})) ||
+                (grep(/^cr$/,@{$roles}) && $role =~ /^cr\//))) {
                 my ($uname,$udom) = split(/:/,$user);
                 if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) {
                     if (grep(/^all$/,@{$sections})) {
@@ -4359,8 +4391,13 @@ sub get_course_users {
                     $usec = 'none';
                 }
                 if ($uname ne '' && $udom ne '') {
-                    my $status = &check_user_status($udom,$uname,$cdom,$cnum,$role,
-                                                    $usec);
+                    if ($end < $now) {
+                        $status = 'previous';
+                    } elsif ($start > $now) {
+                        $status = 'future';
+                    } else {
+                        $status = 'active';
+                    }
                     foreach my $type (keys(%{$types})) { 
                         if ($status eq $type) {
                             if (!grep(/^\Q$type\E$/,@{$$users{$role}{$user}})) {
@@ -4385,7 +4422,10 @@ sub get_course_users {
                 my %csettings = &Apache::lonnet::get('environment',['internal.courseowner'],$cdom,$cnum);
                 if ( defined($csettings{'internal.courseowner'}) ) {
                     my $owner = $csettings{'internal.courseowner'};
-                    @{$$users{'ow'}{$owner.':'.$cdom}} = 'any';
+                    if ($owner !~ /^[^:]+:[^:]+$/) {
+                        $owner = $owner.':'.$cdom;
+                    }
+                    @{$$users{'ow'}{$owner}} = 'any';
                     if (defined($userdata) && 
 			!exists($$userdata{$owner.':'.$cdom})) {
 			&get_user_info($cdom,$owner,\%idx,$userdata);