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

raeburn lon-capa-cvs@mail.lon-capa.org
Mon, 17 Jul 2006 21:59:25 -0000


raeburn		Mon Jul 17 17:59:25 2006 EDT

  Modified files:              
    /loncom/interface	lonbulletin.pm 
  Log:
  priv checking for group bulletin board editing for roles which include section specification. Breadcrumbs include link back to listing of groups if board was reached via the "Groups" link.
  
  
Index: loncom/interface/lonbulletin.pm
diff -u loncom/interface/lonbulletin.pm:1.36 loncom/interface/lonbulletin.pm:1.37
--- loncom/interface/lonbulletin.pm:1.36	Fri Jul  7 21:23:13 2006
+++ loncom/interface/lonbulletin.pm	Mon Jul 17 17:59:24 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Bulletin Board Handler
 #
-# $Id: lonbulletin.pm,v 1.36 2006/07/08 01:23:13 raeburn Exp $
+# $Id: lonbulletin.pm,v 1.37 2006/07/17 21:59:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -78,7 +78,7 @@
 # ------------------------------------------------------------ Get Query String
     &Apache::loncommon::get_unprocessed_cgi
                 ($ENV{'QUERY_STRING'},['forcestudent','forceedit','register',
-                                       'origpage','group']);
+                                       'origpage','group','ref']);
 # ----------------------------------------------------- Force menu registration
     my %addentries;
     if ($env{'form.origpage'}) {
@@ -90,6 +90,8 @@
 
     my $forceedit='';
     if ($env{'form.forceedit'}) { $forceedit='edit'; }
+    my $refarg = '';
+    if (exists($env{'form.ref'})) { $refarg = 'ref='.$env{'form.ref'}; }
 
     my %syllabus=&Apache::lonnet::dump('bulletinpage_'.$marker,$dom,$crs);
 
@@ -134,23 +136,26 @@
             my $gpterm =  &Apache::loncommon::group_term();
             my $ucgpterm = $gpterm;
             $ucgpterm =~ s/^(\w)/uc($1)/e;
-            my ($groupboards,$boards) = &Apache::longroup::get_group_bbinfo(
-                                                            $dom,$crs,$group);
-            my $boardtitle = $$boards{$marker}{'title'};
+            my ($groupboards,$boards) =
+                &Apache::longroup::get_group_bbinfo($dom,$crs,$group,$boardurl);
+            my $boardtitle;
+            if ((ref($groupboards) eq 'ARRAY') && (@{$groupboards} > 0)) {
+                $boardtitle = $$boards{$$groupboards[0]}{'title'};
+            }
             $boardurl .= '?register=1&group='.$group;
-            $r->print(&groupboard_breadcrumbs($dom,$crs,$group,$gpterm,
+            $r->print(&groupboard_breadcrumbs($dom,$crs,$group,$refarg,$gpterm,
                                 $ucgpterm,$grp_desc,$boardurl,$boardtitle));
         }
     }
     my ($allowed);
     if ($group ne '') {
-        $allowed=&Apache::lonnet::allowed('mdg',$env{'request.course.id'});
+        $allowed=&Apache::lonnet::allowed('mdg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
         if (!$allowed) {
             $allowed = &Apache::lonnet::allowed('cgb',$env{'request.course.id'}.
                                                 '/'.$group);
         }
         if (!$allowed) {
-            if ((!&Apache::lonnet::allowed('vcg',$env{'request.course.id'})) &&
+            if ((!&Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) &&
                (!&Apache::lonnet::allowed('vgb',$env{'request.course.id'}.
                                                 '/'.$group))) { 
                  &print_end_page($r,$target);
@@ -171,7 +176,7 @@
       if ($allowed) {
           my $query_str = 'forcestudent=1';
           if (($group ne '') && ($env{'form.group'} eq $group)) {
-              $query_str.='&group='.$group;
+              $query_str.='&group='.$group.'&'.$refarg;
           }
           $r->print(
 	  '<p>'.
@@ -180,7 +185,7 @@
       }  elsif ($privileged and $target ne 'tex') {
           my $query_str = 'forceedit=edit';
           if (($group ne '') && ($env{'form.group'} eq $group)) {
-              $query_str.='&amp;group='.$group;
+              $query_str.='&amp;group='.$group.'&amp;'.$refarg;
           }
 	  $r->print('<a href="'.$r->uri.'?'.$query_str.'"><font size="+1">'
 		    .&mt('Edit').'</font></a>');
@@ -281,11 +286,11 @@
     if ($target ne 'tex') {
 	$r->print(&Apache::lonfeedback::list_discussion
 	           ('board','OPEN','bulletin___'.$marker.'___'.
-	            $r->uri));
+	            $r->uri,undef,$group));
     } else {
 	$r->print('\\\\'.&Apache::lonxml::xmlparse($r,'tex',&Apache::lonfeedback::list_discussion
 	           ('board','OPEN','bulletin___'.$marker.'___'.
-	            $r->uri)));
+	            $r->uri,undef,$group)));
     }
     &print_end_page($r,$target);
     return OK;
@@ -301,13 +306,20 @@
 }
 
 sub groupboard_breadcrumbs {
-    my ($cdom,$cnum,$group,$gpterm,$ucgpterm,$description,$boardurl,$boardtitle)= @_;
+    my ($cdom,$cnum,$group,$refarg,$gpterm,$ucgpterm,$description,$boardurl,
+        $boardtitle)= @_;
     &Apache::lonhtmlcommon::clear_breadcrumbs();
+    if ($refarg ne '') {
+        &Apache::lonhtmlcommon::add_breadcrumb
+            ({href=>"/adm/coursegroups",
+              text=>"Groups",
+              title=>"View course groups"});
+    }
     &Apache::lonhtmlcommon::add_breadcrumb
-        ({href=>"/adm/$cdom/$cnum/$group/smppg",
+        ({href=>"/adm/$cdom/$cnum/$group/smppg?$refarg",
           text=>"$ucgpterm: $description",
           title=>"Go to group's home page"},
-         {href=>"/adm/groupboards?group=$group",
+         {href=>"/adm/groupboards?group=$group&amp;$refarg",
           text=>"Discussion Boards",
           title=>"Display group discussion boards"},
          {href=>"$boardurl",