--- loncom/interface/loncreateuser.pm 2014/02/15 19:31:22 1.392 +++ loncom/interface/loncreateuser.pm 2014/03/03 17:11:41 1.396 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.392 2014/02/15 19:31:22 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.396 2014/03/03 17:11:41 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1271,11 +1271,9 @@ ENDTITLE } $r->print('

'.$title.'

'."\n"); $r->print('
'); - my $personal_table = - &personal_data_display($ccuname,$ccdomain,$newuser,$context, - $inst_results{$ccuname.':'.$ccdomain}); - # (Do not offer Disable Safeguard here) - $r->print($personal_table); + $r->print(&personal_data_display($ccuname,$ccdomain,$newuser,$context, + $inst_results{$ccuname.':'.$ccdomain})); + # Option to disable student/employee ID conflict checking not offerred for new users. my ($home_server_pick,$numlib) = &Apache::loncommon::home_server_form_item($ccdomain,'hserver', 'default','hide'); @@ -1376,10 +1374,8 @@ ENDAUTH } $r->print('

'.$title.'

'."\n"); $r->print('
'); - my $personal_table = - &personal_data_display($ccuname,$ccdomain,$newuser,$context, - $inst_results{$ccuname.':'.$ccdomain}); - $r->print($personal_table); + $r->print(&personal_data_display($ccuname,$ccdomain,$newuser,$context, + $inst_results{$ccuname.':'.$ccdomain})); if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { $r->print('

'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'

'. &Apache::loncommon::start_data_table()); @@ -1475,7 +1471,8 @@ ENDNOTOOLSPRIV } $r->print('
'."\n"); } else { - $r->print('
'.&mt('Add Roles').''); + $r->print('
'. + '
'.&mt('Add Roles').''); my $addrolesdisplay = 0; if ($context eq 'domain' || $context eq 'author') { $addrolesdisplay = &new_coauthor_roles($r,$ccuname,$ccdomain); @@ -1486,27 +1483,32 @@ ENDNOTOOLSPRIV $addrolesdisplay = $add_domainroles; } $r->print(&course_level_dc($env{'request.role.domain'},$showcredits)); - $r->print('

'."\n"); + $r->print('
'. + '
'."\n"); } elsif ($context eq 'author') { if ($addrolesdisplay) { - $r->print('
print('
'. + '
print(' onclick="auth_check()" \>'."\n"); } else { $r->print('onclick="this.form.submit()" \>'."\n"); } } else { - $r->print('
'. + $r->print(''. + ''. + '
'. &mt('Back to previous page').''); } } else { $r->print(&course_level_table(\%inccourses,$showcredits,$defaultcredits)); - $r->print('
'."\n"); + $r->print(''. + '
'."\n"); } } $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain'])); $r->print(''); - $r->print(''); + $r->print('

'); return; } @@ -1811,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); @@ -1861,7 +1863,7 @@ sub display_existing_roles { } else { $contextrole = &mt('Existing Roles in this Domain'); } - $r->print('
'. + $r->print('
'. '
'.$contextrole.''. &Apache::loncommon::start_data_table("LC_createuser"). &Apache::loncommon::start_data_table_header_row(). @@ -2162,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'); @@ -2204,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} .= '*'; + } } } } @@ -2232,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. @@ -2264,7 +2271,7 @@ sub personal_data_display { } else { if ($context eq 'selfcreate') { if ($canmodify{$item}) { - $row .= ''; + $row .= ''; $editable ++; } else { $hiderow = 1; @@ -2280,9 +2287,9 @@ sub personal_data_display { } else { if ($canmodify{$item}) { if ($newuser eq 'email') { - $row .= ''; + $row .= ''; } else { - $row .= ''; + $row .= ''; } $editable ++; } else { @@ -2296,12 +2303,12 @@ sub personal_data_display { } else { if ($canmodify{$item}) { $row .= ''; + if (($item eq 'id') && (!$newuser)) { + $row .= '
'.&Apache::lonuserutils::forceid_change($context); + } } else { $row .= $userenv{$item}; } - if (($item eq 'id') && ($canmodify{$item})) { - $row .= '
'.&Apache::lonuserutils::forceid_change($context); - } } $row .= &Apache::lonhtmlcommon::row_closure(1); if (!$hiderow) { @@ -2358,6 +2365,7 @@ sub personal_data_display { $output .= &Apache::lonhtmlcommon::row_title()."\n". '
'. + ''. &Apache::lonhtmlcommon::row_closure(1); } $output .= &Apache::lonhtmlcommon::end_pick_box(); @@ -2713,7 +2721,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( @@ -2723,7 +2731,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 @@ -4177,6 +4185,7 @@ sub custom_role_editor { my $dompriv=''; my $coursepriv=''; my $body_top; + my $newrole; my ($rdummy,$roledef)= &Apache::lonnet::get('roles',["rolesdef_$rolename"]); # ------------------------------------------------------- Does this role exist? @@ -4189,6 +4198,7 @@ sub custom_role_editor { $syspriv =~ s/bre\&S//; } } else { + $newrole = 1; $body_top .= &mt('New Role').' "'; $roledef=''; } @@ -4458,6 +4468,7 @@ sub set_custom_role { bread_crumbs_component => 'User Management'}; $r->print(&Apache::loncommon::start_page('Save Custom Role',$jscript,$args)); + my $newrole; my ($rdummy,$roledef)= &Apache::lonnet::get('roles',["rolesdef_$rolename"]); @@ -4468,6 +4479,7 @@ sub set_custom_role { } else { $r->print(&mt('New Role').' "'); $roledef=''; + $newrole = 1; } $r->print($rolename.'"'); # ------------------------------------------------------- What can be assigned? @@ -4810,26 +4822,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().'
'); } - $r->print(&Apache::lonhtmlcommon::end_pick_box().'
'); } } }