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

raeburn raeburn@source.lon-capa.org
Fri, 24 Dec 2010 23:18:57 -0000


raeburn		Fri Dec 24 23:18:57 2010 EDT

  Modified files:              (Branch: version_2_10_X)
    /loncom/interface	lonfeedback.pm 
  Log:
  - Backport 1.303, 1.304.
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.290.2.6 loncom/interface/lonfeedback.pm:1.290.2.7
--- loncom/interface/lonfeedback.pm:1.290.2.6	Tue Sep 21 05:40:59 2010
+++ loncom/interface/lonfeedback.pm	Fri Dec 24 23:18:57 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.290.2.6 2010/09/21 05:40:59 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.290.2.7 2010/12/24 23:18:57 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -727,9 +727,10 @@
                 $attachnum += @{$currnewattach};
             }
         }
-	if (&discussion_open($status) && ($outputtarget ne 'tex')) {
-            if (($group ne '') && ($mode eq 'board')) {  
-                if (&check_group_priv($group,'pgd') eq 'ok') {
+	if ((&discussion_open($status)) && ($outputtarget ne 'tex')) {
+            if (($group ne '') && ($mode eq 'board')) {
+                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>';
+        }
     } elsif ($outputtarget ne 'tex') {
         $discussion.='<div class="LC_feedback_link">';
         if (&discussion_open($status) &&
@@ -760,8 +772,7 @@
         } else {
             $discussion.= '<span class="LC_feedback_link">'.&mt('This discussion is closed.').'</span>';
         }
-	$discussion.= &send_message_link($ressymb).
-                      '</div>';
+	$discussion.= &send_message_link($ressymb).'</div>';
     }
     return $discussion;
 }
@@ -2291,7 +2302,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;
         }
@@ -2632,7 +2643,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');
@@ -2681,6 +2692,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];
@@ -2688,9 +2701,10 @@
             $realsymb=&Apache::lonnet::symbread($filename);
         }
         if (!$blocked && &discussion_open(undef,$realsymb) && 
-	    &Apache::lonnet::allowed('pch',
+	    (&Apache::lonnet::allowed('pch',
 				     $env{'request.course.id'}.
-				     ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
+				     ($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" /> '.
@@ -2829,7 +2843,7 @@
 }
 
 sub adddiscuss {
-    my ($symb,$email,$anon,$attachmenturl,$subject)=@_;
+    my ($symb,$email,$anon,$attachmenturl,$subject,$group)=@_;
     my $status='';
     my $realsymb;
     if ($symb=~/^bulletin___/) {
@@ -2837,9 +2851,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'},
@@ -3888,7 +3909,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 {
@@ -3948,7 +3969,7 @@
       if ($env{'form.discuss'} =~ /^(?:author|question|course|policy)$/) {
           $override = 1;
       }
-      my $message=&clear_out_html($env{'form.comment'},1);
+      my $message=&clear_out_html($env{'form.comment'},$override);
 
 # Assemble email
       my ($email,$citations)=&assemble_email($message,$prevattempts,
@@ -3970,7 +3991,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++;
       }