--- loncom/interface/slotrequest.pm	2006/03/21 16:05:57	1.48.2.1
+++ loncom/interface/slotrequest.pm	2006/03/07 16:15:48	1.49
@@ -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.48.2.1 2006/03/21 16:05:57 albertel Exp $
+# $Id: slotrequest.pm,v 1.49 2006/03/07 16:15:48 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -529,34 +529,46 @@ STUFF
 
 sub allowed_slot {
     my ($slot_name,$slot,$symb,$slots,$consumed_uniqueperiods)=@_;
+
     #already started
     if ($slot->{'starttime'} < time) {
 	# all open slot to be schedulable
 	#return 0;
     }
     &Apache::lonxml::debug("$slot_name starttime good");
+
     #already ended
     if ($slot->{'endtime'} < time) {
 	return 0;
     }
     &Apache::lonxml::debug("$slot_name endtime good");
+
     # not allowed to pick this one
     if (defined($slot->{'type'})
 	&& $slot->{'type'} ne 'schedulable_student') {
 	return 0;
     }
     &Apache::lonxml::debug("$slot_name type good");
-    # not allowed for this resource
-    if (defined($slot->{'symb'})
-	&& $slot->{'symb'} ne $symb) {
+
+    # its for a different set of users
+    if (defined($slot->{'allowedsection'})) {
+	
 	return 0;
     }
-    # reserve time not yet started
-    if ($slot->{'startreserve'} > time) {
+    &Apache::lonxml::debug("$slot_name type good");
+
+    # its for a different set of users
+    if (defined($slot->{'allowedusers'})) {
+	
 	return 0;
     }
-    &Apache::lonxml::debug("$slot_name reserve good");
+    &Apache::lonxml::debug("$slot_name type good");
 
+    # 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) {
@@ -744,22 +756,25 @@ sub show_table {
     &Apache::grades::reset_perm();
 
     my %show_fields=&Apache::lonlocal::texthash(
-	     'name'         => 'Slot Name',
-	     'description'  => 'Description',
-	     'type'         => 'Type',
-	     'starttime'    => 'Start time',
-	     'endtime'      => 'End Time',
-             'startreserve' => 'Time students can start reserving',
-	     'secret'       => 'Secret Word',
-	     'maxspace'     => 'Maximum # of students',
-	     'ip'           => 'IP or DNS restrictions',
-	     'symb'         => 'Resource slot is restricted to.',
-	     'uniqueperiod' => 'Period of time slot is unique',
-	     'scheduled'    => 'Scheduled Students',
-	     'proctor'      => 'List of proctors');
+	     'name'            => 'Slot Name',
+	     'description'     => 'Description',
+	     'type'            => 'Type',
+	     'starttime'       => 'Start time',
+	     'endtime'         => 'End Time',
+             'startreserve'    => 'Time students can start reserving',
+	     'secret'          => 'Secret Word',
+	     'maxspace'        => 'Maximum # of students',
+	     'ip'              => 'IP or DNS restrictions',
+	     'symb'            => 'Resource slot is restricted to.',
+	     'allowedsections' => 'Sections slot is restricted to.',
+	     'allowedusers'    => 'Users slot is restricted to.',
+	     'uniqueperiod'    => 'Period of time slot is unique',
+	     'scheduled'       => 'Scheduled Students',
+	     'proctor'         => 'List of proctors');
     my @show_order=('name','description','type','starttime','endtime',
-	       'startreserve','secret','maxspace','ip','symb',
-	       'uniqueperiod','scheduled','proctor');
+		    'startreserve','secret','maxspace','ip','symb',
+		    'allowedsections','allowedusers','uniqueperiod',
+		    'scheduled','proctor');
     my @show = 
 	(exists($env{'form.show'})) ? &Apache::loncommon::get_env_multiple('form.show')
 	                            : keys(%show_fields);
@@ -838,7 +853,7 @@ sub show_table {
 
     my %name_cache;
     my $slotsort = sub {
-	if ($env{'form.order'}=~/^(type|description|endtime|startreserve|maxspace|ip|symb)$/) {
+	if ($env{'form.order'}=~/^(type|description|endtime|startreserve|maxspace|ip|symb|allowedsections|allowedusers)$/) {
 	    if (lc($slots{$a}->{$env{'form.order'}})
 		ne lc($slots{$b}->{$env{'form.order'}})) {
 		return (lc($slots{$a}->{$env{'form.order'}}) 
@@ -917,6 +932,28 @@ sub show_table {
 	    $title='<a href="'.$res.'?symb='.$slots{$slot}{'symb'}.'">'.$title.'</a>';
 	}
 
+	my $allowedsections;
+	if (exists($show{'allowedsections'})) {
+	    $allowedsections = 
+		join(', ',sort(split(/\s*,\s*/,
+				     $slots{$slot}->{'allowedsections'})));
+	}
+
+	my @allowedusers;
+	if (exists($show{'allowedusers'})) {
+	    @allowedusers= map {
+		my ($uname,$udom)=split(/:/,$_);
+		my $fullname=$name_cache{$_};
+		if (!defined($fullname)) {
+		    $fullname = &Apache::loncommon::plainname($uname,$udom);
+		    $fullname =~s/\s/&nbsp;/g;
+		    $name_cache{$_} = $fullname;
+		}
+		&Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
+	    } (sort(split(/\s*,\s*/,$slots{$slot}->{'allowedusers'})));
+	}
+	my $allowedusers=join(', ',@allowedusers);
+	
 	my @proctors;
 	my $rowspan=1;
 	my $colspan=1;
@@ -926,7 +963,6 @@ sub show_table {
 		my ($uname,$udom)=split(/@/,$_);
 		my $fullname=$name_cache{$_};
 		if (!defined($fullname)) {
-		    &Apache::lonnet::logthis("Gettign $uname $udom");
 		    $fullname = &Apache::loncommon::plainname($uname,$udom);
 		    $fullname =~s/\s/&nbsp;/g;
 		    $name_cache{$_} = $fullname;
@@ -976,8 +1012,11 @@ DELETELINK
 	if (exists($show{'symb'})) {
 	    $colspan++;$r->print("<td>$title</td>\n");
 	}
-	if (exists($show{'uniqueperiod'})) {
-	    $colspan++;$r->print("<td>$unique</td>\n");
+	if (exists($show{'allowedsections'})) {
+	    $colspan++;$r->print("<td>$allowedsections</td>\n");
+	}
+	if (exists($show{'allowedusers'})) {
+	    $colspan++;$r->print("<td>$allowedusers</td>\n");
 	}
 	if (exists($show{'scheduled'})) {
 	    $colspan++;$r->print("<td>$ids</td>\n</tr>\n");
@@ -1162,7 +1201,10 @@ sub csvupload_fields {
 	    ['maxspace','Maximum number of reservations'],
 	    ['symb','Resource Restriction'],
 	    ['uniqueperiod','Date range of slot exclusion'],
-	    ['secret','Secret word proctor uses to validate']);
+	    ['secret','Secret word proctor uses to validate'],
+	    ['allowedsections','Sections slot is restricted to'],
+	    ['allowedusers','Users slot is restricted to'],
+	    );
 }
 
 sub csv_upload_assign {