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

raeburn lon-capa-cvs@mail.lon-capa.org
Fri, 21 Jul 2006 02:46:53 -0000


raeburn		Thu Jul 20 22:46:53 2006 EDT

  Modified files:              
    /loncom/interface	loncoursegroups.pm 
  Log:
  If discussion functionality is added to a group wen modifying settings, a new discussion board folder is created for the group and an entry is added to the group_folder_$groupname sequence, if one does not currently exist.
  
  
Index: loncom/interface/loncoursegroups.pm
diff -u loncom/interface/loncoursegroups.pm:1.55 loncom/interface/loncoursegroups.pm:1.56
--- loncom/interface/loncoursegroups.pm:1.55	Thu Jul 20 18:17:14 2006
+++ loncom/interface/loncoursegroups.pm	Thu Jul 20 22:46:51 2006
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursegroups.pm,v 1.55 2006/07/20 22:17:14 raeburn Exp $
+# $Id: loncoursegroups.pm,v 1.56 2006/07/21 02:46:51 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2808,7 +2808,47 @@
                 $r->print(&mt('A problem occurred when creating folders for the new [_1]. [_2].<br />',$gpterm,$result));
             }
             $r->print(&mt('[_1] [_2] was created.<br />',$ucgpterm,$groupname));
-        } else {
+        } elsif ($action eq 'modify') {
+            my (@oldtools,@newtools); 
+            if (ref($$stored{'tool'}) eq 'ARRAY') {
+                @oldtools = @{$$stored{'tool'}};
+            }
+            if (ref($tools) eq 'ARRAY') {
+                @newtools = @{$tools};
+            }
+            if (!grep(/^discussion$/,@oldtools) && 
+                 grep(/^discussion$/,@newtools)) {
+                my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
+                my $boardsmap = $crspath.'group_boards_'.$groupname.'.sequence';
+                my $navmap = Apache::lonnavmaps::navmap->new();
+                my $bbmapres = $navmap->getResourceByUrl($boardsmap);
+                undef($navmap);
+                if (!$bbmapres) {
+                    my $grpmap = $crspath.'group_folder_'.$groupname.'.sequence';
+                    my $disctitle = &mt('Discussion Boards');
+                    my $outcome = &map_updater($cdom,$cnum,'group_boards_'.
+                                               $groupname.'.sequence','bbseq',
+                                               $disctitle,$grpmap);
+                    my ($furl,$ferr) = 
+                        &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
+                    $navmap = Apache::lonnavmaps::navmap->new();
+                    # modify parameter
+                    if ($outcome eq 'ok') {
+                        my $parm_result = &parm_setter($navmap,$cdom,$boardsmap,
+                                                       $groupname);
+                        if ($parm_result) {
+                            $r->print(&mt('Error while setting parameters '.
+                                          'for Discussion Boards folder: '.
+                                          '[_1]<br />.',$parm_result));
+                        } else {
+                            $r->print(&mt('Discussion Boards Folder created.<br />'));
+                        }
+                    } else {
+                        $r->print($outcome);
+                    }
+                    undef($navmap);
+                }
+            }
             $r->print(&mt('[_1] [_2] was updated.<br />',$ucgpterm,$groupname));
         }
     } else {