--- loncom/interface/loncreateuser.pm 2006/12/01 21:00:35 1.140 +++ loncom/interface/loncreateuser.pm 2007/03/12 17:06:59 1.148 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.140 2006/12/01 21:00:35 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.148 2007/03/12 17:06:59 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -135,7 +135,6 @@ sub portfolio_quota { sub print_username_entry_form { my ($r) = @_; my $defdom=$env{'request.role.domain'}; - my @domains = &Apache::loncommon::get_domains(); my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain'); my $selscript=&Apache::loncommon::studentbrowser_javascript(); my $start_page = @@ -358,36 +357,6 @@ sub print_user_modification_page { } return -1; } - - function setType() { - var crstype = document.cu.crstype.options[document.cu.crstype.selectedIndex].value; - rolevals = new Array("$rolevalslist"); - if (crstype == 'Group') { - if (document.cu.currsec.options[0].text == "$pickcrsfirst") { - document.cu.currsec.options[0].text = "$pickgrpfirst"; - } - grprolenames = new Array("$grprolenameslist"); - for (var i=0; i<rolevals.length; i++) { - if (document.cu.role.selectedIndex == i) { - document.cu.role.options[i] = new Option(grprolenames[i],rolevals[i],true,false); - } else { - document.cu.role.options[i] = new Option(grprolenames[i],rolevals[i],false,false); - } - } - } else { - if (document.cu.currsec.options[0].text == "$pickgrpfirst") { - document.cu.currsec.options[0].text = "$pickcrsfirst"; - } - crsrolenames = new Array("$crsrolenameslist"); - for (var i=0; i<rolevals.length; i++) { - if (document.cu.role.selectedIndex == i) { - document.cu.role.options[i] = new Option(crsrolenames[i],rolevals[i],true,false); - } else { - document.cu.role.options[i] = new Option(crsrolenames[i],rolevals[i],false,false); - } - } - } - } ENDSCRIPT } else { $nondc_setsection_code = <<"ENDSECCODE"; @@ -484,11 +453,7 @@ ENDSECCODE <input type="hidden" name="pres_marker" value="" > ENDFORMINFO my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); - my %incdomains; my %inccourses; - foreach my $item (values(%Apache::lonnet::hostdom)) { - $incdomains{$item}=1; - } foreach my $key (keys(%env)) { if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) { $inccourses{$1.'_'.$2}=1; @@ -624,7 +589,7 @@ END my $delallowed=0; my $sortkey=$role_code; my $class='Unknown'; - if ($area =~ m{^/($match_domain)/($match_username)} ) { + if ($area =~ m{^/($match_domain)/($match_courseid)} ) { $class='Course'; my ($coursedom,$coursedir) = ($1,$2); $sortkey.="\0$coursedom"; @@ -660,7 +625,7 @@ END } } # Compute the background color based on $area - if ($area=~m{^/($match_domain)/($match_username)/(\w+)}) { + if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) { $carea.='<br />Section: '.$3; $sortkey.="\0$3"; } @@ -962,7 +927,7 @@ ENDNOPRIV &mt('Extent').'</th>'. '<th>'.&mt('Start').'</th><th>'.&mt('End').'</th>'. &Apache::loncommon::end_data_table_header_row(); - foreach my $thisdomain ( sort( keys(%incdomains))) { + foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) { foreach my $role ('dc','li','dg','au','sc') { if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) { my $plrole=&Apache::lonnet::plaintext($role); @@ -1099,8 +1064,8 @@ ENDNEWUSERHEAD if (lc($desiredhost) eq 'default') { $desiredhost = undef; } else { - my %home_servers = &Apache::loncommon::get_library_servers - ($env{'form.ccdomain'}); + my %home_servers = + &Apache::lonnet::get_servers($env{'form.ccdomain'},'library'); if (! exists($home_servers{$desiredhost})) { $r->print($error.&mt('Invalid home server specified')); return; @@ -1117,7 +1082,7 @@ ENDNEWUSERHEAD my $home = &Apache::lonnet::homeserver($env{'form.ccuname'}, $env{'form.ccdomain'}); $r->print('<br />'.&mt('Home server').': '.$home.' '. - $Apache::lonnet::libserv{$home}); + &Apache::lonnet::hostname($home)); } elsif (($env{'form.login'} ne 'nochange') && ($env{'form.login'} ne '' )) { # Modify user privileges @@ -1274,7 +1239,7 @@ END &Apache::lonnet::revokerole($env{'form.ccdomain'}, $env{'form.ccuname'},$1,$2).'</b><br />'); if ($2 eq 'st') { - $1=~m{^/($match_domain)/($match_username)}; + $1=~m{^/($match_domain)/($match_courseid)}; my $cid=$1.'_'.$2; $r->print(&mt('Drop from classlist').': <b>'. &Apache::lonnet::critical('put:'. @@ -1301,7 +1266,7 @@ END &Apache::lonnet::assignrole($env{'form.ccdomain'}, $env{'form.ccuname'},$1,$2,$now,0,1).'<br />'); if ($2 eq 'st') { - $1=~m{^/($match_domain)/($match_username)}; + $1=~m{^/($match_domain)/($match_courseid)}; my $cid=$1.'_'.$2; $r->print(&mt('Drop from classlist').': <b>'. &Apache::lonnet::critical('put:'. @@ -1332,7 +1297,7 @@ END my $logmsg; my $output; if ($role eq 'st') { - if ($url =~ m-^/($match_domain)/($match_username)/?(\w*)$-) { + if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) { my $result = &Apache::loncommon::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"; @@ -1363,7 +1328,7 @@ END } elsif ($key=~/^form\.act/) { my $udom = $env{'form.ccdomain'}; my $uname = $env{'form.ccuname'}; - if ($key=~/^form\.act\_($match_domain)\_($match_username)\_cr_cr_($match_domain)_($match_username)_([^\_]+)$/) { + if ($key=~/^form\.act\_($match_domain)\_($match_courseid)\_cr_cr_($match_domain)_($match_username)_([^\_]+)$/) { # Activate a custom role my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5); my $url='/'.$one.'/'.$two; @@ -1394,7 +1359,7 @@ END $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end)); } } - } elsif ($key=~/^form\.act\_($match_domain)\_($match_username)\_([^\_]+)$/) { + } elsif ($key=~/^form\.act\_($match_domain)\_($match_name)\_([^\_]+)$/) { # Activate roles for sections with 3 id numbers # set start, end times, and the url for the class my ($one,$two,$three)=($1,$2,$3); @@ -1868,7 +1833,7 @@ sub course_sections { $output = '<select name="currsec_'.$role.'" '; my $multiple = 4; if (scalar(@sections) < 4) { $multiple = scalar(@sections); } - $output .= '"multiple" size="'.$multiple.'">'."\n"; + $output .= 'multiple="multiple" size="'.$multiple.'">'."\n"; foreach my $sec (@sections) { $output .= '<option value="'.$sec.'">'.$sec."</option>\n"; } @@ -1887,7 +1852,6 @@ sub course_level_dc { ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Course').'</b>'; my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu'); my %lt=&Apache::lonlocal::texthash( - 'typ' => "Type", 'rol' => "Role", 'grs' => "Section", 'exs' => "Existing sections", @@ -1900,14 +1864,9 @@ sub course_level_dc { my $header = '<h4>'.&mt('Course Level').'</h4>'. &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). - '<th>'.$lt{'typ'}.'</th><th>'.$courseform.'</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'grs'}.'</th><th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th>'. + '<th>'.$courseform.'</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'grs'}.'</th><th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th>'. &Apache::loncommon::end_data_table_header_row(); - my $otheritems = &Apache::loncommon::start_data_table_row(). - '<td><select name="crstype" onChange="javascript:setType();">'."\n". - ' <option value="">'.&mt('Please select')."\n". - ' <option value="Course">'.&mt('Course')."\n". - ' <option value="Non-standard course">'.&mt('Non-standard course')."\n". - '</select>'."\n". + my $otheritems = &Apache::loncommon::start_data_table_row()."\n". '<td><input type="text" name="coursedesc" value="" onFocus="this.blur();opencrsbrowser('."'cu','dccourse','dcdomain','coursedesc',''".')" /></td>'."\n". '<td><select name="role">'."\n"; foreach my $role ('st','ta','ep','in','cc') {