--- loncom/interface/lonuserutils.pm 2007/12/24 05:26:31 1.33 +++ loncom/interface/lonuserutils.pm 2008/01/01 17:24:59 1.37 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.33 2007/12/24 05:26:31 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.37 2008/01/01 17:24:59 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -76,7 +76,7 @@ sub modifystudent { } } if ($result eq '') { - $result = 'Unable to find section for this student'; + $result = &mt('Unable to find section for this student'); } else { $result =~ s/(ok:)+/ok/g; } @@ -333,17 +333,12 @@ sub print_upload_manager_header { sub javascript_validations { my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain, $context,$groupslist)=@_; - my %param = ( kerb_def_dom => $krbdefdom, curr_authtype => $curr_authtype, ); - if ($mode eq 'createuser') { - $param{'formname'} = 'cu'; - } elsif ($mode eq 'upload') { + if ($mode eq 'upload') { $param{'formname'} = 'studentform'; - } elsif ($mode eq 'singlestudent') { - $param{'formname'} = 'cu'; } elsif ($mode eq 'createcourse') { $param{'formname'} = 'ccrs'; } elsif ($mode eq 'modifycourse') { @@ -367,7 +362,7 @@ sub javascript_validations { } } elsif ($context eq 'domain') { $setsection_call = 'setCourse()'; - $setsections_js = &dc_setcourse_js($param{'formname'},$mode); + $setsections_js = &dc_setcourse_js($param{'formname'},$mode,$context); } $finish = " var checkSec = $setsection_call\n". " if (checkSec == 'ok') {\n". @@ -389,8 +384,7 @@ sub javascript_validations { role => 'The optional role field was not specified.', continue => 'Continue adding users?', ); - - my $function_name =(<".&mt('Full Update')."\n". '

\n"; + ' '.&mt('Display students with current/future access who are not in the uploaded file.').'
'.&mt('Students selected from this list can be dropped.').'

'."\n"; } if ($context eq 'course' || $context eq 'domain') { $Str .= &forceid_change($context); @@ -1311,7 +1298,7 @@ sub print_userlist { &Apache::lonhtmlcommon::row_closure(1). &Apache::lonhtmlcommon::end_pick_box().'

'. '

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

\n"); + "\n".'

'.&mt('Warning: data retrieval for multiple courses can take considerable time, as this operation is not currently optimized.').''."\n"); if ($env{'form.coursepick'}) { $r->print('
'.&mt('Searching').' ...
 
'); } @@ -1877,7 +1864,7 @@ sub show_users_list { $sortby = 'username'; } my $setting = $env{'form.roletype'}; - my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers,$secfilter,$grpfilter); + my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers); if ($context eq 'course') { $cid = $env{'request.course.id'}; ($cnum,$cdom) = &get_course_identity($cid); @@ -2377,7 +2364,6 @@ END $r->print("$cellentry\n"); } else { $r->print("$rowcount\n"); - $checkval; if ($actionselect) { my $showcheckbox; if ($role =~ /^cr\//) { @@ -4170,7 +4156,7 @@ sub get_groupslist { } sub setsections_javascript { - my ($formname,$groupslist,$mode) = @_; + my ($formname,$groupslist,$mode,$checkauth) = @_; my ($checkincluded,$finish,$rolecode,$setsection_js); if ($mode eq 'upload') { $checkincluded = 'formname.name == "'.$formname.'"'; @@ -4178,12 +4164,26 @@ sub setsections_javascript { $rolecode = "var role = formname.defaultrole.options[formname.defaultrole.selectedIndex].value;\n"; } elsif ($formname eq 'cu') { $checkincluded = 'formname.elements[i-1].checked == true'; - $finish = 'formname.submit()'; + if ($checkauth) { + $finish = "var authcheck = auth_check();\n". + " if (authcheck == 'ok') {\n". + " formname.submit();\n". + " }\n"; + } else { + $finish = 'formname.submit()'; + } $rolecode = "var match = str.split('_'); var role = match[3];\n"; } elsif ($formname eq 'enrollstudent') { $checkincluded = 'formname.name == "'.$formname.'"'; - $finish = 'formname.submit()'; + if ($checkauth) { + $finish = "var authcheck = auth_check();\n". + " if (authcheck == 'ok') {\n". + " formname.submit();\n". + " }\n"; + } else { + $finish = 'formname.submit()'; + } $rolecode = "var match = str.split('_'); var role = match[1];\n"; } else { @@ -4520,15 +4520,19 @@ sub get_course_identity { } sub dc_setcourse_js { - my ($formname,$mode) = @_; - my $dc_setcourse_code; + my ($formname,$mode,$context) = @_; + my ($dc_setcourse_code,$authen_check); my $cctext = &Apache::lonnet::plaintext('cc'); my %alerts = §ioncheck_alerts(); my $role = 'role'; if ($mode eq 'upload') { $role = 'courserole'; + } else { + $authen_check = &verify_authen($formname,$context); } $dc_setcourse_code = (<<"SCRIPTTOP"); +$authen_check + function setCourse() { var course = document.$formname.dccourse.value; if (course != "") { @@ -4613,9 +4617,11 @@ SCRIPTTOP } } } - document.$formname.submit(); + var authcheck = auth_check(); + if (authcheck == 'ok') { + document.$formname.submit(); + } } - ENDSCRIPT } else { $dc_setcourse_code .= " @@ -4636,6 +4642,66 @@ ENDSCRIPT return -1; } ENDSCRIPT + return $dc_setcourse_code; +} + +sub verify_authen { + my ($formname,$context) = @_; + my %alerts = &authcheck_alerts(); + my $finish = "return 'ok';"; + if ($context eq 'author') { + $finish = "document.$formname.submit();"; + } + my $outcome = <<"ENDSCRIPT"; + +function auth_check() { + var logintype; + if (document.$formname.login.length) { + if (document.$formname.login.length > 0) { + var loginpicked = 0; + for (var i=0; i 'You must choose an authentication type.', + krb => 'You need to specify the Kerberos domain.', + ipass => 'You need to specify the initial password.', + ); + return %alerts; +} + 1;