[LON-CAPA-cvs] cvs: loncom(version_2_9_X) /interface loncommon.pm

raeburn raeburn@source.lon-capa.org
Tue, 19 Jan 2010 16:27:48 -0000


raeburn		Tue Jan 19 16:27:48 2010 EDT

  Modified files:              (Branch: version_2_9_X)
    /loncom/interface	loncommon.pm 
  Log:
  - Backport 1.919.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.692.4.23 loncom/interface/loncommon.pm:1.692.4.24
--- loncom/interface/loncommon.pm:1.692.4.23	Tue Jan 19 16:20:38 2010
+++ loncom/interface/loncommon.pm	Tue Jan 19 16:27:47 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.692.4.23 2010/01/19 16:20:38 raeburn Exp $
+# $Id: loncommon.pm,v 1.692.4.24 2010/01/19 16:27:47 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -8994,6 +8994,8 @@
                 my $trailstr;
                 if ($name eq 'instcode') {
                     $trailstr = &mt('Official courses (with institutional codes)');
+                } elsif ($name eq 'communities') {
+                    $trailstr = &mt('Communities');
                 } else {
                     $trailstr = $name;
                 }
@@ -9104,14 +9106,16 @@
 cathash - reference to hash of categories defined for the domain (from
           configuration.db)
 
-currcat - scalar with an & separated list of categories assigned to a course. 
+currcat - scalar with an & separated list of categories assigned to a course.
+
+type    - scalar contains course type (Course or Community).
 
 Returns: $output (markup to be displayed) 
 
 =cut
 
 sub assign_categories_table {
-    my ($cathash,$currcat) = @_;
+    my ($cathash,$currcat,$type) = @_;
     my $output;
     if (ref($cathash) eq 'HASH') {
         my (@cats,@trails,%allitems,%idx,@jsarray,@path,$maxdepth);
@@ -9120,15 +9124,20 @@
         if (@cats > 0) {
             my $itemcount = 0;
             if (ref($cats[0]) eq 'ARRAY') {
-                $output = &Apache::loncommon::start_data_table();
                 my @currcategories;
                 if ($currcat ne '') {
                     @currcategories = split('&',$currcat);
                 }
+                my $table;
                 for (my $i=0; $i<@{$cats[0]}; $i++) {
                     my $parent = $cats[0][$i];
-                    my $css_class = $itemcount%2?' class="LC_odd_row"':'';
                     next if ($parent eq 'instcode');
+                    if ($type eq 'Community') {
+                        next unless ($parent eq 'communities');
+                    } else {
+                        next if ($parent eq 'communities');
+                    }
+                    my $css_class = $itemcount%2?' class="LC_odd_row"':'';
                     my $item = &escape($parent).'::0';
                     my $checked = '';
                     if (@currcategories > 0) {
@@ -9136,18 +9145,26 @@
                             $checked = ' checked="checked" ';
                         }
                     }
-                    $output .= '<tr '.$css_class.'><td><span class="LC_nobreak">'.
-                               '<input type="checkbox" name="usecategory" value="'.
-                               $item.'"'.$checked.' />'.$parent.'</span>'.
-                               '<input type="hidden" name="catname" value="'.$parent.'" /></td>';
+                    my $parent_title = $parent;
+                    if ($parent eq 'communities') {
+                        $parent_title = &mt('Communities');
+                    }
+                    $table .= '<tr '.$css_class.'><td><span class="LC_nobreak">'.
+                              '<input type="checkbox" name="usecategory" value="'.
+                              $item.'"'.$checked.' />'.$parent_title.'</span>'.
+                              '<input type="hidden" name="catname" value="'.$parent.'" /></td>';
                     my $depth = 1;
                     push(@path,$parent);
-                    $output .= &assign_category_rows($itemcount,\@cats,$depth,$parent,\@path,\@currcategories);
+                    $table .= &assign_category_rows($itemcount,\@cats,$depth,$parent,\@path,\@currcategories);
                     pop(@path);
-                    $output .= '</tr><tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr>';
+                    $table .= '</tr><tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr>';
                     $itemcount ++;
                 }
-                $output .= &Apache::loncommon::end_data_table();
+                if ($itemcount) {
+                    $output = &Apache::loncommon::start_data_table().
+                              $table.
+                              &Apache::loncommon::end_data_table();
+                }
             }
         }
     }