[LON-CAPA-cvs] cvs: loncom /interface slotrequest.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 21 Nov 2005 18:55:41 -0000
albertel Mon Nov 21 13:55:41 2005 EDT
Modified files:
/loncom/interface slotrequest.pm
Log:
- can now remove a user for a slot reservation
Index: loncom/interface/slotrequest.pm
diff -u loncom/interface/slotrequest.pm:1.32 loncom/interface/slotrequest.pm:1.33
--- loncom/interface/slotrequest.pm:1.32 Mon Nov 21 12:50:45 2005
+++ loncom/interface/slotrequest.pm Mon Nov 21 13:55:41 2005
@@ -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.32 2005/11/21 17:50:45 albertel Exp $
+# $Id: slotrequest.pm,v 1.33 2005/11/21 18:55:41 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -231,17 +231,55 @@
return undef;
}
+sub remove_registration {
+ my ($r) = @_;
+ my $name = &Apache::loncommon::plainname($env{'form.uname'},
+ $env{'form.udom'});
+
+ my $title = &Apache::lonnet::gettitle($env{'form.symb'});
+
+ my $hidden_input;
+ foreach my $parm ('uname','udom','slotname','entry','symb') {
+ $hidden_input .=
+ '<input type="hidden" name="'.$parm.'" value="'
+ .&HTML::Entities::encode($env{'form.'.$parm},'"<>&\'').'" />'."\n";
+ }
+ $r->print(<<"END_CONFIRM");
+<p> Remove $name from slot $env{'form.slotname'} for $title</p>
+<form action="/adm/slotrequest" method="POST">
+ <input type="hidden" name="command" value="release" />
+ $hidden_input
+ <input type="submit" name="Yes" value="yes" />
+</form>
+<form action="/adm/slotrequest" method="POST">
+ <input type="hidden" name="command" value="showslots" />
+ <input type="submit" name="No" value="no" />
+</form>
+END_CONFIRM
+
+}
+
sub release_slot {
- my ($r,$symb,$slot_name,$inhibit_return_link)=@_;
+ my ($r,$symb,$slot_name,$inhibit_return_link,$mgr)=@_;
if ($slot_name eq '') { $slot_name=$env{'form.slotname'}; }
my ($cnum,$cdom)=&get_course();
+ my ($uname,$udom) = ($env{'user.name'}, $env{'user.domain'});
+ if ($mgr eq 'F'
+ && defined($env{'form.uname'}) && defined($env{'form.udom'})) {
+ ($uname,$udom) = ($env{'form.uname'}, $env{'form.udom'});
+ }
+
+ if ($mgr eq 'F'
+ && defined($env{'form.symb'})) {
+ $symb = $env{'form.symb'};
+ }
+
# get parameter string, check for existance, rebuild string with the slot
-
my @slots = split(/:/,&Apache::lonnet::EXT("resource.0.availablestudent",
- $symb,$env{'user.domain'},
- $env{'user.name'}));
+ $symb,$udom,$uname));
+
my @new_slots;
foreach my $exist_slot (@slots) {
if ($exist_slot eq $slot_name) { next; }
@@ -253,21 +291,24 @@
my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum,
"^$slot_name\0");
foreach my $entry (keys(%consumed)) {
- if ( $consumed{$entry}->{'name'} eq
- ($env{'user.name'}.'@'.$env{'user.domain'}) ) {
+ if ( $consumed{$entry}->{'name'} eq ($uname.'@'.$udom) ) {
&Apache::lonnet::del('slot_reservations',[$entry],
$cdom,$cnum);
}
}
+
# store new parameter string
my $result=&Apache::lonparmset::storeparm_by_symb($symb,
'0_availablestudent',
1, $new_param, 'string',
- $env{'user.name'},
- $env{'user.domain'});
+ $uname,$udom);
my %slot=&Apache::lonnet::get_slot($slot_name);
my $description=&get_description($env{'form.slotname'},\%slot);
$r->print("<p>Released Reservation: $description</p>");
+ if ($mgr eq 'F') {
+ $r->print('<p><a href="/adm/slotrequest?command=showslots">'.
+ &mt('Return to slot list').'</a></p>');
+ }
if (!$inhibit_return_link) {
$r->print('<p><a href="/adm/flip?postdata=return:">'.
&mt('Return to last resource').'</a></p>');
@@ -493,6 +534,24 @@
return 1;
}
+sub remove_link {
+ my ($slotname,$entry,$uname,$udom,$symb) = @_;
+
+ $slotname = &Apache::lonnet::escape($slotname);
+ $entry = &Apache::lonnet::escape($entry);
+ $uname = &Apache::lonnet::escape($uname);
+ $udom = &Apache::lonnet::escape($udom);
+ $symb = &Apache::lonnet::escape($symb);
+
+ my $remove= &mt('Remove');
+
+ return <<"END_LINK";
+ <a href="/adm/slotrequest?command=remove_registration&slotname=$slotname&entry=$entry&uname=$uname&udom=$udom&symb=$symb"
+ >($remove)</a>
+END_LINK
+
+}
+
sub show_table {
my ($r,$mgr)=@_;
@@ -611,8 +670,13 @@
my $ids;
foreach my $entry (sort(keys(%consumed))) {
my (undef,$id)=split("\0",$entry);
- $ids.= $id.'-> '.$consumed{$entry}->{'name'}.'<br />';
+ my ($uname,$udom) = split('@',$consumed{$entry}{'name'});
+ my $name = &Apache::loncommon::plainname($uname,$udom);
+ $ids.= '<nobr>'.$name.&remove_link($slot,$entry,$uname,$udom,
+ $consumed{$entry}{'symb'})
+ .'</nobr><br />';
}
+
my $start=($slots{$slot}->{'starttime'}?
&Apache::lonlocal::locallocaltime($slots{$slot}->{'starttime'}):'');
my $end=($slots{$slot}->{'endtime'}?
@@ -625,6 +689,7 @@
$unique=localtime($slots{$slot}{'uniqueperiod'}[0]).','.
localtime($slots{$slot}{'uniqueperiod'}[1]);
}
+
my $title;
if (exists($slots{$slot}{'symb'})) {
my (undef,undef,$res)=
@@ -633,6 +698,7 @@
$title = &Apache::lonnet::gettitle($slots{$slot}{'symb'});
$title='<a href="'.$res.'?symb='.$slots{$slot}{'symb'}.'">'.$title.'</a>';
}
+
my @proctors;
my $rowspan=1;
my $colspan=1;
@@ -660,12 +726,12 @@
if (exists($show{'name'})) {
$colspan++;$r->print("<td>$slot</td>");
}
- if (exists($show{'type'})) {
- $colspan++;$r->print("<td>$slots{$slot}->{'type'}</td>\n");
- }
if (exists($show{'description'})) {
$colspan++;$r->print("<td>$description</td>\n");
}
+ if (exists($show{'type'})) {
+ $colspan++;$r->print("<td>$slots{$slot}->{'type'}</td>\n");
+ }
if (exists($show{'starttime'})) {
$colspan++;$r->print("<td>$start</td>\n");
}
@@ -970,6 +1036,10 @@
if ($env{'form.command'} eq 'showslots' && $vgr eq 'F') {
&show_table($r,$mgr);
+ } elsif ($env{'form.command'} eq 'remove_registration' && $mgr eq 'F') {
+ &remove_registration($r);
+ } elsif ($env{'form.command'} eq 'release' && $mgr eq 'F') {
+ &release_slot($r,undef,undef,undef,$mgr);
} elsif ($env{'form.command'} eq 'uploadstart' && $mgr eq 'F') {
&upload_start($r);
} elsif ($env{'form.command'} eq 'csvuploadmap' && $mgr eq 'F') {