[LON-CAPA-cvs] cvs: loncom /interface slotrequest.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 07 Mar 2006 21:37:30 -0000


albertel		Tue Mar  7 16:37:30 2006 EDT

  Modified files:              
    /loncom/interface	slotrequest.pm 
  Log:
  - respect the allowedsections and allowedusers slot attributes
  
  
Index: loncom/interface/slotrequest.pm
diff -u loncom/interface/slotrequest.pm:1.49 loncom/interface/slotrequest.pm:1.50
--- loncom/interface/slotrequest.pm:1.49	Tue Mar  7 11:15:48 2006
+++ loncom/interface/slotrequest.pm	Tue Mar  7 16:37:29 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler for requesting to have slots added to a students record
 #
-# $Id: slotrequest.pm,v 1.49 2006/03/07 16:15:48 albertel Exp $
+# $Id: slotrequest.pm,v 1.50 2006/03/07 21:37:29 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -550,25 +550,37 @@
     }
     &Apache::lonxml::debug("$slot_name type good");
 
+    my $userallowed=0;
     # its for a different set of users
-    if (defined($slot->{'allowedsection'})) {
-	
-	return 0;
+    if (defined($slot->{'allowedsections'})) {
+	if (!defined($env{'request.role.sec'})
+	    && grep(/^No section assigned$/,
+		    split(',',$slot->{'allowedsections'}))) {
+	    $userallowed=1;
+	}
+	if (defined($env{'request.role.sec'})
+	    && grep(/^\Q$env{'request.role.sec'}\E$/,
+		    split(',',$slot->{'allowedsections'}))) {
+	    $userallowed=1;
+	}
     }
-    &Apache::lonxml::debug("$slot_name type good");
+    &Apache::lonxml::debug("$slot_name sections is $userallowed");
 
     # its for a different set of users
-    if (defined($slot->{'allowedusers'})) {
-	
-	return 0;
+    if (defined($slot->{'allowedusers'})
+	&& grep(/^\Q$env{'user.name'}:$env{'user.domain'}\E$/,
+		split(',',$slot->{'allowedusers'}))) {
+	$userallowed=1;
     }
-    &Apache::lonxml::debug("$slot_name type good");
+    &Apache::lonxml::debug("$slot_name user is $userallowed");
+    return 0 if (!$userallowed);
 
     # not allowed for this resource
     if (defined($slot->{'symb'})
 	&& $slot->{'symb'} ne $symb) {
 	return 0;
     }
+
     my $conflict = &check_for_conflict($symb,$slot_name,$slot,$slots,
 				       $consumed_uniqueperiods);
     if ($conflict) {