[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm
raeburn
raeburn@source.lon-capa.org
Wed, 18 Nov 2009 21:24:40 -0000
raeburn Wed Nov 18 21:24:40 2009 EDT
Modified files:
/loncom/interface loncreateuser.pm
Log:
- Restore earlier optimizations by reversing some of 1.301 changes.
- Users can choose to display up to 10,000 records/page so ...
print immediately from within loop instead of storing to a scalar.
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.326 loncom/interface/loncreateuser.pm:1.327
--- loncom/interface/loncreateuser.pm:1.326 Wed Nov 18 20:01:36 2009
+++ loncom/interface/loncreateuser.pm Wed Nov 18 21:24:40 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.326 2009/11/18 20:01:36 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.327 2009/11/18 21:24:40 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -5161,7 +5161,6 @@
my %roleslog=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);
if ((keys(%roleslog))[0]=~/^error\:/) { undef(%roleslog); }
- $r->print('<form action="/adm/createuser" method="post" name="'.$formname.'">');
my %saveable_parameters = ('show' => 'scalar',);
&Apache::loncommon::store_course_settings('roles_log',
\%saveable_parameters);
@@ -5196,7 +5195,6 @@
}
my (%whodunit,%changed,$version);
($version) = ($r->dir_config('lonVersion') =~ /^([\d\.]+)\-/);
- $r->print(&role_display_filter($formname,$cdom,$cnum,\%curr,$version,$crstype));
my ($minshown,$maxshown);
$minshown = 1;
my $count = 0;
@@ -5207,8 +5205,29 @@
}
}
- # Collect user change log data
- my $content = '';
+ # Form Header
+ $r->print('<form action="/adm/createuser" method="post" name="'.$formname.'">'.
+ &role_display_filter($formname,$cdom,$cnum,\%curr,$version,$crstype));
+
+ # Create navigation
+ my ($nav_script,$nav_links) = &userlogdisplay_nav($formname,\%curr,$more_records);
+ my $showntableheader = 0;
+
+ # Table Header
+ my $tableheader =
+ &Apache::loncommon::start_data_table_header_row()
+ .'<th> </th>'
+ .'<th>'.&mt('When').'</th>'
+ .'<th>'.&mt('Who made the change').'</th>'
+ .'<th>'.&mt('Changed User').'</th>'
+ .'<th>'.&mt('Role').'</th>'
+ .'<th>'.&mt('Section').'</th>'
+ .'<th>'.&mt('Context').'</th>'
+ .'<th>'.&mt('Start').'</th>'
+ .'<th>'.&mt('End').'</th>'
+ .&Apache::loncommon::end_data_table_header_row();
+
+ # Display user change log data
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'}));
@@ -5230,7 +5249,14 @@
}
$count ++;
next if ($count < $minshown);
-
+ unless ($showntableheader) {
+ $r->print($nav_script
+ .$nav_links
+ .&Apache::loncommon::start_data_table()
+ .$tableheader);
+ $r->rflush();
+ $showntableheader = 1;
+ }
if ($whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}} eq '') {
$whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}} =
&Apache::loncommon::plainname($roleslog{$id}{'exe_uname'},$roleslog{$id}{'exe_udom'});
@@ -5269,7 +5295,7 @@
if ($chgcontext ne '' && $lt{$chgcontext} ne '') {
$chgcontext = $lt{$chgcontext};
}
- $content .=
+ $r->print(
&Apache::loncommon::start_data_table_row()
.'<td>'.$count.'</td>'
.'<td>'.&Apache::lonlocal::locallocaltime($roleslog{$id}{'exe_time'}).'</td>'
@@ -5280,30 +5306,34 @@
.'<td>'.$chgcontext.'</td>'
.'<td>'.$rolestart.'</td>'
.'<td>'.$roleend.'</td>'
- .&Apache::loncommon::end_data_table_row();
+ .&Apache::loncommon::end_data_table_row()."\n");
}
- # Form Footer
- my $form_footer =
- '<input type="hidden" name="page" value="'.$curr{'page'}.'" />'
- .'<input type="hidden" name="action" value="changelogs" />'
- .'</form>';
-
- # Only display table, if content is available (has been collected above)
- if (!$content) {
+ if ($showntableheader) { # Table footer, if content displayed above
+ $r->print(&Apache::loncommon::end_data_table()
+ .$nav_links);
+ } else { # No content displayed above
$r->print('<p class="LC_info">'
.&mt('There are no records to display.')
.'</p>'
);
- $r->print($form_footer);
- return;
}
- # Content to display, so create navigation and display table
+ # Form Footer
+ $r->print(
+ '<input type="hidden" name="page" value="'.$curr{'page'}.'" />'
+ .'<input type="hidden" name="action" value="changelogs" />'
+ .'</form>');
+ return;
+}
- # Create Navigation:
- # Navigation Script
- my $nav_script = <<"ENDSCRIPT";
+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";
<script type="text/javascript">
// <![CDATA[
function chgPage(caller) {
@@ -5313,57 +5343,31 @@
if (caller == 'next') {
document.$formname.page.value ++;
}
- document.$formname.submit();
+ document.$formname.submit();
return;
}
// ]]>
</script>
ENDSCRIPT
- # Navigation Buttons
- my $nav_links;
- $nav_links = '<p>';
- if (($curr{'page'} > 1) || ($more_records)) {
- if ($curr{'page'} > 1) {
- $nav_links .= '<input type="button"'
- .' onclick="javascript:chgPage('."'previous'".');"'
- .' value="'.&mt('Previous [_1] changes',$curr{'show'})
- .'" /> ';
- }
- if ($more_records) {
- $nav_links .= '<input type="button"'
- .' onclick="javascript:chgPage('."'next'".');"'
- .' value="'.&mt('Next [_1] changes',$curr{'show'})
- .'" />';
+ # Navigation Buttons
+ $nav_links = '<p>';
+ if (($curr->{'page'} > 1) || ($more_records)) {
+ if ($curr->{'page'} > 1) {
+ $nav_links .= '<input type="button"'
+ .' onclick="javascript:chgPage('."'previous'".');"'
+ .' value="'.&mt('Previous [_1] changes',$curr->{'show'})
+ .'" /> ';
+ }
+ if ($more_records) {
+ $nav_links .= '<input type="button"'
+ .' onclick="javascript:chgPage('."'next'".');"'
+ .' value="'.&mt('Next [_1] changes',$curr->{'show'})
+ .'" />';
+ }
}
+ $nav_links .= '</p>';
}
- $nav_links .= '</p>';
-
- # Table Header
- my $tableheader =
- &Apache::loncommon::start_data_table_header_row()
- .'<th> </th>'
- .'<th>'.&mt('When').'</th>'
- .'<th>'.&mt('Who made the change').'</th>'
- .'<th>'.&mt('Changed User').'</th>'
- .'<th>'.&mt('Role').'</th>'
- .'<th>'.&mt('Section').'</th>'
- .'<th>'.&mt('Context').'</th>'
- .'<th>'.&mt('Start').'</th>'
- .'<th>'.&mt('End').'</th>'
- .&Apache::loncommon::end_data_table_header_row();
-
- # Print Content
- $r->print(
- $nav_script
- .$nav_links
- .&Apache::loncommon::start_data_table()
- .$tableheader
- .$content
- .&Apache::loncommon::end_data_table()
- .$nav_links
- .$form_footer
- );
- return;
+ return ($nav_script,$nav_links);
}
sub role_display_filter {