[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Sun, 30 Jan 2005 15:34:46 -0000
raeburn Sun Jan 30 10:34:46 2005 EDT
Modified files:
/loncom/interface loncreateuser.pm
Log:
Domain and username of user included as arguments in calls to commit_standardrole, commit_studentrole and commit_customrole. Make these functions more generally useable.
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.98 loncom/interface/loncreateuser.pm:1.99
--- loncom/interface/loncreateuser.pm:1.98 Tue Jan 11 17:12:22 2005
+++ loncom/interface/loncreateuser.pm Sun Jan 30 10:34:46 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.98 2005/01/11 22:12:22 albertel Exp $
+# $Id: loncreateuser.pm,v 1.99 2005/01/30 15:34:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1126,6 +1126,8 @@
}
}
} elsif ($_=~/^form\.ren/) {
+ my $udom = $ENV{'form.ccdomain'};
+ my $uname = $ENV{'form.ccuname'};
if ($_=~/^form\.ren\:([^\_]+)\_([^\_]+)$/) {
my $url = $1;
my $role = $2;
@@ -1133,7 +1135,7 @@
my $output;
if ($role eq 'st') {
if ($url =~ m-^/(\w+)/(\w+)/?(\w*)$-) {
- my $result = &commit_studentrole(\$logmsg,$url,$role,$now,0,$1,$2,$3);
+ my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {
$output = "Error: $result\n";
} else {
@@ -1152,6 +1154,8 @@
$r->print($output);
}
} elsif ($_=~/^form\.act/) {
+ my $udom = $ENV{'form.ccdomain'};
+ my $uname = $ENV{'form.ccuname'};
if ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) {
# Activate a custom role
my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5);
@@ -1169,11 +1173,11 @@
my %sections = ();
my $num_sections = &build_roles($ENV{'form.sec_'.$full},\%sections,$5);
if ($num_sections == 0) {
- $r->print(&commit_customrole($url,$three,$four,$five,$start,$end));
+ $r->print(&commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end));
} else {
foreach (sort {$a cmp $b} keys %sections) {
my $securl = $url.'/'.$_;
- $r->print(&commit_customrole($securl,$three,$four,$five,$start,$end));
+ $r->print(&commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end));
}
}
} elsif ($_=~/^form\.act\_([^\_]+)\_(\w+)\_([^\_]+)$/) {
@@ -1192,20 +1196,20 @@
my %sections = ();
my $num_sections = &build_roles($ENV{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
if ($num_sections == 0) {
- $r->print(&commit_standardrole($url,$three,$start,$end,$one,$two,''));
+ $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
} else {
my $emptysec = 0;
foreach my $sec (sort {$a cmp $b} keys %sections) {
$sec =~ s/\W//g;
if ($sec ne '') {
my $securl = $url.'/'.$sec;
- $r->print(&commit_standardrole($securl,$three,$start,$end,$one,$two,$sec));
+ $r->print(&commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec));
} else {
$emptysec = 1;
}
}
if ($emptysec) {
- $r->print(&commit_standardrole($url,$three,$start,$end,$one,$two,''));
+ $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
}
}
} elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
@@ -1222,19 +1226,19 @@
my %sections = ();
my $num_sections = &build_roles($ENV{'form.sec_'.$1.'_'.$2},\%sections,$2);
if ($num_sections == 0) {
- $r->print(&commit_standardrole($url,$2,$start,$end,$1,undef,''));
+ $r->print(&commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,''));
} else {
my $emptysec = 0;
foreach my $sec (sort {$a cmp $b} keys %sections) {
if ($sec ne '') {
my $securl = $url.'/'.$sec;
- $r->print(&commit_standardrole($securl,$2,$start,$end,$1,undef,$sec));
+ $r->print(&commit_standardrole($udom,$uname,$securl,$2,$start,$end,$1,undef,$sec));
} else {
$emptysec = 1;
}
}
if ($emptysec) {
- $r->print(&commit_standardrole($url,$2,$start,$end,$1,undef,''));
+ $r->print(&commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,''));
}
}
} else {
@@ -1248,22 +1252,22 @@
}
sub commit_customrole {
- my ($url,$three,$four,$five,$start,$end) = @_;
+ my ($udom,$uname,$url,$three,$four,$five,$start,$end) = @_;
my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.'@'.$three.' in '.$url.
($start?', '.&mt('starting').' '.localtime($start):'').
($end?', ending '.localtime($end):'').': <b>'.
&Apache::lonnet::assigncustomrole(
- $ENV{'form.ccdomain'},$ENV{'form.ccuname'},$url,$three,$four,$five,$end,$start).
- '</b><br>';
+ $udom,$uname,$url,$three,$four,$five,$end,$start).
+ '</b><br>';
return $output;
}
sub commit_standardrole {
- my ($url,$three,$start,$end,$one,$two,$sec) = @_;
+ my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;
my $output;
my $logmsg;
if ($three eq 'st') {
- my $result = &commit_studentrole(\$logmsg,$url,$three,$start,$end,$one,$two,$sec);
+ my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec);
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {
$output = "Error: $result\n";
} else {
@@ -1278,17 +1282,14 @@
($start?', '.&mt('starting').' '.localtime($start):'').
($end?', '.&mt('ending').' '.localtime($end):'').': <b>'.
&Apache::lonnet::assignrole(
- $ENV{'form.ccdomain'},$ENV{'form.ccuname'},
- $url,$three,$end,$start).
+ $udom,$uname,$url,$three,$end,$start).
'</b><br>';
}
return $output;
}
sub commit_studentrole {
- my ($logmsg,$url,$three,$start,$end,$one,$two,$sec) = @_;
- my $udom = $ENV{'form.ccdomain'};
- my $uname = $ENV{'form.ccuname'};
+ my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;
my $linefeed = '<br />'."\n";
my $result;
if (defined($one) && defined($two)) {