version 1.62, 2014/03/30 23:44:50
|
version 1.73, 2017/07/26 19:45:45
|
Line 124 sub handler {
|
Line 124 sub handler {
|
|
|
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
my ($cancreate,$statustocreate,$emailusername) = |
my ($cancreate,$statustocreate) = |
&get_creation_controls($domain,$domconfig{'usercreation'}); |
&get_creation_controls($domain,$domconfig{'usercreation'}); |
|
|
my ($result,$output) = |
my ($result,$output) = |
Line 146 sub handler {
|
Line 146 sub handler {
|
return OK; |
return OK; |
} |
} |
} |
} |
$start_page = &Apache::loncommon::start_page($title,$js); |
|
|
|
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
my ($cancreate,$statustocreate,$emailusername) = |
my ($cancreate,$statustocreate,$statusforemail,$emailusername, |
|
$verification,$emaildomain,$types,$usertypes,$othertitle) = |
&get_creation_controls($domain,$domconfig{'usercreation'}); |
&get_creation_controls($domain,$domconfig{'usercreation'}); |
|
my ($additems,$pagetitle); |
|
if (ref($cancreate) eq 'ARRAY') { |
|
unless (($env{'form.token'}) || ($sso_username ne '') || ($env{'form.phase'}) || |
|
($env{'form.create_with_email'})) { |
|
if ((grep(/^email$/,@{$cancreate})) && (ref($statusforemail) eq 'ARRAY')) { |
|
my $usertype = &get_usertype($domain); |
|
if (($usertype ne '') && (grep(/^\Q$usertype\E$/,@{$statusforemail}))) { |
|
$js .= &username_js(); |
|
} elsif (($usertype eq '') || (!grep(/^\Q$usertype\E$/,@{$statusforemail}))) { |
|
$js .= &setelements_js($statusforemail,$types,$usertypes,$othertitle); |
|
$additems = {'add_entries' => { 'onload' => "setElements();"} }; |
|
if (@{$cancreate} == 1) { |
|
$pagetitle = 'Select affiliation'; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
$start_page = &Apache::loncommon::start_page($title,$js,$additems); |
if (@{$cancreate} == 0) { |
if (@{$cancreate} == 0) { |
&print_header($r,$start_page,$courseid); |
&print_header($r,$start_page,$courseid,$pagetitle); |
my $output = '<h3>'.&mt('Account creation unavailable').'</h3>'. |
my $output = '<h3>'.&mt('Account creation unavailable').'</h3>'. |
'<span class="LC_warning">'. |
'<span class="LC_warning">'. |
&mt('Creation of a new user account using an e-mail address or an institutional log-in ID as username is not permitted at this institution ([_1]).',$domdesc). |
&mt('Creation of a new user account using an institutional log-in ID or e-mail verification is not permitted for: [_1].',$domdesc). |
'</span><br /><br />'; |
'</span><br /><br />'; |
$r->print($output); |
$r->print($output); |
&print_footer($r); |
&print_footer($r); |
Line 170 sub handler {
|
Line 189 sub handler {
|
if (grep(/^sso$/,@{$cancreate})) { |
if (grep(/^sso$/,@{$cancreate})) { |
$msg = '<h3>'.&mt('Account creation').'</h3>'. |
$msg = '<h3>'.&mt('Account creation').'</h3>'. |
&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.").'<br />'; |
&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.").'<br />'; |
|
my $shibenv; |
|
if (($r->dir_config('lonOtherAuthen') eq 'yes') && |
|
($r->dir_config('lonOtherAuthenType') eq 'Shibboleth')) { |
|
if (ref($domconfig{'usercreation'}) eq 'HASH') { |
|
if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') { |
|
if (ref($domconfig{'usercreation'}{'cancreate'}{'shibenv'}) eq 'HASH') { |
|
my @possfields = ('firstname','middlename','lastname','generation', |
|
'permanentemail','id'); |
|
$shibenv= {}; |
|
foreach my $key (keys(%{$domconfig{'usercreation'}{'cancreate'}{'shibenv'}})) { |
|
if ($key eq 'inststatus') { |
|
if (ref($usertypes) eq 'HASH') { |
|
if ($domconfig{'usercreation'}{'cancreate'}{'shibenv'}{$key} ne '') { |
|
if (exists($usertypes->{$domconfig{'usercreation'}{'cancreate'}{'shibenv'}{$key}})) { |
|
$shibenv->{$key} = $domconfig{'usercreation'}{'cancreate'}{'shibenv'}{$key}; |
|
} |
|
} |
|
} |
|
} elsif (grep(/^\Q$key\E/,@possfields)) { |
|
if ($domconfig{'usercreation'}{'cancreate'}{'shibenv'}{$key} ne '') { |
|
$shibenv->{$key} = $domconfig{'usercreation'}{'cancreate'}{'shibenv'}{$key}; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
$msg .= &username_check($sso_username,$domain,$domdesc,$courseid, |
$msg .= &username_check($sso_username,$domain,$domdesc,$courseid, |
$lonhost,$contact_email,$contact_name, |
$lonhost,$contact_email,$contact_name, |
$sso_logout,$statustocreate); |
$sso_logout,$statustocreate,$shibenv); |
} else { |
} else { |
$msg = '<h3>'.&mt('Account creation unavailable').'</h3>'. |
$msg = '<h3>'.&mt('Account creation unavailable').'</h3>'. |
'<span class="LC_warning">'.&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.").'</span><br /><br />'.&mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email).'<hr />'. |
'<span class="LC_warning">'.&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.").'</span><br /><br />'.&mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email).'<hr />'. |
Line 190 sub handler {
|
Line 236 sub handler {
|
($output,$nostart,$noend,$redirect) = |
($output,$nostart,$noend,$redirect) = |
&process_mailtoken($r,$token,$contact_name,$contact_email,$domain, |
&process_mailtoken($r,$token,$contact_name,$contact_email,$domain, |
$domdesc,$lonhost,$include,$start_page,$cancreate, |
$domdesc,$lonhost,$include,$start_page,$cancreate, |
$domconfig{'usercreation'}); |
$domconfig{'usercreation'},$types); |
if ($redirect) { |
if ($redirect) { |
$r->internal_redirect('/adm/switchserver'); |
$r->internal_redirect('/adm/switchserver'); |
return OK; |
return OK; |
Line 209 sub handler {
|
Line 255 sub handler {
|
return OK; |
return OK; |
} |
} |
} |
} |
|
my ($usernameset,$condition); |
|
if ((grep(/^email$/,@{$cancreate})) && (($env{'form.create_with_email'}) || |
|
((!$token) && ($env{'form.phase'} eq '')))) { |
|
my $usertype = &get_usertype($domain); |
|
if (ref($verification) eq 'HASH') { |
|
if ($verification->{$usertype} eq 'other') { |
|
$usernameset = 1; |
|
if (ref($emaildomain) eq 'HASH') { |
|
if ($emaildomain->{$usertype} ne '') { |
|
$condition = $emaildomain->{$usertype}; |
|
} |
|
} |
|
} |
|
} |
|
} |
if ($env{'form.phase'} eq 'username_activation') { |
if ($env{'form.phase'} eq 'username_activation') { |
(my $result,$output,$nostart) = |
(my $result,$output,$nostart) = |
&username_activation($r,$env{'form.uname'},$domain,$domdesc, |
&username_activation($r,$env{'form.uname'},$domain,$domdesc, |
Line 244 sub handler {
|
Line 304 sub handler {
|
$output = &process_email_request($env{'form.uname'},$domain,$domdesc, |
$output = &process_email_request($env{'form.uname'},$domain,$domdesc, |
$contact_name,$contact_email,$cancreate, |
$contact_name,$contact_email,$cancreate, |
$lonhost,$domconfig{'usercreation'}, |
$lonhost,$domconfig{'usercreation'}, |
$emailusername,$courseid,$usertype); |
$emailusername,$courseid,$usertype, |
|
$usernameset,$condition); |
} elsif (!$token) { |
} elsif (!$token) { |
&print_header($r,$start_page,$courseid); |
&print_header($r,$start_page,$courseid,$pagetitle); |
my $now=time; |
my $now=time; |
my $gotlondes; |
if ((grep(/^login$/,@{$cancreate})) && (!grep(/^email$/,@{$cancreate}))) { |
if (grep(/^login$/,@{$cancreate})) { |
|
if (open(my $jsh,"<$include/londes.js")) { |
if (open(my $jsh,"<$include/londes.js")) { |
while(my $line = <$jsh>) { |
while(my $line = <$jsh>) { |
$r->print($line); |
$r->print($line); |
} |
} |
close($jsh); |
close($jsh); |
$r->print(&javascript_setforms($now)); |
$r->print(&javascript_setforms($now)); |
$gotlondes = 1; |
|
} |
} |
} |
} |
if (grep(/^email(|approval)$/,@{$cancreate})) { |
if (grep(/^email$/,@{$cancreate})) { |
$r->print(&javascript_validmail()); |
$r->print(&javascript_validmail()); |
} |
} |
my $usertype = &get_usertype($domain); |
my $usertype = &get_usertype($domain); |
$output = &print_username_form($r,$domain,$domdesc,$cancreate,$now,$lonhost, |
$output = &print_username_form($r,$domain,$domdesc,$cancreate,$now,$lonhost, |
$include,$courseid,$gotlondes,$emailusername, |
$include,$courseid,$emailusername, |
$usertype); |
$statusforemail,$usernameset,$condition, |
|
$usertype,$types,$usertypes,$othertitle); |
} |
} |
$r->print($output); |
$r->print($output); |
&print_footer($r); |
&print_footer($r); |
Line 273 sub handler {
|
Line 333 sub handler {
|
} |
} |
|
|
sub print_header { |
sub print_header { |
my ($r,$start_page,$courseid) = @_; |
my ($r,$start_page,$courseid,$pagetitle) = @_; |
$r->print($start_page); |
$r->print($start_page); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
|
my $url = '/adm/createaccount'; |
|
if ($pagetitle eq '') { |
|
$pagetitle = 'New username'; |
|
} |
if ($courseid ne '') { |
if ($courseid ne '') { |
my %coursehash = &Apache::lonnet::coursedescription($courseid); |
my %coursehash = &Apache::lonnet::coursedescription($courseid); |
&selfenroll_crumbs($r,$courseid,$coursehash{'description'}); |
&selfenroll_crumbs($r,$courseid,$coursehash{'description'}); |
} |
} |
|
if ($env{'form.reportedtype'}) { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>$url, |
|
text=>"Select affiliation"}); |
|
} |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"/adm/createuser", |
({href=>$url, |
text=>"New username"}); |
text=>$pagetitle}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Create account')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Create account')); |
return; |
return; |
} |
} |
Line 293 sub print_footer {
|
Line 362 sub print_footer {
|
$r->print('<form name="backupcrumbs" method="post" action="">'. |
$r->print('<form name="backupcrumbs" method="post" action="">'. |
&Apache::lonhtmlcommon::echo_form_input(['backto','logtoken', |
&Apache::lonhtmlcommon::echo_form_input(['backto','logtoken', |
'token','serverid','uname','upass','phase','create_with_email', |
'token','serverid','uname','upass','phase','create_with_email', |
'code','crypt','cfirstname','clastname', |
'code','crypt','cfirstname','clastname','g-recaptcha-response', |
'recaptcha_challenge_field','recaptcha_response_field', |
'recaptcha_challenge_field','recaptcha_response_field', |
'cmiddlename','cgeneration','cpermanentemail','cid']). |
'cmiddlename','cgeneration','cpermanentemail','cid']). |
'</form>'); |
'</form>'); |
Line 303 sub print_footer {
|
Line 372 sub print_footer {
|
|
|
sub get_usertype { |
sub get_usertype { |
my ($domain) = @_; |
my ($domain) = @_; |
my $usertype = 'default'; |
my $usertype; |
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($domain); |
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($domain); |
if (ref($types) eq 'ARRAY') { |
if (ref($types) eq 'ARRAY') { |
push(@{$types},'default'); |
push(@{$types},'default'); |
Line 340 sub selfenroll_crumbs {
|
Line 409 sub selfenroll_crumbs {
|
} |
} |
|
|
sub javascript_setforms { |
sub javascript_setforms { |
my ($now,$emailusername,$captcha,$usertype) = @_; |
my ($now,$emailusername,$captcha,$usertype,$recaptchaversion,$usernameset,$condition) = @_; |
my ($setuserinfo,@required,$requiredchk); |
my ($setuserinfo,@required,$requiredchk); |
if (ref($emailusername) eq 'HASH') { |
if (ref($emailusername) eq 'HASH') { |
if (ref($emailusername->{$usertype}) eq 'HASH') { |
if (ref($emailusername->{$usertype}) eq 'HASH') { |
Line 356 sub javascript_setforms {
|
Line 425 sub javascript_setforms {
|
$setuserinfo .= ' server.elements.code.value=client.elements.code.value;'."\n". |
$setuserinfo .= ' server.elements.code.value=client.elements.code.value;'."\n". |
' server.elements.crypt.value=client.elements.crypt.value;'."\n"; |
' server.elements.crypt.value=client.elements.crypt.value;'."\n"; |
} elsif ($captcha eq 'recaptcha') { |
} elsif ($captcha eq 'recaptcha') { |
$setuserinfo .= |
if ($recaptchaversion ne '2') { |
|
$setuserinfo .= |
' server.elements.recaptcha_challenge_field.value=client.elements.recaptcha_challenge_field.value;'."\n". |
' server.elements.recaptcha_challenge_field.value=client.elements.recaptcha_challenge_field.value;'."\n". |
' server.elements.recaptcha_response_field.value=client.elements.recaptcha_response_field.value;'."\n"; |
' server.elements.recaptcha_response_field.value=client.elements.recaptcha_response_field.value;'."\n"; |
|
} |
|
} |
|
if ($usernameset) { |
|
$setuserinfo .= |
|
' server.elements.username.value=client.elements.username.value;'."\n"; |
} |
} |
} |
} |
if (@required) { |
if (@required) { |
my $missprompt = &mt('One or more required fields are currently blank.'); |
my $missprompt = &mt('One or more required fields are currently blank.'); |
|
&js_escape(\$missprompt); |
my $reqstr = join("','",@required); |
my $reqstr = join("','",@required); |
$requiredchk = <<"ENDCHK"; |
$requiredchk = <<"ENDCHK"; |
var requiredfields = new Array('$reqstr'); |
var requiredfields = new Array('$reqstr'); |
Line 404 $requiredchk
|
Line 480 $requiredchk
|
initkeys(); |
initkeys(); |
|
|
server.elements.upass.value |
server.elements.upass.value |
= crypted(client.elements.upass$now.value); |
= getCrypted(client.elements.upass$now.value); |
|
|
client.elements.uname.value=''; |
client.elements.uname.value=''; |
client.elements.upass$now.value=''; |
client.elements.upass$now.value=''; |
Line 417 $setuserinfo
|
Line 493 $setuserinfo
|
} |
} |
return false; |
return false; |
} |
} |
|
|
// ]]> |
// ]]> |
</script> |
</script> |
ENDSCRIPT |
ENDSCRIPT |
|
if (($captcha eq 'recaptcha') && ($recaptchaversion eq '2')) { |
|
$js .= "\n".'<script src="https://www.google.com/recaptcha/api.js"></script>'."\n"; |
|
} |
return $js; |
return $js; |
} |
} |
|
|
sub javascript_checkpass { |
sub javascript_checkpass { |
my ($now,$context) = @_; |
my ($now,$context) = @_; |
my $nopass = &mt('You must enter a password.'); |
my $nopass = &mt('You must enter a password.'); |
my $mismatchpass = &mt('The passwords you entered did not match.').'\\n'. |
my $mismatchpass = &mt('The passwords you entered did not match.')."\n". |
&mt('Please try again.'); |
&mt('Please try again.'); |
|
&js_escape(\$nopass); |
|
&js_escape(\$mismatchpass); |
my $js = <<"ENDSCRIPT"; |
my $js = <<"ENDSCRIPT"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
Line 461 ENDSCRIPT
|
Line 543 ENDSCRIPT
|
} |
} |
|
|
sub javascript_validmail { |
sub javascript_validmail { |
my %lt = &Apache::lonlocal::texthash ( |
my %js_lt = &Apache::lonlocal::texthash ( |
email => 'The e-mail address you entered', |
email => 'The e-mail address you entered', |
notv => 'is not a valid e-mail address', |
notv => 'is not a valid e-mail address', |
); |
); |
my $output = "\n".'<script type="text/javascript">'."\n". |
my $output = "\n".'<script type="text/javascript">'."\n". |
'// <![CDATA['."\n". |
'// <![CDATA['."\n". |
&Apache::lonhtmlcommon::javascript_valid_email()."\n"; |
&Apache::lonhtmlcommon::javascript_valid_email()."\n"; |
|
&js_escape(\%js_lt); |
$output .= <<"ENDSCRIPT"; |
$output .= <<"ENDSCRIPT"; |
function validate_email(client) { |
function validate_email(client) { |
field = client.uname; |
field = client.uname; |
if (validmail(field) == false) { |
if (validmail(field) == false) { |
alert("$lt{'email'}: "+field.value+" $lt{'notv'}."); |
alert("$js_lt{'email'}: "+field.value+" $js_lt{'notv'}."); |
return false; |
return false; |
} |
} |
return true; |
return true; |
Line 483 ENDSCRIPT
|
Line 566 ENDSCRIPT
|
} |
} |
|
|
sub print_username_form { |
sub print_username_form { |
my ($r,$domain,$domdesc,$cancreate,$now,$lonhost,$include,$courseid,$gotlondes,$emailusername, |
my ($r,$domain,$domdesc,$cancreate,$now,$lonhost,$include,$courseid,$emailusername, |
$usertype) = @_; |
$statusforemail,$usernameset,$condition,$usertype,$types,$usertypes, |
|
$othertitle) = @_; |
my %lt = &Apache::lonlocal::texthash ( |
my %lt = &Apache::lonlocal::texthash ( |
unam => 'username', |
|
udom => 'domain', |
|
uemail => 'E-mail address in LON-CAPA', |
|
proc => 'Proceed', |
|
crac => 'Create account with a username provided by this institution', |
crac => 'Create account with a username provided by this institution', |
clca => 'Create LON-CAPA account', |
clca => 'Create LON-CAPA account', |
type => 'Type in your log-in ID and password to find out.', |
type => 'Type in your log-in ID and password to find out.', |
plse => 'Please provide a password for your new account.', |
plse => 'Please provide a password for your new account.', |
info => 'Please provide user information and a password for your new account.', |
info => 'Please provide user information and a password for your new account.', |
yopw => 'Your password will be encrypted when sent (and stored).', |
yopw => 'Your password will be encrypted when sent (and stored).', |
|
crae => 'Create account using e-mail address verification', |
); |
); |
my $output; |
my $output; |
if (ref($cancreate) eq 'ARRAY') { |
if (ref($cancreate) eq 'ARRAY') { |
Line 511 sub print_username_form {
|
Line 592 sub print_username_form {
|
$domain,'createaccount').'</div>'; |
$domain,'createaccount').'</div>'; |
} |
} |
} |
} |
if (grep(/^email(|approval)$/,@{$cancreate})) { |
if (grep(/^email$/,@{$cancreate})) { |
$output .= '<div class="LC_left_float"><h3>'.&mt('Create account with an e-mail address as your username').'</h3>'; |
$output .= '<div class="LC_left_float"><h3>'.$lt{'crae'}.'</h3>'; |
my ($captchaform,$error,$captcha) = &Apache::loncommon::captcha_display('usercreation',$lonhost); |
if ($usertype ne '') { |
if ($error) { |
if (ref($statusforemail) eq 'ARRAY') { |
my $helpdesk = '/adm/helpdesk?origurl=%2fadm%2fcreateaccount'; |
unless (grep(/^\Q$usertype\E$/,@{$statusforemail})) { |
if ($courseid ne '') { |
undef($usertype); |
$helpdesk .= '&courseid='.$courseid; |
} |
} |
} |
$output .= '<span class="LC_error">'. |
} |
&mt('An error occurred generating the validation code[_1] required for an e-mail address to be used as username.','<br />'). |
if (($usertype eq '') && (ref($statusforemail) eq 'ARRAY') && |
'</span><br /><br />'. |
(@{$statusforemail}) && (ref($types) eq 'ARRAY')) { |
&mt('[_1]Contact the helpdesk[_2] or [_3]reload[_2] the page and try again.', |
my @posstypes = @{$types}; |
'<a href="'.$helpdesk.'">','</a>','<a href="javascript:window.location.reload()">'); |
unless (grep(/^default$/,@posstypes)) { |
|
push(@posstypes,'default'); |
|
} |
|
$output .= '<p>'.&mt('Choose your affiliation at [_1]',$domdesc).'</p>'."\n". |
|
'<form name="reportstatus" id="LC_reportstatus" action="" method="post" '. |
|
'onsubmit="return checkVerification();"><p>'; |
|
foreach my $type (@posstypes) { |
|
my $name; |
|
if ($type eq 'default') { |
|
$name = $othertitle; |
|
} else { |
|
$name = $type; |
|
if (ref($usertypes) eq 'HASH') { |
|
if (exists($usertypes->{$type})) { |
|
$name = $usertypes->{$type}; |
|
} |
|
} |
|
} |
|
$output .= '<label><input type="radio" name="type" value="'.$type.'" />'. |
|
$name.'</label>'.(' 'x2); |
|
} |
|
if ($env{'form.courseid'} =~ /^$match_domain\_$match_courseid$/) { |
|
$output .= "\n".'<input type="hidden" name="courseid" value="'.$env{'form.courseid'}.'" />'; |
|
} |
|
$output .= '</p>'."\n".'<p><input type="submit" name="reportedtype" value="'.&mt('Submit').'" /></p></form>'; |
} else { |
} else { |
if (grep(/^login$/,@{$cancreate})) { |
my ($captchaform,$error,$captcha,$recaptchaversion) = |
$output .= &mt('If you do not have a log-in ID at your institution, [_1]provide your e-mail address to request a LON-CAPA account.','<br />').'<br /><br />'. |
&Apache::loncommon::captcha_display('usercreation',$lonhost); |
$lt{'plse'}.'<br />'. |
if ($error) { |
$lt{'yopw'}.'<br />'; |
my $helpdesk = '/adm/helpdesk?origurl=%2fadm%2fcreateaccount'; |
|
if ($courseid ne '') { |
|
$helpdesk .= '&courseid='.$courseid; |
|
} |
|
$output .= '<span class="LC_error">'. |
|
&mt('An error occurred generating the validation code[_1] required for use of an e-mail address to request a LON-CAPA account.','<br />'). |
|
'</span><br /><br />'. |
|
&mt('[_1]Contact the helpdesk[_2] or [_3]reload[_2] the page and try again.', |
|
'<a href="'.$helpdesk.'">','</a>','<a href="javascript:window.location.reload()">'); |
} else { |
} else { |
my $prompt = $lt{'plse'}; |
if (grep(/^login$/,@{$cancreate})) { |
if (ref($emailusername) eq 'HASH') { |
$output .= &mt('If you do not have a log-in ID at your institution, [_1]provide your e-mail address to request a LON-CAPA account.','<br />').'<br /><br />'. |
if (ref($emailusername->{$usertype}) eq 'HASH') { |
$lt{'plse'}.'<br />'. |
if (keys(%{$emailusername->{$usertype}}) > 0) { |
$lt{'yopw'}.'<br />'; |
$prompt = $lt{'info'}; |
} else { |
|
my $prompt = $lt{'plse'}; |
|
if (ref($emailusername) eq 'HASH') { |
|
if (ref($emailusername->{$usertype}) eq 'HASH') { |
|
if (keys(%{$emailusername->{$usertype}}) > 0) { |
|
$prompt = $lt{'info'}; |
|
} |
} |
} |
} |
} |
|
$output .= $prompt.'<br />'. |
|
$lt{'yopw'}.'<br />'; |
} |
} |
$output .= $prompt.'<br />'. |
$output .= &print_dataentry_form($r,$domain,$lonhost,$include,$now,$captchaform, |
$lt{'yopw'}.'<br />'; |
$courseid,$emailusername,$captcha,$usertype, |
|
$recaptchaversion,$usernameset,$condition); |
} |
} |
$output .= &print_dataentry_form($r,$domain,$lonhost,$include,$now,$captchaform, |
|
$courseid,$gotlondes,$emailusername,$captcha, |
|
$usertype); |
|
} |
} |
$output .= '</div>'; |
$output .= '</div>'; |
} |
} |
} |
} |
if ($output eq '') { |
if ($output eq '') { |
$output = &mt('Creation of a new LON-CAPA user account using an e-mail address or an institutional log-in ID as your username is not permitted at [_1].',$domdesc); |
$output = &mt('Creation of a new LON-CAPA user account using an institutional log-in ID or verification by e-mail is not permitted at [_1].',$domdesc); |
} else { |
} else { |
$output .= '<div class="LC_clear_float_footer"></div>'; |
$output .= '<div class="LC_clear_float_footer"></div>'; |
} |
} |
Line 609 sub login_box {
|
Line 728 sub login_box {
|
|
|
sub process_email_request { |
sub process_email_request { |
my ($useremail,$domain,$domdesc,$contact_name,$contact_email,$cancreate, |
my ($useremail,$domain,$domdesc,$contact_name,$contact_email,$cancreate, |
$server,$settings,$emailusername,$courseid,$usertype) = @_; |
$server,$settings,$emailusername,$courseid,$usertype,$usernameset, |
my $output; |
$condition) = @_; |
|
my ($output,$uname); |
if (ref($cancreate) eq 'ARRAY') { |
if (ref($cancreate) eq 'ARRAY') { |
if (!grep(/^email(|approval)$/,@{$cancreate})) { |
if (!grep(/^email$/,@{$cancreate})) { |
$output = &invalid_state('noemails',$domdesc, |
$output = &invalid_state('noemails',$domdesc, |
$contact_name,$contact_email); |
$contact_name,$contact_email); |
return $output; |
return $output; |
Line 622 sub process_email_request {
|
Line 742 sub process_email_request {
|
return $output; |
return $output; |
} else { |
} else { |
$useremail =~ s/^\s+|\s+$//g; |
$useremail =~ s/^\s+|\s+$//g; |
my $uname=&LONCAPA::clean_username($useremail); |
my $possuname; |
if ($useremail ne $uname) { |
if ($env{'form.username'}) { |
$output = &invalid_state('badusername',$domdesc, |
$possuname = $env{'form.username'}; |
$contact_name,$contact_email); |
$possuname =~ s/^\s+|\s+$//g; |
return $output; |
} |
|
if (($usernameset) && ($possuname ne '')) { |
|
if ($condition ne '') { |
|
if ($useremail =~ /\Q$condition\E/) { |
|
$uname = &LONCAPA::clean_username($possuname); |
|
} else { |
|
$output = &invalid_state('emailfail',$domdesc, |
|
$contact_name,$contact_email); |
|
return $output; |
|
} |
|
} else { |
|
$uname=&LONCAPA::clean_username($possuname); |
|
} |
|
if ($uname ne $possuname) { |
|
$output = &invalid_state('badusername',$domdesc, |
|
$contact_name,$contact_email); |
|
return $output; |
|
} |
|
} else { |
|
$uname=&LONCAPA::clean_username($useremail); |
|
if ($useremail ne $uname) { |
|
$output = &invalid_state('badusername',$domdesc, |
|
$contact_name,$contact_email); |
|
return $output; |
|
} |
} |
} |
my $uhome = &Apache::lonnet::homeserver($useremail,$domain); |
my $uhome = &Apache::lonnet::homeserver($uname,$domain); |
if ($uhome ne 'no_host') { |
if ($uhome ne 'no_host') { |
$output = &invalid_state('existinguser',$domdesc, |
$output = &invalid_state('existinguser',$domdesc, |
$contact_name,$contact_email); |
$contact_name,$contact_email); |
Line 641 sub process_email_request {
|
Line 785 sub process_email_request {
|
return $output; |
return $output; |
} |
} |
my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts); |
my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts); |
&call_rulecheck($useremail,$domain,\%alerts,\%rulematch, |
&call_rulecheck($uname,$domain,\%alerts,\%rulematch, |
\%inst_results,\%curr_rules,\%got_rules,'username'); |
\%inst_results,\%curr_rules,\%got_rules,'username'); |
if (ref($alerts{'username'}) eq 'HASH') { |
if (ref($alerts{'username'}) eq 'HASH') { |
if (ref($alerts{'username'}{$domain}) eq 'HASH') { |
if (ref($alerts{'username'}{$domain}) eq 'HASH') { |
if ($alerts{'username'}{$domain}{$useremail}) { |
if ($alerts{'username'}{$domain}{$uname}) { |
$output = &invalid_state('userrules',$domdesc, |
$output = &invalid_state('userrules',$domdesc, |
$contact_name,$contact_email); |
$contact_name,$contact_email); |
return $output; |
return $output; |
} |
} |
} |
} |
} |
} |
my $format_msg = |
if (($usernameset) && ($possuname ne '')) { |
&guest_format_check($useremail,$domain,$cancreate, |
my $format_msg = |
$settings); |
&guest_format_check($useremail,$domain,$cancreate, |
if ($format_msg) { |
$settings); |
$output = &invalid_state('userformat',$domdesc,$contact_name, |
if ($format_msg) { |
$contact_email,$format_msg); |
$output = &invalid_state('userformat',$domdesc,$contact_name, |
return $output; |
$contact_email,$format_msg); |
|
return $output; |
|
} |
} |
} |
} |
} |
} |
} |
$output = &send_token($domain,$useremail,$server,$domdesc,$contact_name, |
$output = &send_token($domain,$useremail,$server,$domdesc,$contact_name, |
$contact_email,$courseid,$emailusername,$usertype); |
$contact_email,$courseid,$emailusername,$usertype, |
|
$uname); |
} |
} |
return $output; |
return $output; |
} |
} |
Line 684 sub call_rulecheck {
|
Line 831 sub call_rulecheck {
|
|
|
sub send_token { |
sub send_token { |
my ($domain,$email,$server,$domdesc,$contact_name,$contact_email,$courseid,$emailusername, |
my ($domain,$email,$server,$domdesc,$contact_name,$contact_email,$courseid,$emailusername, |
$usertype) = @_; |
$usertype,$uname) = @_; |
my $msg = '<h3>'.&mt('Account creation status').'</h3>'. |
my $msg = '<h3>'.&mt('Account creation status').'</h3>'. |
&mt('Thank you for your request to create a new LON-CAPA account.'). |
&mt('Thank you for your request to create a new LON-CAPA account.'). |
'<br /><br />'; |
'<br /><br />'; |
Line 710 sub send_token {
|
Line 857 sub send_token {
|
'upass' => $env{'form.upass'}, |
'upass' => $env{'form.upass'}, |
'serverid' => $env{'form.serverid'}, |
'serverid' => $env{'form.serverid'}, |
'tmpinfo' => $tmpinfo); |
'tmpinfo' => $tmpinfo); |
|
if ($uname ne '') { |
|
$info{'username'} = $uname; |
|
$info{'email'} = $email; |
|
} |
if (ref($emailusername) eq 'HASH') { |
if (ref($emailusername) eq 'HASH') { |
if (ref($emailusername->{$usertype}) eq 'HASH') { |
if (ref($emailusername->{$usertype}) eq 'HASH') { |
foreach my $item (keys(%{$emailusername->{$usertype}})) { |
foreach my $item (keys(%{$emailusername->{$usertype}})) { |
$info{$item} = $env{'form.'.$item}; |
$info{$item} = $env{'form.'.$item}; |
$info{$item} =~ s/(`)//g; |
$info{$item} =~ s/(`)//g; |
} |
} |
unless ($usertype eq 'default') { |
|
$info{'inststatus'} = $usertype; |
|
} |
|
} |
} |
} |
} |
|
if ($usertype ne '') { |
|
$info{'usertype'} = $usertype; |
|
} |
my $token = &Apache::lonnet::tmpput(\%info,$server,'createaccount'); |
my $token = &Apache::lonnet::tmpput(\%info,$server,'createaccount'); |
if ($token !~ /^error/ && $token ne 'no_such_host') { |
if ($token !~ /^error/ && $token ne 'no_such_host') { |
my $esc_token = &escape($token); |
my $esc_token = &escape($token); |
Line 755 sub send_token {
|
Line 905 sub send_token {
|
|
|
sub process_mailtoken { |
sub process_mailtoken { |
my ($r,$token,$contact_name,$contact_email,$domain,$domdesc,$lonhost, |
my ($r,$token,$contact_name,$contact_email,$domain,$domdesc,$lonhost, |
$include,$start_page,$cancreate,$settings) = @_; |
$include,$start_page,$cancreate,$settings,$types) = @_; |
my ($msg,$nostart,$noend,$redirect); |
my ($msg,$nostart,$noend,$redirect); |
my %data = &Apache::lonnet::tmpget($token); |
my %data = &Apache::lonnet::tmpget($token); |
my $now = time; |
my $now = time; |
Line 768 sub process_mailtoken {
|
Line 918 sub process_mailtoken {
|
} |
} |
if (($data{'time'} =~ /^\d+$/) && |
if (($data{'time'} =~ /^\d+$/) && |
($data{'domain'} ne '') && |
($data{'domain'} ne '') && |
($data{'username'} =~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/)) { |
((($data{'email'} =~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/) && ($data{'username'} =~ /^$match_username$/)) || |
|
($data{'username'} =~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/))) { |
if ($now - $data{'time'} < 7200) { |
if ($now - $data{'time'} < 7200) { |
# Check if request should be queued. |
# Check if request should be queued. |
if (ref($cancreate) eq 'ARRAY') { |
if (ref($cancreate) eq 'ARRAY') { |
|
my ($disposition,$usertype); |
if (grep(/^email$/,@{$cancreate})) { |
if (grep(/^email$/,@{$cancreate})) { |
my ($result,$output,$uhome) = |
if (exists($data{'usertype'})) { |
&create_account($r,$domain,$domdesc,\%data); |
$usertype = $data{'usertype'}; |
if ($result eq 'ok') { |
my @posstypes; |
$msg = $output; |
if (ref($types) eq 'ARRAY') { |
my $shownow = &Apache::lonlocal::locallocaltime($now); |
@posstypes = @{$types}; |
my $mailmsg = &mt('A LON-CAPA account for the institution: [_1] has been created [_2] from IP address: [_3]. If you did not perform this action or authorize it, please contact the [_4] ([_5]).',$domdesc,$shownow,$ENV{'REMOTE_ADDR'},$contact_name,$contact_email)."\n"; |
if (@posstypes) { |
my $mailresult = &Apache::resetpw::send_mail($domdesc,$data{'email'}, |
unless (grep(/^default$/,@posstypes)) { |
$mailmsg,$contact_name, |
push(@posstypes,'default'); |
$contact_email); |
} |
if ($mailresult eq 'ok') { |
} |
$msg .= &mt('An e-mail confirming creation of your new LON-CAPA account has been sent to [_1].',$data{'username'}); |
if (grep(/\Q$usertype\E/,@posstypes)) { |
} else { |
unless ($usertype eq 'default') { |
$msg .= &mt('An error occurred when sending e-mail to [_1] confirming creation of your LON-CAPA account.',$data{'username'}); |
$data{'inststatus'} = $usertype; |
|
} |
|
} else { |
|
undef($usertype); |
|
} |
|
} |
|
delete($data{'usertype'}); |
|
} |
|
if (ref($settings) eq 'HASH') { |
|
if (ref($settings->{'cancreate'}) eq 'HASH') { |
|
if (ref($settings->{'cancreate'}{'selfcreateprocessing'}) eq 'HASH') { |
|
$disposition = $settings->{'cancreate'}{'selfcreateprocessing'}{$usertype}; |
|
} |
} |
} |
$redirect = &start_session($r,$data{'username'},$domain,$uhome, |
} |
$data{'courseid'},$token); |
if ($disposition eq 'approval') { |
$nostart = 1; |
$msg = &store_request($domain,$data{'username'},'approval',\%data,$settings); |
$noend = 1; |
my $delete = &Apache::lonnet::tmpdel($token); |
} else { |
} else { |
$msg .= &mt('A problem occurred when attempting to create your new LON-CAPA account.') |
my ($result,$output,$uhome) = |
.'<br />'.$output; |
&create_account($r,$domain,$domdesc,\%data); |
if (($contact_name ne '') && ($contact_email ne '')) { |
if ($result eq 'ok') { |
$msg .= &mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email); |
$msg = $output; |
|
my $shownow = &Apache::lonlocal::locallocaltime($now); |
|
my $mailmsg = &mt('A LON-CAPA account for the institution: [_1] has been created [_2] from IP address: [_3]. If you did not perform this action or authorize it, please contact the [_4] ([_5]).',$domdesc,$shownow,$ENV{'REMOTE_ADDR'},$contact_name,$contact_email)."\n"; |
|
my $mailresult = &Apache::resetpw::send_mail($domdesc,$data{'email'}, |
|
$mailmsg,$contact_name, |
|
$contact_email); |
|
if ($mailresult eq 'ok') { |
|
$msg .= &mt('An e-mail confirming creation of your new LON-CAPA account has been sent to [_1].',$data{'username'}); |
|
} else { |
|
$msg .= &mt('An error occurred when sending e-mail to [_1] confirming creation of your LON-CAPA account.',$data{'username'}); |
|
} |
|
$redirect = &start_session($r,$data{'username'},$domain,$uhome, |
|
$data{'courseid'},$token); |
|
$nostart = 1; |
|
$noend = 1; |
|
} else { |
|
$msg .= &mt('A problem occurred when attempting to create your new LON-CAPA account.') |
|
.'<br />'.$output; |
|
if (($contact_name ne '') && ($contact_email ne '')) { |
|
$msg .= &mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email); |
|
} |
} |
} |
|
my $delete = &Apache::lonnet::tmpdel($token); |
} |
} |
my $delete = &Apache::lonnet::tmpdel($token); |
|
} elsif (grep(/^emailapproval$/,@{$cancreate})) { |
|
$msg = &store_request($domain,$data{'username'},'approval',\%data,$settings); |
|
my $delete = &Apache::lonnet::tmpdel($token); |
|
} else { |
} else { |
$msg = &invalid_state('noemails',$domdesc,$contact_name,$contact_email); |
$msg = &invalid_state('noemails',$domdesc,$contact_name,$contact_email); |
} |
} |
Line 821 sub process_mailtoken {
|
Line 1002 sub process_mailtoken {
|
|
|
sub start_session { |
sub start_session { |
my ($r,$username,$domain,$uhome,$courseid,$token) = @_; |
my ($r,$username,$domain,$uhome,$courseid,$token) = @_; |
|
my ($is_balancer) = &Apache::lonnet::check_loadbalancing($username,$domain); |
if ($r->dir_config('lonBalancer') eq 'yes') { |
if ($is_balancer) { |
Apache::lonauth::success($r, $username, $domain, $uhome, |
Apache::lonauth::success($r, $username, $domain, $uhome, |
'noredirect', undef, {}); |
'noredirect', undef, {}); |
|
|
Line 836 sub start_session {
|
Line 1017 sub start_session {
|
($courseid ? "/adm/selfenroll?courseid=$courseid" : '/adm/roles'), |
($courseid ? "/adm/selfenroll?courseid=$courseid" : '/adm/roles'), |
undef, {}); |
undef, {}); |
} |
} |
|
|
return; |
return; |
} |
} |
|
|
Line 846 sub start_session {
|
Line 1026 sub start_session {
|
# Stores token to store DES-key and stage during creation session |
# Stores token to store DES-key and stage during creation session |
# |
# |
sub print_dataentry_form { |
sub print_dataentry_form { |
my ($r,$domain,$lonhost,$include,$now,$captchaform,$courseid,$gotlondes,$emailusername,$captcha, |
my ($r,$domain,$lonhost,$include,$now,$captchaform,$courseid,$emailusername,$captcha, |
$usertype) = @_; |
$usertype,$recaptchaversion,$usernameset,$condition) = @_; |
my ($error,$output); |
my ($error,$output); |
unless ($gotlondes) { |
if (open(my $jsh,"<$include/londes.js")) { |
if (open(my $jsh,"<$include/londes.js")) { |
while(my $line = <$jsh>) { |
while(my $line = <$jsh>) { |
$r->print($line); |
$r->print($line); |
} |
} |
close($jsh); |
close($jsh); |
$output = &javascript_setforms($now,$emailusername,$captcha,$usertype,$recaptchaversion, |
$output = &javascript_setforms($now,$emailusername,$captcha,$usertype)."\n"; |
$usernameset,$condition). |
$gotlondes = 1; |
"\n".&javascript_checkpass($now,'email'); |
} |
|
} |
|
if ($gotlondes) { |
|
$output .= &javascript_checkpass($now,'email'); |
|
my ($lkey,$ukey) = &Apache::loncommon::des_keys(); |
my ($lkey,$ukey) = &Apache::loncommon::des_keys(); |
my ($lextkey,$uextkey) = &getkeys($lkey,$ukey); |
my ($lextkey,$uextkey) = &getkeys($lkey,$ukey); |
my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount', |
my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount', |
Line 875 sub print_dataentry_form {
|
Line 1051 sub print_dataentry_form {
|
foreach my $field (sort(keys(%{$emailusername->{$usertype}}))) { |
foreach my $field (sort(keys(%{$emailusername->{$usertype}}))) { |
$output .= '<input type="hidden" name="'.$field.'" value="" />'."\n"; |
$output .= '<input type="hidden" name="'.$field.'" value="" />'."\n"; |
} |
} |
$output .= '<input type="hidden" name="type" value="" />'."\n"; |
|
} |
} |
} |
} |
if ($captcha eq 'original') { |
if ($captcha eq 'original') { |
Line 884 sub print_dataentry_form {
|
Line 1059 sub print_dataentry_form {
|
<input type="hidden" name="code" value="" /> |
<input type="hidden" name="code" value="" /> |
'; |
'; |
} elsif ($captcha eq 'recaptcha') { |
} elsif ($captcha eq 'recaptcha') { |
$output .= ' |
if ($recaptchaversion eq '2') { |
|
$output .= "$captchaform\n"; |
|
undef($captchaform); |
|
} else { |
|
$output .= ' |
<input type="hidden" name="recaptcha_challenge_field" value="" /> |
<input type="hidden" name="recaptcha_challenge_field" value="" /> |
<input type="hidden" name="recaptcha_response_field" value="" /> |
<input type="hidden" name="recaptcha_response_field" value="" /> |
'; |
'; |
|
} |
|
} |
|
if ($usertype ne '') { |
|
$output .= '<input type="hidden" name="type" value="'. |
|
&HTML::Entities::encode($usertype,'\'<>"&').'" />'."\n"; |
|
} |
|
if ($usernameset) { |
|
$output .= '<input type="hidden" name="username" value="" />'."\n"; |
} |
} |
$output .= <<"ENDSERVERFORM"; |
$output .= <<"ENDSERVERFORM"; |
<input type="hidden" name="logtoken" value="$logtoken" /> |
<input type="hidden" name="logtoken" value="$logtoken" /> |
Line 909 ENDSERVERFORM
|
Line 1096 ENDSERVERFORM
|
my ($datatable,$rowcount) = |
my ($datatable,$rowcount) = |
&Apache::loncreateuser::personal_data_display('',$domain,'email','selfcreate', |
&Apache::loncreateuser::personal_data_display('',$domain,'email','selfcreate', |
'','',$now,$captchaform, |
'','',$now,$captchaform, |
$emailusername,$usertype); |
$emailusername,$usertype, |
|
$usernameset,$condition); |
if ($rowcount) { |
if ($rowcount) { |
$output .= '<div class="LC_left_float">'.$beginclientform.$datatable.$endclientform; |
$output .= '<div class="LC_left_float">'.$beginclientform.$datatable.$endclientform; |
} else { |
} else { |
Line 931 ENDSERVERFORM
|
Line 1119 ENDSERVERFORM
|
|
|
sub get_creation_controls { |
sub get_creation_controls { |
my ($domain,$usercreation) = @_; |
my ($domain,$usercreation) = @_; |
my (@cancreate,@statustocreate,$emailusername); |
my (@cancreate,@statustocreate,@statusforemail,$emailusername,$processing, |
|
$verification,$emaildomain,$othertitle,$usertypes,$types); |
if (ref($usercreation) eq 'HASH') { |
if (ref($usercreation) eq 'HASH') { |
if (ref($usercreation->{'cancreate'}) eq 'HASH') { |
if (ref($usercreation->{'cancreate'}) eq 'HASH') { |
|
($othertitle,$usertypes,$types) = |
|
&Apache::loncommon::sorted_inst_types($domain); |
if (ref($usercreation->{'cancreate'}{'statustocreate'}) eq 'ARRAY') { |
if (ref($usercreation->{'cancreate'}{'statustocreate'}) eq 'ARRAY') { |
@statustocreate = @{$usercreation->{'cancreate'}{'statustocreate'}}; |
@statustocreate = @{$usercreation->{'cancreate'}{'statustocreate'}}; |
if (@statustocreate == 0) { |
if (@statustocreate == 0) { |
my ($othertitle,$usertypes,$types) = |
|
&Apache::loncommon::sorted_inst_types($domain); |
|
if (ref($types) eq 'ARRAY') { |
if (ref($types) eq 'ARRAY') { |
if (@{$types} == 0) { |
if (@{$types} == 0) { |
@statustocreate = ('default'); |
@statustocreate = ('default'); |
Line 949 sub get_creation_controls {
|
Line 1138 sub get_creation_controls {
|
} |
} |
} else { |
} else { |
@statustocreate = ('default'); |
@statustocreate = ('default'); |
my ($othertitle,$usertypes,$types) = |
|
&Apache::loncommon::sorted_inst_types($domain); |
|
if (ref($types) eq 'ARRAY') { |
if (ref($types) eq 'ARRAY') { |
push(@statustocreate,@{$types}); |
push(@statustocreate,@{$types}); |
} |
} |
Line 961 sub get_creation_controls {
|
Line 1148 sub get_creation_controls {
|
($usercreation->{'cancreate'}{'selfcreate'} ne '')) { |
($usercreation->{'cancreate'}{'selfcreate'} ne '')) { |
@cancreate = ($usercreation->{'cancreate'}{'selfcreate'}); |
@cancreate = ($usercreation->{'cancreate'}{'selfcreate'}); |
} |
} |
|
if (grep(/^email$/,@cancreate)) { |
|
if (ref($usercreation->{'cancreate'}{'selfcreateprocessing'}) eq 'HASH') { |
|
$processing = $usercreation->{'cancreate'}{'selfcreateprocessing'}; |
|
} |
|
if (ref($usercreation->{'cancreate'}{'emailverified'}) eq 'HASH') { |
|
$verification = $usercreation->{'cancreate'}{'emailverified'}; |
|
} |
|
if (ref($usercreation->{'cancreate'}{'emaildomain'}) eq 'HASH') { |
|
$emaildomain = $usercreation->{'cancreate'}{'emaildomain'}; |
|
} |
|
if (ref($processing)) { |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($domain); |
|
my @emailtypes; |
|
if (ref($domdefaults{'inststatusguest'}) eq 'ARRAY') { |
|
@emailtypes = @{$domdefaults{'inststatusguest'}}; |
|
if (@emailtypes) { |
|
unless (grep(/^default$/,@emailtypes)) { |
|
push(@emailtypes,'default'); |
|
} |
|
foreach my $type (@emailtypes) { |
|
if ($processing->{$type} ne 'notinuse') { |
|
unless (grep(/^$type$/,@statusforemail)) { |
|
push(@statusforemail,$type); |
|
} |
|
} |
|
} |
|
unless (@statusforemail) { |
|
my @okcreate; |
|
foreach my $poss (@cancreate) { |
|
unless ($poss eq 'email') { |
|
push(@okcreate,$poss); |
|
} |
|
} |
|
@cancreate = @okcreate; |
|
} |
|
} |
|
} |
|
} |
|
} |
if (ref($usercreation->{'cancreate'}{'emailusername'}) eq 'HASH') { |
if (ref($usercreation->{'cancreate'}{'emailusername'}) eq 'HASH') { |
$emailusername = $usercreation->{'cancreate'}{'emailusername'}; |
$emailusername = $usercreation->{'cancreate'}{'emailusername'}; |
} else { |
} else { |
$emailusername = {'lastname' => '1', 'firstname' => 1, }; |
$emailusername = { |
|
default => { |
|
'lastname' => '1', |
|
'firstname' => 1, |
|
}, |
|
}; |
} |
} |
} |
} |
} |
} |
return (\@cancreate,\@statustocreate,$emailusername); |
return (\@cancreate,\@statustocreate,\@statusforemail,$emailusername, |
|
$verification,$emaildomain,$types,$usertypes,$othertitle); |
} |
} |
|
|
sub create_account { |
sub create_account { |
Line 981 sub create_account {
|
Line 1213 sub create_account {
|
my $output; |
my $output; |
if (ref($dataref) eq 'HASH') { |
if (ref($dataref) eq 'HASH') { |
my ($username,$encpass,$serverid,$courseid,$id,$firstname,$middlename,$lastname, |
my ($username,$encpass,$serverid,$courseid,$id,$firstname,$middlename,$lastname, |
$generation,$inststatus); |
$generation,$inststatus,$permanentemail); |
$username = $dataref->{'username'}; |
$username = $dataref->{'username'}; |
$encpass = $dataref->{'upass'}; |
$encpass = $dataref->{'upass'}; |
$serverid = $dataref->{'serverid'}; |
$serverid = $dataref->{'serverid'}; |
Line 991 sub create_account {
|
Line 1223 sub create_account {
|
$middlename = $dataref->{'middlename'}; |
$middlename = $dataref->{'middlename'}; |
$lastname = $dataref->{'lastname'}; |
$lastname = $dataref->{'lastname'}; |
$generation = $dataref->{'generation'}; |
$generation = $dataref->{'generation'}; |
$inststatus = $dataref->{'usertype'}; |
$inststatus = $dataref->{'inststatus'}; |
|
|
|
if ($dataref->{'email'} ne '') { |
|
$permanentemail = $dataref->{'email'}; |
|
} else { |
|
$permanentemail = $dataref->{'username'}; |
|
} |
my $currhome = &Apache::lonnet::homeserver($username,$domain); |
my $currhome = &Apache::lonnet::homeserver($username,$domain); |
unless ($currhome eq 'no_host') { |
unless ($currhome eq 'no_host') { |
$output = &mt('User account requested for username: [_1] in domain: [_2] already exists.',$username,$domain); |
$output = &mt('User account requested for username: [_1] in domain: [_2] already exists.',$username,$domain); |
Line 1024 sub create_account {
|
Line 1261 sub create_account {
|
my $result = |
my $result = |
&Apache::lonnet::modifyuser($domain,$username,$id, |
&Apache::lonnet::modifyuser($domain,$username,$id, |
'internal',$upass,$firstname,$middlename, |
'internal',$upass,$firstname,$middlename, |
$lastname,$generation,undef,undef,$username); |
$lastname,$generation,undef,undef,$permanentemail); |
$output = &mt('Generating user: [_1]',$result); |
$output = &mt('Generating user: [_1]',$result); |
|
|
# Now that the user account exists, retrieve the homeserver, and include it in the output. |
# Now that the user account exists, retrieve the homeserver, and include it in the output. |
Line 1153 sub login_failure_msg {
|
Line 1390 sub login_failure_msg {
|
|
|
sub username_check { |
sub username_check { |
my ($username,$domain,$domdesc,$courseid,$lonhost,$contact_email, |
my ($username,$domain,$domdesc,$courseid,$lonhost,$contact_email, |
$contact_name,$sso_logout,$statustocreate) = @_; |
$contact_name,$sso_logout,$statustocreate,$shibenv) = @_; |
my (%rulematch,%inst_results,$checkfail,$rowcount,$editable,$output,$msg, |
my (%rulematch,%inst_results,$checkfail,$rowcount,$editable,$output,$msg, |
%alerts,%curr_rules,%got_rules); |
%alerts,%curr_rules,%got_rules); |
&call_rulecheck($username,$domain,\%alerts,\%rulematch, |
&call_rulecheck($username,$domain,\%alerts,\%rulematch, |
Line 1189 sub username_check {
|
Line 1426 sub username_check {
|
} |
} |
if (!$checkfail) { |
if (!$checkfail) { |
$output = '<form method="post" action="/adm/createaccount">'; |
$output = '<form method="post" action="/adm/createaccount">'; |
|
if (ref($shibenv) eq 'HASH') { |
|
foreach my $key (keys(%{$shibenv})) { |
|
if ($ENV{$shibenv->{$key}} ne '') { |
|
$inst_results{$username.':'.$domain}{$key} = $ENV{$shibenv->{$key}}; |
|
} |
|
} |
|
} |
(my $datatable,$rowcount,$editable) = |
(my $datatable,$rowcount,$editable) = |
&Apache::loncreateuser::personal_data_display($username,$domain,1,'selfcreate', |
&Apache::loncreateuser::personal_data_display($username,$domain,1,'selfcreate', |
$inst_results{$username.':'.$domain}); |
$inst_results{$username.':'.$domain}); |
Line 1407 sub invalid_state {
|
Line 1651 sub invalid_state {
|
$msg .= &mt('Validation of the code you entered failed.'); |
$msg .= &mt('Validation of the code you entered failed.'); |
} elsif ($error eq 'noemails') { |
} elsif ($error eq 'noemails') { |
$msg .= &mt('Creation of a new user account using an e-mail address as username is not permitted at this LON-CAPA institution.'); |
$msg .= &mt('Creation of a new user account using an e-mail address as username is not permitted at this LON-CAPA institution.'); |
|
} elsif ($error eq 'emailfail') { |
|
$msg .= &mt('Creation of a new user account with verification by e-mail is not permitted with the e-mail address you provided'); |
} |
} |
$msg .= '</span>'; |
$msg .= '</span>'; |
if ($msgtext) { |
if ($msgtext) { |
Line 1647 function getFormByName(item) {
|
Line 1893 function getFormByName(item) {
|
} |
} |
// ]]> |
// ]]> |
</script> |
</script> |
|
ENDSCRIPT |
|
|
|
} |
|
|
|
sub setelements_js { |
|
my ($statusforemail,$types,$usertypes,$othertitle) = @_; |
|
my ($posstypes,$posstypesnames,$availabletypes); |
|
if ((ref($statusforemail) eq 'ARRAY') && (ref($types) eq 'ARRAY') && |
|
(ref($usertypes) eq 'HASH')) { |
|
$posstypes = join("','",@{$types},'default'); |
|
$posstypesnames = join("','",(map {$usertypes->{$_};} @{$types}),$othertitle); |
|
$availabletypes = join("','", @{$statusforemail}); |
|
} |
|
return <<"ENDSCRIPT"; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
|
|
function setElements() { |
|
if (document.getElementById('LC_reportstatus')) { |
|
var reportnum = document.reportstatus.type.length; |
|
if ((reportnum != 'undefined') && (typeof(document.reportstatus.type) != 'undefined')) { |
|
for (var i=0; i<reportnum; i++) { |
|
document.reportstatus.type[i].checked = false; |
|
} |
|
} |
|
} |
|
} |
|
|
|
function checkVerification() { |
|
var curr; |
|
var cancreate = false; |
|
var reportnum = document.reportstatus.type.length; |
|
if ((reportnum == 'undefined') && (typeof(document.reportstatus.type) != 'undefined')) { |
|
curr = document.reportstatus.type.value; |
|
} else if (document.reportstatus.type.length) { |
|
for (var i=0; i<document.reportstatus.type.length; i++) { |
|
if (document.reportstatus.type[i].checked) { |
|
curr = document.reportstatus.type[i].value; |
|
break; |
|
} |
|
} |
|
} |
|
var types = Array('$posstypes'); |
|
var names = Array('$posstypesnames'); |
|
var available = Array('$availabletypes'); |
|
if (available.length) { |
|
for (var i=0; i<available.length; i++) { |
|
if (curr == available[i]) { |
|
cancreate = true; |
|
break; |
|
} |
|
} |
|
} |
|
if (types.length > 0) { |
|
for (var j=0; j<types.length; j++) { |
|
if (curr == types[j]) { |
|
if (!cancreate) { |
|
alert('Creation of an account via verification by e-mail unavailable for user type: "'+names[j]+'"'); |
|
} |
|
break; |
|
} |
|
} |
|
} |
|
if (cancreate) { |
|
return true; |
|
} else { |
|
return false; |
|
} |
|
} |
|
|
|
// ]]> |
|
</script> |
|
ENDSCRIPT |
|
|
|
} |
|
|
|
sub username_js { |
|
return <<"ENDSCRIPT"; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
|
|
function toggleDisplay(caller,divid) { |
|
if (document.getElementById(divid)) { |
|
if (caller.checked) { |
|
if (caller.value == '1') { |
|
document.getElementById(divid).style.display = 'none'; |
|
} else { |
|
document.getElementById(divid).style.display = 'inline'; |
|
} |
|
} |
|
} |
|
} |
|
// ]]> |
|
</script> |
ENDSCRIPT |
ENDSCRIPT |
|
|
} |
} |