[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm rolesplain.tab /interface loncommon.pm loncreateuser.pm lonpickstudent.pm /lonnet/perl lonnet.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Fri, 02 Jun 2006 13:58:59 -0000


This is a MIME encoded message

--raeburn1149256739
Content-Type: text/plain

raeburn		Fri Jun  2 09:58:59 2006 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm lonpickstudent.pm loncommon.pm 
    /loncom/auth	lonroles.pm rolesplain.tab 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Conversion of role names now occurs in lonnet::plaintext().  If rolename is set for a specific role in the course environment this is used, otherwise defaults to name defined in rolesplain.tab.  rolesplain.tab can now contain multiple entries (: separated) - which one is used depends on course type. loncommon::course_type() is accesssor function added to provide type; loncommon::convert_role() eliminated.  loncommon::bodytag() now includes $realm information for co-author role.
  
  
--raeburn1149256739
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060602095859.txt"

Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.119 loncom/interface/loncreateuser.pm:1.120
--- loncom/interface/loncreateuser.pm:1.119	Tue May 30 16:12:15 2006
+++ loncom/interface/loncreateuser.pm	Fri Jun  2 09:58:31 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.119 2006/05/30 20:12:15 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.120 2006/06/02 13:58:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -246,8 +246,8 @@
         my @rolevals = ('st','ta','ep','in','cc');
         my (@crsroles,@grproles);
         for (my $i=0; $i<@rolevals; $i++) {
-            $crsroles[$i]=&Apache::lonnet::plaintext($rolevals[$i]);
-            $grproles[$i]=&Apache::loncommon::convert_role($crsroles[$i],'Group');
+            $crsroles[$i]=&Apache::lonnet::plaintext($rolevals[$i],'Course');
+            $grproles[$i]=&Apache::lonnet::plaintext($rolevals[$i],'Group');
         }
         my $rolevalslist = join('","',@rolevals);
         my $crsrolenameslist = join('","',@crsroles);
@@ -705,10 +705,7 @@
                }
 	       my $plaintext='';
 	       unless ($croletitle) {
-		   $plaintext=&Apache::lonnet::plaintext($role_code);
-                   if ($class eq 'Group') {
-                       $plaintext = &Apache::loncommon::convert_role($plaintext,$class);
-                   }
+                   $plaintext=&Apache::lonnet::plaintext($role_code,$class)
 	       } else {
 	           $plaintext=
 		"Customrole '$croletitle' defined by $croleuname\@$croleudom";
Index: loncom/interface/lonpickstudent.pm
diff -u loncom/interface/lonpickstudent.pm:1.18 loncom/interface/lonpickstudent.pm:1.19
--- loncom/interface/lonpickstudent.pm:1.18	Tue May 30 16:16:59 2006
+++ loncom/interface/lonpickstudent.pm	Fri Jun  2 09:58:31 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a student from the classlist
 #
-# $Id: lonpickstudent.pm,v 1.18 2006/05/30 20:16:59 raeburn Exp $
+# $Id: lonpickstudent.pm,v 1.19 2006/06/02 13:58:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -106,9 +106,8 @@
     foreach my $role (sort keys %coursepersonnel) {
        foreach (split(/\,/,$coursepersonnel{$role})) {
 	   my ($puname,$pudom)=split(/\:/,$_);
-           if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Group') {
-               $role = &Apache::loncommon::convert_role($role,'Group');
-           }
+           $role = &Apache::lonnet::plaintext($role,
+                                            &Apache::loncommon::course_type());
 	   $r->print('<tr><td>'.
              '<input type="button" value="Select" onClick="gochoose('.
              "'".$puname."','".$pudom."')".'" /></td><td>'.$role.'</td><td>'.
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.377 loncom/interface/loncommon.pm:1.378
--- loncom/interface/loncommon.pm:1.377	Tue May 30 16:05:05 2006
+++ loncom/interface/loncommon.pm	Fri Jun  2 09:58:31 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.377 2006/05/30 20:05:05 raeburn Exp $
+# $Id: loncommon.pm,v 1.378 2006/06/02 13:58:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2826,17 +2826,19 @@
     @$addentries{keys(%design)} = @design{keys(%design)};
 
  # role and realm
-    my ($role,$realm) =
-	&Apache::lonnet::plaintext((split(/\./,$env{'request.role'}))[0]);
+    my ($role,$realm) = split(/\./,$env{'request.role'},2);
+    if ($role  eq 'ca') {
+        my ($rdom,$rname) = ($realm =~ m-^/(\w+)/(\w+)$-);
+        $realm = &plainname($rname,$rdom).':'.$rdom;
+    } 
 # realm
     if ($env{'request.course.id'}) {
-        my $type = $env{'course.'.$env{'request.course.id'}.'.type'};
-        if ($type eq 'Group') {
-            if ($env{'request.role'} !~ /^cr/) { # Change role name if Group
-                $role = &convert_role($role,$type);  
-            }
-        } 
+        if ($env{'request.role'} !~ /^cr/) {
+            $role = &Apache::lonnet::plaintext($role,&course_type());
+        }
 	$realm = $env{'course.'.$env{'request.course.id'}.'.description'};
+    } else {
+        $role = &Apache::lonnet::plaintext($role);
     }
     if (!$realm) { $realm='&nbsp;'; }
 # Set messages
@@ -4981,15 +4983,16 @@
 ############################################################
 ############################################################
 
-sub convert_role {
-    my ($rolename,$type) = @_;
-    if ($type eq 'Group') {
-        $rolename =~ s/Course/Group/;
-        $rolename =~ s/Instructor/Leader/;
-        $rolename =~ s/Teaching Assistant/Assistant Leader/;
-        $rolename =~ s/Student/Member/;
+sub course_type {
+    my ($cid) = @_;
+    if (!defined($cid)) {
+        $cid = $env{'request.course.id'};
+    }
+    if (defined($env{'course.'.$cid.'type'})) {
+        return $env{'course.'.$cid.'type'};
+    } else {
+        return 'Course';
     }
-    return $rolename;
 }
 
 sub icon {
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.152 loncom/auth/lonroles.pm:1.153
--- loncom/auth/lonroles.pm:1.152	Tue May 30 17:16:40 2006
+++ loncom/auth/lonroles.pm	Fri Jun  2 09:58:37 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.152 2006/05/30 21:16:40 raeburn Exp $
+# $Id: lonroles.pm,v 1.153 2006/06/02 13:58:37 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -565,15 +565,9 @@
 		    $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$env{'user.name'}.'/');
 		    $sortkey=$role;
                 } elsif ($trest) {
-                    $ttype='Course';
                     my $tcourseid=$tdom.'_'.$trest;
-                    if (defined($env{'course.'.$tcourseid.'.type'})) {
-                        $ttype = $env{'course.'.$tcourseid.'.type'};
-                        if ($ttype eq 'Group') {
-                            $trole = &Apache::loncommon::convert_role($trole,
-                                                                      $ttype);    
-                        }
-                    }
+                    $ttype = &Apache::loncommon::course_type($tcourseid);
+                    $trole = &Apache::lonnet::plaintext($role,$ttype);
                     if ($env{'course.'.$tcourseid.'.description'}) {
                         $twhere=$env{'course.'.$tcourseid.'.description'};
 			$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
@@ -592,10 +586,7 @@
         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).
                               '</font>';
                             $ttype = $newhash{'type'};
-                            if ($ttype eq 'Group') {
-                                $trole = &Apache::loncommon::convert_role(
-                                                                $trole,$ttype);
-                            }
+                            $trole = &Apache::lonnet::plaintext($role,$ttype);
                         } else {
                             $twhere=&mt('Currently not available');
                             $env{'course.'.$tcourseid.'.description'}=$twhere;
@@ -998,7 +989,6 @@
         if ($rolekey =~ m-^user\.role.cc\./(\w+)/(\w+)$-) {
             my $tcourseid = $1.'_'.$2;
             my $trolecode = 'cc./'.$1.'/'.$2;
-            my $trole = Apache::lonnet::plaintext('cc');
             my $twhere;
             my $ttype;
             my $tbg='#77FF77';
@@ -1009,15 +999,12 @@
                         ' <font size="-2">'.
                         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont).
                         '</font>';
-                $ttype=$newhash{'type'};
-                if ($ttype eq 'Group') {
-                    $trole = &Apache::loncommon::convert_role($trole,$ttype);
-                }
+                $ttype = $newhash{'type'};
             } else {
                 $twhere=&mt('Currently not available');
                 $env{'course.'.$tcourseid.'.description'}=$twhere;
-                $ttype = 'Unavailable';
             }
+            my $trole = &Apache::lonnet::plaintext('cc',$ttype);
             $twhere.="<br />".&mt('Domain').":".$1;
             $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,$twhere,'','','',1,'');
         }
@@ -1027,14 +1014,11 @@
 
 sub allcourses_row {
     my ($dcdom,$rowtype) = @_;
-    my $ccrole = Apache::lonnet::plaintext('cc');
     my $output = '<tr bgcolor="#77FF77">'.
                  ' <td colspan="5">';
     foreach my $type ('Course','Group') {
         my $selectlink = &courselink($dcdom,$rowtype,$type);
-        if ($type eq 'Group') {
-            $ccrole = &Apache::loncommon::convert_role($ccrole,$type);
-        }
+        my $ccrole = &Apache::lonnet::plaintext('cc',$type);
         $output.= '<font color="#002200">'.$ccrole.'</font>'.
               ' <b>'.$selectlink.'</b>'.
               ' from '.&mt('Domain').' '.$dcdom.'<br />';
Index: loncom/auth/rolesplain.tab
diff -u loncom/auth/rolesplain.tab:1.22 loncom/auth/rolesplain.tab:1.23
--- loncom/auth/rolesplain.tab:1.22	Tue May  9 15:04:40 2006
+++ loncom/auth/rolesplain.tab	Fri Jun  2 09:58:37 2006
@@ -13,12 +13,12 @@
 cm:No Role, Cumulative Privileges
 su:Superuser
 dc:Domain Coordinator
-cc:Course Coordinator
-in:Instructor
-ta:Teaching Assistant
+cc:Course Coordinator:Group Coordinator
+in:Instructor:Leader
+ta:Teaching Assistant:Assistant Leader
 ep:Exam Proctor
 cr:Course Custom Role
-st:Student
+st:Student:Member
 ad:Administrator
 li:Librarian
 au:Author
@@ -85,6 +85,7 @@
 rgi:Get identities of anonymous posters in group boards
 vgb:View postings in group discussion boards
 pgc:Participate in group chat
+rci:Get identities of anonymous posters in group chat
 rgf:Retrieve files from group repository
 ugf:Upload files to group repository
 dgf:Delete files from group repository
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.741 loncom/lonnet/perl/lonnet.pm:1.742
--- loncom/lonnet/perl/lonnet.pm:1.741	Tue May 30 16:05:23 2006
+++ loncom/lonnet/perl/lonnet.pm	Fri Jun  2 09:58:58 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.741 2006/05/30 20:05:23 raeburn Exp $
+# $Id: lonnet.pm,v 1.742 2006/06/02 13:58:58 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4097,8 +4097,25 @@
 # ------------------------------------------------------------------ Plain Text
 
 sub plaintext {
-    my $short=shift;
-    return &Apache::lonlocal::mt($prp{$short});
+    my ($short,$type,$cid) = @_;
+    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'});
+    }
+    my %rolenames = (
+                      Course => 'std',
+                      Group => 'alt1',
+                    );
+    if (defined($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'});
+    }
 }
 
 # ----------------------------------------------------------------- Assign Role
@@ -6779,8 +6796,14 @@
     while (my $configline=<$config>) {
 	chomp($configline);
 	if ($configline) {
-	    my ($short,$plain)=split(/:/,$configline);
-	    if ($plain ne '') { $prp{$short}=$plain; }
+	    my ($short,@plain)=split(/:/,$configline);
+            %{$prp{$short}} = ();
+	    if (@plain > 0) {
+                $prp{$short}{'std'} = $plain[0];
+                for (my $i=1; $i<@plain; $i++) {
+                    $prp{$short}{'alt'.$i} = $plain[$i];  
+                }
+            }
 	}
     }
     close($config);

--raeburn1149256739--