--- loncom/interface/createaccount.pm 2022/02/14 01:15:24 1.86 +++ loncom/interface/createaccount.pm 2025/02/18 17:45:11 1.90 @@ -4,7 +4,7 @@ # kerberos, or SSO) or an e-mail address. Requests to use an e-mail address as # username may be processed automatically, or may be queued for approval. # -# $Id: createaccount.pm,v 1.86 2022/02/14 01:15:24 raeburn Exp $ +# $Id: createaccount.pm,v 1.90 2025/02/18 17:45:11 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -94,17 +94,24 @@ sub handler { my $lonhost = $r->dir_config('lonHostID'); my $include = $r->dir_config('lonIncludes'); my $start_page; + my $args = {}; + (undef,undef,undef,my $clientmathml,my $clientunicode) = + &Apache::loncommon::decode_user_agent(); + if ($clientunicode && !$clientmathml) { + $args->{'browser.unicode'} = 1; + } my $handle = &Apache::lonnet::check_for_valid_session($r); if (($handle ne '') && ($handle !~ /^publicuser_\d+$/)) { $start_page = - &Apache::loncommon::start_page('Already logged in'); + &Apache::loncommon::start_page('Already logged in',undef,$args); my $end_page = &Apache::loncommon::end_page(); - $r->print($start_page."\n".'

'.&mt('You are already logged in').'

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

'.&mt('You are already logged in').'

'. '

'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].', '','','',''). - '

'.&mt('Login problems?').'

'.$end_page); + '

'.&mt('Login problems?').'

'.$end_page); return OK; } @@ -139,7 +146,7 @@ sub handler { &print_footer($r); return OK; } else { - $start_page = &Apache::loncommon::start_page($title,$js); + $start_page = &Apache::loncommon::start_page($title,$js,$args); &print_header($r,$start_page,$courseid); $r->print($output); &print_footer($r); @@ -152,7 +159,7 @@ sub handler { my ($cancreate,$statustocreate,$statusforemail,$emailusername, $emailoptions,$verification,$emaildomain,$types,$usertypes,$othertitle) = &get_creation_controls($domain,$domconfig{'usercreation'}); - my ($additems,$pagetitle); + my ($pagetitle,$need_affiliation); if (ref($cancreate) eq 'ARRAY') { unless (($env{'form.token'}) || ($sso_username ne '') || ($env{'form.phase'}) || ($env{'form.create_with_email'})) { @@ -161,20 +168,21 @@ sub handler { if ((($usertype eq '') || (!grep(/^\Q$usertype\E$/,@{$statusforemail}))) && (@{$statusforemail} > 0)) { $js .= &setelements_js($statusforemail,$types,$usertypes,$othertitle); - $additems = {'add_entries' => { 'onload' => "setElements();"} }; + $args->{'add_entries'} = { 'onload' => "setElements();"}; if ((@{$cancreate} == 1) && (@{$statusforemail} > 0)) { $pagetitle = 'Select affiliation'; } + $need_affiliation = 1; } else { $js .= &username_js(); } } } } - $start_page = &Apache::loncommon::start_page($title,$js,$additems); + $start_page = &Apache::loncommon::start_page($title,$js,$args); if (@{$cancreate} == 0) { &print_header($r,$start_page,$courseid,$pagetitle); - my $output = '

'.&mt('Account creation unavailable').'

'. + my $output = '

'.&mt('Account creation unavailable').'

'. ''. &mt('Creation of a new user account using an institutional log-in ID or e-mail verification is not permitted for: [_1].',$domdesc). '

'; @@ -188,7 +196,7 @@ sub handler { my ($msg,$sso_logout); $sso_logout = &sso_logout_frag($r,$domain); if (grep(/^sso$/,@{$cancreate})) { - $msg = '

'.&mt('Account creation').'

'. + $msg = '

'.&mt('Account creation').'

'. &mt("Although your username and password were authenticated by your institution's Single Sign On system, you do not currently have a LON-CAPA account at this institution.").'
'; my $shibenv; if (($r->dir_config('lonOtherAuthen') eq 'yes') && @@ -222,7 +230,7 @@ sub handler { $lonhost,$contact_email,$contact_name, $sso_logout,$statustocreate,$shibenv); } else { - $msg = '

'.&mt('Account creation unavailable').'

'. + $msg = '

'.&mt('Account creation unavailable').'

'. ''.&mt("Although your username and password were authenticated by your institution's Single Sign On system, you do not currently have a LON-CAPA account at this institution, and you are not permitted to create one.").'

'.&mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email).'
'. $sso_logout; } @@ -327,7 +335,8 @@ sub handler { } elsif (!$token) { &print_header($r,$start_page,$courseid,$pagetitle); my $now=time; - if ((grep(/^login$/,@{$cancreate})) && (!grep(/^email$/,@{$cancreate}))) { + if ((grep(/^login$/,@{$cancreate})) && + ((!grep(/^email$/,@{$cancreate})) || ($need_affiliation))) { if (open(my $jsh,"<","$include/londes.js")) { while(my $line = <$jsh>) { $r->print($line); @@ -614,7 +623,7 @@ sub print_username_form { if (grep(/^login$/,@{$cancreate})) { my %domdefaults = &Apache::lonnet::get_domain_defaults($domain); if ((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth')) { - $output = '

'.$lt{'crac'}.'

'; + $output = '

'.$lt{'crac'}.'

'; $output .= &mt('If you already have a log-in ID at this institution [_1]you may be able to use it for LON-CAPA.','
'). '

'. $lt{'type'}. @@ -624,7 +633,7 @@ sub print_username_form { } } if (grep(/^email$/,@{$cancreate})) { - $output .= '

'.$lt{'crae'}.'

'; + $output .= '

'.$lt{'crae'}.'

'; if ($usertype ne '') { if ((ref($statusforemail) eq 'ARRAY') && (@{$statusforemail} > 0)) { unless (grep(/^\Q$usertype\E$/,@{$statusforemail})) { @@ -640,9 +649,9 @@ sub print_username_form { unless (grep(/^default$/,@posstypes)) { push(@posstypes,'default'); } - $output .= '

'.&mt('Choose your affiliation at [_1]',$domdesc).'

'."\n". - '

'; + $output .= '

'. + &mt('Choose your affiliation at [_1]',$domdesc).''; foreach my $type (@posstypes) { my $name; if ($type eq 'default') { @@ -665,7 +674,8 @@ sub print_username_form { if ($env{'form.courseid'} =~ /^$match_domain\_$match_courseid$/) { $output .= "\n".''; } - $output .= '

'."\n".'

'; + $output .= "\n".'

'. + '

'."\n"; } else { my ($captchaform,$error,$captcha,$recaptchaversion) = &Apache::loncommon::captcha_display('usercreation',$lonhost); @@ -739,15 +749,15 @@ sub login_box { my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount', $lonhost); $output = &serverform($logtoken,$lonhost,undef,$courseid,$context); - my $unameform = ''; - my $upassform = ''; + my $unameform = ''; + my $upassform = ''; $output .= '
'."\n". &Apache::lonhtmlcommon::start_pick_box()."\n". - &Apache::lonhtmlcommon::row_title($titles{$context}, + &Apache::lonhtmlcommon::row_title('', 'LC_pick_box_title')."\n". $unameform."\n". &Apache::lonhtmlcommon::row_closure(1)."\n". - &Apache::lonhtmlcommon::row_title(&mt('Password'), + &Apache::lonhtmlcommon::row_title('', 'LC_pick_box_title')."\n". $upassform; if ($context eq 'selfenroll') { @@ -761,7 +771,8 @@ sub login_box { $output .= ''; } $output .= &Apache::lonhtmlcommon::row_closure(1). - &Apache::lonhtmlcommon::row_title(). + &Apache::lonhtmlcommon::row_title(''. + &mt('Submit').'','','','',1). '
'."\n"; if ($context eq 'selfenroll') { @@ -890,7 +901,7 @@ sub process_email_request { $contact_email,$courseid,$emailusername,$usertype, $uname); } - return $output; + return '
'.$output.'
'; } sub call_rulecheck { @@ -910,7 +921,7 @@ sub call_rulecheck { sub send_token { my ($domain,$email,$server,$domdesc,$contact_name,$contact_email,$courseid,$emailusername, $usertype,$uname) = @_; - my $msg = '

'.&mt('Account creation status').'

'. + my $msg = '

'.&mt('Account creation status').'

'. &mt('Thank you for your request to create a new LON-CAPA account.'). '

'; my $now = time; @@ -1254,7 +1265,7 @@ ENDSERVERFORM '
'."\n"; my ($datatable,$rowcount) = &Apache::loncreateuser::personal_data_display('',$domain,'email','selfcreate', - '','',$now,$captchaform, + '','','',$now,$captchaform, $emailusername,$usertype, $usernameset,$condition,$excluded, $showsubmit); @@ -1538,7 +1549,7 @@ sub login_failure_msg { } else { $url = "/adm/createaccount"; } - my $output = '

'.&mt('Authentication failed').'

'. + my $output = '

'.&mt('Authentication failed').'

'. &mt('Username and/or password could not be authenticated.'). '
'. &mt('Please check the username and password.').'

'; @@ -1617,7 +1628,7 @@ sub username_check { } } if ($checkfail) { - $msg = '

'.&mt('Account creation unavailable').'

'; + $msg = '

'.&mt('Account creation unavailable').'

'; if ($checkfail eq 'username') { $msg .= ''. &mt('A LON-CAPA account may not be created with the username you use.'). @@ -1643,18 +1654,18 @@ sub username_check { if ($rowcount) { if ($editable) { if ($courseid ne '') { - $msg = '

'.&mt('User information').'

'; + $msg = '

'.&mt('User information').'

'; } $msg .= &mt('To create one, use the table below to provide information about yourself, then click the [_1]Create LON-CAPA account[_2] button.','','').'
'; } else { if ($courseid ne '') { - $msg = '

'.&mt('Review user information').'

'; + $msg = '

'.&mt('Review user information').'

'; } $msg .= &mt('A user account will be created with information displayed in the table below, when you click the [_1]Create LON-CAPA account[_2] button.','','').'
'; } } else { if ($courseid ne '') { - $msg = '

'.&mt('Confirmation').'

'; + $msg = '

'.&mt('Confirmation').'

'; } $msg .= &mt('Confirm that you wish to create an account.'); } @@ -1795,7 +1806,7 @@ sub check_id { sub invalid_state { my ($error,$domdesc,$contact_name,$contact_email,$msgtext) = @_; - my $msg = '

'.&mt('Account creation unavailable').'

'; + my $msg = '

'.&mt('Account creation unavailable').'

'; if ($error eq 'baduseremail') { $msg .= &mt('The e-mail address you provided does not appear to be a valid address.'); } elsif ($error eq 'badusername') {