version 1.98, 2005/01/11 22:12:22
|
version 1.99, 2005/01/30 15:34:46
|
Line 1126 END
|
Line 1126 END
|
} |
} |
} |
} |
} elsif ($_=~/^form\.ren/) { |
} elsif ($_=~/^form\.ren/) { |
|
my $udom = $ENV{'form.ccdomain'}; |
|
my $uname = $ENV{'form.ccuname'}; |
if ($_=~/^form\.ren\:([^\_]+)\_([^\_]+)$/) { |
if ($_=~/^form\.ren\:([^\_]+)\_([^\_]+)$/) { |
my $url = $1; |
my $url = $1; |
my $role = $2; |
my $role = $2; |
Line 1133 END
|
Line 1135 END
|
my $output; |
my $output; |
if ($role eq 'st') { |
if ($role eq 'st') { |
if ($url =~ m-^/(\w+)/(\w+)/?(\w*)$-) { |
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')) { |
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) { |
$output = "Error: $result\n"; |
$output = "Error: $result\n"; |
} else { |
} else { |
Line 1152 END
|
Line 1154 END
|
$r->print($output); |
$r->print($output); |
} |
} |
} elsif ($_=~/^form\.act/) { |
} elsif ($_=~/^form\.act/) { |
|
my $udom = $ENV{'form.ccdomain'}; |
|
my $uname = $ENV{'form.ccuname'}; |
if ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) { |
if ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) { |
# Activate a custom role |
# Activate a custom role |
my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5); |
my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5); |
Line 1169 END
|
Line 1173 END
|
my %sections = (); |
my %sections = (); |
my $num_sections = &build_roles($ENV{'form.sec_'.$full},\%sections,$5); |
my $num_sections = &build_roles($ENV{'form.sec_'.$full},\%sections,$5); |
if ($num_sections == 0) { |
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 { |
} else { |
foreach (sort {$a cmp $b} keys %sections) { |
foreach (sort {$a cmp $b} keys %sections) { |
my $securl = $url.'/'.$_; |
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+)\_([^\_]+)$/) { |
} elsif ($_=~/^form\.act\_([^\_]+)\_(\w+)\_([^\_]+)$/) { |
Line 1192 END
|
Line 1196 END
|
my %sections = (); |
my %sections = (); |
my $num_sections = &build_roles($ENV{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three); |
my $num_sections = &build_roles($ENV{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three); |
if ($num_sections == 0) { |
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 { |
} else { |
my $emptysec = 0; |
my $emptysec = 0; |
foreach my $sec (sort {$a cmp $b} keys %sections) { |
foreach my $sec (sort {$a cmp $b} keys %sections) { |
$sec =~ s/\W//g; |
$sec =~ s/\W//g; |
if ($sec ne '') { |
if ($sec ne '') { |
my $securl = $url.'/'.$sec; |
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 { |
} else { |
$emptysec = 1; |
$emptysec = 1; |
} |
} |
} |
} |
if ($emptysec) { |
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\_([^\_]+)\_([^\_]+)$/) { |
} elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) { |
Line 1222 END
|
Line 1226 END
|
my %sections = (); |
my %sections = (); |
my $num_sections = &build_roles($ENV{'form.sec_'.$1.'_'.$2},\%sections,$2); |
my $num_sections = &build_roles($ENV{'form.sec_'.$1.'_'.$2},\%sections,$2); |
if ($num_sections == 0) { |
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 { |
} else { |
my $emptysec = 0; |
my $emptysec = 0; |
foreach my $sec (sort {$a cmp $b} keys %sections) { |
foreach my $sec (sort {$a cmp $b} keys %sections) { |
if ($sec ne '') { |
if ($sec ne '') { |
my $securl = $url.'/'.$sec; |
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 { |
} else { |
$emptysec = 1; |
$emptysec = 1; |
} |
} |
} |
} |
if ($emptysec) { |
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 { |
} else { |
Line 1248 END
|
Line 1252 END
|
} |
} |
|
|
sub commit_customrole { |
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. |
my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.'@'.$three.' in '.$url. |
($start?', '.&mt('starting').' '.localtime($start):''). |
($start?', '.&mt('starting').' '.localtime($start):''). |
($end?', ending '.localtime($end):'').': <b>'. |
($end?', ending '.localtime($end):'').': <b>'. |
&Apache::lonnet::assigncustomrole( |
&Apache::lonnet::assigncustomrole( |
$ENV{'form.ccdomain'},$ENV{'form.ccuname'},$url,$three,$four,$five,$end,$start). |
$udom,$uname,$url,$three,$four,$five,$end,$start). |
'</b><br>'; |
'</b><br>'; |
return $output; |
return $output; |
} |
} |
|
|
sub commit_standardrole { |
sub commit_standardrole { |
my ($url,$three,$start,$end,$one,$two,$sec) = @_; |
my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_; |
my $output; |
my $output; |
my $logmsg; |
my $logmsg; |
if ($three eq 'st') { |
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')) { |
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) { |
$output = "Error: $result\n"; |
$output = "Error: $result\n"; |
} else { |
} else { |
Line 1278 sub commit_standardrole {
|
Line 1282 sub commit_standardrole {
|
($start?', '.&mt('starting').' '.localtime($start):''). |
($start?', '.&mt('starting').' '.localtime($start):''). |
($end?', '.&mt('ending').' '.localtime($end):'').': <b>'. |
($end?', '.&mt('ending').' '.localtime($end):'').': <b>'. |
&Apache::lonnet::assignrole( |
&Apache::lonnet::assignrole( |
$ENV{'form.ccdomain'},$ENV{'form.ccuname'}, |
$udom,$uname,$url,$three,$end,$start). |
$url,$three,$end,$start). |
|
'</b><br>'; |
'</b><br>'; |
} |
} |
return $output; |
return $output; |
} |
} |
|
|
sub commit_studentrole { |
sub commit_studentrole { |
my ($logmsg,$url,$three,$start,$end,$one,$two,$sec) = @_; |
my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_; |
my $udom = $ENV{'form.ccdomain'}; |
|
my $uname = $ENV{'form.ccuname'}; |
|
my $linefeed = '<br />'."\n"; |
my $linefeed = '<br />'."\n"; |
my $result; |
my $result; |
if (defined($one) && defined($two)) { |
if (defined($one) && defined($two)) { |