[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm

raeburn raeburn at source.lon-capa.org
Sun Oct 9 22:53:03 EDT 2016


raeburn		Mon Oct 10 02:53:03 2016 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm 
  Log:
  - "Previous N changes" and "Next N changes" buttons available if changes/page
    set (N) such that results require more than 1 page. 
    - javascript for chgPage() function is passed to start_page().
    - &userlogdisplay_navlinks() is called after looping over role log items
      so that $more_records value has been set.
  
  
-------------- next part --------------
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.414 loncom/interface/loncreateuser.pm:1.415
--- loncom/interface/loncreateuser.pm:1.414	Tue Oct  4 21:02:16 2016
+++ loncom/interface/loncreateuser.pm	Mon Oct 10 02:53:02 2016
@@ -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 @@
         }
         $r->print("<h3>$actiontext</h3>");
         if ($env{'form.origform'} ne 'crtusername') {
-            $r->print("\n".$response);
+            if ($response) {
+               $r->print("\n<div>$response</div>".
+                         '<br clear="all" />');
+            }
         }
         $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype));
     }
@@ -5015,19 +5018,7 @@
                           $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 @@
          {categorytitle => 'Administration',
          items => [ ]},
        );
-            
+
     if ($context eq 'domain'){
         
         push(@{ $menu[2]->{items} }, #Category: Administration
@@ -6377,7 +6368,7 @@
 }
 
 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 @@
     }
     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);
+<script type="text/javascript">
+// <![CDATA[
+$jsnav
+// ]]>
+</script>
+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 @@
     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 @@
               &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 @@
     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 @@
         $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 @@
     }
 
     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('<p class="LC_info">'
                  .&mt('There are no records to display.')
@@ -6576,15 +6591,10 @@
     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";
-<script type="text/javascript">
-// <![CDATA[
+sub userlogdisplay_js {
+    my ($formname) = @_;
+    return <<"ENDSCRIPT";
+
 function chgPage(caller) {
     if (caller == 'previous') {
         document.$formname.page.value --;
@@ -6595,28 +6605,30 @@
     document.$formname.submit();
     return;
 }
-// ]]>
-</script>
 ENDSCRIPT
-        # 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'})
-                             .'" />';
-            }
+}
+
+sub userlogdisplay_navlinks {
+    my ($curr,$more_records) = @_;
+    return unless(ref($curr) eq 'HASH');
+    # Navigation Buttons
+    my $nav_links = '<p>';
+    if (($curr->{'page'} > 1) || ($more_records)) {
+        if (($curr->{'page'} > 1) && ($curr->{'show'} !~ /\D/)) {
+            $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>';
     }
-    return ($nav_script,$nav_links);
+    $nav_links .= '</p>';
+    return $nav_links;
 }
 
 sub role_display_filter {
@@ -6806,7 +6818,7 @@
             if ($domd_chk eq 'ok') {
                 $response .= &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.');
             }
-            $response .= '<br /><br />';
+            $response .= '<br />';
         }
     } else {
         unless (($context eq 'requestcrs') && ($srch->{'srchtype'} eq 'exact')) { 
@@ -6817,7 +6829,7 @@
                 if ($instd_chk eq 'ok') {
                     $response .= &mt('You may want to search in the institutional directory instead of the LON-CAPA domain.');
                 }
-                $response .= '<br /><br />';
+                $response .= '<br />';
             }
         }
     }
@@ -6914,7 +6926,7 @@
                     &mt('Institutional directory search is not available in domain: [_1]',$showdom).
                     '</span><br />'.
                     &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
-                    '<br /><br />'; 
+                    '<br />'; 
             }
         }
     } else {
@@ -6987,7 +6999,7 @@
                     &mt('Institutional directory search is not available in domain: [_1]',$showdom).
                     '</span><br />'.
                     &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
-                    '<br /><br />';
+                    '<br />';
             }
         }
     }
@@ -7215,7 +7227,7 @@
                                  .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.'
                                     ,' <a'.$helplink.'>'
                                     ,'</a>')
-                                 .'<br /><br />';
+                                 .'<br />';
                 }
             }
         }


More information about the LON-CAPA-cvs mailing list