--- loncom/interface/lonuserutils.pm 2017/08/11 18:58:16 1.189 +++ loncom/interface/lonuserutils.pm 2018/03/23 01:01:21 1.194 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.189 2017/08/11 18:58:16 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.194 2018/03/23 01:01:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -546,6 +546,7 @@ END case 'fsys': alertmsg = ''; break; + case 'lti': default: alertmsg = ''; } @@ -898,6 +899,7 @@ sub print_upload_manager_footer { my $krbform = &Apache::loncommon::authform_kerberos(%param); my $intform = &Apache::loncommon::authform_internal(%param); my $locform = &Apache::loncommon::authform_local(%param); + my $ltiform = &Apache::loncommon::authform_lti(%param); my $date_table = &date_setting_table(undef,undef,$context,undef, $formname,$permission,$crstype); @@ -926,7 +928,7 @@ sub print_upload_manager_footer { &Apache::loncommon::help_open_topic('Auth_Options'). "

\n"; } - $Str .= &set_login($defdom,$krbform,$intform,$locform); + $Str .= &set_login($defdom,$krbform,$intform,$locform,$ltiform); my ($home_server_pick,$numlib) = &Apache::loncommon::home_server_form_item($defdom,'lcserver', @@ -1132,6 +1134,11 @@ sub print_upload_manager_form { &Apache::loncommon::load_tmp_file($r,$datatoken); } } + if ($datatoken eq '') { + $r->print('

'.&mt('Error').': '. + &mt('Invalid datatoken').'

'); + return 'missingdata'; + } my @records=&Apache::loncommon::upfile_record_sep(); if($env{'form.noFirstLine'}){ $firstLine=shift(@records); @@ -1214,6 +1221,7 @@ sub print_upload_manager_form { } &print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear, $context,$permission,$crstype,$showcredits); + return 'ok'; } sub setup_date_selectors { @@ -4133,10 +4141,6 @@ sub upfile_drop_add { $fields{$env{'form.f'.$i}}=$keyfields[$i]; } } - if ($env{'form.fullup'} ne 'yes') { - $r->print('
'."\n". - ''); - } # # Store the field choices away my @storefields = qw/username names fname mname lname gen id @@ -4174,39 +4178,43 @@ sub upfile_drop_add { my $domain; if ($env{'form.defaultdomain'} ne '') { if (($context eq 'course') || ($setting eq 'course')) { - unless ($env{'form.defaultdomain'} eq $crsdom) { + if ($env{'form.defaultdomain'} eq $crsdom) { + $domain = $env{'form.defaultdomain'}; + } else { if (&Apache::lonnet::will_trust('enroll',$crsdom,$env{'form.defaultdomain'})) { $domain = $env{'form.defaultdomain'}; } else { - $r->print(''.&mt('Error'). + $r->print(''.&mt('Error').': '. &mt('Enrollment of users not permitted for specified default domain: [_1].', &Apache::lonnet::domain($env{'form.defaultdomain'},'description')).''); - $r->print(&Apache::loncommon::end_page()); + return 'untrusted'; } - return; } } elsif ($context eq 'author') { - unless ($env{'form.defaultdomain'} eq $defdom) { + if ($env{'form.defaultdomain'} eq $defdom) { + $domain = $env{'form.defaultdomain'}; + } else { if ((&Apache::lonnet::will_trust('othcoau',$defdom,$env{'form.defaultdomain'})) && (&Apache::lonnet::will_trust('coaurem',$env{'form.defaultdomain'},$defdom))) { $domain = $env{'form.defaultdomain'}; } else { - $r->print(''.&mt('Error'). + $r->print(''.&mt('Error').': '. &mt('Addition of users not permitted for specified default domain: [_1].', &Apache::lonnet::domain($env{'form.defaultdomain'},'description')).''); - $r->print(&Apache::loncommon::end_page()); + return 'untrusted'; } - return; } } elsif (($context eq 'domain') && ($setting eq 'domain')) { - unless ($env{'form.defaultdomain'} eq $defdom) { + if ($env{'form.defaultdomain'} eq $defdom) { + $domain = $env{'form.defaultdomain'}; + } else { if (&Apache::lonnet::will_trust('domroles',$defdom,$env{'form.defaultdomain'})) { $domain = $env{'form.defaultdomain'}; } else { - $r->print(''.&mt('Error'). + $r->print(''.&mt('Error').': '. &mt('Addition of users not permitted for specified default domain: [_1].', &Apache::lonnet::domain($env{'form.defaultdomain'},'description')).''); - $r->print(&Apache::loncommon::end_page()); + return 'untrusted'; } } } @@ -4219,10 +4227,9 @@ sub upfile_drop_add { } else { my %home_servers = &Apache::lonnet::get_servers($defdom,'library'); if (! exists($home_servers{$desiredhost})) { - $r->print(''.&mt('Error'). - &mt('Invalid home server specified').''); - $r->print(&Apache::loncommon::end_page()); - return; + $r->print('

'.&mt('Error').': '. + &mt('Invalid home server specified').'

'); + return 'invalidhome'; } } # Determine authentication mechanism @@ -4246,6 +4253,8 @@ sub upfile_drop_add { if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) { $genpwd=$env{'form.locarg'}; } + } elsif ($env{'form.login'} eq 'lti') { + $amode='lti'; } if ($amode =~ /^krb/) { if (! defined($genpwd) || $genpwd eq '') { @@ -4322,6 +4331,11 @@ sub upfile_drop_add { } } } + if ($datatoken eq '') { + $r->print('

'.&mt('Error').': '. + &mt('Invalid datatoken').'

'); + return 'missingdata'; + } if ( $domain eq &LONCAPA::clean_domain($domain) && ($amode ne '')) { ####################################### @@ -4615,7 +4629,7 @@ sub upfile_drop_add { &mt('The user does not already exist, and you may not create a new user in a different domain.'); next; } else { - unless ($password || $env{'form.login'} eq 'loc') { + unless (($password ne '') || ($env{'form.login'} eq 'loc') || ($env{'form.login'} eq 'lti')) { $disallow{$counter} = &mt('[_1]: This is a new user but no default password was provided, and the authentication type requires one.', ''.$username.''); @@ -4897,7 +4911,9 @@ sub upfile_drop_add { "

\n"); if ($counts{'role'} > 0) { $r->print("

\n". - &mt('Roles added for [quant,_1,user].',$counts{'role'}).' '.&mt('If a user is currently logged-in to LON-CAPA, any new roles which are active will be available when the user next logs in.')."

\n"); + &mt('Roles added for [quant,_1,user].',$counts{'role'}).' '. + &mt('If a user is currently logged-in to LON-CAPA, any new roles which are active will be available when the user next logs in.'). + "

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

'.&mt('No roles added').'

'); } @@ -4915,10 +4931,9 @@ sub upfile_drop_add { # Get current classlist my $classlist = &Apache::loncoursedata::get_classlist(); if (! defined($classlist)) { - $r->print(''. - ''. - '

'.&mt('There are no students with current/future access to the course.').'

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

'. + &mt('There are no students with current/future access to the course.'). + '

'."\n"); } elsif (ref($classlist) eq 'HASH') { # Remove the students we just added from the list of students. foreach my $line (@userdata) { @@ -4934,9 +4949,7 @@ sub upfile_drop_add { } } } # end of unless - if ($env{'form.fullup'} ne 'yes') { - $r->print(''); - } + return 'ok'; } sub print_namespacing_alerts { @@ -5482,7 +5495,7 @@ END } sub set_login { - my ($dom,$authformkrb,$authformint,$authformloc) = @_; + my ($dom,$authformkrb,$authformint,$authformloc,$authformlti) = @_; my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); my $response; my ($authnum,%can_assign) = @@ -5504,6 +5517,11 @@ sub set_login { ''.$authformloc.''. &Apache::loncommon::end_data_table_row()."\n"; } + if ($can_assign{'lti'}) { + $response .= &Apache::loncommon::start_data_table_row(). + ''.$authformlti.''. + &Apache::loncommon::end_data_table_row()."\n"; + } $response .= &Apache::loncommon::end_data_table(); } return $response;