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

raeburn raeburn@source.lon-capa.org
Fri, 19 Nov 2010 20:32:39 -0000


raeburn		Fri Nov 19 20:32:39 2010 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm 
  Log:
  - Consistent behavior for bulletin boards for course configuration:
    exclusion from contributing to discussions (role or user-based) -- pch priv.
    - Textarea for posting not shown if pch priv prevents posts by current user.
    - Show "Discussion closed" if unable to post.
    - If board is a group board and user has pgd priv for the group, this 
      trumps exclusion based on pch priv.
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.302 loncom/interface/lonfeedback.pm:1.303
--- loncom/interface/lonfeedback.pm:1.302	Tue Sep 21 04:18:50 2010
+++ loncom/interface/lonfeedback.pm	Fri Nov 19 20:32:38 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.302 2010/09/21 04:18:50 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.303 2010/11/19 20:32:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -732,12 +732,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>';
+        }
     } elsif ($outputtarget ne 'tex') {
         $discussion.='<div class="LC_feedback_link">';
         if (&discussion_open($status) &&
@@ -2618,7 +2629,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');
@@ -2674,9 +2685,9 @@
             $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 '') && (&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" /> '.
@@ -2815,7 +2826,7 @@
 }
 
 sub adddiscuss {
-    my ($symb,$email,$anon,$attachmenturl,$subject)=@_;
+    my ($symb,$email,$anon,$attachmenturl,$subject,$group)=@_;
     my $status='';
     my $realsymb;
     if ($symb=~/^bulletin___/) {
@@ -2824,8 +2835,9 @@
 	$realsymb=&Apache::lonnet::symbread($filename);
     }
     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')))) {
 
     my %contrib=('message'      => $email,
                  'sendername'   => $env{'user.name'},
@@ -3870,7 +3882,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 {
@@ -3952,7 +3964,7 @@
 	  my $subject = &clear_out_html($env{'form.subject'});
 	  my $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} );
 	  $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl,
-				  $subject);
+				  $subject,$group);
 	  $numpost++;
       }