[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 05 Dec 2003 16:03:53 -0000
albertel Fri Dec 5 11:03:53 2003 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
Log:
-Adding $cid as an arg to modifystudent and modify_student_enrollement to support auto enrollement
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.454 loncom/lonnet/perl/lonnet.pm:1.455
--- loncom/lonnet/perl/lonnet.pm:1.454 Thu Dec 4 19:28:32 2003
+++ loncom/lonnet/perl/lonnet.pm Fri Dec 5 11:03:53 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.454 2003/12/05 00:28:32 albertel Exp $
+# $Id: lonnet.pm,v 1.455 2003/12/05 16:03:53 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3144,10 +3144,11 @@
sub modifystudent {
my ($udom,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene,$usec,
- $end,$start,$forceid,$desiredhome,$email)=@_;
- my $cid='';
- unless ($cid=$ENV{'request.course.id'}) {
- return 'not_in_class';
+ $end,$start,$forceid,$desiredhome,$email,$type,$cid)=@_;
+ if (!$cid) {
+ unless ($cid=$ENV{'request.course.id'}) {
+ return 'not_in_class';
+ }
}
# --------------------------------------------------------------- Make the user
my $reply=&modifyuser
@@ -3157,24 +3158,34 @@
# This will cause &modify_student_enrollment to get the uid from the
# students environment
$uid = undef if (!$forceid);
- $reply = &modify_student_enrollment($udom,$uname,$uid,$first,$middle,
- $last,$gene,$usec,$end,$start);
+ $reply = &modify_student_enrollment($udom,$uname,$uid,$first,$middle,$last,
+ $gene,$usec,$end,$start,$type,$cid);
return $reply;
}
sub modify_student_enrollment {
- my ($udom,$uname,$uid,$first,$middle,$last,$gene,$usec,$end,$start) = @_;
- # Get the course id from the environment
- my $cid='';
- unless ($cid=$ENV{'request.course.id'}) {
- return 'not_in_class';
+ my ($udom,$uname,$uid,$first,$middle,$last,$gene,$usec,$end,$start,$type,
+ $cid) = @_;
+ my ($cdom,$cnum,$chome);
+ if (!$cid) {
+ unless ($cid=$ENV{'request.course.id'}) {
+ return 'not_in_class';
+ }
+ $cdom=$ENV{'course.'.$cid.'.domain'};
+ $cnum=$ENV{'course.'.$cid.'.num'};
+ } else {
+ ($cdom,$cnum)=split(/_/,$cid);
+ }
+ $chome=$ENV{'course.'.$cid.'.home'};
+ if (!$chome) {
+ my $chome=&homeserver($uname,$udom);
}
+ if (!$chome) { return 'unknown_course'; }
# Make sure the user exists
my $uhome=&homeserver($uname,$udom);
if (($uhome eq '') || ($uhome eq 'no_host')) {
return 'error: no such user';
}
- #
# Get student data if we were not given enough information
if (!defined($first) || $first eq '' ||
!defined($last) || $last eq '' ||
@@ -3187,9 +3198,9 @@
['firstname','middlename','lastname', 'generation','id']
,$udom,$uname);
- foreach (keys(%tmp)) {
- &logthis("key $_ = ".$tmp{$_});
- }
+ #foreach (keys(%tmp)) {
+ # &logthis("key $_ = ".$tmp{$_});
+ #}
$first = $tmp{'firstname'} if (!defined($first) || $first eq '');
$middle = $tmp{'middlename'} if (!defined($middle) || $middle eq '');
$last = $tmp{'lastname'} if (!defined($last) || $last eq '');
@@ -3198,11 +3209,9 @@
}
my $fullname = &Apache::loncoursedata::ProcessFullName($last,$gene,
$first,$middle);
- my $reply=critical('put:'.$ENV{'course.'.$cid.'.domain'}.':'.
- $ENV{'course.'.$cid.'.num'}.':classlist:'.
- &escape($uname.':'.$udom).'='.
- &escape(join(':',$end,$start,$uid,$usec,$fullname)),
- $ENV{'course.'.$cid.'.home'});
+ my $value=&escape($uname.':'.$udom).'='.
+ &escape(join(':',$end,$start,$uid,$usec,$fullname,undef,$type));
+ my $reply=critical('put:'.$cdom.':'.$cnum.':classlist:'.$value,$chome);
unless (($reply eq 'ok') || ($reply eq 'delayed')) {
return 'error: '.$reply;
}