--- loncom/interface/lonuserutils.pm 2007/12/26 14:38:13 1.36 +++ loncom/interface/lonuserutils.pm 2009/08/28 22:47:07 1.98 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.36 2007/12/26 14:38:13 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.98 2009/08/28 22:47:07 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,7 @@ use LONCAPA qw(:DEFAULT :match); ############################################################### # Drop student from all sections of a course, except optional $csec sub modifystudent { - my ($udom,$unam,$courseid,$csec,$desiredhost)=@_; + my ($udom,$unam,$courseid,$csec,$desiredhost,$context)=@_; # if $csec is undefined, drop the student from all the courses matching # this one. If $csec is defined, drop them from all other sections of # this course and add them to section $csec @@ -69,14 +69,14 @@ sub modifystudent { # dom name id mode pass f m l g ($udom,$unam,'', '', '',undef,undef,undef,undef, $section,time,undef,undef,$desiredhost,'','manual', - '',$courseid); + '',$courseid,'',$context); $result .= $reply.':'; } } } } 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; } @@ -86,7 +86,7 @@ sub modifystudent { sub modifyuserrole { my ($context,$setting,$changeauth,$cid,$udom,$uname,$uid,$umode,$upass, $first,$middle,$last,$gene,$sec,$forceid,$desiredhome,$email,$role, - $end,$start,$checkid) = @_; + $end,$start,$checkid,$inststatus) = @_; my ($scope,$userresult,$authresult,$roleresult,$idresult); if ($setting eq 'course' || $context eq 'course') { $scope = '/'.$cid; @@ -124,12 +124,13 @@ sub modifyuserrole { $userresult = &Apache::lonnet::modifyuser($udom,$uname,$uid,$umode,$upass,$first, $middle,$last,$gene,$forceid,$desiredhome, - $email,$role,$start,$end); + $email,$inststatus); if ($userresult eq 'ok') { if ($role ne '') { $role =~ s/_/\//g; $roleresult = &Apache::lonnet::assignrole($udom,$uname,$scope, - $role,$end,$start); + $role,$end,$start,'', + '',$context); } } return ($userresult,$authresult,$roleresult,$idresult); @@ -168,7 +169,7 @@ sub propagate_id_change { } sub update_classlist { - my ($cdom,$cnum,$udom,$uname,$user) = @_; + my ($cdom,$cnum,$udom,$uname,$user,$newend) = @_; my ($uid,$classlistentry); my $fullname = &Apache::lonnet::format_name($user->{'firstname'},$user->{'middlename'}, @@ -179,15 +180,37 @@ sub update_classlist { my @classinfo = split(/:/,$classhash{$uname.':'.$udom}); my $ididx=&Apache::loncoursedata::CL_ID() - 2; my $nameidx=&Apache::loncoursedata::CL_FULLNAME() - 2; + my $endidx = &Apache::loncoursedata::CL_END() - 2; + my $startidx = &Apache::loncoursedata::CL_START() - 2; for (my $i=0; $i<@classinfo; $i++) { - if ($i == $ididx) { + if ($i == $endidx) { + if ($newend ne '') { + $classlistentry .= $newend.':'; + } else { + $classlistentry .= $classinfo[$i].':'; + } + } elsif ($i == $startidx) { + if ($newend ne '') { + if ($classinfo[$i] > $newend) { + $classlistentry .= $newend.':'; + } else { + $classlistentry .= $classinfo[$i].':'; + } + } else { + $classlistentry .= $classinfo[$i].':'; + } + } elsif ($i == $ididx) { if (defined($user->{'id'})) { $classlistentry .= $user->{'id'}.':'; } else { $classlistentry .= $classinfo[$i].':'; } } elsif ($i == $nameidx) { - $classlistentry .= $fullname.':'; + if (defined($user->{'lastname'})) { + $classlistentry .= $fullname.':'; + } else { + $classlistentry .= $classinfo[$i].':'; + } } else { $classlistentry .= $classinfo[$i].':'; } @@ -305,9 +328,11 @@ sub print_upload_manager_header { &javascript_validations('upload',$krbdefdom,$password_choice,undef, $env{'request.role.domain'},$context, $groupslist); - my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':''); - $r->print(&mt('Total number of records found in file: [_1].',$distotal). - "
\n"); + my $checked=(($env{'form.noFirstLine'})?' checked="checked"':''); + $r->print('

' + .&mt('Total number of records found in file: [_1]' + ,''.$distotal.'') + ."

\n"); $r->print('

'. &mt('Identify fields in uploaded list')."

\n"); $r->print(&mt('Enter as many fields as you can.
The system will inform you and bring you back to this page,
if the data selected are insufficient to add users.')."
\n"); @@ -318,14 +343,17 @@ sub print_upload_manager_header { &hidden_input('fileupload',$env{'form.fileupload'}). &hidden_input('upfiletype',$env{'form.upfiletype'}). &hidden_input('upfile_associate',$env{'form.upfile_associate'})); - $r->print('
'); - $r->print(''); + $r->print('

'); + $r->print('
'); $r->print("

\n". ''); + '// '."\n". + ''); } ############################################################### @@ -333,17 +361,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 +390,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". @@ -383,17 +406,20 @@ sub javascript_validations { krb => 'You need to specify the Kerberos domain.', ipass => 'You need to specify the initial password.', name => 'The optional name field was not specified.', - snum => 'The optional ID number field was not specified.', + snum => 'The optional student/employee ID field was not specified.', section => 'The optional section field was not specified.', - email => 'The optional email address field was not specified.', + email => 'The optional e-mail address field was not specified.', role => 'The optional role field was not specified.', + domain => 'The optional domain field was not specified.', continue => 'Continue adding users?', ); - - my $function_name =(<'; $Str .= &hidden_input('nfields',$i); $Str .= &hidden_input('keyfields',$keyfields); - $Str .= "

".&mt('Login Type')."

\n"; + + $Str .= '

'.&mt('Options').'

' + .&Apache::lonhtmlcommon::start_pick_box(); + + $Str .= &Apache::lonhtmlcommon::row_title(&mt('Login Type')); if ($context eq 'domain') { - $Str .= '

'.&mt('Change authentication for existing users to these settings?').'   

'; + $Str .= '

' + .&mt('Change authentication for existing users in domain "[_1]" to these settings?' + ,$defdom) + .' ' + .'  ' + .'

'; } else { - $Str .= "

\n". - &mt('Note: this will not take effect if the user already exists'). + $Str .= '

'."\n". + &mt('This will not take effect if the user already exists.'). &Apache::loncommon::help_open_topic('Auth_Options'). "

\n"; } $Str .= &set_login($defdom,$krbform,$intform,$locform); + my ($home_server_pick,$numlib) = &Apache::loncommon::home_server_form_item($defdom,'lcserver', 'default','hide'); if ($numlib > 1) { - $Str .= '

'.&mt('LON-CAPA Home Server for New Users')."

\n". - &mt('LON-CAPA domain: [_1] with home server: [_2]',$defdom, - $home_server_pick).'
'; - } else { - $Str .= $home_server_pick; - } - $Str .= '

'.&mt('Starting and Ending Dates'). - "

\n"; - $Str .= "

\n".$date_table."

\n"; + $Str .= &Apache::lonhtmlcommon::row_closure() + .&Apache::lonhtmlcommon::row_title( + &mt('LON-CAPA Home Server for New Users')) + .&mt('LON-CAPA domain: [_1] with home server:','"'.$defdom.'"') + .$home_server_pick + .&Apache::lonhtmlcommon::row_closure(); + } else { + $Str .= $home_server_pick. + &Apache::lonhtmlcommon::row_closure(); + } + + $Str .= &Apache::lonhtmlcommon::row_title(&mt('Default domain')) + .&Apache::loncommon::select_dom_form($defdom,'defaultdomain',undef,1) + .&Apache::lonhtmlcommon::row_closure(); + + $Str .= &Apache::lonhtmlcommon::row_title(&mt('Starting and Ending Dates')) + ."

\n".$date_table."

\n" + .&Apache::lonhtmlcommon::row_closure(); + if ($context eq 'domain') { - $Str .= '

'.&mt('Settings for assigning roles:').'

'."\n". - &mt('Pick the action to take on roles for these users:').'
      '; - } - if ($context eq 'author') { - $Str .= '

'.&mt('Default role')."

\n". - &mt('Choose the role to assign to users without a value specified in the uploaded file'); + $Str .= &Apache::lonhtmlcommon::row_title( + &mt('Settings for assigning roles')) + .&mt('Pick the action to take on roles for these users:').'
' + .'' + .'   ' + .'   ' + .''; + } elsif ($context eq 'author') { + $Str .= &Apache::lonhtmlcommon::row_title( + &mt('Default role')) + .&mt('Choose the role to assign to users without a value specified in the uploaded file.') } elsif ($context eq 'course') { - $Str .= '

'.&mt('Default role and section')."

\n". - &mt('Choose the role and/or section(s) to assign to users without values specified in the uploaded file'); - } else { - $Str .= '

'.&mt('Default role and/or section(s)')."
\n". - &mt('Role and/or section(s) for users without values specified in the uploaded file.'); + $Str .= &Apache::lonhtmlcommon::row_title( + &mt('Default role and section')) + .&mt('Choose the role and/or section(s) to assign to users without values specified in the uploaded file.'); + } else { + $Str .= &Apache::lonhtmlcommon::row_title( + &mt('Default role and/or section(s)')) + .&mt('Role and/or section(s) for users without values specified in the uploaded file.'); } - $Str .= '
'; if (($context eq 'domain') || ($context eq 'author')) { + $Str .= '
'; my ($options,$cb_script,$coursepick) = &default_role_selector($context,1); if ($context eq 'domain') { - $Str .= ''.&mt('Domain Level').'
'.$options.'

'.&mt('Course Level').'
'.$cb_script.$coursepick; + $Str .= '

' + .''.&mt('Domain Level').'
' + .$options + .'

' + .''.&mt('Course Level').'' + .'

' + .$cb_script.$coursepick + .&Apache::lonhtmlcommon::row_closure(); } elsif ($context eq 'author') { - $Str .= $options; + $Str .= $options + .&Apache::lonhtmlcommon::row_closure(1); # last row in pick_box } } else { my ($cnum,$cdom) = &get_course_identity(); my $rowtitle = &mt('section'); my $secbox = §ion_picker($cdom,$cnum,'Any',$rowtitle, $permission,$context,'upload'); - $Str .= $secbox."

".&mt('Full Update')."

\n". - '


'.&mt('Students selected from this list can be dropped.').'

'."\n"; + $Str .= $secbox + .&Apache::lonhtmlcommon::row_closure(); + + $Str .= &Apache::lonhtmlcommon::row_title(&mt('Full Update')) + .'
' + .&mt('Students selected from this list can be dropped.') + .&Apache::lonhtmlcommon::row_closure(); } if ($context eq 'course' || $context eq 'domain') { $Str .= &forceid_change($context); } - $Str .= '
'; + + # Footer + $Str .= ''; $r->print($Str); return; } @@ -781,18 +898,18 @@ sub print_upload_manager_footer { sub forceid_change { my ($context) = @_; my $output = - "

".&mt('ID/Student Number')."

\n". - "

\n".'
'."\n". - &mt('(only do if you know what you are doing.)')."\n"; + &Apache::lonhtmlcommon::row_title(&mt('Student/Employee ID')) + .'
'."\n" + .&mt('(only do if you know what you are doing.)')."\n"; if ($context eq 'domain') { $output .= '
'."\n"; } - $output .= '

'; + $output .= &Apache::lonhtmlcommon::row_closure(1); # last row in pick_box return $output; } @@ -829,6 +946,8 @@ sub print_upload_manager_form { 'ipwd_choice' => 'scalar', 'email_choice' => 'scalar', 'role_choice' => 'scalar', + 'domain_choice' => 'scalar', + 'inststatus_choice' => 'scalar', }; my $defdom = $env{'request.role.domain'}; if ($context eq 'course') { @@ -855,11 +974,13 @@ sub print_upload_manager_form { ['mname',&mt('Middle Names/Initials'),$env{'form.mname_choice'}], ['lname',&mt('Last Name'), $env{'form.lname_choice'}], ['gen', &mt('Generation'), $env{'form.gen_choice'}], - ['id', &mt('ID/Student Number'),$env{'form.id_choice'}], + ['id', &mt('Student/Employee ID'),$env{'form.id_choice'}], ['sec', &mt('Section'), $env{'form.sec_choice'}], ['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}], ['email',&mt('E-mail Address'), $env{'form.email_choice'}], - ['role',&mt('Role'), $env{'form.role_choice'}]); + ['role',&mt('Role'), $env{'form.role_choice'}], + ['domain',&mt('Domain'), $env{'form.domain_choice'}], + ['inststatus',&mt('Affiliation'), $env{'form.inststatus_choice'}]); if ($env{'form.upfile_associate'} eq 'reverse') { &Apache::loncommon::csv_print_samples($r,\@records); $i=&Apache::loncommon::csv_print_select_table($r,\@records, @@ -936,8 +1057,15 @@ sub setup_date_selectors { sub get_dates_from_form { - my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate'); - my $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate'); + my ($startname,$endname) = @_; + if ($startname eq '') { + $startname = 'startdate'; + } + if ($endname eq '') { + $endname = 'enddate'; + } + my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname); + my $enddate = &Apache::lonhtmlcommon::get_date_from_form($endname); if ($env{'form.no_end_date'}) { $enddate = 0; } @@ -970,7 +1098,7 @@ sub date_setting_table { } my $perpetual = ''; if ($mode eq 'create_enrolldates') { @@ -1055,7 +1183,7 @@ sub default_role_selector { ''.$lt{'grs'}.''. &Apache::loncommon::end_data_table_header_row(). &Apache::loncommon::start_data_table_row()."\n". - ''."\n". + ''."\n". ''. @@ -1248,49 +1376,36 @@ sub print_userlist { 'html' => 'HTML'); my $output_selector = ''; - $r->print(''.(' 'x3)); - } - $r->print(''.(' 'x3)."\n"); + $r->print(''.(' 'x3)); + } + $r->print(''.(' 'x3)."\n"); my $roleselected = ''; if ($env{'form.showrole'} eq 'Any') { - $roleselected = ' selected="selected" '; + $roleselected = ' selected="selected"'; } - my ($role_select,$cnum,$cdom); - if ($context eq 'domain') { - $role_select = &domain_roles_select(); - $r->print(''); - } else { - $role_select = ''; - $r->print(''); - if ($context eq 'course') { - ($cnum,$cdom) = &get_course_identity(); - $r->print(§ion_group_filter($cnum,$cdom)); - } + my ($cnum,$cdom); + $r->print(&role_filter($context)); + if ($context eq 'course') { + ($cnum,$cdom) = &get_course_identity(); + $r->print(§ion_group_filter($cnum,$cdom)); + } + if ($env{'form.phase'} eq '') { + $r->print('

'.&list_submit_button(&mt('Display List of Users')). + "\n

\n". + ''); + return; } if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) { $r->print(' '.&list_submit_button(&mt('Update Display')). @@ -1319,32 +1434,26 @@ sub print_userlist { } $r->rflush(); if ($context eq 'course') { - my $classlist = &Apache::loncoursedata::get_classlist(); - my $secidx = &Apache::loncoursedata::CL_SECTION(); - my $viewablesec = &viewable_section($permission); - foreach my $student (keys(%{$classlist})) { - my $section = $classlist->{$student}[$secidx]; - if ($viewablesec ne '') { - if ($section ne $viewablesec) { - next; - } else { - $userlist{$student} = $classlist->{$student}; - } - } else { - $userlist{$student} = $classlist->{$student}; + if (($env{'form.showrole'} eq 'st') || ($env{'form.showrole'} eq 'Any')) { + my $classlist = &Apache::loncoursedata::get_classlist(); + if (ref($classlist) eq 'HASH') { + %userlist = %{$classlist}; } } - my $showroles; - if ($env{'form.showrole'} ne 'Any') { - $showroles = [$env{'form.showrole'}]; - } else { - $showroles = undef; + if ($env{'form.showrole'} ne 'st') { + my $showroles; + if ($env{'form.showrole'} ne 'Any') { + $showroles = [$env{'form.showrole'}]; + } else { + $showroles = undef; + } + my $withsec = 1; + my $hidepriv = 1; + my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef, + \@statuses,$showroles,undef,$withsec,$hidepriv); + &gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo, + \%advrolehash,$permission); } - my $withsec = 1; - my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef, - \@statuses,$showroles,undef,$withsec); - &gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo, - \%advrolehash,$permission); } else { my (%cstr_roles,%dom_roles); if ($context eq 'author') { @@ -1393,7 +1502,8 @@ sub print_userlist { } elsif ($env{'form.roletype'} eq 'course') { if ($env{'form.coursepick'}) { my %courses = &process_coursepick(); - my %allusers; + my %allusers; + my $hidepriv = 1; foreach my $cid (keys(%courses)) { my ($cnum,$cdom,$cdesc) = &get_course_identity($cid); next if ($cnum eq '' || $cdom eq ''); @@ -1411,7 +1521,7 @@ sub print_userlist { foreach my $type (@statuses) { $access{$type} = $type; } - &Apache::loncommon::get_course_users($cdom,$cnum,\%access,\@roles,\@sections,\%users,\%userdata,\%statushash); + &Apache::loncommon::get_course_users($cdom,$cnum,\%access,\@roles,\@sections,\%users,\%userdata,\%statushash,$hidepriv); foreach my $user (keys(%userdata)) { next if (ref($userinfo{$user}) eq 'HASH'); foreach my $item ('fullname','id') { @@ -1462,13 +1572,55 @@ sub print_userlist { $permission,$env{'form.Status'},\%userlist,$keylist); } if (!$usercount) { - $r->print('
'.&mt('There are no users matching the search criteria.')); + $r->print('
' + .&mt('There are no users matching the search criteria.') + .'' + ); } } $r->print(''); } +sub role_filter { + my ($context) = @_; + my $output; + my $roleselected = ''; + if ($env{'form.showrole'} eq 'Any') { + $roleselected = ' selected="selected"'; + } + my ($role_select); + if ($context eq 'domain') { + $role_select = &domain_roles_select(); + $output = ''; + } else { + $role_select = ''; + $output = ''; + } + return $output; +} + sub section_group_filter { my ($cnum,$cdom) = @_; my @filters; @@ -1486,9 +1638,9 @@ sub section_group_filter { all => 'all', none => 'none', ); - my ($output,@options); + my $output; foreach my $item (@filters) { - my $markup; + my ($markup,@options); if ($env{'form.'.$name{$item}} eq '') { $env{'form.'.$name{$item}} = 'all'; } @@ -1508,7 +1660,7 @@ sub section_group_filter { foreach my $option ('all','none',@options) { $currsel = ''; if ($env{'form.'.$name{$item}} eq $option) { - $currsel = ' selected="selected" '; + $currsel = ' selected="selected"'; } $markup .= ' '."\n". + ' '."\n"; + if ($current_sec eq 'none') { + $output .= + ' \n"; + } else { + $output .= ' \n"; + } } else { $output .= 'multiple="multiple" size="'.$multiple.'">'."\n"; } foreach my $sec (@sections) { - $output .= '\n"; + if ($current_sec eq $sec) { + $output .= '\n"; + } else { + $output .= '\n"; + } } } $output .= ''; @@ -4168,7 +4606,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.'"'; @@ -4176,12 +4614,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 { @@ -4327,10 +4779,14 @@ sub can_modify_userinfo { if (ref($userroles) eq 'ARRAY') { foreach my $role (@{$userroles}) { my $testrole; - if ($role =~ /^cr\//) { - $testrole = 'cr'; - } else { + if ($context eq 'selfcreate') { $testrole = $role; + } else { + if ($role =~ /^cr\//) { + $testrole = 'cr'; + } else { + $testrole = $role; + } } if (ref($domconfig{'usermodification'}{$context}{$testrole}) eq 'HASH') { if ($domconfig{'usermodification'}{$context}{$testrole}{$field}) { @@ -4476,24 +4932,17 @@ sub authorpriv { } sub roles_on_upload { - my ($context,%customroles) = @_; + my ($context,$setting,%customroles) = @_; my (@possible_roles,@permitted_roles); - if ($context eq 'domain') { - @possible_roles = &curr_role_permissions($context,undef,1); - push(@possible_roles,&curr_role_permissions($context,'course',1)); - } else { - @possible_roles = &curr_role_permissions($context,undef,1); - } - my $custom_ok = 0; + @possible_roles = &curr_role_permissions($context,$setting,1); foreach my $role (@possible_roles) { if ($role eq 'cr') { - $custom_ok = 1; push(@permitted_roles,keys(%customroles)); } else { push(@permitted_roles,$role); } } - return ($custom_ok,@permitted_roles); + return @permitted_roles; } sub get_course_identity { @@ -4518,15 +4967,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 != "") { @@ -4611,9 +5064,11 @@ SCRIPTTOP } } } - document.$formname.submit(); + var authcheck = auth_check(); + if (authcheck == 'ok') { + document.$formname.submit(); + } } - ENDSCRIPT } else { $dc_setcourse_code .= " @@ -4634,6 +5089,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;