--- loncom/interface/loncreateuser.pm 2017/07/26 19:42:22 1.441 +++ loncom/interface/loncreateuser.pm 2017/07/26 19:45:45 1.442 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.441 2017/07/26 19:42:22 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.442 2017/07/26 19:45:45 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2352,7 +2352,7 @@ sub modify_login_block { sub personal_data_display { my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray, - $now,$captchaform,$emailusername,$usertype) = @_; + $now,$captchaform,$emailusername,$usertype,$usernameset,$condition) = @_; my ($output,%userenv,%canmodify,%canmodify_status); my @userinfo = ('firstname','middlename','lastname','generation', 'permanentemail','id'); @@ -2379,6 +2379,7 @@ sub personal_data_display { 'inststatus' => "Affiliation", 'email' => 'E-mail address', 'valid' => 'Validation', + 'username' => 'Username', ); %canmodify_status = @@ -2397,7 +2398,7 @@ sub personal_data_display { if (ref($emailusername) eq 'HASH') { if (ref($emailusername->{$usertype}) eq 'HASH') { my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info(); - @userinfo = (); + @userinfo = (); if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) { foreach my $field (@{$infofields}) { if ($emailusername->{$usertype}->{$field}) { @@ -2427,9 +2428,16 @@ sub personal_data_display { $output = '

'.$lt{'pd'}.'

'. &Apache::lonhtmlcommon::start_pick_box(); if (($context eq 'selfcreate') && ($newuser eq 'email')) { + if ($condition) { + if ($condition =~ /[-\w]+\.[-\w]+$/) { + $condition = '@'.$condition; + } else { + undef($condition); + } + } $output .= &Apache::lonhtmlcommon::row_title($lt{'email'}.'*',undef, 'LC_oddrow_value')."\n". - ''; + ''; $rowcount ++; $output .= &Apache::lonhtmlcommon::row_closure(1); my $upassone = ''; @@ -2444,6 +2452,19 @@ sub personal_data_display { 'LC_oddrow_value')."\n". $upasstwo. &Apache::lonhtmlcommon::row_closure()."\n"; + if ($usernameset) { + my $onclick = "toggleDisplay(this,'selfcreateusername');"; + $output .= &Apache::lonhtmlcommon::row_title($lt{'username'},undef,'LC_oddrow_value')."\n". + &mt('Use e-mail address: '). + ''."\n". + (' 'x2). + ''."\n". + ''."\n".&Apache::lonhtmlcommon::row_closure(1); + $rowcount ++; + } } foreach my $item (@userinfo) { my $rowtitle = $lt{$item}; @@ -4919,47 +4940,73 @@ sub handler { unless ($usertype) { $usertype = 'default'; } + my ($showstatus,$showemail,$pickstart); + my $numextras = 0; + my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); + if (ref($usertypes) eq 'HASH') { + if ($usertypes->{$usertype}) { + $showstatus = $usertypes->{$usertype}; + } else { + $showstatus = $othertitle; + } + $numextras ++; + } + if (($info{$uname}{'email'} ne '') && ($info{$uname}{'email'} ne $uname)) { + $showemail = $info{$uname}{'email'}; + $numextras ++; + } if (ref($domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$usertype}) eq 'HASH') { if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) { + $pickstart = 1; $r->print('
'.&Apache::lonhtmlcommon::start_pick_box()); - my ($num,$count,$showstatus); + my ($num,$count); $count = scalar(keys(%{$domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$usertype}})); - unless ($usertype eq 'default') { - my ($othertitle,$usertypes,$types) = - &Apache::loncommon::sorted_inst_types($dom); - if (ref($usertypes) eq 'HASH') { - if ($usertypes->{$usertype}) { - $showstatus = $usertypes->{$usertype}; - $count ++; - } - } - } + $count += $numextras; foreach my $field (@{$infofields}) { next unless ($domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$usertype}{$field}); next unless ($infotitles->{$field}); $r->print(&Apache::lonhtmlcommon::row_title($infotitles->{$field}). $info{$uname}{$field}); $num ++; - if ($count == $num) { - $r->print(&Apache::lonhtmlcommon::row_closure(1)); - } else { + unless ($count == $num) { $r->print(&Apache::lonhtmlcommon::row_closure()); } } - if ($showstatus) { - $r->print(&Apache::lonhtmlcommon::row_title(&mt('Status type (self-reported)')). - $showstatus. - &Apache::lonhtmlcommon::row_closure(1)); + } + } + if ($numextras) { + unless ($pickstart) { + $r->print('
'.&Apache::lonhtmlcommon::start_pick_box()); + $pickstart = 1; + } + if ($showemail) { + my $closure = ''; + unless ($showstatus) { + $closure = 1; } - $r->print(&Apache::lonhtmlcommon::end_pick_box().'
'); + $r->print(&Apache::lonhtmlcommon::row_title(&mt('E-mail address')). + $showemail. + &Apache::lonhtmlcommon::row_closure($closure)); } + if ($showstatus) { + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Status type[_1](self-reported)','
')). + $showstatus. + &Apache::lonhtmlcommon::row_closure(1)); + } + } + if ($pickstart) { + $r->print(&Apache::lonhtmlcommon::end_pick_box().'
'); + } else { + $r->print('
'.&mt('No information to display for this account request.').'
'); } + } else { + $r->print('
'.&mt('No information available for this account request.').'
'); } } } } - $r->print(&close_popup_form()); } + $r->print(&close_popup_form()); } elsif (($env{'form.action'} eq 'listusers') && ($permission->{'view'} || $permission->{'cusr'})) { my $helpitem = 'Course_View_Class_List';