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

raeburn lon-capa-cvs@mail.lon-capa.org
Tue, 31 Aug 2004 22:27:11 -0000


raeburn		Tue Aug 31 18:27:11 2004 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm 
  Log:
  1. Guy's fixes so close date for bulletin boards work correctly, and advanced users can still see posts after close, when display blocked fro students.
  2. A fix so subject and comment are preserved when added via HTMLarea during round-trip to add attachments screen.
  3. Clean-up: sub build_ims() no longer needed. Export achieved via other routines.
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.121 loncom/interface/lonfeedback.pm:1.122
--- loncom/interface/lonfeedback.pm:1.121	Tue Aug 31 14:31:31 2004
+++ loncom/interface/lonfeedback.pm	Tue Aug 31 18:27:10 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.121 2004/08/31 18:31:31 albertel Exp $
+# $Id: lonfeedback.pm,v 1.122 2004/08/31 22:27:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -41,13 +41,13 @@
 use Cwd;
 
 sub discussion_open {
-    my ($status)=@_;
+    my ($status,$symb)=@_;
     if (defined($status) &&
 	!($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
 	  || $status eq 'OPEN')) {
 	return 0;
     }
-    my $close=&Apache::lonnet::EXT('resource.0.discussend');
+    my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb);
     if (defined($close) && $close ne '' && $close < time) {
 	return 0;
     }
@@ -59,7 +59,7 @@
     if (not &discussion_open($status)) {
 	my $hidden=&Apache::lonnet::EXT('resource.0.discusshide');
 	if (lc($hidden) eq 'yes' or $hidden eq '' or !defined($hidden))  {
-	    return 0;
+	    if (!$ENV{'request.role.adv'}) { return 0; }
 	}
     }
     return 1;
@@ -626,7 +626,8 @@
                 $attachnum += @currnewattach;
             }
         }
-	$discussion.=(<<ENDDISCUSS);
+	if (&discussion_open($status)) {
+	    $discussion.=(<<ENDDISCUSS);
 <form action="/adm/feedback" method="post" name="mailform" enctype="multipart/form-data">
 <input type="submit" name="discuss" value="Post Discussion" />
 <input type="submit" name="anondiscuss" value="Post Anonymous Discussion" />
@@ -665,6 +666,7 @@
             $discussion.=$newattachmsg;
 	    $discussion.=&generate_preview_button();
 	}
+	}
         } else {
 	if (&discussion_open($status) &&
 	    &Apache::lonnet::allowed('pch',
@@ -1977,45 +1979,6 @@
     return;
 }
 
-sub build_ims_export {
-    my ($r,$symb,$previous,$feedurl) = @_;
- # backward compatibility (bulletin boards used to be 'wrapped')
-    if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
-        $feedurl=~s|^/adm/wrapper||;
-    }
-    my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
-                          $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                          $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
-    my @depth=();
-    my %alldiscussion=();
-    my @discussionitems=();
-    my %usernamesort = ();
-    my %subjectsort = ();
-    my %namesort = ();
-    my %notshown = ();
-    my %newitem = ();
-    my %dischash = ();
-    my %shown = ();
-    my %roleinfo = ();
-    my @posters=();
-    my $maxdepth=0;
-    my $visible=0;
-    my $newpostsflag=0;
-    my $status;
-    my $viewgrades;
-    my $seeid;
-    my $prevread;
-    my $sortposts;
-    my $ressymb;
-    my $target;
-    my $readkey;
-    my $showunmark;
-    my $showonlyunread;
-
-}
-
-
-
 sub fail_redirect {;
   my ($r,$feedurl) = @_;
   if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
@@ -2334,7 +2297,13 @@
 sub adddiscuss {
     my ($symb,$email,$anon,$attachmenturl,$subject)=@_;
     my $status='';
-    if (&discussion_open() &&
+    my $realsymb;
+    if ($symb=~/^bulletin___/) {
+	my $filename=(&Apache::lonnet::decode_symb($symb))[2];
+	$filename=~s|^adm/wrapper/||;
+	$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'}:''))) {
 
@@ -2600,7 +2569,7 @@
     my $response = (<<END);
 <form name="attachment" action="/adm/feedback?attach=$ressymb" method="post">
 Click to add/remove attachments:&nbsp;<input type="button" value="$att"
-onClick="this.form.subject.value=document.mailform.subject.value;this.form.comment.value=document.mailform.comment.value;
+onClick="if (typeof(document.mailform.onsubmit)=='function') {document.mailform.onsubmit();};this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;
 END
     unless ($mode eq 'board') {
         $response .= 'javascript:anonchk();';
@@ -3194,7 +3163,6 @@
           $status=$Apache::inputtags::status[-1];
       }
       my $discussion = &list_discussion($mode,$status,$symb); 
-#      &build_ims_export($r,$symb,$previous,$feedurl);
       my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion');
       $r->print($bodytag.$discussion);                                     
       return OK;