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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Fri, 27 Jun 2008 00:42:48 -0000


This is a MIME encoded message

--raeburn1214527368
Content-Type: text/plain

raeburn		Thu Jun 26 20:42:48 2008 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - Change in structure of frozen coursecategories hash within configuration.db.
    hash can contain:
    togglecats => scalar (dom or crs)
    categorize => scalar (dom or crs)
    cats => HASH (hash of course categories).
  - togglecats determines whether setting of "hidefromcat" course parameter is by CC in "Set Course Environment", or by DC in "Modify course"
  - categorize determines whether manual setting of category for a course is by CC in "Set Course Environment", or by DC in "Modify course"
  - cats contains the hash of categories:
  e.g.,
            'cats' => {
                        'instcode::0' => '0',
                        'Schools::0' => '3',
                        'Colleges::0' => '1',
                        'Departments::0' => '2'
                      },
  If there are any developers who created categories for testing purposes in the past month using domainprefs.pm 1.52 and later, these will need to be recreated using the "Domain Configuration" interface.
  
  
--raeburn1214527368
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080626204248.txt"

Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.56 loncom/interface/domainprefs.pm:1.57
--- loncom/interface/domainprefs.pm:1.56	Tue Jun 24 11:01:23 2008
+++ loncom/interface/domainprefs.pm	Thu Jun 26 20:42:48 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.56 2008/06/24 15:01:23 bisitz Exp $
+# $Id: domainprefs.pm,v 1.57 2008/06/27 00:42:48 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -162,9 +162,11 @@
         'coursecategories' => 
                   { text => 'Cataloging of courses',
                     help => 'Domain_Course_Catalog',
-                    header => [  {col1 => 'Categories',
-                                  col2 => '',
-                              }],
+                    header => [{col1 => 'Category settings',  
+                                col2 => '',},
+                               {col1 => 'Categories',
+                                col2 => '',
+                               }],
                   }
     );
     my @roles = ('student','coordinator','author','admin');
@@ -386,7 +388,8 @@
 #          </tr>');
     $rowtotal ++;
     if (($action eq 'autoupdate') || ($action eq 'rolecolors') || 
-        ($action eq 'usercreation') || ($action eq 'usermodification')) {
+        ($action eq 'usercreation') || ($action eq 'usermodification') ||
+        ($action eq 'coursecategories')) {
         my $colspan = ($action eq 'rolecolors')?' colspan="2"':'';
         $output .= '
           <tr>
@@ -403,6 +406,8 @@
             $output .= &print_usercreation('top',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'usermodification') {
             $output .= &print_usermodification('top',$dom,$settings,\$rowtotal);
+        } elsif ($action eq 'coursecategories') {
+            $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal);
         } else {
             $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
         }
@@ -414,8 +419,10 @@
            <td>
             <table class="LC_nested">
              <tr class="LC_info_row">
-              <td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[1]->{'col1'}.'</td>
-              <td class="LC_right_item">'.$item->{'header'}->[1]->{'col2'}.'</td>
+              <td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[1]->{'col1'}.'</td>';
+        my $colspan = ($action eq 'coursecategories')?' colspan="2"':'';
+        $output .= '
+              <td class="LC_right_item"'.$colspan.'>'.$item->{'header'}->[1]->{'col2'}.'</td>
              </tr>';
             $rowtotal ++;
         if ($action eq 'autoupdate') {
@@ -435,6 +442,8 @@
             $rowtotal ++;
         } elsif ($action eq 'usermodification') {
             $output .= &print_usermodification('bottom',$dom,$settings,\$rowtotal);
+        } elsif ($action eq 'coursecategories') {
+            $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
         } else {
             $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
            </table>
@@ -474,9 +483,8 @@
             $output .= '
               <td class="LC_left_item">'.$item->{'header'}->[0]->{'col1'}.'</td>';
         }
-        my $colspan = ($action eq 'coursecategories')?' colspan="2"':'';
         $output .= '
-              <td class="LC_right_item"'.$colspan.'>'.$item->{'header'}->[0]->{'col2'}.'</td>
+              <td class="LC_right_item">'.$item->{'header'}->[0]->{'col2'}.'</td>
              </tr>';
         $rowtotal ++;
         if ($action eq 'login') {
@@ -493,8 +501,6 @@
             $output .= &print_defaults($dom,\$rowtotal);
         } elsif ($action eq 'scantron') {
             $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
-        } elsif ($action eq 'coursecategories'){
-            $output .= &print_coursecategories($dom,$item,$settings,\$rowtotal);
         }
     }
     $output .= '
@@ -1961,118 +1967,167 @@
 }
 
 sub print_coursecategories {
-    my ($dom,$hdritem,$settings,$rowtotal) = @_;
-    my ($datatable,$css_class);
-    my $itemcount = 1;
-    if (ref($settings) eq 'HASH') {
-        my (@cats,@trails,%allitems,%idx,@jsarray);
-        &Apache::loncommon::extract_categories($settings,\@cats,\@trails,
-                                               \%allitems,\%idx,\@jsarray);
-        my $maxdepth = scalar(@cats);
-        my $colattrib = '';
-        if ($maxdepth > 2) {
-            $colattrib = ' colspan="2" ';
-        }
-        my @path;
-        if (@cats > 0) {
-            if (ref($cats[0]) eq 'ARRAY') {
-                my $numtop = @{$cats[0]};
-                my $maxnum = $numtop;
-                if ((!grep(/^instcode$/,@{$cats[0]})) || ($settings->{'instcode::0'} eq '')) {
-                    $maxnum ++;
-                }
-                my $lastidx;
-                for (my $i=0; $i<$numtop; $i++) {
-                    my $parent = $cats[0][$i];
+    my ($position,$dom,$hdritem,$settings,$rowtotal) = @_;
+    my $datatable;
+    if ($position eq 'top') {
+        my $toggle_cats_crs = ' ';
+        my $toggle_cats_dom = ' checked="checked" ';
+        my $can_cat_crs = ' ';
+        my $can_cat_dom = ' checked="checked" ';
+        if (ref($settings) eq 'HASH') {
+            if ($settings->{'togglecats'} eq 'crs') {
+                $toggle_cats_crs = $toggle_cats_dom;
+                $toggle_cats_dom = ' ';
+            }
+            if ($settings->{'categorize'} eq 'crs') {
+                $can_cat_crs = $can_cat_dom;
+                $can_cat_dom = ' ';
+            }
+        }
+        my %title = &Apache::lonlocal::texthash (
+                     togglecats => 'Show/Hide a course in the catalog',
+                     categorize    => 'Assign a category to a course',
+                    );
+        my %level = &Apache::lonlocal::texthash (
+                     dom => 'Set in "Modify Course" (Domain)',
+                     crs => 'Set in "Parameters" (Course)',   
+                    );
+        $datatable = '<tr class="LC_odd_row">'.
+                  '<td>'.$title{'togglecats'}.'</td>'.
+                  '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
+                  '<input type="radio" name="togglecats"'.
+                  $toggle_cats_dom.' value="dom" />'.$level{'dom'}.'</label>&nbsp;'.
+                  '<label><input type="radio" name="togglecats"'.
+                  $toggle_cats_crs.' value="crs" />'.$level{'crs'}.'</label></span></td>'.
+                  '</tr><tr>'.
+                  '<td>'.$title{'categorize'}.'</td>'.
+                  '<td class="LC_right_item"><span class="LC_nobreak">'.
+                  '<label><input type="radio" name="categorize"'.
+                  $can_cat_dom.' value="dom" />'.$level{'dom'}.'</label>&nbsp;'.
+                  '<label><input type="radio" name="categorize"'.
+                  $can_cat_crs.'value="crs" />'.$level{'crs'}.'</label></span></td>'.
+                  '</tr>';
+        $$rowtotal += 2;
+    } else {
+        my $css_class;
+        my $itemcount = 1;
+        my $cathash; 
+        if (ref($settings) eq 'HASH') {
+            $cathash = $settings->{'cats'};
+        }
+        if (ref($cathash) eq 'HASH') {
+            my (@cats,@trails,%allitems,%idx,@jsarray);
+            &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,
+                                                   \%allitems,\%idx,\@jsarray);
+            my $maxdepth = scalar(@cats);
+            my $colattrib = '';
+            if ($maxdepth > 2) {
+                $colattrib = ' colspan="2" ';
+            }
+            my @path;
+            if (@cats > 0) {
+                if (ref($cats[0]) eq 'ARRAY') {
+                    my $numtop = @{$cats[0]};
+                    my $maxnum = $numtop;
+                    if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
+                        $maxnum ++;
+                    }
+                    my $lastidx;
+                    for (my $i=0; $i<$numtop; $i++) {
+                        my $parent = $cats[0][$i];
+                        $css_class = $itemcount%2?' class="LC_odd_row"':'';
+                        my $item = &escape($parent).'::0';
+                        my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$item','$idx{$item}'".');"';
+                        $lastidx = $idx{$item};
+                        $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
+                                      .'<select name="'.$item.'"'.$chgstr.'>';
+                        for (my $k=0; $k<=$maxnum; $k++) {
+                            my $vpos = $k+1;
+                            my $selstr;
+                            if ($k == $i) {
+                                $selstr = ' selected="selected" ';
+                            }
+                            $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
+                        }
+                        $datatable .= '</select></td><td>';
+                        if ($parent eq 'instcode') {
+                            $datatable .=  '<span class="LC_nobreak">'.&mt('Official courses')
+                                           .'</span><br /><span class="LC_nobreak">('
+                                           .&mt('with institutional codes').')</span></td>'
+                                           .'<td'.$colattrib.'><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" checked="checked" />'
+                                            .&mt('Display').'</label>&nbsp;'
+                                            .'<label><input type="radio" name="instcode" value="0" />'
+                                            .&mt('Do not display').'</label></span></td>';
+                        } else {
+                            $datatable .= $parent
+                                          .'&nbsp;<label><input type="checkbox" name="deletecategory" '
+                                          .'value="'.$item.'" />'.&mt('Delete').'</label></span></td>';
+                        }
+                        my $depth = 1;
+                        push(@path,$parent);
+                        $datatable .= &build_category_rows($itemcount,\@cats,$depth,$parent,\@path,\%idx);
+                        pop(@path);
+                        $datatable .= '</tr><tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr>';
+                        $itemcount ++;
+                    }
                     $css_class = $itemcount%2?' class="LC_odd_row"':'';
-                    my $item = &escape($parent).'::0';
-                    my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$item','$idx{$item}'".');"';
-                    $lastidx = $idx{$item};
-                    $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
-                                  .'<select name="'.$item.'"'.$chgstr.'>';
+                    my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','$lastidx'".');"';
+                    $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak"><select name="addcategory_pos"'.$chgstr.'>';
                     for (my $k=0; $k<=$maxnum; $k++) {
                         my $vpos = $k+1;
                         my $selstr;
-                        if ($k == $i) {
+                        if ($k == $numtop) {
                             $selstr = ' selected="selected" ';
                         }
                         $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
                     }
-                    $datatable .= '</select></td><td>';
-                    if ($parent eq 'instcode') {
-                        $datatable .=  '<span class="LC_nobreak">'.&mt('Official courses')
-                                       .'</span><br /><span class="LC_nobreak">('
-                                       .&mt('with institutional codes').')</span></td>'
-                                       .'<td'.$colattrib.'><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" checked="checked" />'
-                                        .&mt('Display').'</label>&nbsp;'
-                                        .'<label><input type="radio" name="instcode" value="0" />'
-                                        .&mt('Do not display').'</label></span></td>';
-                    } else {
-                        $datatable .= $parent
-                                      .'&nbsp;<label><input type="checkbox" name="deletecategory" '
-                                      .'value="'.$item.'" />'.&mt('Delete').'</label></span></td>';
-                    }
-                    my $depth = 1;
-                    push(@path,$parent);
-                    $datatable .= &build_category_rows($itemcount,\@cats,$depth,$parent,\@path,\%idx);
-                    pop(@path);
-                    $datatable .= '</tr><tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr>';
+                    $datatable .= '</select></span></td><td colspan="2">'.&mt('New:').'&nbsp;'
+                                  .'<input type="text" size="20" name="addcategory_name" value="" /></td>'
+                                  .'</tr>'."\n";
                     $itemcount ++;
-                }
-                $css_class = $itemcount%2?' class="LC_odd_row"':'';
-                my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','$lastidx'".');"';
-                $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak"><select name="addcategory_pos"'.$chgstr.'>';
-                for (my $k=0; $k<=$maxnum; $k++) {
-                    my $vpos = $k+1;
-                    my $selstr;
-                    if ($k == $numtop) {
-                        $selstr = ' selected="selected" ';
-                    }
-                    $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
-                }
-                $datatable .= '</select></span></td><td colspan="2">'.&mt('New:').'&nbsp;'
-                              .'<input type="text" size="20" name="addcategory_name" value="" /></td>'
-                              .'</tr>'."\n";
-                $itemcount ++;
-                if ((!grep(/^instcode$/,@{$cats[0]})) || ($settings->{'instcode::0'} eq '')) {
-                    $css_class = $itemcount%2?' class="LC_odd_row"':'';
-                    my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','$lastidx'".');"';
-                    $datatable .= '<tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr><tr '.$css_class.'><td>'.
-                                  '<span class="LC_nobreak"><select name="instcode_pos"'.$chgstr.'>';
-                    for (my $k=0; $k<=$maxnum; $k++) {
-                        my $vpos = $k+1;
-                        my $selstr;
-                        if ($k == $maxnum) {
-                            $selstr = ' selected="selected" ';
+                    if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
+                        $css_class = $itemcount%2?' class="LC_odd_row"':'';
+                        my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','$lastidx'".');"';
+                        $datatable .= '<tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr><tr '.$css_class.'><td>'.
+                                      '<span class="LC_nobreak"><select name="instcode_pos"'.$chgstr.'>';
+                        for (my $k=0; $k<=$maxnum; $k++) {
+                            my $vpos = $k+1;
+                            my $selstr;
+                            if ($k == $maxnum) {
+                                $selstr = ' selected="selected" ';
+                            }
+                            $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
                         }
-                        $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
+                        $datatable .= '</select></span></td><td><span class="LC_nobreak">'
+                                      .&mt('Official courses').'</span>'.'<br /><span class="LC_nobreak">('
+                                      .&mt('with institutional codes').')</span></td>'
+                                      .'<td><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" />'
+                                      .&mt('Display').'</label>&nbsp;'
+                                      .'<label><input type="radio" name="instcode" value="0" checked="checked"/>'
+                                      .&mt('Do not display').'</label></span></td></tr>';
                     }
-                    $datatable .= '</select></span></td><td><span class="LC_nobreak">'
-                                  .&mt('Official courses').'</span>'.'<br /><span class="LC_nobreak">('
-                                  .&mt('with institutional codes').')</span></td>'
-                                  .'<td><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" />'
-                                  .&mt('Display').'</label>&nbsp;'
-                                  .'<label><input type="radio" name="instcode" value="0" checked="checked"/>'
-                                  .&mt('Do not display').'</label></span></td></tr>';
                 }
+            } else {
+                $datatable .= &initialize_categories($itemcount);
             }
         } else {
-            $datatable .= &initialize_categories($itemcount);
+            $datatable .= '<td class="LC_right_item">'.$hdritem->{'header'}->[0]->{'col2'}.'</td>'
+                          .&initialize_categories($itemcount);
         }
-    } else {
-        $datatable .= '<td class="LC_right_item">'.$hdritem->{'header'}->[0]->{'col2'}.'</td>'
-                      .&initialize_categories($itemcount);
+        $$rowtotal += $itemcount;
     }
-    $$rowtotal += $itemcount;
     return $datatable;
 }
 
 sub coursecategories_javascript {
     my ($settings) = @_;
-    my ($output,$jstext);
+    my ($output,$jstext,$cathash);
     if (ref($settings) eq 'HASH') {
+        $cathash = $settings->{'cats'};
+    }
+    if (ref($cathash) eq 'HASH') {
         my (@cats,@jsarray,%idx);
-        &Apache::loncommon::gather_categories($settings,\@cats,\%idx,\@jsarray);
+        &Apache::loncommon::gather_categories($cathash,\@cats,\%idx,\@jsarray);
         if (@jsarray > 0) {
             $jstext = '    var categories = Array('.scalar(@jsarray).');'."\n";
             for (my $i=0; $i<@jsarray; $i++) {
@@ -4257,69 +4312,85 @@
 
 sub modify_coursecategories {
     my ($dom,%domconfig) = @_;
-    my ($resulttext,%deletions,%reorderings,%needreordering,%adds,$errors);
+    my ($resulttext,%deletions,%reorderings,%needreordering,%adds,%changes,$errors,
+        $cathash);
     my @deletecategory = &Apache::loncommon::get_env_multiple('form.deletecategory');
     if (ref($domconfig{'coursecategories'}) eq 'HASH') {
-        if (($domconfig{'coursecategories'}{'instcode::0'} ne '')  && ($env{'form.instcode'} == 0)) {
+        $cathash = $domconfig{'coursecategories'}{'cats'};
+        if ($domconfig{'coursecategories'}{'togglecats'} ne $env{'form.togglecats'}) {
+            $changes{'togglecats'} = 1;
+            $domconfig{'coursecategories'}{'togglecats'} = $env{'form.togglecats'};
+        }
+        if ($domconfig{'coursecategories'}{'categorize'} ne $env{'form.categorize'}) {
+            $changes{'categorize'} = 1;
+            $domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};
+        }
+    } else {
+        $changes{'togglecats'} = 1;
+        $changes{'categorize'} = 1;
+        $domconfig{'coursecategories'}{'togglecats'} = $env{'form.togglecats'};
+        $domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};
+    }
+    if (ref($cathash) eq 'HASH') {
+        if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '')  && ($env{'form.instcode'} == 0)) {
             push (@deletecategory,'instcode::0');
         }
     }
-    my (@predelcats,@predeltrails,%predelallitems);
-    if (ref($domconfig{'coursecategories'}) eq 'HASH') {
+    my (@predelcats,@predeltrails,%predelallitems,%sort_by_deltrail);
+    if (ref($cathash) eq 'HASH') {
         if (@deletecategory > 0) {
             #FIXME Need to remove category from all courses using a deleted category 
-            &Apache::loncommon::extract_categories($domconfig{'coursecategories'},\@predelcats,\@predeltrails,\%predelallitems);
+            &Apache::loncommon::extract_categories($cathash,\@predelcats,\@predeltrails,\%predelallitems);
             foreach my $item (@deletecategory) {
-                if ($domconfig{'coursecategories'}{$item} ne '') {
-                    delete($domconfig{'coursecategories'}{$item});
+                if ($domconfig{'coursecategories'}{'cats'}{$item} ne '') {
+                    delete($domconfig{'coursecategories'}{'cats'}{$item});
                     $deletions{$item} = 1;
-                    &recurse_cat_deletes($item,$domconfig{'coursecategories'},
-                                         \%deletions);
+                    &recurse_cat_deletes($item,$cathash,\%deletions);
                 }
             }
         }
-        foreach my $item (keys(%{$domconfig{'coursecategories'}})) {
+        foreach my $item (keys(%{$cathash})) {
             my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$item);
-            if ($domconfig{'coursecategories'}{$item} ne $env{'form.'.$item}) {
+            if ($cathash->{$item} ne $env{'form.'.$item}) {
                 $reorderings{$item} = 1;
-                $domconfig{'coursecategories'}{$item} = $env{'form.'.$item};
+                $domconfig{'coursecategories'}{'cats'}{$item} = $env{'form.'.$item};
             }
             if ($env{'form.addcategory_name_'.$item} ne '') {
                 my $newcat = $env{'form.addcategory_name_'.$item};
                 my $newdepth = $depth+1;
                 my $newitem = &escape($newcat).':'.&escape($cat).':'.$newdepth;
-                $domconfig{'coursecategories'}{$newitem} = $env{'form.addcategory_pos_'.$item};
+                $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos_'.$item};
                 $adds{$newitem} = 1; 
             }
             if ($env{'form.subcat_'.$item} ne '') {
                 my $newcat = $env{'form.subcat_'.$item};
                 my $newdepth = $depth+1;
                 my $newitem = &escape($newcat).':'.&escape($cat).':'.$newdepth;
-                $domconfig{'coursecategories'}{$newitem} = 0;
+                $domconfig{'coursecategories'}{'cats'}{$newitem} = 0;
                 $adds{$newitem} = 1;
             }
         }
     }
     if ($env{'form.instcode'} eq '1') {
-        if (ref($domconfig{'coursecategories'}) eq 'HASH') {
+        if (ref($cathash) eq 'HASH') {
             my $newitem = 'instcode::0';
-            if ($domconfig{'coursecategories'}{$newitem} eq '') {  
-                $domconfig{'coursecategories'}{$newitem} = $env{'form.instcode_pos'};
+            if ($cathash->{$newitem} eq '') {  
+                $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.instcode_pos'};
                 $adds{$newitem} = 1;
             }
         } else {
             my $newitem = 'instcode::0';
-            $domconfig{'coursecategories'}{$newitem} = $env{'form.instcode_pos'};
+            $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.instcode_pos'};
             $adds{$newitem} = 1;
         }
     }
     if ($env{'form.addcategory_name'} ne '') {
         my $newitem = &escape($env{'form.addcategory_name'}).'::0';
-        $domconfig{'coursecategories'}{$newitem} = $env{'form.addcategory_pos'};
+        $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'};
         $adds{$newitem} = 1;
     }
+    my $putresult;
     if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
-        my %sort_by_deltrail;
         if (keys(%deletions) > 0) {
             foreach my $key (keys(%deletions)) {
                 if ($predelallitems{$key} ne '') {
@@ -4328,7 +4399,7 @@
             }
         }
         my (@chkcats,@chktrails,%chkallitems);
-        &Apache::loncommon::extract_categories($domconfig{'coursecategories'},\@chkcats,\@chktrails,\%chkallitems);
+        &Apache::loncommon::extract_categories($domconfig{'coursecategories'}{'cats'},\@chkcats,\@chktrails,\%chkallitems);
         if (ref($chkcats[0]) eq 'ARRAY') {
             my $depth = 0;
             my $chg = 0;
@@ -4340,56 +4411,80 @@
                 } else {
                     $item = &escape($name).'::0';
                     if ($chg) {
-                        $domconfig{'coursecategories'}{$item} -= $chg;
+                        $domconfig{'coursecategories'}{'cats'}{$item} -= $chg;
                     }
                     $depth ++; 
-                    &recurse_check(\@chkcats,$domconfig{'coursecategories'},$depth,$name);
+                    &recurse_check(\@chkcats,$domconfig{'coursecategories'}{'cats'},$depth,$name);
                     $depth --;
                 }
             }
         }
-        my $putresult = &Apache::lonnet::put_dom('configuration',\%domconfig,$dom);
-        my (@cats,@trails,%allitems);
-        &Apache::loncommon::extract_categories($domconfig{'coursecategories'},\@cats,\@trails,\%allitems);
+    }
+    if ((keys(%changes) > 0) || (keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
+        $putresult = &Apache::lonnet::put_dom('configuration',\%domconfig,$dom);
         if ($putresult eq 'ok') {
+            my %title = (
+                         togglecats  => 'Show/Hide a course in the catalog',
+                         categorize     => 'Category assigned to course',
+                        );
+            my %level = (
+                         dom => 'set from "Modify Course" (Domain)',
+                         crs => 'set from "Parameters" (Course)',
+                        );
             $resulttext = &mt('Changes made:').'<ul>';
-            if (keys(%deletions) > 0) {
-                $resulttext .= '<li>'.&mt('Deleted categories:').'<ul>';
-                foreach my $predeltrail (sort {$a <=> $b } (keys(%sort_by_deltrail))) { 
-                    $resulttext .= '<li>'.$predeltrails[$predeltrail].'</li>';
-                }
-                $resulttext .= '</ul></li>';
+            if ($changes{'togglecats'}) {
+                $resulttext .= '<li>'.&mt("$title{'togglecats'} $level{$env{'form.togglecats'}}").'</li>'; 
             }
-            if (keys(%reorderings) > 0) {
-                my %sort_by_trail;
-                $resulttext .= '<li>'.&mt('Reordered categories:').'<ul>';
-                foreach my $key (keys(%reorderings)) {
-                    if ($allitems{$key} ne '') {
-                        $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
-                    }
-                }
-                foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
-                    $resulttext .= '<li>'.$trails[$trail].'</li>';
-                }
-                $resulttext .= '</ul></li>';
+            if ($changes{'categorize'}) {
+                $resulttext .= '<li>'.&mt("$title{'categorize'} $level{$env{'form.categorize'}}").'</li>';
             }
-            if (keys(%adds) > 0) {
-                my %sort_by_trail;
-                $resulttext .= '<li>'.&mt('Added categories:').'<ul>';
-                foreach my $key (keys(%adds)) {
-                    if ($allitems{$key} ne '') {
-                        $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
+            if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
+                my $cathash;
+                if (ref($domconfig{'coursecategories'}) eq 'HASH') {
+                    $cathash = $domconfig{'coursecategories'}{'cats'};
+                } else {
+                    $cathash = {};
+                } 
+                my (@cats,@trails,%allitems);
+                    &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems);
+                if (keys(%deletions) > 0) {
+                    $resulttext .= '<li>'.&mt('Deleted categories:').'<ul>';
+                    foreach my $predeltrail (sort {$a <=> $b } (keys(%sort_by_deltrail))) { 
+                        $resulttext .= '<li>'.$predeltrails[$predeltrail].'</li>';
+                    }
+                    $resulttext .= '</ul></li>';
+                }
+                if (keys(%reorderings) > 0) {
+                    my %sort_by_trail;
+                    $resulttext .= '<li>'.&mt('Reordered categories:').'<ul>';
+                    foreach my $key (keys(%reorderings)) {
+                        if ($allitems{$key} ne '') {
+                            $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
+                        }
                     }
+                    foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
+                        $resulttext .= '<li>'.$trails[$trail].'</li>';
+                    }
+                    $resulttext .= '</ul></li>';
                 }
-                foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
-                    $resulttext .= '<li>'.$trails[$trail].'</li>';
+                if (keys(%adds) > 0) {
+                    my %sort_by_trail;
+                    $resulttext .= '<li>'.&mt('Added categories:').'<ul>';
+                    foreach my $key (keys(%adds)) {
+                        if ($allitems{$key} ne '') {
+                            $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
+                        }
+                    }
+                    foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
+                        $resulttext .= '<li>'.$trails[$trail].'</li>';
+                    }
+                    $resulttext .= '</ul></li>';
                 }
-                $resulttext .= '</ul></li>';
             }
             $resulttext .= '</ul>';
         } else {
             $resulttext = '<span class="LC_error">'.
-                &mt('An error occurred: [_1]',$putresult).'</span>';
+                          &mt('An error occurred: [_1]',$putresult).'</span>';
         }
     } else {
         $resulttext = &mt('No changes made to course categories');

--raeburn1214527368--