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

raeburn raeburn@source.lon-capa.org
Sat, 20 Nov 2010 01:33:04 -0000


raeburn		Sat Nov 20 01:33:04 2010 EDT

  Modified files:              (Branch: version_2_9_X)
    /loncom/interface	lonfeedback.pm 
  Log:
  - Backport 1.303, 1.304.
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.273.4.11 loncom/interface/lonfeedback.pm:1.273.4.12
--- loncom/interface/lonfeedback.pm:1.273.4.11	Tue Sep 21 04:58:17 2010
+++ loncom/interface/lonfeedback.pm	Sat Nov 20 01:33:04 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.273.4.11 2010/09/21 04:58:17 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.273.4.12 2010/11/20 01:33:04 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -727,9 +727,10 @@
                 $attachnum += @{$currnewattach};
             }
         }
-	if (&discussion_open($status)) {
+	if ((&discussion_open($status)) && ($outputtarget ne 'tex')) {
             if (($group ne '') && ($mode eq 'board')) {  
-                if (&check_group_priv($group,'pgd') eq 'ok') {
+                if ((&check_group_priv($group,'pgd') eq 'ok') && 
+                    ($ressymb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})) {
                     $discussion .=
 			&postingform_display($mode,$ressymb,$now,$subject,
 					     $comment,$outputtarget,$attachnum,
@@ -737,12 +738,23 @@
 					     $group,$crstype);
                 }
             } else {
-	        $discussion.= 
-		    &postingform_display($mode,$ressymb,$now,$subject,
-					 $comment,$outputtarget,$attachnum,
-					 $currnewattach,$currdelold,'',$crstype);
+                if (&Apache::lonnet::allowed('pch',$env{'request.course.id'}.
+                    ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
+
+                    $discussion.=
+		        &postingform_display($mode,$ressymb,$now,$subject,
+					     $comment,$outputtarget,$attachnum,
+					     $currnewattach,$currdelold,'',$crstype);
+                } else {
+                    $discussion.= '<span class="LC_feedback_link">'.
+                                  &mt('This discussion is closed.').'</span>';
+                }
             }
 	}
+        if (!(&discussion_open($status)) && ($outputtarget ne 'tex')) {
+            $discussion.= '<span class="LC_feedback_link">'.
+                          &mt('This discussion is closed.').'</span>';
+        }
     } else {
         $discussion.='<div class="LC_feedback_link">';
         if (&discussion_open($status) &&
@@ -2252,7 +2264,7 @@
     my $group = $env{'form.group'};
     my $ressymb = &wrap_symb($symb);
     if (($group ne '') &&
-        ($ressymb =~ m|^bulletin___ \d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|)) {
+        ($ressymb =~ m|^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|)) {
         if (&check_group_priv($group,'dgp') eq 'ok') {
             $seeid = 1;
         }
@@ -2593,7 +2605,7 @@
 }
 
 sub screen_header {
-    my ($feedurl,$symb) = @_;
+    my ($feedurl,$symb,$group) = @_;
     my $crscontent = &mt('Question/Comment/Feedback about course content');
     my $crspolicy = &mt('Question/Comment/Feedback about course policy');
     my $contribdisc = &mt('Contribution to course discussion of resource');
@@ -2642,6 +2654,8 @@
     }
     if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) {
         my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards');
+        my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+        my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
         my $realsymb = $symb;
         if ($symb=~/^bulletin___/) {
             my $filename=(&Apache::lonnet::decode_symb($symb))[2];
@@ -2649,9 +2663,10 @@
             $realsymb=&Apache::lonnet::symbread($filename);
         }
         if (!$blocked && &discussion_open(undef,$realsymb) &&
-	    &Apache::lonnet::allowed('pch',
-				     $env{'request.course.id'}.
-				     ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
+            (&Apache::lonnet::allowed('pch',
+                                      $env{'request.course.id'}.
+                                      ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) || 
+            (($group ne '') && ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$}) && (&check_group_priv($group,'pgd') eq 'ok')))) {
 	    $discussoptions='<label><input type="radio" name="discuss" value="nonanon" checked="checked" /> '.
                 $contribdisc.
                 '</label><br /><label><input type="radio" name="discuss" value="anon" /> '.
@@ -2791,7 +2806,7 @@
 }
 
 sub adddiscuss {
-    my ($symb,$email,$anon,$attachmenturl,$subject)=@_;
+    my ($symb,$email,$anon,$attachmenturl,$subject,$group)=@_;
     my $status='';
     my $realsymb;
     if ($symb=~/^bulletin___/) {
@@ -2799,9 +2814,16 @@
 	$filename=~s|^adm/wrapper/||;
 	$realsymb=&Apache::lonnet::symbread($filename);
     }
+    my ($cnum,$cdom);
+    if ($env{'request.course.id'}) {
+        $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+        $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+    }
     if (&discussion_open(undef,$realsymb) &&
-	&Apache::lonnet::allowed('pch',$env{'request.course.id'}.
-        ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
+	(&Apache::lonnet::allowed('pch',$env{'request.course.id'}.
+         ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) ||
+         (($group ne '') && (&check_group_priv($group,'pgd') eq 'ok') &&
+         ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})))) {
 
     my %contrib=('message'      => $email,
                  'sendername'   => $env{'user.name'},
@@ -3828,7 +3850,7 @@
                   return OK;
               }
           }
-	  my $options=&screen_header($feedurl,$symb);
+	  my $options=&screen_header($feedurl,$symb,$group);
 	  if ($options) {
 	      &mail_screen($r,$feedurl,$options,$symb,$attachmax{'text'});
 	  } else {
@@ -3907,7 +3929,7 @@
 	  my $subject = &clear_out_html($env{'form.subject'},undef,1);
 	  my $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} );
 	  $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl,
-				  $subject);
+				  $subject,$group);
 	  $numpost++;
       }