--- loncom/interface/loncreateuser.pm 2014/02/19 17:12:52 1.394
+++ loncom/interface/loncreateuser.pm 2016/02/17 19:15:48 1.408
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.394 2014/02/19 17:12:52 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.408 2016/02/17 19:15:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1813,7 +1813,7 @@ sub display_existing_roles {
}
} else {
$plaintext=
- &mt('Customrole [_1][_2]defined by [_3]',
+ &mt('Custom role [_1][_2]defined by [_3]',
'"'.$croletitle.'"',
' ',
$croleuname.':'.$croleudom);
@@ -2164,7 +2164,7 @@ sub modify_login_block {
sub personal_data_display {
my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray,
- $now,$captchaform,$emailusername) = @_;
+ $now,$captchaform,$emailusername,$usertype) = @_;
my ($output,%userenv,%canmodify,%canmodify_status);
my @userinfo = ('firstname','middlename','lastname','generation',
'permanentemail','id');
@@ -2206,19 +2206,24 @@ sub personal_data_display {
\@userinfo,$rolesarray);
} elsif ($context eq 'selfcreate') {
if ($newuser eq 'email') {
- if (ref($emailusername) eq 'HASH') {
- my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info();
- @userinfo = ();
- if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) {
- foreach my $field (@{$infofields}) {
- if ($emailusername->{$field}) {
- push(@userinfo,$field);
- $canmodify{$field} = 1;
- unless ($textboxsize{$field}) {
- $textboxsize{$field} = 25;
- }
- unless ($lt{$field}) {
- $lt{$field} = $infotitles->{$field};
+ if (ref($emailusername) eq 'HASH') {
+ if (ref($emailusername->{$usertype}) eq 'HASH') {
+ my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info();
+ @userinfo = ();
+ if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) {
+ foreach my $field (@{$infofields}) {
+ if ($emailusername->{$usertype}->{$field}) {
+ push(@userinfo,$field);
+ $canmodify{$field} = 1;
+ unless ($textboxsize{$field}) {
+ $textboxsize{$field} = 25;
+ }
+ unless ($lt{$field}) {
+ $lt{$field} = $infotitles->{$field};
+ }
+ if ($emailusername->{$usertype}->{$field} eq 'required') {
+ $lt{$field} .= '*';
+ }
}
}
}
@@ -2234,19 +2239,19 @@ sub personal_data_display {
$output = '
'.$lt{'pd'}.'
'.
&Apache::lonhtmlcommon::start_pick_box();
if (($context eq 'selfcreate') && ($newuser eq 'email')) {
- $output .= &Apache::lonhtmlcommon::row_title($lt{'email'},undef,
+ $output .= &Apache::lonhtmlcommon::row_title($lt{'email'}.'*',undef,
'LC_oddrow_value')."\n".
'';
$rowcount ++;
$output .= &Apache::lonhtmlcommon::row_closure(1);
- my $upassone = '';
- my $upasstwo = '';
- $output .= &Apache::lonhtmlcommon::row_title(&mt('Password'),
+ my $upassone = '';
+ my $upasstwo = '';
+ $output .= &Apache::lonhtmlcommon::row_title(&mt('Password').'*',
'LC_pick_box_title',
'LC_oddrow_value')."\n".
$upassone."\n".
&Apache::lonhtmlcommon::row_closure(1)."\n".
- &Apache::lonhtmlcommon::row_title(&mt('Confirm password'),
+ &Apache::lonhtmlcommon::row_title(&mt('Confirm password').'*',
'LC_pick_box_title',
'LC_oddrow_value')."\n".
$upasstwo.
@@ -2277,19 +2282,15 @@ sub personal_data_display {
}
} else {
if ($context eq 'selfcreate') {
- if (($item eq 'permanentemail') && ($newuser eq 'email')) {
- $row .= $ccuname;
- } else {
- if ($canmodify{$item}) {
- if ($newuser eq 'email') {
- $row .= '';
- } else {
- $row .= '';
- }
- $editable ++;
+ if ($canmodify{$item}) {
+ if ($newuser eq 'email') {
+ $row .= '';
} else {
- $hiderow = 1;
+ $row .= '';
}
+ $editable ++;
+ } else {
+ $hiderow = 1;
}
} else {
$row .= '';
@@ -2360,6 +2361,7 @@ sub personal_data_display {
$output .= &Apache::lonhtmlcommon::row_title()."\n".
' '.
+ ''.
&Apache::lonhtmlcommon::row_closure(1);
}
$output .= &Apache::lonhtmlcommon::end_pick_box();
@@ -2715,7 +2717,7 @@ sub update_user_data {
$r->print($error.'Invalid login mode or password'.$end.$rtnlink);
return;
}
- # Only allow authentification modification if the person has authority
+ # Only allow authentication modification if the person has authority
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
$r->print('Modifying authentication: '.
&Apache::lonnet::modifyuserauth(
@@ -2725,7 +2727,7 @@ sub update_user_data {
($env{'form.ccuname'},$env{'form.ccdomain'}));
} else {
# Okay, this is a non-fatal error.
- $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);
+ $r->print($error.&mt('You do not have the authority to modify this users authentication information.').$end);
}
}
$r->rflush(); # Finish display of header before time consuming actions start
@@ -3042,7 +3044,7 @@ sub update_user_data {
my %newenvhash;
foreach my $key (keys(%changed)) {
if (($key eq 'official') || ($key eq 'unofficial')
- || ($key eq 'community')) {
+ || ($key eq 'community') || ($key eq 'textbook')) {
$newenvhash{'environment.requestcourses.'.$key} =
$changeHash{'requestcourses.'.$key};
if ($changeHash{'requestcourses.'.$key}) {
@@ -3108,7 +3110,7 @@ sub update_user_data {
\%newsettingstext);
if ($env{'form.cid'} ne $userenv{'id'}) {
&Apache::lonnet::idput($env{'form.ccdomain'},
- ($env{'form.ccuname'} => $env{'form.cid'}));
+ {$env{'form.ccuname'} => $env{'form.cid'}},$uhome,'ids');
if (($recurseid) &&
(&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) {
my $idresult =
@@ -3150,9 +3152,9 @@ sub update_user_data {
$rolestr = &mt('No roles');
}
if ($context eq 'course') {
- $contextname = &mt('course');
+ $contextname = 'course';
} elsif ($context eq 'author') {
- $contextname = &mt('co-author');
+ $contextname = 'co-author';
}
$r->print(&mt('The following fields were not updated: ').'
');
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
@@ -3161,9 +3163,9 @@ sub update_user_data {
}
$r->print('
');
if (@mod_disallowed == 1) {
- $r->print(&mt("You do not have the authority to change this field given the user's current set of active/future [_1] roles:",$contextname));
+ $r->print(&mt("You do not have the authority to change this field given the user's current set of active/future $contextname roles:"));
} else {
- $r->print(&mt("You do not have the authority to change these fields given the user's current set of active/future [_1] roles:",$contextname));
+ $r->print(&mt("You do not have the authority to change these fields given the user's current set of active/future $contextname roles:"));
}
my $helplink = 'javascript:helpMenu('."'display'".')';
$r->print(''.$rolestr.' '
@@ -3623,7 +3625,7 @@ sub update_roles {
my @rolechanges;
my %disallowed;
$r->print('
'.&mt('Modifying Roles').'
');
- foreach my $key (keys (%env)) {
+ foreach my $key (keys(%env)) {
next if (! $env{$key});
next if ($key eq 'form.action');
# Revoke roles
@@ -3805,7 +3807,7 @@ sub update_roles {
} else {
my %curr_groups =
&Apache::longroup::coursegroups($one,$two);
- foreach my $sec (sort {$a cmp $b} keys %sections) {
+ foreach my $sec (sort {$a cmp $b} keys(%sections)) {
if (($sec eq 'none') || ($sec eq 'all') ||
exists($curr_groups{$sec})) {
$disallowed{$sec} = $url;
@@ -3851,7 +3853,7 @@ sub update_roles {
my %curr_groups =
&Apache::longroup::coursegroups($one,$two);
my $emptysec = 0;
- foreach my $sec (sort {$a cmp $b} keys %sections) {
+ foreach my $sec (sort {$a cmp $b} keys(%sections)) {
$sec =~ s/\W//g;
if ($sec ne '') {
if (($sec eq 'none') || ($sec eq 'all') ||
@@ -3891,7 +3893,7 @@ sub update_roles {
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context));
} else {
my $emptysec = 0;
- foreach my $sec (sort {$a cmp $b} keys %sections) {
+ foreach my $sec (sort {$a cmp $b} keys(%sections)) {
if ($sec ne '') {
my $securl = $url.'/'.$sec;
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec,$context));
@@ -4816,26 +4818,47 @@ sub handler {
if (ref($domconfig{'usercreation'}) eq 'HASH') {
if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') {
if (ref($domconfig{'usercreation'}{'cancreate'}{'emailusername'}) eq 'HASH') {
- my $count = scalar(keys(%{$domconfig{'usercreation'}{'cancreate'}{'emailusername'}}));
my %info =
&Apache::lonnet::get('nohist_requestedusernames',[$uname],$dom,$domconfiguser);
if (ref($info{$uname}) eq 'HASH') {
- if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) {
- $r->print('
'.&Apache::lonhtmlcommon::start_pick_box());
- my $num;
- foreach my $field (@{$infofields}) {
- next unless ($domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$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 {
- $r->print(&Apache::lonhtmlcommon::row_closure());
+ my $usertype = $info{$uname}{'inststatus'};
+ unless ($usertype) {
+ $usertype = 'default';
+ }
+ if (ref($domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$usertype}) eq 'HASH') {
+ if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) {
+ $r->print('
'.&Apache::lonhtmlcommon::start_pick_box());
+ my ($num,$count,$showstatus);
+ $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 ++;
+ }
+ }
}
+ 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 {
+ $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));
+ }
+ $r->print(&Apache::lonhtmlcommon::end_pick_box().'