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

raeburn lon-capa-cvs@mail.lon-capa.org
Sun, 02 Jul 2006 17:08:43 -0000


This is a MIME encoded message

--raeburn1151860123
Content-Type: text/plain

raeburn		Sun Jul  2 13:08:43 2006 EDT

  Modified files:              
    /loncom/interface	longroup.pm loncoursegroups.pm 
  Log:
  Moving generation of fixed privs and toolprivs hashes from loncoursegroups.pm to longroup.pm to be more widely available. Routine used to retrieve group membership information also moved (to be available for group roster display).
  
  
--raeburn1151860123
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060702130843.txt"

Index: loncom/interface/longroup.pm
diff -u loncom/interface/longroup.pm:1.7 loncom/interface/longroup.pm:1.8
--- loncom/interface/longroup.pm:1.7	Fri Jun 30 14:27:19 2006
+++ loncom/interface/longroup.pm	Sun Jul  2 13:08:42 2006
@@ -415,6 +415,160 @@
 
 ###############################################
 
+sub get_fixed_privs {
+    my $fixedprivs = {
+                      email      => {sgm => 1},
+                      discussion => {vgb => 1},
+                      chat       => {pgc => 1},
+                      files      => {rgf => 1},
+                      roster     => {vgm => 1},
+                      homepage   => {vgh => 1},
+                     };
+    return $fixedprivs;
+}
+
+###############################################
+
+sub get_tool_privs {
+    my ($gpterm) = @_;
+    my $toolprivs = {
+        email      => {
+            sgm => 'Send '.$gpterm.' mail',
+            sgb => 'Broadcast mail',
+        },
+        discussion => {
+            cgb => 'Create boards',
+            pgd => 'Post',
+            pag => 'Anon. posts',
+            rgi => 'Get identities',
+            vgb => 'View boards',
+        },
+        chat       => {
+            pgc => 'Chat',
+        },
+        files      => {
+            rgf => 'Retrieve',
+            ugf => 'Upload',
+            mgf => 'Modify',
+            dgf => 'Delete',
+            agf => 'Control Access',
+        },
+        roster     => {
+            vgm => 'View',
+        },
+        homepage   => {
+            vgh => 'View page',
+            mgh => 'Modify page',
+        },
+    };
+    return $toolprivs;
+}
+
+###############################################
+
+
+sub group_memberlist {
+    my ($cdom,$cnum,$groupname,$fixedprivs,$available) = @_;
+    my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum,
+                                                           $groupname);
+    my %current = ();
+    my $hastools = 0;
+    my $addtools = 0;
+    my $num_previous = 0;
+    my $num_future = 0;
+    my $num_active = 0;
+    my $now = time;
+    if (keys(%membership) > 0) {
+        my %allnames = ();
+        foreach my $key (sort(keys(%membership))) {
+            if ($key =~ /^\Q$groupname\E:([^:]+):([^:]+)$/) {
+                my $uname = $1;
+                my $udom = $2;
+                my $user = $uname.':'.$udom;
+                my($end,$start,@userprivs) = split(/:/,$membership{$key});
+                unless ($start == -1) {
+                    $allnames{$udom}{$uname} = 1;
+                    $current{$user} = {
+                        uname     => $uname,
+                        udom      => $udom,
+                        start     => &Apache::lonlocal::locallocaltime($start),
+                        currtools => [],
+                        newtools  => [],
+                        privs     => \@userprivs,
+                    };
+
+                    if ($end == 0) {
+                        $current{$user}{end} =  'No end date';
+                    } else {
+                        $current{$user}{end} =
+                                     &Apache::lonlocal::locallocaltime($end);
+                    }
+                    my $now = time;
+                    if (($end > 0) && ($end < $now)) {
+                        $current{$user}{changestate} = 'reenable';
+                        $current{$user}{'status'} = 'previous';
+                        $num_previous++;
+                    } elsif (($start > $now)) {
+                        $current{$user}{changestate} = 'activate';
+                        $current{$user}{'status'} = 'future';
+                        $num_future ++;
+                    } else {
+                        $current{$user}{changestate} = 'expire';
+                        $current{$user}{'status'} = 'active';
+                        $num_active ++;
+                    }
+                    if (@userprivs > 0) {
+                        foreach my $tool (sort(keys(%{$fixedprivs}))) {
+                            foreach my $priv (keys(%{$$fixedprivs{$tool}})) {
+                                if (grep/^$priv$/,@userprivs) {
+                                    push(@{$current{$user}{currtools}},$tool);
+                                    last;
+                                }
+                            }
+                        }
+                        $hastools = 1;
+                    }
+                    if (@{$available} > 0) {
+                        if (@{$current{$user}{currtools}} > 0) {
+                            if ("@{$available}" ne "@{$current{$user}{currtools}}") {
+                                foreach my $tool (@{$available}) {
+                                    unless (grep/^$tool$/,@{$current{$user}{currtools}}) {
+                                        push(@{$current{$user}{newtools}},$tool);                                    }
+                                }
+                            }
+                        } else {
+                            @{$current{$user}{newtools}} = @{$available};
+
+                        }
+                        if (@{$current{$user}{newtools}} > 0) {
+                            $addtools = 1;
+                        }
+                    }
+                }
+            }
+        }
+        if (keys(%current) > 0) {
+            my %idhash;
+            foreach my $udom (keys(%allnames)) {
+                %{$idhash{$udom}} = &Apache::lonnet::idrget($udom,
+                                                keys(%{$allnames{$udom}}));
+                foreach my $uname (keys(%{$idhash{$udom}})) {
+                    $current{$uname.':'.$udom}{'id'} = $idhash{$udom}{$uname};
+                }
+                foreach my $uname (keys(%{$allnames{$udom}})) {
+                    $current{$uname.':'.$udom}{'fullname'} =
+                                &Apache::loncommon::plainname($uname,$udom,
+                                                                  'lastname');
+                }
+            }
+        }
+    }
+    return (\%current,$hastools,$addtools,$num_previous,$num_future,
+            $num_active);
+}
+
+###############################################
+
 sub sum_quotas {
     my ($courseid) = @_;
     my $totalquotas = 0;
Index: loncom/interface/loncoursegroups.pm
diff -u loncom/interface/loncoursegroups.pm:1.35 loncom/interface/loncoursegroups.pm:1.36
--- loncom/interface/loncoursegroups.pm:1.35	Sun Jul  2 08:46:06 2006
+++ loncom/interface/loncoursegroups.pm	Sun Jul  2 13:08:42 2006
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursegroups.pm,v 1.35 2006/07/02 12:46:06 raeburn Exp $
+# $Id: loncoursegroups.pm,v 1.36 2006/07/02 17:08:42 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -438,47 +438,9 @@
         }
     }
 
-    my %toolprivs =
-	(
-	 email      => {
-	     sgm => 'Send '.$gpterm.' mail',
-	     sgb => 'Broadcast mail',
-	 },
-	 discussion => {
-	     cgb => 'Create boards',
-	     pgd => 'Post',
-	     pag => 'Anon. posts',
-	     rgi => 'Get identities', 
-	     vgb => 'View boards',
-	 },
-	 chat       => {
-	     pgc => 'Chat',
-	 },
-	 files      => {
-	     rgf => 'Retrieve',
-	     ugf => 'Upload',
-             mgf => 'Modify',
-	     dgf => 'Delete',
-             agf => 'Control Access',
-	 },
-	 roster     => {
-	     vgm => 'View',
-	 },
-	 homepage   => {
-	     vgh => 'View page',
-	     mgh => 'Modify page',
-	 },
-	 );
+    my $toolprivs = &Apache::longroup::get_tool_privs($gpterm);
 
-    my %fixedprivs = 
-	(
-	 email      => {sgm => 1},
-	 discussion => {vgb => 1},
-	 chat       => {pgc => 1},
-	 files      => {rgf => 1},
-	 roster     => {vgm => 1},
-	 homepage   => {vgh => 1},
-	 );
+    my $fixedprivs = &Apache::longroup::get_fixed_privs();
 
     my %elements = 
 	(
@@ -686,8 +648,8 @@
                         }
                         my @currtools = ();
                         if (@userprivs > 0) {
-                            foreach my $tool (sort(keys(%fixedprivs))) {
-                                foreach my $priv (keys(%{$fixedprivs{$tool}})) {
+                            foreach my $tool (sort(keys(%{$fixedprivs}))) {
+                                foreach my $priv (keys(%{$$fixedprivs{$tool}})) {
                                     if (grep/^$priv$/,@userprivs) {
                                         push(@currtools,$tool);
                                         last;
@@ -757,8 +719,8 @@
         && ($specificity eq 'Yes')) {
         foreach my $user (sort(keys(%usertools))) {
             foreach my $tool (keys(%{$usertools{$user}})) {
-                foreach my $priv (keys(%{$toolprivs{$tool}})) {
-                    unless (exists($fixedprivs{$tool}{$priv})) {
+                foreach my $priv (keys(%{$$toolprivs{$tool}})) {
+                    unless (exists($$fixedprivs{$tool}{$priv})) {
                         $elements{$action}{$state}{'userpriv_'.$priv} = 'checkbox';
                     }
                 }
@@ -868,7 +830,7 @@
 			  ("$crumbtitle Manager"));
                 &display_control($r,$cdom,$cnum,$tabcol,$action,$state,$page,
                        \%sectioncount,$groupname,$description,$functions,
-                       \@tools,\%toolprivs,\%fixedprivs,$startdate,$enddate,
+                       \@tools,$toolprivs,$fixedprivs,$startdate,$enddate,
                        \%users,\%userdata,$idx,\%memchg,\%usertools,
                        $function,$view_permission,$manage_permission,
                        \%stored,$granularity,$quota,$specificity,\@types,\@roles,
@@ -2227,114 +2189,33 @@
                                           'curf' => 'Current Functionality',
                                           'chpr' => 'Change Privileges' 
                                         );
-    if (keys(%membership) > 0) {
-        my %current = ();
-        my %allnames = ();
-        my $hastools = 0;
-        my $addtools = 0;
-        my $num_reenable = 0;
-        my $num_activate = 0;
-        my $num_expire = 0;
-        foreach my $key (sort(keys(%membership))) {
-            if ($key =~ /^\Q$groupname\E:([^:]+):([^:]+)$/) {
-                my $uname = $1;
-                my $udom = $2;
-                my $user = $uname.':'.$udom;
-                my($end,$start,@userprivs) = split(/:/,$membership{$key});
-                unless ($start == -1) {
-                    $allnames{$udom}{$uname} = 1;
-                    $current{$user} = {
-			uname     => $uname,
-			udom      => $udom,
-			start     => &Apache::lonlocal::locallocaltime($start),
-			currtools => [],
-			newtools  => [],
-		    };
-
-                    if ($end == 0) {
-                        $current{$user}{end} =  'No end date';
-                    } else {
-                        $current{$user}{end} = 
-                                     &Apache::lonlocal::locallocaltime($end);
-                    }
-                    my $now = time;
-                    if (($end > 0) && ($end < $now)) {
-                        $current{$user}{changestate} = 'reenable';
-                        $num_reenable++;
-                    } elsif (($start > $now)) {
-                        $current{$user}{changestate} = 'activate';
-                        $num_activate ++;
-                    } else {
-                        $current{$user}{changestate} = 'expire';
-                        $num_expire ++;
-                    }
-                    if (@userprivs > 0) {
-                        foreach my $tool (sort(keys(%{$fixedprivs}))) {
-                            foreach my $priv (keys(%{$$fixedprivs{$tool}})) {
-                                if (grep/^$priv$/,@userprivs) {
-                                    push(@{$current{$user}{currtools}},$tool);
-                                    last;
-                                }
-                            }
-                        }
-                        $hastools = 1;
-                    }
-                    if (@{$available} > 0) {
-                        if (@{$current{$user}{currtools}} > 0) {
-                            if ("@{$available}" ne "@{$current{$user}{currtools}}") {
-                                foreach my $tool (@{$available}) {
-                                    unless (grep/^$tool$/,@{$current{$user}{currtools}}) {
-                                        push(@{$current{$user}{newtools}},$tool);
-                                    }
-                                }
-                            }
-                        } else {
-                            @{$current{$user}{newtools}} = @{$available};
-                        }
-                        if (@{$current{$user}{newtools}} > 0) {
-                            $addtools = 1;
-                        }
-                    }
-                }
-            }
-        }
-        if (keys(%current) > 0) {
-            my %idhash;
-            foreach my $udom (keys(%allnames)) {
-                %{$idhash{$udom}} = &Apache::lonnet::idrget($udom,
-                                                keys(%{$allnames{$udom}}));
-                foreach my $uname (keys(%{$idhash{$udom}})) {
-                    $current{$uname.':'.$udom}{'id'} = $idhash{$udom}{$uname};
-                }
-                foreach my $uname (keys(%{$allnames{$udom}})) {
-                    $current{$uname.':'.$udom}{'fullname'} =
-                                &Apache::loncommon::plainname($uname,$udom,
-                                                                  'lastname');
-                }
-            }
-            $r->print('
+    my ($current,$hastools,$addtools,$num_reenable,$num_activate,$num_expire) =
+        &Apache::longroup::group_memberlist($cdom,$cnum,$groupname,$fixedprivs,
+                                            $available);
+    if (keys(%{$current}) > 0) {
+        $r->print('
  <tr>
   <td>&nbsp;</td>
   <td colspan="2">
    <table>
     <tr>');
-            if ($num_expire) {
-                &check_uncheck_buttons($r,$formname,'expire',$lt{'expi'});
-            }
-            if ($num_reenable) {
-                &check_uncheck_buttons($r,$formname,'reenable',$lt{'reen'});
-            }
-            if ($num_activate) {
-                &check_uncheck_buttons($r,$formname,'activate',$lt{'acti'});
+        if ($num_expire) {
+            &check_uncheck_buttons($r,$formname,'expire',$lt{'expi'});
+        }
+        if ($num_reenable) {
+            &check_uncheck_buttons($r,$formname,'reenable',$lt{'reen'});
+        }
+        if ($num_activate) {
+            &check_uncheck_buttons($r,$formname,'activate',$lt{'acti'});
+        }
+        &check_uncheck_buttons($r,$formname,'deletion',$lt{'dele'});
+        if (@{$available} > 0) {
+            if ($specificity eq 'Yes') {
+                &check_uncheck_buttons($r,$formname,'changepriv',$lt{'chpr'});
             }
-            &check_uncheck_buttons($r,$formname,'deletion',$lt{'dele'});
-            if (@{$available} > 0) {
-                if ($specificity eq 'Yes') {
-                    &check_uncheck_buttons($r,$formname,'changepriv',$lt{'chpr'});
-                }
-                if ($granularity eq 'Yes') {
-                    $r->print(&check_uncheck_tools($r,$available));
-                    $r->print('
+            if ($granularity eq 'Yes') {
+                $r->print(&check_uncheck_tools($r,$available));
+                $r->print('
      <td>
       <nobr>
        <fieldset><legend><b>'.$lt{'curf'}.'</b></legend>
@@ -2347,9 +2228,9 @@
      </nobr>
     </td>
 ');
-                }
             }
-            $r->print(<<"END");
+        }
+        $r->print(<<"END");
    </tr>
   </table>
   </td>
@@ -2362,8 +2243,8 @@
   <td>&nbsp;</td>
   <td colspan="3">
 END
-            $r->print(&Apache::lonhtmlcommon::start_pick_box());
-            $r->print(<<"END");
+        $r->print(&Apache::lonhtmlcommon::start_pick_box());
+        $r->print(<<"END");
    <table border="0" cellpadding="4" cellspacing="1">
     <tr bgcolor="$tabcol" align="center">
      <td><b>$lt{'actn'}</b></td>
@@ -2375,135 +2256,134 @@
      <td><b><a href="javascript:changeSort('start')">$lt{'stda'}</a></b></td>
      <td><b><a href="javascript:changeSort('end')">$lt{'enda'}</a></b></td>
 END
-            my $colspan = 0;
-            if ($hastools) {
-                $r->print('<td><b>'.$lt{'curf'}.'</b></td>');
-                $colspan ++;  
-            }
-            if ($addtools) {
-                $r->print('<td><b>Additional Functionality</b></td>');
-                $colspan ++;
-            }
-            $r->print('</tr>');
-            if ($colspan) {
-                if ($granularity eq 'Yes') {
-                    $r->print('<tr bgcolor="#cccccc">
+        my $colspan = 0;
+        if ($hastools) {
+            $r->print('<td><b>'.$lt{'curf'}.'</b></td>');
+            $colspan ++;  
+        }
+        if ($addtools) {
+            $r->print('<td><b>Additional Functionality</b></td>');
+            $colspan ++;
+        }
+        $r->print('</tr>');
+        if ($colspan) {
+            if ($granularity eq 'Yes') {
+                $r->print('<tr bgcolor="#cccccc">
  <td colspan="7">&nbsp;</td>
  <td colspan="'.$colspan.'" align="center"><small><nobr><b>'.&mt('All:').
   '</b>&nbsp;');
-                    foreach my $tool (@{$available}) {
-                        $r->print('<label><input type="checkbox" name="togglefunc"'.
+                foreach my $tool (@{$available}) {
+                    $r->print('<label><input type="checkbox" name="togglefunc"'.
    ' onclick="javascript:toggleTools(document.'.$formname.'.user_'.$tool.',this);"'.
    ' value="'.$tool.'">'.'<b>'.$tool.'</b></label>&nbsp;&nbsp;&nbsp;');
-                    }
-                    $r->print('</nobr></small></td></tr>');
                 }
+                $r->print('</nobr></small></td></tr>');
             }
-            my %Sortby = ();
-            foreach my $user (sort(keys(%current))) {
-                if ($env{'form.sortby'} eq 'fullname') {
-                    push(@{$Sortby{$current{$user}{fullname}}},$user);
-                } elsif ($env{'form.sortby'} eq 'username') {
-                    push(@{$Sortby{$current{$user}{uname}}},$user);
-                } elsif ($env{'form.sortby'} eq 'domain') {
-                    push(@{$Sortby{$current{$user}{udom}}},$user);
-                } elsif ($env{'form.sortby'} eq 'id') {
-                    push(@{$Sortby{$current{$user}{id}}},$user);
+        }
+        my %Sortby = ();
+        foreach my $user (sort(keys(%{$current}))) {
+            if ($env{'form.sortby'} eq 'fullname') {
+                push(@{$Sortby{$$current{$user}{fullname}}},$user);
+            } elsif ($env{'form.sortby'} eq 'username') {
+                push(@{$Sortby{$$current{$user}{uname}}},$user);
+            } elsif ($env{'form.sortby'} eq 'domain') {
+                push(@{$Sortby{$$current{$user}{udom}}},$user);
+            } elsif ($env{'form.sortby'} eq 'id') {
+                push(@{$Sortby{$$current{$user}{id}}},$user);
+            } else {
+                push(@{$Sortby{$$current{$user}{fullname}}},$user);
+            }
+        }
+        my $rowNum = 0;
+        my $rowColor;
+        foreach my $key (sort(keys(%Sortby))) {
+            foreach my $user (@{$Sortby{$key}}) {
+                if ($rowNum %2 == 1) {
+                    $rowColor = $rowColor1;
                 } else {
-                    push(@{$Sortby{$current{$user}{fullname}}},$user);
+                    $rowColor = $rowColor2;
                 }
-            }
-            my $rowNum = 0;
-            my $rowColor;
-            foreach my $key (sort(keys(%Sortby))) {
-                foreach my $user (@{$Sortby{$key}}) {
-                    if ($rowNum %2 == 1) {
-                        $rowColor = $rowColor1;
-                    } else {
-                        $rowColor = $rowColor2;
-                    }
-                    my $id = $current{$user}{id};
-                    my $fullname = $current{$user}{fullname};
-                    my $udom = $current{$user}{udom};
-                    my $uname = $current{$user}{uname};
-                    my $start = $current{$user}{start};
-                    my $end = $current{$user}{end};
-                    $r->print('<tr bgcolor="'.$rowColor.'">
-                                <td><small>');
-                    if ($current{$user}{changestate} eq 'reenable') {
-                        $r->print('<nobr><label>'. 
+                my $id = $$current{$user}{id};
+                my $fullname = $$current{$user}{fullname};
+                my $udom = $$current{$user}{udom};
+                my $uname = $$current{$user}{uname};
+                my $start = $$current{$user}{start};
+                my $end = $$current{$user}{end};
+                $r->print('<tr bgcolor="'.$rowColor.'">
+                            <td><small>');
+                if ($$current{$user}{changestate} eq 'reenable') {
+                    $r->print('<nobr><label>'. 
    '<input type="checkbox" name="reenable" value="'.$user.'" />'.
    $lt{'reen'}.'</label></nobr><br />');
-                    } elsif ($current{$user}{changestate} eq 'expire') {
-                        $r->print('<nobr><label>'.
+                } elsif ($$current{$user}{changestate} eq 'expire') {
+                    $r->print('<nobr><label>'.
    '<input type="checkbox" name="expire" value="'.$user.'" />'.
    $lt{'expi'}.'</label></nobr><br />');
-                    } elsif ($current{$user}{changestate} eq 'activate') {
-                        $r->print('<nobr><label>'.
+                } elsif ($$current{$user}{changestate} eq 'activate') {
+                    $r->print('<nobr><label>'.
    '<input type="checkbox" name="activate" value="'.$user.'" />'.
    $lt{'acti'}.'</label></nobr><br />');
-                    }
-                    $r->print('<nobr><label>'.
+                }
+                $r->print('<nobr><label>'.
    '<input type="checkbox" name="deletion" value="'.$user.'" />'.
    $lt{'dele'}.'</label></nobr>');
-                    if ($specificity eq 'Yes') {
-                        $r->print('<br /><nobr><label>'.
+                if ($specificity eq 'Yes') {
+                    $r->print('<br /><nobr><label>'.
    '<input type="checkbox" name="changepriv" value="'.$user.'" />'.$lt{'chpr'}.
    '</label></nobr>');
-                    }
-                    $r->print('
+                }
+                $r->print('
    </td>
    <td><small>'.
     $fullname.'</small></td><td><small>'.$uname.'</small></td><td><small>'.
     $udom.'</small></td><td><small>'.$id.'</small></td><td><small>'.$start.
     '</small></td><td><small>'.$end.'</small></td>');
-                    if ($hastools) {
-                        $r->print('<td align="left"><small><nobr>'.
+                if ($hastools) {
+                    $r->print('<td align="left"><small><nobr>'.
                                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
-                        foreach my $tool (@{$current{$user}{currtools}}) {
-                            if ($granularity eq 'Yes') {
-                                $r->print('<label><input type="checkbox" '. 
+                    foreach my $tool (@{$$current{$user}{currtools}}) {
+                        if ($granularity eq 'Yes') {
+                            $r->print('<label><input type="checkbox" '. 
                                        'checked="checked" '. 
                                        'name="user_'.$tool.'" value="'.
                                        $user.'" />'.$tool.'</label>');
-                             } else {
-                               $r->print('<input type="hidden" '.
+                         } else {
+                             $r->print('<input type="hidden" '.
                                        'checked="checked" '.
                                        'name="user_'.$tool.'" value="'.
                                        $user.'" />'.$tool);
-                             }
-                             $r->print('&nbsp;&nbsp;&nbsp;');
-                        }
-                        $r->print('</nobr></small></td>');
+                         }
+                         $r->print('&nbsp;&nbsp;&nbsp;');
                     }
-                    if ($addtools) {
-                        $r->print('<td align="left"><small>');
-                        if ($granularity eq 'Yes') {
-                            foreach my $tool (@{$current{$user}{newtools}}) {
-                                $r->print('<nobr><label><input type="checkbox"
+                    $r->print('</nobr></small></td>');
+                }
+                if ($addtools) {
+                    $r->print('<td align="left"><small>');
+                    if ($granularity eq 'Yes') {
+                        foreach my $tool (@{$$current{$user}{newtools}}) {
+                            $r->print('<nobr><label><input type="checkbox"
                                           name="user_'.$tool.'" value="'.
                                           $user.'" />'.$tool.
                                           '</label></nobr>&nbsp;&nbsp;&nbsp;');
-                            }
-                        } else {
-                            foreach my $tool (@{$current{$user}{newtools}}) {
-                                $r->print('<nobr><input type="hidden" 
+                        }
+                    } else {
+                        foreach my $tool (@{$$current{$user}{newtools}}) {
+                            $r->print('<nobr><input type="hidden" 
                                           name="user_'. $tool.'" value="'.
                                           $user.'" />'.$tool.
                                           '</nobr>&nbsp;&nbsp;&nbsp;');
-                            }
                         }
-                        $r->print('</small></td>');
                     }
-                    $r->print('</tr>'."\n");
-                    $rowNum ++;
+                    $r->print('</small></td>');
                 }
+                $r->print('</tr>'."\n");
+                $rowNum ++;
             }
-            $r->print(&Apache::lonhtmlcommon::end_pick_box());
-            $r->print('
+        }
+        $r->print(&Apache::lonhtmlcommon::end_pick_box());
+        $r->print('
   </td>
  </tr>');
-        }
     }
     return;
 }

--raeburn1151860123--