--- loncom/interface/loncreateuser.pm 2016/10/04 21:02:16 1.414 +++ loncom/interface/loncreateuser.pm 2016/10/10 02:53:02 1.415 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.414 2016/10/04 21:02:16 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.415 2016/10/10 02:53:02 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -821,7 +821,10 @@ sub print_username_entry_form { } $r->print("

$actiontext

"); if ($env{'form.origform'} ne 'crtusername') { - $r->print("\n".$response); + if ($response) { + $r->print("\n
$response
". + '
'); + } } $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype)); } @@ -5015,19 +5018,7 @@ sub handler { $cdom,$cnum,$coursedesc)); } } elsif ($env{'form.action'} eq 'changelogs') { - my $helpitem; - if ($context eq 'course') { - $helpitem = 'Course_User_Logs'; - } - push (@{$brcrum}, - {href => '/adm/createuser?action=changelogs', - text => 'User Management Logs', - help => $helpitem}); - $bread_crumbs_component = 'User Changes'; - $args = { bread_crumbs => $brcrum, - bread_crumbs_component => $bread_crumbs_component}; - $r->print(&header(undef,$args)); - &print_userchangelogs_display($r,$context,$permission); + &print_userchangelogs_display($r,$context,$permission,$brcrum); } else { $bread_crumbs_component = 'User Management'; $args = { bread_crumbs => $brcrum, @@ -5317,7 +5308,7 @@ sub print_main_menu { {categorytitle => 'Administration', items => [ ]}, ); - + if ($context eq 'domain'){ push(@{ $menu[2]->{items} }, #Category: Administration @@ -6377,7 +6368,7 @@ sub selfenroll_date_forms { } sub print_userchangelogs_display { - my ($r,$context,$permission) = @_; + my ($r,$context,$permission,$brcrum) = @_; my $formname = 'rolelog'; my ($username,$domain,$crstype,%roleslog); if ($context eq 'domain') { @@ -6407,6 +6398,32 @@ sub print_userchangelogs_display { } if ((keys(%roleslog))[0]=~/^error\:/) { undef(%roleslog); } + my $helpitem; + if ($context eq 'course') { + $helpitem = 'Course_User_Logs'; + } + push (@{$brcrum}, + {href => '/adm/createuser?action=changelogs', + text => 'User Management Logs', + help => $helpitem}); + my $bread_crumbs_component = 'User Changes'; + my $args = { bread_crumbs => $brcrum, + bread_crumbs_component => $bread_crumbs_component}; + + # Create navigation javascript + my $jsnav = &userlogdisplay_js($formname); + + my $jscript = (< +// + +ENDSCRIPT + + # print page header + $r->print(&header($jscript,$args)); + # set defaults my $now = time(); my $defstart = $now - (7*24*3600); #7 days ago @@ -6439,7 +6456,9 @@ sub print_userchangelogs_display { my ($minshown,$maxshown); $minshown = 1; my $count = 0; - if ($curr{'show'} ne &mt('all')) { + if ($curr{'show'} =~ /\D/) { + $curr{'page'} = 1; + } else { $maxshown = $curr{'page'} * $curr{'show'}; if ($curr{'page'} > 1) { $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'}; @@ -6451,8 +6470,6 @@ sub print_userchangelogs_display { &role_display_filter($context,$formname,$domain,$username,\%curr, $version,$crstype)); - # Create navigation - my ($nav_script,$nav_links) = &userlogdisplay_nav($formname,\%curr,$more_records); my $showntableheader = 0; # Table Header @@ -6477,7 +6494,7 @@ sub print_userchangelogs_display { foreach my $id (sort { $roleslog{$b}{'exe_time'}<=>$roleslog{$a}{'exe_time'} } (keys(%roleslog))) { next if (($roleslog{$id}{'exe_time'} < $curr{'rolelog_start_date'}) || ($roleslog{$id}{'exe_time'} > $curr{'rolelog_end_date'})); - if ($curr{'show'} ne &mt('all')) { + if ($curr{'show'} !~ /\D/) { if ($count >= $curr{'page'} * $curr{'show'}) { $more_records = 1; last; @@ -6496,9 +6513,7 @@ sub print_userchangelogs_display { $count ++; next if ($count < $minshown); unless ($showntableheader) { - $r->print($nav_script - .$nav_links - .&Apache::loncommon::start_data_table() + $r->print(&Apache::loncommon::start_data_table() .$tableheader); $r->rflush(); $showntableheader = 1; @@ -6559,8 +6574,8 @@ sub print_userchangelogs_display { } if ($showntableheader) { # Table footer, if content displayed above - $r->print(&Apache::loncommon::end_data_table() - .$nav_links); + $r->print(&Apache::loncommon::end_data_table(). + &userlogdisplay_navlinks(\%curr,$more_records)); } else { # No content displayed above $r->print('

' .&mt('There are no records to display.') @@ -6576,15 +6591,10 @@ sub print_userchangelogs_display { return; } -sub userlogdisplay_nav { - my ($formname,$curr,$more_records) = @_; - my ($nav_script,$nav_links); - if (ref($curr) eq 'HASH') { - # Create Navigation: - # Navigation Script - $nav_script = <<"ENDSCRIPT"; - ENDSCRIPT - # Navigation Buttons - $nav_links = '

'; - if (($curr->{'page'} > 1) || ($more_records)) { - if ($curr->{'page'} > 1) { - $nav_links .= ' '; - } - if ($more_records) { - $nav_links .= ''; - } +} + +sub userlogdisplay_navlinks { + my ($curr,$more_records) = @_; + return unless(ref($curr) eq 'HASH'); + # Navigation Buttons + my $nav_links = '

'; + if (($curr->{'page'} > 1) || ($more_records)) { + if (($curr->{'page'} > 1) && ($curr->{'show'} !~ /\D/)) { + $nav_links .= ' '; + } + if ($more_records) { + $nav_links .= ''; } - $nav_links .= '

'; } - return ($nav_script,$nav_links); + $nav_links .= '

'; + return $nav_links; } sub role_display_filter { @@ -6806,7 +6818,7 @@ sub user_search_result { if ($domd_chk eq 'ok') { $response .= &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.'); } - $response .= '

'; + $response .= '
'; } } else { unless (($context eq 'requestcrs') && ($srch->{'srchtype'} eq 'exact')) { @@ -6817,7 +6829,7 @@ sub user_search_result { if ($instd_chk eq 'ok') { $response .= &mt('You may want to search in the institutional directory instead of the LON-CAPA domain.'); } - $response .= '

'; + $response .= '
'; } } } @@ -6914,7 +6926,7 @@ sub user_search_result { &mt('Institutional directory search is not available in domain: [_1]',$showdom). '
'. &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.'). - '

'; + '
'; } } } else { @@ -6987,7 +6999,7 @@ sub user_search_result { &mt('Institutional directory search is not available in domain: [_1]',$showdom). '
'. &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.'). - '

'; + '
'; } } } @@ -7215,7 +7227,7 @@ sub build_search_response { .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.' ,' ' ,'') - .'

'; + .'
'; } } }