--- loncom/interface/lonuserutils.pm 2010/11/15 18:50:37 1.97.2.25 +++ loncom/interface/lonuserutils.pm 2010/09/14 06:02:35 1.122 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.97.2.25 2010/11/15 18:50:37 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.122 2010/09/14 06:02:35 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -47,8 +47,7 @@ sub modifystudent { # this one. If $csec is defined, drop them from all other sections of # this course and add them to section $csec my ($cnum,$cdom) = &get_course_identity($courseid); - my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1}); - my %roles = &Apache::lonnet::dump('roles',$udom,$unam,'.',undef,$extra); + my %roles = &Apache::lonnet::dump('roles',$udom,$unam); my ($tmp) = keys(%roles); # Bail out if we were unable to get the students roles return "$1" if ($tmp =~ /^(con_lost|error|no_such_host)/i); @@ -296,8 +295,7 @@ sub hidden_input { } sub print_upload_manager_header { - my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype, - $can_assign)=@_; + my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype)=@_; my $javascript; # if (! exists($env{'form.upfile_associate'})) { @@ -311,9 +309,9 @@ sub print_upload_manager_header { } } if ($env{'form.upfile_associate'} eq 'reverse') { - $javascript=&upload_manager_javascript_reverse_associate($can_assign); + $javascript=&upload_manager_javascript_reverse_associate(); } else { - $javascript=&upload_manager_javascript_forward_associate($can_assign); + $javascript=&upload_manager_javascript_forward_associate(); } # # Deal with restored settings @@ -534,7 +532,6 @@ END if (message!='') { message+='\\n'; } - message+='$alert{'section'}'; } if (foundemail==0) { if (message!='') { @@ -588,46 +585,6 @@ END ############################################################### ############################################################### sub upload_manager_javascript_forward_associate { - my ($can_assign) = @_; - my ($auth_update,$numbuttons,$argreset); - if (ref($can_assign) eq 'HASH') { - if ($can_assign->{'krb4'} || $can_assign->{'krb5'}) { - $argreset .= " vf.krbarg.value='';\n"; - $numbuttons ++ ; - } - if ($can_assign->{'int'}) { - $argreset .= " vf.intarg.value='';\n"; - $numbuttons ++; - } - if ($can_assign->{'loc'}) { - $argreset .= " vf.locarg.value='';\n"; - $numbuttons ++; - } - if (!$can_assign->{'int'}) { - my $warning = &mt('You may not specify an initial password for each user, as this is only available when new users use LON-CAPA internal authentication.\n'). - &mt('Your current role does not have rights to create users with that authentication type.'); - $auth_update = <<"END"; - // Currently the initial password field is only supported for internal auth - // (see bug 6368). - if (nw==9) { - eval('vf.f'+tf+'.selectedIndex=0;') - alert('$warning'); - } -END - } elsif ($numbuttons > 1) { - $auth_update = <<"END"; - // If we set the password, make the password form below correspond to - // the new value. - if (nw==9) { - changed_radio('int',document.studentform); - set_auth_radio_buttons('int',document.studentform); -$argreset - } - -END - } - } - return(<{'krb4'} || $can_assign->{'krb5'}) { - $argreset .= " vf.krbarg.value='';\n"; - $numbuttons ++ ; - } - if ($can_assign->{'int'}) { - $argreset .= " vf.intarg.value='';\n"; - $numbuttons ++; - } - if ($can_assign->{'loc'}) { - $argreset .= " vf.locarg.value='';\n"; - $numbuttons ++; - } - if (!$can_assign->{'int'}) { - my $warning = &mt('You may not specify an initial password, as this is only available when new users use LON-CAPA internal authentication.\n'). - &mt('Your current role does not have rights to create users with that authentication type.'); - $auth_update = <<"END"; - // Currently the initial password field is only supported for internal auth - // (see bug 6368). - if (tf==8 && nw!=0) { - eval('vf.f'+tf+'.selectedIndex=0;') - alert('$warning'); - } -END - } elsif ($numbuttons > 1) { - $auth_update = <<"END"; - // initial password specified, pick internal authentication - if (tf==8 && nw!=0) { - changed_radio('int',document.studentform); - set_auth_radio_buttons('int',document.studentform); -$argreset - } - -END - } - } - return(<=2) && (tf<=5) && (nw!=0)) { eval('vf.f1.selectedIndex=0;') } - $auth_update + // intial password specified, pick internal authentication + if (tf==8 && nw!=0) { + changed_radio('int',document.studentform); + set_auth_radio_buttons('int',document.studentform); + vf.krbarg.value=''; + vf.intarg.value=''; + vf.locarg.value=''; + } } function clearpwd(vf) { @@ -1047,9 +978,8 @@ sub print_upload_manager_form { my ($krbdef,$krbdefdom) = &Apache::loncommon::get_kerberos_defaults($defdom); # - my ($authnum,%can_assign) = &Apache::loncommon::get_assignable_auth($defdom); &print_upload_manager_header($r,$datatoken,$distotal,$krbdefdom,$context, - $permission,$crstype,\%can_assign); + $permission,$crstype); my $i; my $keyfields; if ($total>=0) { @@ -1517,7 +1447,7 @@ sub print_userlist { return; } if (!(($context eq 'domain') && - (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) { + (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) { $r->print( "\n

\n" .'

' @@ -1528,7 +1458,7 @@ sub print_userlist { my ($indexhash,$keylist) = &make_keylist_array(); my (%userlist,%userinfo,$clearcoursepick); if (($context eq 'domain') && - ($env{'form.roletype'} eq 'course') || + ($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')) { my ($crstype,$numcodes,$title,$warning); if ($env{'form.roletype'} eq 'course') { @@ -1542,9 +1472,11 @@ sub print_userlist { $title = &mt('Select Communities'); $warning = &mt('Warning: data retrieval for multiple communities can take considerable time, as this operation is not currently optimized.'); } + my @standardnames = &Apache::loncommon::get_standard_codeitems(); my $courseform = &Apache::lonhtmlcommon::course_selection($formname,$numcodes, - $codetitles,$idlist,$idlist_titles,$crstype); + $codetitles,$idlist,$idlist_titles,$crstype, + \@standardnames); $r->print('

'.&Apache::lonhtmlcommon::start_pick_box()."\n". &Apache::lonhtmlcommon::start_pick_box()."\n". &Apache::lonhtmlcommon::row_title($title,'LC_oddrow_value')."\n". @@ -1762,7 +1694,7 @@ sub role_filter { $role_select .= ''; $output = ''; + .' '; } return $output; } @@ -1993,7 +1925,7 @@ function setCourseCat(formname) { if (formname.Year.options[formname.Year.selectedIndex].value == -1) { return; } - courseSet('Year'); + courseSet('$codetitles[0]'); for (var j=0; jprint(''.$results_description.'

'); } my ($output,$actionselect,%canchange,%canchangesec); @@ -2401,7 +2332,7 @@ END END if ($actionselect) { $output .= <<"END"; -

$lt{'ac'} +
$lt{'ac'} $actionselect

 
@@ -2446,7 +2377,7 @@ END } } } - $output .= '
'.$lt{'link'}.''. + $output .= '
'.$lt{'link'}.''. ''; my @linkdests = ('aboutme'); if ($permission->{'cusr'}) { @@ -2457,6 +2388,7 @@ END $env{'request.course.sec'})) { push(@linkdests,'track'); } + $output .= '
'; my $usernamelink = $env{'form.usernamelink'}; if ($usernamelink eq '') { @@ -2473,7 +2405,7 @@ END if ($env{'form.userwin'}) { $checkwin = ' checked="checked"'; } - $output .= ''.$lt{'owin'}.'
'; + $output .= ''.$lt{'owin'}.'
'; } $output .= "\n".''."\n". &Apache::loncommon::start_data_table(). @@ -2726,7 +2658,7 @@ END if ($clickers!~/\w/) { $clickers='-'; } $in{'clicker'} = $clickers; my $role = $in{'role'}; - $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype); + $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype); if (! defined($in{'start'}) || $in{'start'} == 0) { $in{'start'} = &mt('none'); } else { @@ -3245,7 +3177,7 @@ ENDJS chse => 'Changes in section affiliation to apply to selected users', fors => 'For student roles, changing the section will result in a section switch as students may only be in one section of a course at a time.', forn => 'For a course role that is not "student", users may have roles in more than one section at a time.', - reta => "Retain each user's current section affiliations?", + reta => "Retain each user's current section affiliations?", dnap => '(Does not apply to student roles).', ); my ($date_items,$headertext); @@ -3478,7 +3410,6 @@ sub results_header_row { } } elsif (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')) { - my $coursefilter = $env{'form.coursepick'}; if ($env{'form.roletype'} eq 'course') { if ($coursefilter eq 'category') { @@ -3742,8 +3673,15 @@ sub print_first_users_upload_form { &mt("How do I create a CSV file from a spreadsheet")) .'

'."\n"; $str .= &Apache::lonhtmlcommon::start_pick_box() - .&Apache::lonhtmlcommon::row_title(&mt('File')) - .&Apache::loncommon::upfile_select_html() + .&Apache::lonhtmlcommon::row_title(&mt('File')); + if (&Apache::lonlocal::current_language() ne 'en') { + if ($context eq 'course') { + $str .= '

'."\n" + .&mt('Please upload an UTF8 encoded file to ensure a correct character encoding in your classlist.')."\n" + .'

'."\n"; + } + } + $str .= &Apache::loncommon::upfile_select_html() .&Apache::lonhtmlcommon::row_closure() .&Apache::lonhtmlcommon::row_title( '