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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Mon, 10 Mar 2008 23:26:31 -0000


raeburn		Mon Mar 10 19:26:31 2008 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Bug 2441
  &get_course_adv() takes optional second arg.
   - if true keys in returned hash are: role:section
   - if false (or undefined) keys are role name (Section section).
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.947 loncom/lonnet/perl/lonnet.pm:1.948
--- loncom/lonnet/perl/lonnet.pm:1.947	Sun Mar  9 13:22:21 2008
+++ loncom/lonnet/perl/lonnet.pm	Mon Mar 10 19:26:28 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.947 2008/03/09 17:22:21 raeburn Exp $
+# $Id: lonnet.pm,v 1.948 2008/03/10 23:26:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2449,7 +2449,7 @@
 }
 
 sub get_course_adv_roles {
-    my $cid=shift;
+    my ($cid,$codes) = @_;
     $cid=$env{'request.course.id'} unless (defined($cid));
     my %coursehash=&coursedescription($cid);
     my %nothide=();
@@ -2474,14 +2474,23 @@
 	if ((&privileged($username,$domain)) && 
 	    (!$nothide{$username.':'.$domain})) { next; }
 	if ($role eq 'cr') { next; }
-        my $key=&plaintext($role);
-        if ($section) { $key.=' (Sec/Grp '.$section.')'; }
-        if ($returnhash{$key}) {
-	    $returnhash{$key}.=','.$username.':'.$domain;
+        if ($codes) {
+            if ($section) { $role .= ':'.$section; }
+            if ($returnhash{$role}) {
+                $returnhash{$role}.=','.$username.':'.$domain;
+            } else {
+                $returnhash{$role}=$username.':'.$domain;
+            }
         } else {
-            $returnhash{$key}=$username.':'.$domain;
+            my $key=&plaintext($role);
+            if ($section) { $key.=' (Section '.$section.')'; }
+            if ($returnhash{$key}) {
+	        $returnhash{$key}.=','.$username.':'.$domain;
+            } else {
+                $returnhash{$key}=$username.':'.$domain;
+            }
         }
-     }
+    }
     return %returnhash;
 }