--- loncom/interface/loncreateuser.pm 2016/11/12 00:16:24 1.421 +++ loncom/interface/loncreateuser.pm 2016/11/12 00:39:39 1.422 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.421 2016/11/12 00:16:24 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.422 2016/11/12 00:39:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -757,7 +757,7 @@ sub print_username_entry_form { } elsif ($env{'form.action'} eq 'accesslogs') { $helpitem = 'Domain_User_Access_Logs'; } - my %breadcrumb_text = &singleuser_breadcrumb($crstype); + my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$defdom); if ($env{'form.action'} eq 'custom') { push(@{$brcrum}, {href=>"javascript:backPage(document.crtuser)", @@ -785,6 +785,7 @@ sub print_username_entry_form { 'srst' => 'Search for a user and enroll as a student', 'srme' => 'Search for a user and enroll as a member', 'srad' => 'Search for a user and modify/add user information or roles', + 'srvu' => 'Search for a user and view user information and roles', 'srva' => 'Search for a user and view access log information', 'usr' => "Username", 'dom' => "Domain", @@ -840,6 +841,9 @@ sub print_username_entry_form { } } elsif ($env{'form.action'} eq 'accesslogs') { $actiontext = $lt{'srva'}; + } elsif (($env{'form.action'} eq 'singleuser') && + ($context eq 'domain') && (!&Apache::lonnet::allowed('mau',$defdom))) { + $actiontext = $lt{'srvu'}; } $r->print("

$actiontext

"); if ($env{'form.origform'} ne 'crtusername') { @@ -933,7 +937,9 @@ ENDBLOCK } else { $output = '

'.$userpicker.'

'; } - if (($env{'form.phase'} eq '') && ($env{'form.action'} ne 'accesslogs')) { + if (($env{'form.phase'} eq '') && ($env{'form.action'} ne 'accesslogs') && + (!(($env{'form.action'} eq 'singleuser') && ($context eq 'domain') && + (!&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))))) { my $defdom=$env{'request.role.domain'}; my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain'); my %lt=&Apache::lonlocal::texthash( @@ -1050,7 +1056,9 @@ ENDSCRIPT 'stusrch' => "User Search to enroll student", 'memsrch' => "User Search to enroll member", 'srcva' => "Search for a user and view access log information", + 'usrvu' => "User Search to view user roles", 'usel' => "Select a user to add/modify roles", + 'suvr' => "Select a user to view roles", 'stusel' => "Select a user to enroll as a student", 'memsel' => "Select a user to enroll as a member", 'vacsel' => "Select a user to view access log", @@ -1063,7 +1071,7 @@ ENDSCRIPT if ($context eq 'requestcrs') { $r->print('
'); } else { - my %breadcrumb_text = &singleuser_breadcrumb($crstype); + my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$srch->{'srchdomain'}); my $helpitem; if ($env{'form.action'} eq 'singleuser') { $helpitem = 'Course_Change_Privileges'; @@ -1083,9 +1091,19 @@ ENDSCRIPT ); $r->print(&Apache::loncommon::start_page('User Management',$jscript,{bread_crumbs => $brcrum})); if ($env{'form.action'} eq 'singleuser') { - $r->print("$lt{'usrch'}
"); + my $readonly; + if (($context eq 'domain') && (!&Apache::lonnet::allowed('mau',$srch->{'srchdomain'}))) { + $readonly = 1; + $r->print("$lt{'usrvu'}
"); + } else { + $r->print("$lt{'usrch'}
"); + } $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context,undef,$crstype)); - $r->print('

'.$lt{'usel'}.'

'); + if ($readonly) { + $r->print('

'.$lt{'suvr'}.'

'); + } else { + $r->print('

'.$lt{'usel'}.'

'); + } } elsif ($env{'form.action'} eq 'singlestudent') { $r->print($jscript.""); if ($crstype eq 'Community') { @@ -1279,7 +1297,7 @@ sub print_user_modification_page { my $js = &validation_javascript($context,$ccdomain,$pjump_def,$crstype, $groupslist,$newuser,$formname,\%loaditem); - my %breadcrumb_text = &singleuser_breadcrumb($crstype); + my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$ccdomain); my $helpitem = 'Course_Change_Privileges'; if ($env{'form.action'} eq 'singlestudent') { $helpitem = 'Course_Add_Student'; @@ -1654,7 +1672,7 @@ ENDNOTOOLSPRIV } sub singleuser_breadcrumb { - my ($crstype) = @_; + my ($crstype,$context,$domain) = @_; my %breadcrumb_text; if ($env{'form.action'} eq 'singlestudent') { if ($crstype eq 'Community') { @@ -1662,16 +1680,21 @@ sub singleuser_breadcrumb { } else { $breadcrumb_text{'search'} = 'Enroll a student'; } - $breadcrumb_text{'userpicked'} = 'Select a user', - $breadcrumb_text{'modify'} = 'Set section/dates', + $breadcrumb_text{'userpicked'} = 'Select a user'; + $breadcrumb_text{'modify'} = 'Set section/dates'; } elsif ($env{'form.action'} eq 'accesslogs') { $breadcrumb_text{'search'} = 'View access logs for a user'; - $breadcrumb_text{'userpicked'} = 'Select a user', - $breadcrumb_text{'activity'} = 'Activity', + $breadcrumb_text{'userpicked'} = 'Select a user'; + $breadcrumb_text{'activity'} = 'Activity'; + } elsif (($env{'form.action'} eq 'singleuser') && ($context eq 'domain') && + (!&Apache::lonnet::allowed('mau',$domain))) { + $breadcrumb_text{'search'} = "View user's roles"; + $breadcrumb_text{'userpicked'} = 'Select a user'; + $breadcrumb_text{'modify'} = 'User roles'; } else { $breadcrumb_text{'search'} = 'Create/modify a user'; - $breadcrumb_text{'userpicked'} = 'Select a user', - $breadcrumb_text{'modify'} = 'Set user role', + $breadcrumb_text{'userpicked'} = 'Select a user'; + $breadcrumb_text{'modify'} = 'Set user role'; } return %breadcrumb_text; } @@ -2689,7 +2712,7 @@ sub update_user_data { $jsback."\n". '// ]]>'."\n". ''."\n"; - my %breadcrumb_text = &singleuser_breadcrumb($crstype); + my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$env{'form.ccdomain'}); push (@{$brcrum}, {href => "javascript:backPage(document.userupdate)", text => $breadcrumb_text{'search'}, @@ -6814,7 +6837,7 @@ sub print_useraccesslogs_display { my $form = 'document.accesslog'; # set breadcrumbs - my %breadcrumb_text = &singleuser_breadcrumb(); + my %breadcrumb_text = &singleuser_breadcrumb('','domain',$udom); push (@{$brcrum}, {href => "javascript:backPage($form)", text => $breadcrumb_text{'search'}}); @@ -7762,18 +7785,21 @@ sub build_search_response { .&mt("Click 'Search'") .'
'; } else { - my $helplink = ' href="javascript:helpMenu('."'display'".')"'; - $response .= '

'; - if ($context eq 'requestcrs') { - $response .= &mt("You are not authorized to define new users in the new course's domain - [_1].",$targetdom); - } else { - $response .= &mt("You are not authorized to create new users in your current role's domain - [_1].",$targetdom); + unless (($context eq 'domain') && ($env{'form.action'} eq 'singleuser')) { + my $helplink = ' href="javascript:helpMenu('."'display'".')"'; + $response .= '

'; + if ($context eq 'requestcrs') { + $response .= &mt("You are not authorized to define new users in the new course's domain - [_1].",$targetdom); + } else { + $response .= &mt("You are not authorized to create new users in your current role's domain - [_1].",$targetdom); + } + $response .= '
' + .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.' + ,' ' + ,'') + .'
'; + } - $response .= '
' - .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.' - ,' ' - ,'') - .'
'; } } }