--- loncom/interface/slotrequest.pm 2006/03/07 16:15:48 1.49 +++ loncom/interface/slotrequest.pm 2006/03/21 16:03:19 1.53 @@ -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.53 2006/03/21 16:03:19 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -54,14 +54,12 @@ sub fail { sub start_page { my ($r,$title)=@_; - my $html=&Apache::lonxml::xmlbegin(); - $r->print($html.''.&mt($title).''); - $r->print(&Apache::loncommon::bodytag($title)); + $r->print(&Apache::loncommon::start_page($title)); } sub end_page { my ($r)=@_; - $r->print(&Apache::loncommon::endbodytag().''); + $r->print(&Apache::loncommon::end_page()); } =pod @@ -550,25 +548,49 @@ sub allowed_slot { } &Apache::lonxml::debug("$slot_name type good"); - # its for a different set of users - if (defined($slot->{'allowedsection'})) { - + # reserve time not yet started + if ($slot->{'startreserve'} > time) { return 0; } - &Apache::lonxml::debug("$slot_name type good"); + &Apache::lonxml::debug("$slot_name reserve good"); + my $userallowed=0; # its for a different set of users - if (defined($slot->{'allowedusers'})) { - - 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'}) + && grep(/^\Q$env{'user.name'}:$env{'user.domain'}\E$/, + split(',',$slot->{'allowedusers'}))) { + $userallowed=1; + } + + if (!defined($slot->{'allowedusers'}) + && !defined($slot->{'allowedsections'})) { + $userallowed=1; + } + + &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) {