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

raeburn lon-capa-cvs@mail.lon-capa.org
Fri, 30 Jun 2006 18:27:20 -0000


This is a MIME encoded message

--raeburn1151692040
Content-Type: text/plain

raeburn		Fri Jun 30 14:27:20 2006 EDT

  Modified files:              
    /loncom/interface	loncoursegroups.pm longroup.pm groupboards.pm 
  Log:
  Moving get_bbfolder_url() and get_group_bbinfo() to longroup.pm.  symb no longer needed for each bulletinboard when building links in groupboards.pm.  Total number of discussion boards now displayed in view group table for each group.  Also some alignment changes in this table.
  
  
--raeburn1151692040
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060630142720.txt"

Index: loncom/interface/loncoursegroups.pm
diff -u loncom/interface/loncoursegroups.pm:1.32 loncom/interface/loncoursegroups.pm:1.33
--- loncom/interface/loncoursegroups.pm:1.32	Fri Jun 30 04:14:31 2006
+++ loncom/interface/loncoursegroups.pm	Fri Jun 30 14:27:19 2006
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursegroups.pm,v 1.32 2006/06/30 08:14:31 raeburn Exp $
+# $Id: loncoursegroups.pm,v 1.33 2006/06/30 18:27:19 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -230,7 +230,10 @@
                     $grp_info{$group}{'diskuse'} = sprintf("%.0f",$pct_use);
                 } else {
                     $grp_info{$group}{'diskuse'} = 'N/A';
-                }     
+                }
+                my ($groupboards,$boardshash)=&Apache::longroup::get_group_bbinfo(
+                                                               $cdom,$cnum,$group);
+                $grp_info{$group}{'boards'} = scalar(@{$groupboards});
                 if ($env{'form.sortby'} eq 'groupname') {
                     push(@{$Sortby{$group}},$group);
                 } elsif ($env{'form.sortby'} eq 'description') {
@@ -299,7 +302,7 @@
                                       $group.'">'.$lt{'modify'}.'</a>';
                         }
                     }
-                    $r->print('<tr bgcolor="'.$rowColor.'"><td><small>'.$link.'</small></td><td><small>'.$group.'</small></td><td><small>'.$description.'</small></td><td><small>'.$creator.'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($creation).'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($modified).'</small></td><td><small>'.$functionality.'</small></td><td><small>'.$quota.'</small></td><td><small>'.$totalmembers.'</small></td><td><small><nobr>'.&mt('Files: ').$totalfiles.'</nobr><br /><nobr>'.&mt('Folders: ').$totaldirs.'</nobr></small></td><td><small>'.$boards.'</small></td><td><small>'.$diskuse.'</small></td></tr>');
+                    $r->print('<tr bgcolor="'.$rowColor.'"><td><small>'.$link.'</small></td><td><small>'.$group.'</small></td><td><small>'.$description.'</small></td><td><small>'.$creator.'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($creation).'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($modified).'</small></td><td><small>'.$functionality.'</small></td><td align="right"><small>'.$quota.'</small></td><td align="right"><small>'.$totalmembers.'</small></td><td align="right"><small><nobr>'.&mt('Files: ').$totalfiles.'</nobr><br /><nobr>'.&mt('Folders: ').$totaldirs.'</nobr></small></td><td align="right"><small>'.$boards.'</small></td><td align="right"><small>'.$diskuse.'</small></td></tr>');
                     $rowNum ++;
                 }
             }
@@ -3638,7 +3641,7 @@
         #modify group folder if status of discussions tools is changed
     }
     my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
-    my $navmap = Apache::lonnavmaps::navmap->new();
+    $navmap = Apache::lonnavmaps::navmap->new();
     # modify parameters
     my $parm_result;
     if ($action eq 'create') {
Index: loncom/interface/longroup.pm
diff -u loncom/interface/longroup.pm:1.6 loncom/interface/longroup.pm:1.7
--- loncom/interface/longroup.pm:1.6	Wed Jun 28 19:38:10 2006
+++ loncom/interface/longroup.pm	Fri Jun 30 14:27:19 2006
@@ -452,5 +452,49 @@
 
 ###############################################
 
+sub get_bbfolder_url {
+    my ($cdom,$cnum,$group) = @_;
+    my %curr_groups = &coursegroups($cdom,$cnum,$group);
+    my $grpbbmap;
+    if (%curr_groups) {
+        my %group_info =  &get_group_settings($curr_groups{$group});
+        my $creation = $group_info{'creation'};
+        my $bbfolder = $creation + 1;
+        my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
+        $grpbbmap = $crspath.'default_'.$bbfolder.'.sequence';
+    }
+    return $grpbbmap;
+}
+
+###############################################
+
+sub get_group_bbinfo {
+    my ($cdom,$cnum,$group) = @_;
+    my $navmap = Apache::lonnavmaps::navmap->new();
+    my @groupboards;
+    my %boardshash;
+    my $grpbbmap = &get_bbfolder_url($cdom,$cnum,$group);
+    if ($grpbbmap) {
+        my $bbfolderres = $navmap->getResourceByUrl($grpbbmap);
+        if ($bbfolderres) {
+            my @boards = $navmap->retrieveResources($bbfolderres,undef,0,0);
+            foreach my $res (@boards) {
+                my $url = $res->src();
+                if ($url =~ m|^/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard|) {
+                    push(@groupboards,$res->symb());
+                    $boardshash{$res->symb()} = {
+                                                  title => $res->title(),
+                                                  url   => $res->src(),
+                                                };
+                }
+            }
+        }
+    }
+    undef($navmap);
+    return (\@groupboards,\%boardshash);
+}
+
+###############################################
+
 1;
 
Index: loncom/interface/groupboards.pm
diff -u loncom/interface/groupboards.pm:1.3 loncom/interface/groupboards.pm:1.4
--- loncom/interface/groupboards.pm:1.3	Fri Jun 30 11:37:58 2006
+++ loncom/interface/groupboards.pm	Fri Jun 30 14:27:19 2006
@@ -73,7 +73,7 @@
     if (defined($env{'form.newbul'})) {
         if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) {
             $r->print(&Apache::loncommon::start_page($bodytitle));
-            my ($outcome,$symb,$newurl,$bbtitle) = 
+            my ($outcome,$newurl,$bbtitle) = 
 		&create_board($cdom,$cnum,$group,$env{'form.newbul'});
             if ($outcome eq 'ok') {
                 my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
@@ -114,25 +114,8 @@
         return OK;
     }
     my $navmap = Apache::lonnavmaps::navmap->new();
-    my @groupboards;
-    my %boards;
-    my $grpbbmap = &get_bbfolder_url($cdom,$cnum,$group);
-    if ($grpbbmap) {
-        my $bbfolderres = $navmap->getResourceByUrl($grpbbmap);
-        if ($bbfolderres) {
-            my @boards = $navmap->retrieveResources($bbfolderres,undef,0,0);
-            foreach my $res (@boards) {
-                my $url = $res->src();
-                if ($url =~ m|^/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard|) {
-                    push(@groupboards,$res->symb());
-                    $boards{$res->symb()} = {
-                                        title => $res->title(),
-                                        url   => $res->src(),
-				    };
-                }
-            }
-        }
-    }
+    my ($groupboards,$boards) = &Apache::longroup::get_group_bbinfo($cdom,$cnum,
+                                                                    $group);
     if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) {
         $r->print('<form method="post" name="newbb" action="/adm/groupboards">'.
                   "\n".'<input type="button" name="bbbutton" value="'.
@@ -142,9 +125,9 @@
                   '  <input type="hidden" name="group" value="'.$group.'" />'.
                   "\n".'</form><br />');
     }
-    if (@groupboards) {
-        foreach my $board (@groupboards) {
-            $r->print('<a href="'.$boards{$board}{'url'}.'?group='.$group.'">'.$boards{$board}{'title'}.'</a><br />');
+    if (@{$groupboards} > 0) {
+        foreach my $board (@{$groupboards}) {
+            $r->print('<a href="'.$$boards{$board}{'url'}.'?group='.$group.'">'.$$boards{$board}{'title'}.'</a><br />');
         }
     } else {
         $r->print(&mt('There are currently no discussion boards in this [_1].',
@@ -155,12 +138,12 @@
 }
 
 sub create_board {
-    my ($cdom,$cnum,$group,$newboard,$symb) = @_;
+    my ($cdom,$cnum,$group,$newboard) = @_;
     my ($bbtitle,$newurl)=split(/\=/,$newboard);
     $bbtitle=&unescape($bbtitle);
     $newurl=&unescape($newurl);
-    my $allbbsmap = &get_bbfolder_url($cdom,$cnum,$group);
-    my ($outcome,$symb);
+    my $allbbsmap = &Apache::longroup::get_bbfolder_url($cdom,$cnum,$group);
+    my ($outcome);
     if ($allbbsmap =~ m|^/uploaded|) {
         my ($errtext,$fatal)=&Apache::lonratedt::mapread($allbbsmap);
         if (!$fatal) {
@@ -173,7 +156,6 @@
                 $outcome = "error: failed to store discussion boards map - $errtext\n";
             } else {
                 $outcome = 'ok';
-                $symb = &Apache::lonnet::encode_symb($allbbsmap,$newidx,$newurl);
             }
         } else {
             $outcome = "error: failed to read all discussion boards map - $errtext\n";
@@ -182,22 +164,7 @@
         $outcome = 'error: discussion boards folder absent, '.
                    'or in unexpected location - '.$allbbsmap."\n";
     }
-    return ($outcome,$symb,$newurl,$bbtitle);
-}
-
-sub get_bbfolder_url {
-    my ($cdom,$cnum,$group) = @_;
-    my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$group);
-    my $grpbbmap;
-    if (%curr_groups) {
-        my %group_info =  &Apache::longroup::get_group_settings(
-                                                    $curr_groups{$group});
-        my $creation = $group_info{'creation'};
-        my $bbfolder = $creation + 1;
-        my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
-        $grpbbmap = $crspath.'default_'.$bbfolder.'.sequence';
-    }
-    return $grpbbmap;
+    return ($outcome,$newurl,$bbtitle);
 }
 
 1;

--raeburn1151692040--