--- loncom/interface/loncreateuser.pm 2006/05/09 14:38:10 1.114 +++ loncom/interface/loncreateuser.pm 2006/05/09 17:21:13 1.116 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.114 2006/05/09 14:38:10 albertel Exp $ +# $Id: loncreateuser.pm,v 1.116 2006/05/09 17:21:13 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -235,25 +235,26 @@ sub user_modification_js { else { sections = document.cu.elements[i+1].value; } - var newsecs = document.cu.elements[i+1].value; - if (newsecs != null && newsecs != "") { - var numsplit = newsecs.split(/,/g); - numsec = numsec + numsplit.length; + var newseclist = document.cu.elements[i+1].value; + var newsecs = new Array(); + if (newseclist != null && newseclist != "") { + newsecs = newseclist.split(/,/g); + numsec = numsec + newsecs.length; } if ((role == 'st') && (numsec > 1)) { alert("In each course, each user may only have one student role at a time. You had selected "+numsec+" sections.\\nPlease modify your selections so they include no more than one section.") return; } else { - for (var j=0; j 1)) { alert("In each course, each user may only have one student role at a time. You had selected "+numsections+" sections.\\nPlease modify your selections so they include no more than one section.") return; } - for (var j=0; jprint(&course_level_dc($1)); @@ -1239,7 +1240,8 @@ END '
'); } } elsif ($_=~/^form\.del/) { - if ($_=~/^form\.del\:([^\_]+)\_([^\_]+)$/) { + if ($_=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) { +# Delete standard role $r->print(&mt('Deleting').' '.$2.' in '.$1.': '. &Apache::lonnet::assignrole($env{'form.ccdomain'}, $env{'form.ccuname'},$1,$2,$now,0,1).'
'); @@ -1255,11 +1257,21 @@ END &Apache::lonnet::escape($now.':'), $env{'course.'.$cid.'.home'}).'
'); } - } + } + if ($_=~/^form\.del\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) { + my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4); +# Delete custom role + $r->print(&mt('Deleting custom role [_1] by [_2]@[_3] in [_4]', + $rolename,$rnam,$rdom,$url).': '. + &Apache::lonnet::assigncustomrole($env{'form.ccdomain'}, + $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now, + 0,1).'
'); + } } elsif ($_=~/^form\.ren/) { my $udom = $env{'form.ccdomain'}; my $uname = $env{'form.ccuname'}; - if ($_=~/^form\.ren\:([^\_]+)\_([^\_]+)$/) { +# Re-enable standard role + if ($_=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) { my $url = $1; my $role = $2; my $logmsg; @@ -1279,11 +1291,20 @@ END } else { my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'}, $env{'form.ccuname'},$url,$role,0,$now); - $output = &mt('Re-Enabling [_1] in [_2]: [_3]', + $output = &mt('Re-enabling [_1] in [_2]: [_3]', $role,$url,$result).'
'; } $r->print($output); } +# Re-enable custom role + if ($_=~/^form\.ren\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) { + my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4); + my $result = &Apache::lonnet::assigncustomrole( + $env{'form.ccdomain'}, $env{'form.ccuname'}, + $url,$rdom,$rnam,$rolename,0,$now); + $r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : [_5]', + $rolename,$rnam,$rdom,$url,$result).'
'); + } } elsif ($_=~/^form\.act/) { my $udom = $env{'form.ccdomain'}; my $uname = $env{'form.ccuname'}; @@ -1761,11 +1782,11 @@ sub course_level_table { $bgcol=~s/[^7-9a-e]//g; $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6); my ($domain,$cnum)=split(/\//,$thiscourse); - my %sections_count = (); - my $num_sections = 0; + my %sections_count; if (defined($env{'request.course.id'})) { if ($env{'request.course.id'} eq $domain.'_'.$cnum) { - $num_sections = &Apache::loncommon::get_sections($domain,$cnum,\%sections_count); + %sections_count = + &Apache::loncommon::get_sections($domain,$cnum); } } foreach ('st','ta','ep','ad','in','cc') { @@ -1778,8 +1799,8 @@ sub course_level_table { $area
Domain: $domain ENDEXTENT if ($_ ne 'cc') { - if ($num_sections > 0) { - my $currsec = &course_sections($num_sections,\%sections_count,$protectedcourse.'_'.$_); + if (%sections_count) { + my $currsec = &course_sections(\%sections_count,$protectedcourse.'_'.$_); $table .= ''. ' END - if ($num_sections > 0) { - my $currsec = &course_sections($num_sections,\%sections_count,$customrole); + if (%sections_count) { + my $currsec = &course_sections(\%sections_count,$customrole); $table.= '
'.$lt{'exs'}.'
'. @@ -1819,8 +1840,8 @@ ENDTIMEENTRY
$plrole $area'. '
'.$lt{'exs'}.'
'. @@ -1859,10 +1880,10 @@ ENDTABLE } sub course_sections { - my ($num_sections,$sections_count,$role) = @_; + my ($sections_count,$role) = @_; my $output = ''; my @sections = (sort {$a <=> $b} keys %{$sections_count}); - if ($num_sections == 1) { + if (scalar(@sections) == 1) { $output = ''."\n"; foreach (@sections) { $output .= '\n";