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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 03 Jun 2004 20:28:23 -0000


albertel		Thu Jun  3 16:28:23 2004 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm 
  Log:
  - if the discussion is closed, make sure they can't post at all
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.89 loncom/interface/lonfeedback.pm:1.90
--- loncom/interface/lonfeedback.pm:1.89	Thu Jun  3 16:06:15 2004
+++ loncom/interface/lonfeedback.pm	Thu Jun  3 16:28:22 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.89 2004/06/03 20:06:15 albertel Exp $
+# $Id: lonfeedback.pm,v 1.90 2004/06/03 20:28:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,18 +37,25 @@
 use Apache::lonlocal; # must not have ()
 use Apache::lonhtmlcommon();
 
-sub list_discussion {
-    my ($mode,$status,$symb)=@_;
-
+sub discussion_closed {
+    my ($status)=@_;
     if (!($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
 	  || $status eq 'OPEN')) {
-	return '';
+	return '1';
     }
     my $close=&Apache::lonnet::EXT('resource.0.discussend');
     if (defined($close) && $close ne '' && $close < time) {
-	return ''
+	return '1'
     }
+    return 0;
+}
 
+sub list_discussion {
+    my ($mode,$status,$symb)=@_;
+
+    if (&discussion_closed($status)) {
+	return '';
+    }
     my @bgcols = ("#cccccc","#eeeeee");
     my $discussiononly=0;
     if ($mode eq 'board') { $discussiononly=1; }
@@ -252,7 +259,8 @@
 			    $sender='<i>'.$screenname.'</i>';
 			}
 		    }
-		    if (&Apache::lonnet::allowed('pch',
+		    if (!&discusion_closed($status) &&
+			&Apache::lonnet::allowed('pch',
 						 $ENV{'request.course.id'}.
 						 ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
 			$sender.=' <a href="/adm/feedback?replydisc='.
@@ -424,7 +432,8 @@
 ENDDISCUSS
       $discussion.=&generate_preview_button();
     } else {
-	if (&Apache::lonnet::allowed('pch',
+	if (!&discussion_closed($status) &&
+	    &Apache::lonnet::allowed('pch',
 				   $ENV{'request.course.id'}.
 	($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
 			    $discussion.='<table bgcolor="#BBBBBB"><tr><td><a href="/adm/feedback?replydisc='.
@@ -647,7 +656,8 @@
 	}
     }
     if ($ENV{'request.course.id'}) {
-	if (&Apache::lonnet::allowed('pch',
+	if (not &discussion_closed() &&
+	    &Apache::lonnet::allowed('pch',
 				     $ENV{'request.course.id'}.
 				     ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
 	    $discussoptions='<input type="checkbox" name="discuss" onClick="this.form.anondiscuss.checked=false;" '.
@@ -823,7 +833,8 @@
 sub adddiscuss {
     my ($symb,$email,$anon,$attachmenturl,$subject)=@_;
     my $status='';
-    if (&Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
+    if (not &discussion_closed() &&
+	&Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
         ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
 
     my %contrib=('message'      => $email,