[LON-CAPA-cvs] cvs: loncom(version_2_9_X) /interface lonaboutme.pm

raeburn raeburn@source.lon-capa.org
Mon, 01 Nov 2010 13:35:42 -0000


raeburn		Mon Nov  1 13:35:42 2010 EDT

  Modified files:              (Branch: version_2_9_X)
    /loncom/interface	lonaboutme.pm 
  Log:
  - Backport 1.147.
  
  
Index: loncom/interface/lonaboutme.pm
diff -u loncom/interface/lonaboutme.pm:1.70.4.3 loncom/interface/lonaboutme.pm:1.70.4.4
--- loncom/interface/lonaboutme.pm:1.70.4.3	Sat Jan 30 18:03:40 2010
+++ loncom/interface/lonaboutme.pm	Mon Nov  1 13:35:42 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # "About Me" Personal Information
 #
-# $Id: lonaboutme.pm,v 1.70.4.3 2010/01/30 18:03:40 raeburn Exp $
+# $Id: lonaboutme.pm,v 1.70.4.4 2010/11/01 13:35:42 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -396,21 +396,19 @@
 	$cdom = $env{'course.'.$cid.'.domain'};
 	$cnum = $env{'course.'.$cid.'.num'};
     }
-    my %roles = &Apache::lonnet::dump('roles',$udom,$uname);
-    my @course_roles = grep(m{^/\Q$cdom\E/\Q$cnum\E[/_]}, keys(%roles));
-    return 0 if (!@course_roles);
-    return 1 if ($type eq 'any');
-    my $now = time();
-    foreach my $role (@course_roles) {
-	my (undef,$role_end,$role_start)=split(/\_/,$roles{$role});
-	my $status = 'active';
-	if ($role_start > 0 && $now < $role_start) {
-	    $status = 'future';
-	}
-	if ($role_end > 0 && $now > $role_end) {
-	    $status = 'previous';
-	}
-	return 1 if ($status eq $type);
+    my $typesref;
+    if ($type eq 'all') {
+        $typesref = ['active','previous','future'];
+    } elsif ($type eq 'previous' || $type eq 'future') {
+        $typesref = [$type];
+    }
+    my %roles = &Apache::lonnet::get_my_roles($uname,$udom,'userroles',
+                                             $typesref,undef,[$cdom]);
+    my ($tmp) = keys(%roles);
+    return 0 if ($tmp =~ /^(con_lost|error|no_such_host)/i);
+    my @course_roles = grep(/^\Q$cnum\E:\Q$cdom\E:/, keys(%roles));
+    if (@course_roles > 0) {
+        return 1;
     }
     return 0;
 }