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

www lon-capa-cvs@mail.lon-capa.org
Wed, 13 Aug 2003 18:45:02 -0000


www		Wed Aug 13 14:45:02 2003 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Toward bug #764
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.399 loncom/lonnet/perl/lonnet.pm:1.400
--- loncom/lonnet/perl/lonnet.pm:1.399	Tue Aug 12 15:46:04 2003
+++ loncom/lonnet/perl/lonnet.pm	Wed Aug 13 14:45:02 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.399 2003/08/12 19:46:04 www Exp $
+# $Id: lonnet.pm,v 1.400 2003/08/13 18:45:02 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1280,6 +1280,25 @@
         } else {
             $returnhash{$key}=$username.':'.$domain;
         }
+     }
+    return %returnhash;
+}
+
+sub get_my_roles {
+    my ($uname,$udom)=@_;
+    unless (defined($uname)) { $uname=$ENV{'user.name'}; }
+    unless (defined($udom)) { $udom=$ENV{'user.domain'}; }
+    my %dumphash=
+            &dump('nohist_userroles',$udom,$uname);
+    my %returnhash=();
+    my $now=time;
+    foreach (keys %dumphash) {
+	my ($tend,$tstart)=split(/\:/,$dumphash{$_});
+        if (($tstart) && ($tstart<0)) { next; }
+        if (($tend) && ($tend<$now)) { next; }
+        if (($tstart) && ($now<$tstart)) { next; }
+        my ($role,$username,$domain,$section)=split(/\:/,$_);
+	$returnhash{$username.':'.$domain.':'.$role}=$tstart.':'.$tend;
      }
     return %returnhash;
 }