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

raeburn raeburn@source.lon-capa.org
Thu, 03 Jun 2010 14:41:07 -0000


raeburn		Thu Jun  3 14:41:07 2010 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
  Log:
  - Active CCs should be able to use "Switch course role to ..." to switch to another course role in cases where their assigned roles include an expired role of the same type/section in the course.
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.251 loncom/auth/lonroles.pm:1.252
--- loncom/auth/lonroles.pm:1.251	Wed Jun  2 16:26:21 2010
+++ loncom/auth/lonroles.pm	Thu Jun  3 14:41:07 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.251 2010/06/02 16:26:21 raeburn Exp $
+# $Id: lonroles.pm,v 1.252 2010/06/03 14:41:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -223,7 +223,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);
                 }
             }