--- loncom/interface/createaccount.pm 2019/05/05 23:19:47 1.78
+++ 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.78 2019/05/05 23:19:47 raeburn Exp $
+# $Id: createaccount.pm,v 1.90 2025/02/18 17:45:11 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -37,7 +37,6 @@ use Apache::lonacc;
use Apache::lonnet;
use Apache::loncommon;
use Apache::lonhtmlcommon;
-use Apache::lonuserutils;
use Apache::lonlocal;
use Apache::lonauth;
use Apache::resetpw;
@@ -95,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".''.$end_page);
return OK;
}
@@ -140,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);
@@ -153,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'})) {
@@ -162,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).
'
';
@@ -189,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') &&
@@ -223,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;
}
@@ -328,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);
@@ -438,7 +446,9 @@ sub javascript_setforms {
}
$setuserinfo .= ' server.elements.'.$key.'.value=client.elements.'.$key.'.value;'."\n";
}
- $setuserinfo .= ' server.elements.type.value=client.elements.type.value;'."\n";
+ if ($usertype ne '') {
+ $setuserinfo .= ' server.elements.type.value=client.elements.type.value;'."\n";
+ }
}
if ($captcha eq 'original') {
$setuserinfo .= ' server.elements.code.value=client.elements.code.value;'."\n".
@@ -526,7 +536,7 @@ sub javascript_checkpass {
my $mismatchpass = &mt('The passwords you entered did not match.')."\n".
&mt('Please try again.');
my ($numrules,$intargjs) =
- &Apache::lonuserutils::passwd_validation_js('upass',$domain);
+ &Apache::loncommon::passwd_validation_js('upass',$domain);
&js_escape(\$nopass);
&js_escape(\$mismatchpass);
my $js = <<"ENDSCRIPT";
@@ -570,8 +580,7 @@ sub javascript_validmail {
my %js_lt = &Apache::lonlocal::texthash (
email => 'The e-mail address you entered',
notv => 'is not a valid e-mail address',
- avae => 'A valid e-mail address is not formed when the value you entered',
- isco => 'is combined with the required domain',
+ avae => 'A valid e-mail address is not formed when the value you entered is combined with the required domain',
);
my $output = "\n".'