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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Fri, 21 Dec 2007 04:22:54 -0000


raeburn		Thu Dec 20 23:22:54 2007 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  &get_my_roles() can include an optional seventh argument - $withsec
  If $withsec is true, keys in the returned hash are:
  $username.':'.$domain.':'.$role.':'.$section
  instead of:
  $username.':'.$domain.':'.$role
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.932 loncom/lonnet/perl/lonnet.pm:1.933
--- loncom/lonnet/perl/lonnet.pm:1.932	Thu Dec 20 23:14:24 2007
+++ loncom/lonnet/perl/lonnet.pm	Thu Dec 20 23:22:53 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.932 2007/12/21 04:14:24 raeburn Exp $
+# $Id: lonnet.pm,v 1.933 2007/12/21 04:22:53 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2427,7 +2427,7 @@
 }
 
 sub get_my_roles {
-    my ($uname,$udom,$context,$types,$roles,$roledoms)=@_;
+    my ($uname,$udom,$context,$types,$roles,$roledoms,$withsec)=@_;
     unless (defined($uname)) { $uname=$env{'user.name'}; }
     unless (defined($udom)) { $udom=$env{'user.domain'}; }
     my %dumphash;
@@ -2486,7 +2486,12 @@
                 }
             }
         }
-	$returnhash{$username.':'.$domain.':'.$role}=$tstart.':'.$tend;
+        if ($withsec) {
+            $returnhash{$username.':'.$domain.':'.$role.':'.$section} =
+                $tstart.':'.$tend;
+        } else {
+            $returnhash{$username.':'.$domain.':'.$role}=$tstart.':'.$tend;
+        }
     }
     return %returnhash;
 }
@@ -8859,10 +8864,11 @@
 All arguments are optional. Returns a hash of a roles, either for
 co-author/assistant author roles for a user's Construction Space
 (default), or if $context is 'userroles', roles for the user himself,
-In the hash, keys are set to colon-sparated $uname,$udom,and $role,
-and value is set to colon-separated start and end times for the role.
-If no username and domain are specified, will default to current
-user/domain. Types, roles, and roledoms are references to arrays,
+In the hash, keys are set to colon-separated $uname,$udom,$role, and
+(optionally) if $withsec is true, a fourth colon-separated item - $section.
+For each key, value is set to colon-separated start and end times for
+the role.  If no username and domain are specified, will default to
+currnt user/domain. Types, roles, and roledoms are references to arrays
 of role statuses (active, future or previous), roles 
 (e.g., cc,in, st etc.) and domains of the roles which can be used
 to restrict the list of roles reported. If no array ref is