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

raeburn raeburn@source.lon-capa.org
Wed, 16 Sep 2009 20:10:32 -0000


raeburn		Wed Sep 16 20:10:32 2009 EDT

  Modified files:              (Branch: GCI_1)
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Backport 1.988 for GCI_1.
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.976.4.1 loncom/lonnet/perl/lonnet.pm:1.976.4.2
--- loncom/lonnet/perl/lonnet.pm:1.976.4.1	Wed Sep 16 20:02:48 2009
+++ loncom/lonnet/perl/lonnet.pm	Wed Sep 16 20:10:32 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.976.4.1 2009/09/16 20:02:48 raeburn Exp $
+# $Id: lonnet.pm,v 1.976.4.2 2009/09/16 20:10:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2636,6 +2636,7 @@
     my ($cid,$codes) = @_;
     $cid=$env{'request.course.id'} unless (defined($cid));
     my %coursehash=&coursedescription($cid);
+    my $crstype = &Apache::loncommon::course_type($cid);
     my %nothide=();
     foreach my $user (split(/\s*\,\s*/,$coursehash{'nothideprivileged'})) {
         if ($user !~ /:/) {
@@ -2680,7 +2681,7 @@
                 $returnhash{$role}=$username.':'.$domain;
             }
         } else {
-            my $key=&plaintext($role);
+            my $key=&plaintext($role,$crstype);
             if ($section) { $key.=' ('.&Apache::lonlocal::mt('Section [_1]',$section).')'; }
             if ($returnhash{$key}) {
 	        $returnhash{$key}.=','.$username.':'.$domain;
@@ -5646,16 +5647,19 @@
 # ------------------------------------------------------------------ Plain Text
 
 sub plaintext {
-    my ($short,$type,$cid) = @_;
+    my ($short,$type,$cid,$forcedefault) = @_;
     if ($short =~ /^cr/) {
 	return (split('/',$short))[-1];
     }
     if (!defined($cid)) {
         $cid = $env{'request.course.id'};
     }
-    if (defined($cid) && defined($env{'course.'.$cid.'.'.$short.'.plaintext'})) {
-        return &Apache::lonlocal::mt($env{'course.'.$cid.'.'.$short.
-                                          '.plaintext'});
+    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',
@@ -9377,8 +9381,13 @@
 
 =item *
 
-plaintext($short) : return value in %prp hash (rolesplain.tab); plain text
-explanation of a user role term
+plaintext($short,$type,$cid,$forcedefault) : return value in %prp hash
+(rolesplain.tab); plain text explanation of a user role term.
+$type is Course (default) or Community.
+If $forcedefault evaluates to true, text returned will be default
+text for $type. Otherwise, if this is a course, the text returned
+will be a custom name for the role (if defined in the course's
+environment).  If no custom name is defined the default is returned.
 
 =item *