[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

raeburn raeburn@source.lon-capa.org
Wed, 28 Oct 2009 19:09:21 -0000


raeburn		Wed Oct 28 19:09:21 2009 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  If no type was included as a second arg, &plaintext() will retrieve type if in
  course context from %env and return appropriate role name. 
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1036 loncom/lonnet/perl/lonnet.pm:1.1037
--- loncom/lonnet/perl/lonnet.pm:1.1036	Sun Oct 25 14:49:07 2009
+++ loncom/lonnet/perl/lonnet.pm	Wed Oct 28 19:09:21 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1036 2009/10/25 14:49:07 raeburn Exp $
+# $Id: lonnet.pm,v 1.1037 2009/10/28 19:09:21 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6090,24 +6090,31 @@
     if (!defined($cid)) {
         $cid = $env{'request.course.id'};
     }
-    if (defined($cid) && ($env{'course.'.$cid.'.'.$short.'.plaintext'} ne '')) {
-        unless ($forcedefault) {
-            my $roletext = $env{'course.'.$cid.'.'.$short.'.plaintext'}; 
-            &Apache::lonlocal::mt_escape(\$roletext);
-            return &Apache::lonlocal::mt($roletext);
-        }
-    }
     my %rolenames = (
                       Course    => 'std',
                       Community => 'alt1',
                     );
-    if (defined($type) && 
-         defined($rolenames{$type}) && 
-         defined($prp{$short}{$rolenames{$type}})) {
+    if ($cid ne '') {
+        if ($env{'course.'.$cid.'.'.$short.'.plaintext'} ne '') {
+            unless ($forcedefault) {
+                my $roletext = $env{'course.'.$cid.'.'.$short.'.plaintext'}; 
+                &Apache::lonlocal::mt_escape(\$roletext);
+                return &Apache::lonlocal::mt($roletext);
+            }
+        }
+    }
+    if ((defined($type)) && (defined($rolenames{$type})) &&
+        (defined($rolenames{$type})) && 
+        (defined($prp{$short}{$rolenames{$type}}))) {
         return &Apache::lonlocal::mt($prp{$short}{$rolenames{$type}});
-    } else {
-        return &Apache::lonlocal::mt($prp{$short}{'std'});
+    } elsif ($cid ne '') {
+        my $crstype = $env{'course.'.$cid.'.type'};
+        if (($crstype ne '') && (defined($rolenames{$crstype})) &&
+            (defined($prp{$short}{$rolenames{$crstype}}))) {
+            return &Apache::lonlocal::mt($prp{$short}{$rolenames{$crstype}});
+        }
     }
+    return &Apache::lonlocal::mt($prp{$short}{'std'});
 }
 
 # ----------------------------------------------------------------- Assign Role