[LON-CAPA-cvs] cvs: loncom(version_2_9_X) /auth lonroles.pm

raeburn raeburn@source.lon-capa.org
Fri, 20 Aug 2010 03:40:01 -0000


raeburn		Fri Aug 20 03:40:01 2010 EDT

  Modified files:              (Branch: version_2_9_X)
    /loncom/auth	lonroles.pm 
  Log:
  - Backport 1.252, 1.253.
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.231.4.14 loncom/auth/lonroles.pm:1.231.4.15
--- loncom/auth/lonroles.pm:1.231.4.14	Wed Jun  2 16:27:43 2010
+++ loncom/auth/lonroles.pm	Fri Aug 20 03:40:01 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.231.4.14 2010/06/02 16:27:43 raeburn Exp $
+# $Id: lonroles.pm,v 1.231.4.15 2010/08/20 03:40:01 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -225,7 +225,16 @@
 	if ($env{'request.course.id'}) {
             # Check if user is CC trying to select a course role
             if ($env{'form.switchrole'}) {
-                if (!defined($env{'user.role.'.$env{'form.switchrole'}})) {
+                my $switch_is_active;
+                if (defined($env{'user.role.'.$env{'form.switchrole'}})) {
+                    my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.switchrole'}});
+                    if (!$end || $end > $now) {
+                        if (!$start || $start < $refresh) {
+                            $switch_is_active = 1;
+                        }
+                    }
+                }
+                unless ($switch_is_active) {
                     &adhoc_course_role($refresh,$then);
                 }
             }
@@ -924,7 +933,7 @@
                 if ($role =~ /^cr\//) {
                     my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
                     if ($tremark) { $tremark.='<br />'; }
-                    $tremark.=&mt('Defined by [_1] at [_2].',$rauthor,$rdomain);
+                    $tremark.=&mt('Customrole defined by [_1].',$rauthor.':'.$rdomain);
                 }
                 $trole=Apache::lonnet::plaintext($role);
                 my $ttype;