[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm

raeburn raeburn@source.lon-capa.org
Mon, 18 May 2009 15:40:20 -0000


raeburn		Mon May 18 15:40:20 2009 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
  Log:
  - Fix alternating background colors for rows in roles table.
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.222 loncom/auth/lonroles.pm:1.223
--- loncom/auth/lonroles.pm:1.222	Sun May 17 23:38:12 2009
+++ loncom/auth/lonroles.pm	Mon May 18 15:40:20 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.222 2009/05/17 23:38:12 bisitz Exp $
+# $Id: lonroles.pm,v 1.223 2009/05/18 15:40:20 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -668,7 +668,7 @@
     foreach $envkey (sort keys %env) {
         my $button = 1;
         my $switchserver='';
-	my $roletext;
+	my ($roletext,$roletext_end);
 	my $sortkey;
         if ($envkey=~/^user\.role\./) {
             my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend);
@@ -812,8 +812,11 @@
                     $twhere=&mt('system wide');
 		    $sortkey=$role.$twhere;
                 }
-                $roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit);
-		$roletext{$envkey}=$roletext;
+                ($roletext,$roletext_end) = 
+                    &build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,
+                                    $advanced,$tremark,$tbg,$trole,$twhere,$tpstart,
+                                    $tpend,$nochoose,$button,$switchserver,$reinit);
+		$roletext{$envkey}=[$roletext,$roletext_end];
 		if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
 		$sortrole{$sortkey}=$envkey;
 		$roleclass{$envkey}=$ttype;
@@ -881,8 +884,13 @@
                &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
 	my $output='';
 	foreach (sort(keys(%recent_roles))) {
-	    if (defined($roletext{'user.role.'.$_})) {
-		$output.=$roletext{'user.role.'.$_};
+	    if (ref($roletext{'user.role.'.$_}) eq 'ARRAY') {
+		$output.= &Apache::loncommon::start_data_table_row().
+                          $roletext{'user.role.'.$_}->[0].
+                          &Apache::loncommon::end_data_table_row().
+                          &Apache::loncommon::continue_data_table_row().
+                          $roletext{'user.role.'.$_}->[1].
+                          &Apache::loncommon::end_data_table_row();
                 if ($_ =~ m-dc\./($match_domain)/- 
 		    && $dcroles{$1}) {
 		    $output .= &adhoc_roles_row($1,'recent');
@@ -1054,7 +1062,14 @@
             foreach my $which (sort {uc($a) cmp uc($b)} (keys(%{$sortrole}))) {
                 if ($roleclass->{$sortrole->{$which}} =~ /^\Q$type\E/) {
                     if (ref($roletext) eq 'HASH') {
-                        $output.=$roletext->{$sortrole->{$which}};
+                        if (ref($roletext->{$sortrole->{$which}}) eq 'ARRAY') {
+                            $output.= &Apache::loncommon::start_data_table_row().
+                                      $roletext->{$sortrole->{$which}}->[0].
+                                      &Apache::loncommon::end_data_table_row().
+                                      &Apache::loncommon::continue_data_table_row().
+                                      $roletext->{$sortrole->{$which}}->[1].
+                                      &Apache::loncommon::end_data_table_row();
+                        }
                         if ($sortrole->{$which} =~ m-dc\./($match_domain)/-) {
                             if (ref($dcroles) eq 'HASH') {
                                 if ($dcroles->{$1}) {
@@ -1202,7 +1217,7 @@
 
 sub build_roletext {
     my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit) = @_;
-    my $roletext=&Apache::loncommon::start_data_table_row();
+    my ($roletext,$roletext_end);
     my $is_dc=($trolecode =~ m/^dc\./);
     my $rowspan=($is_dc) ? ''
                          : ' rowspan="2" ';
@@ -1257,16 +1272,13 @@
     $roletext.='<td>'.$trole.'</td>'
               .'<td>'.$twhere.'</td>'
               .'<td>'.$tpstart.'</td>'
-              .'<td>'.$tpend.'</td>'
-              .&Apache::loncommon::end_data_table_row();
+              .'<td>'.$tpend.'</td>';
     if (!$is_dc) {
-        $roletext.=&Apache::loncommon::continue_data_table_row()
-                  .'<td colspan="4">'
-                  .$tremark.'&nbsp;'
-                  .'</td>'
-                  .&Apache::loncommon::end_data_table_row();
+        $roletext_end = '<td colspan="4">'.
+                        $tremark.'&nbsp;'.
+                        '</td>';
     }
-    return $roletext;
+    return ($roletext,$roletext_end);
 }
 
 sub check_needs_switchserver {
@@ -1458,7 +1470,7 @@
 
 sub display_cc_role {
     my $rolekey = shift;
-    my $roletext;
+    my ($roletext,$roletext_end);
     my $advanced = $env{'user.adv'};
     my $tryagain = $env{'form.tryagain'};
     unless ($rolekey =~/^error\:/) {
@@ -1481,10 +1493,10 @@
             }
             my $trole = &Apache::lonnet::plaintext('cc',$ttype);
             $twhere.="<br />".&mt('Domain').":".$1;
-            $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$trole,$twhere,'','','',1,'');
+            ($roletext,$roletext_end) = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$trole,$twhere,'','','',1,'');
         }
     }
-    return ($roletext);
+    return ($roletext,$roletext_end);
 }
 
 sub adhoc_roles_row {