[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface loncreateuser.pm
raeburn
raeburn at source.lon-capa.org
Tue Jul 30 09:55:17 EDT 2019
raeburn Tue Jul 30 13:55:17 2019 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface loncreateuser.pm
Log:
- For 2.11
Backport 1.442, 1.443
-------------- next part --------------
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.406.2.15 loncom/interface/loncreateuser.pm:1.406.2.16
--- loncom/interface/loncreateuser.pm:1.406.2.15 Fri Sep 14 14:57:52 2018
+++ loncom/interface/loncreateuser.pm Tue Jul 30 13:55:16 2019
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.406.2.15 2018/09/14 14:57:52 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.406.2.16 2019/07/30 13:55:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2345,7 +2345,7 @@
sub personal_data_display {
my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray,
- $now,$captchaform,$emailusername,$usertype) = @_;
+ $now,$captchaform,$emailusername,$usertype,$usernameset,$condition,$excluded) = @_;
my ($output,%userenv,%canmodify,%canmodify_status);
my @userinfo = ('firstname','middlename','lastname','generation',
'permanentemail','id');
@@ -2372,6 +2372,7 @@
'inststatus' => "Affiliation",
'email' => 'E-mail address',
'valid' => 'Validation',
+ 'username' => 'Username',
);
%canmodify_status =
@@ -2390,7 +2391,7 @@
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}) {
@@ -2420,9 +2421,38 @@
$output = '<h3>'.$lt{'pd'}.'</h3>'.
&Apache::lonhtmlcommon::start_pick_box();
if (($context eq 'selfcreate') && ($newuser eq 'email')) {
+ my $size = 25;
+ if ($condition) {
+ if ($condition =~ /^\@[^\@]+$/) {
+ $size = 10;
+ } else {
+ undef($condition);
+ }
+ }
+ if ($excluded) {
+ unless ($excluded =~ /^\@[^\@]+$/) {
+ undef($condition);
+ }
+ }
$output .= &Apache::lonhtmlcommon::row_title($lt{'email'}.'<b>*</b>',undef,
'LC_oddrow_value')."\n".
- '<input type="text" name="uname" size="25" value="" autocomplete="off" />';
+ '<input type="text" name="uname" size="'.$size.'" value="" autocomplete="off" />';
+ if ($condition) {
+ $output .= $condition;
+ } elsif ($excluded) {
+ $output .= '<br /><span style="font-size: smaller">'.&mt('You must use an e-mail address that does not end with [_1]',
+ $excluded).'</span>';
+ }
+ if ($usernameset eq 'first') {
+ $output .= '<br /><span style="font-size: smaller">';
+ if ($condition) {
+ $output .= &mt('Your username in LON-CAPA will be the part of your e-mail address before [_1]',
+ $condition);
+ } else {
+ $output .= &mt('Your username in LON-CAPA will be the part of your e-mail address before the @');
+ }
+ $output .= '</span>';
+ }
$rowcount ++;
$output .= &Apache::lonhtmlcommon::row_closure(1);
my $upassone = '<input type="password" name="upass'.$now.'" size="20" autocomplete="off" />';
@@ -2437,6 +2467,19 @@
'LC_oddrow_value')."\n".
$upasstwo.
&Apache::lonhtmlcommon::row_closure()."\n";
+ if ($usernameset eq 'free') {
+ my $onclick = "toggleUsernameDisp(this,'selfcreateusername');";
+ $output .= &Apache::lonhtmlcommon::row_title($lt{'username'},undef,'LC_oddrow_value')."\n".
+ &mt('Use e-mail address: ').
+ '<label><input type="radio" name="emailused" value="1" checked="checked" onclick="'.$onclick.'" />'.&mt('Yes').'</label>'."\n".
+ (' 'x2).
+ '<label><input type="radio" name="emailused" value="0" onclick="'.$onclick.'" />'.&mt('No').'</label>'."\n".
+ '<div id="selfcreateusername" style="display: none; font-size: smaller">'.
+ '<br /><span class="LC_nobreak">'.&mt('Preferred username').
+ ' <input type="text" name="username" value="" size="20" autocomplete="off"/>'.
+ '</span></div>'."\n".&Apache::lonhtmlcommon::row_closure(1);
+ $rowcount ++;
+ }
}
foreach my $item (@userinfo) {
my $rowtitle = $lt{$item};
@@ -4935,47 +4978,77 @@
unless ($usertype) {
$usertype = 'default';
}
+ my ($showstatus,$showemail,$pickstart);
+ my $numextras = 0;
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ if ((ref($types) eq 'ARRAY') && (@{$types} > 0)) {
+ if (ref($usertypes) eq 'HASH') {
+ if ($usertypes->{$usertype}) {
+ $showstatus = $usertypes->{$usertype};
+ } else {
+ $showstatus = $othertitle;
+ }
+ if ($showstatus) {
+ $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('<div>'.&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('<div>'.&Apache::lonhtmlcommon::start_pick_box());
+ $pickstart = 1;
+ }
+ if ($showemail) {
+ my $closure = '';
+ unless ($showstatus) {
+ $closure = 1;
}
- $r->print(&Apache::lonhtmlcommon::end_pick_box().'</div>');
+ $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)','<br />')).
+ $showstatus.
+ &Apache::lonhtmlcommon::row_closure(1));
}
}
+ if ($pickstart) {
+ $r->print(&Apache::lonhtmlcommon::end_pick_box().'</div>');
+ } else {
+ $r->print('<div>'.&mt('No information to display for this account request.').'</div>');
+ }
+ } else {
+ $r->print('<div>'.&mt('No information available for this account request.').'</div>');
}
}
}
}
- $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';
More information about the LON-CAPA-cvs
mailing list