--- loncom/interface/lonuserutils.pm 2010/11/15 18:50:37 1.97.2.25 +++ loncom/interface/lonuserutils.pm 2009/12/20 01:49:42 1.109 @@ -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.109 2009/12/20 01:49:42 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,18 +1447,14 @@ sub print_userlist { return; } if (!(($context eq 'domain') && - (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) { - $r->print( - "\n

\n" - .'

' - .&list_submit_button(&mt('Update Display')) - ."

\n" - ); + (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) { + $r->print(' '.&list_submit_button(&mt('Update Display')). + "\n

\n"); } 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') { @@ -1802,7 +1728,7 @@ sub section_group_filter { } if (@options > 0) { my $currsel; - $markup = ''."\n"; foreach my $option ('all','none',@options) { $currsel = ''; if ($env{'form.'.$name{$item}} eq $option) { @@ -1817,9 +1743,7 @@ sub section_group_filter { $markup .= ''."\n"; } $markup .= ''."\n"; - $output .= (' 'x3).'' - .'' - .' '; + $output .= (' 'x3).''; } } return $output; @@ -2347,7 +2271,7 @@ END push(@cols,'section'); } if (!($context eq 'domain' && ($env{'form.roletype'} eq 'course') - && ($env{'form.roletype'} eq 'community'))) { + && ($env{'form.roletype'} eq 'community'))) { push(@cols,('start','end')); } if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') { @@ -2358,7 +2282,7 @@ END $env{'form.roletype'} eq 'community')) { push (@cols,'extent'); } - if (($statusmode eq 'Any') && + if (($statusmode eq 'Any') && (!($context eq 'domain' && (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community'))))) { push(@cols,'status'); @@ -2379,7 +2303,6 @@ END if ($mode ne 'autoenroll') { $results_description = &results_header_row($rolefilter,$statusmode, $context,$permission,$mode,$crstype); - $r->print(''.$results_description.'

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

 
@@ -2446,7 +2369,7 @@ END } } } - $output .= '
'.$lt{'link'}.''. + $output .= '
'.$lt{'link'}.''. ''; my @linkdests = ('aboutme'); if ($permission->{'cusr'}) { @@ -2457,6 +2380,7 @@ END $env{'request.course.sec'})) { push(@linkdests,'track'); } + $output .= '
'; my $usernamelink = $env{'form.usernamelink'}; if ($usernamelink eq '') { @@ -2473,7 +2397,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 +2650,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 { @@ -3013,7 +2937,7 @@ sub print_username_link { $output = $in->{'username'}; } else { $output = '{'username'}','$in->{'domain'}'".')">'. + "'$in->{'username'}','$in->{'domain'}'".')" />'. $in->{'username'}.''; } return $output; @@ -3243,8 +3167,8 @@ ENDJS my %lt = &Apache::lonlocal::texthash ( chac => 'Access dates to apply for selected users', 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.', + 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 role in a course that is not a student role, a user may have roles in more than one section of a course at a time.', reta => "Retain each user's current section affiliations?", dnap => '(Does not apply to student roles).', ); @@ -3263,13 +3187,14 @@ ENDJS $permission,$crstype); } $output .= '

'.$headertext.'

'. - '
'."\n". + ''."\n". $date_items; if ($context eq 'course' && $env{'form.bulkaction'} eq 'chgsec') { my ($cnum,$cdom) = &get_course_identity(); + my $crstype = &Apache::loncommon::course_type(); if ($crstype eq 'Community') { - $lt{'fors'} = &mt('For member roles, changing the section will result in a section switch, as members may only be in one section of a community at a time.'); - $lt{'forn'} = &mt('For a community role that is not "member", users may have roles in more than one section at a time.'); + $lt{'fors'} = &mt('For member roles changing the section, will result in a section switch as members may only be in one section of a community at a time.'); + $lt{'forn'} = &mt('For a role in a community that is not a member role, a user may have roles in more than one section of a community at a time.'); $lt{'dnap'} = &mt('(Does not apply to member roles).'); } my $info; @@ -3310,7 +3235,7 @@ sub section_picker { my ($cdom,$cnum,$role,$rowtitle,$permission,$context,$mode,$crstype) = @_; my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); my $sections_select .= &course_sections(\%sections_count,$role); - my $secbox = '
'.&Apache::lonhtmlcommon::start_pick_box()."\n"; + my $secbox = '

'.&Apache::lonhtmlcommon::start_pick_box()."\n"; if ($mode eq 'upload') { my ($options,$cb_script,$coursepick) = &default_role_selector($context,1,$crstype); @@ -3323,7 +3248,7 @@ sub section_picker { ''.&mt('Existing sections')."\n". '
'.$sections_select.''. &mt('New section').'
'."\n". - ''."\n". + ''."\n". ''."\n". ''."\n"; } else { @@ -3332,7 +3257,7 @@ sub section_picker { $env{'request.course.sec'}; } $secbox .= &Apache::lonhtmlcommon::row_closure(1)."\n". - &Apache::lonhtmlcommon::end_pick_box().'

'; + &Apache::lonhtmlcommon::end_pick_box().'

'; return $secbox; } @@ -3473,12 +3398,11 @@ sub results_header_row { if ($rolefilter eq 'Any') { $description .= &mt('All users with co-author roles in domain',$showfilter); } else { - $description .= &mt('All co-authors in domain with [_1] roles',$rolefilter); + $description .= &mt('All co-authors in domain with [_1] roles',$rolefilter); } } } 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 +3666,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( '