[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonhtmlcommon.pm

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 20 Feb 2004 17:03:38 -0000


matthew		Fri Feb 20 12:03:38 2004 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonhtmlcommon.pm 
  Log:
  loncommon.pm: Moved code from &bodytag which determines users primary function
                to new subrountine &get_users_function.
  lonhtmlcommon.pm: &bodytag now gets the default background color for the
                    domain.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.181 loncom/interface/loncommon.pm:1.182
--- loncom/interface/loncommon.pm:1.181	Wed Feb 18 18:33:17 2004
+++ loncom/interface/loncommon.pm	Fri Feb 20 12:03:38 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.181 2004/02/18 23:33:17 albertel Exp $
+# $Id: loncommon.pm,v 1.182 2004/02/20 17:03:38 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2359,19 +2359,7 @@
 sub bodytag {
     my ($title,$function,$addentries,$bodyonly,$domain,$forcereg)=@_;
     $title=&mt($title);
-    unless ($function) {
-	$function='student';
-        if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
-	    $function='coordinator';
-        }
-	if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
-            $function='admin';
-        }
-        if (($ENV{'request.role'}=~/^(au|ca)/) ||
-            ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
-            $function='author';
-        }
-    }
+    $function = &get_users_function() if (! defined($function));
     my $img=&designparm($function.'.img',$domain);
     my $pgbg=&designparm($function.'.pgbg',$domain);
     my $tabbg=&designparm($function.'.tabbg',$domain);
@@ -2455,6 +2443,33 @@
 <td bgcolor="$tabbg" align="right"><font size="2" face="Arial, Helvetica, sans-serif">$realm</font>&nbsp;</td></tr>
 </table><br>
 ENDBODY
+}
+
+###############################################
+
+=pod
+
+=item get_users_function
+
+Used by &bodytag to determine the current users primary role.
+Returns either 'student','coordinator','admin', or 'author'.
+
+=cut
+
+###############################################
+sub get_users_function {
+    my $function = 'student';
+    if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
+        $function='coordinator';
+    }
+    if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
+        $function='admin';
+    }
+    if (($ENV{'request.role'}=~/^(au|ca)/) ||
+        ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
+        $function='author';
+    }
+    return $function;
 }
 
 ###############################################
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.54 loncom/interface/lonhtmlcommon.pm:1.55
--- loncom/interface/lonhtmlcommon.pm:1.54	Fri Feb 20 11:44:43 2004
+++ loncom/interface/lonhtmlcommon.pm	Fri Feb 20 12:03:38 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.54 2004/02/20 16:44:43 matthew Exp $
+# $Id: lonhtmlcommon.pm,v 1.55 2004/02/20 17:03:38 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -60,7 +60,6 @@
 use Apache::lonlocal;
 use strict;
 
-
 ##############################################
 ##############################################
 
@@ -879,8 +878,14 @@
     my @Crumbs;
 
     sub breadcrumbs {
-        my ($color,$component,$component_help) = @_;
-        $color = '#CCCCFF' if (! defined($color));
+        my ($color,$component,$component_help,$function,$domain) = @_;
+        if (! defined($color)) {
+            if (! defined($function)) {
+                $function = &Apache::loncommon::get_users_function();
+            }
+            $color = &Apache::loncommon::designparm($function.'.tabbg',
+                                                    $domain);
+        }
         #
         my $Str = "\n".
             '<table width="100%" border="0" cellpadding="0" cellspacing="0">'.