--- loncom/interface/lonfeedback.pm 2004/08/19 02:08:27 1.117 +++ loncom/interface/lonfeedback.pm 2004/09/15 06:17:11 1.126 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.117 2004/08/19 02:08:27 albertel Exp $ +# $Id: lonfeedback.pm,v 1.126 2004/09/15 06:17:11 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,13 +41,13 @@ use Apache::lonspeller(); 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 @@ sub discussion_visible { 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; @@ -165,34 +165,39 @@ sub list_discussion { } # Get discussion display default settings for user - my %userenv = &Apache::lonnet::get('environment',['discdisplay','discmarkread'],$ENV{'user.domain'},$ENV{'user.name'}); - my $discdisplay=$userenv{'discdisplay'}; - if ($discdisplay eq 'unread') { + if ($ENV{'environment.discdisplay'} eq 'unread') { $showonlyunread = 1; } - my $discmarkread=$userenv{'discmarkread'}; - if ($discmarkread eq 'ondisp') { + if ($ENV{'environment.discmarkread'} eq 'ondisp') { $markondisp = 1; } # Override user's default if user specified display setting for this discussion if (defined($dischash{$ondispkey})) { - $markondisp = $dischash{$ondispkey}; + unless ($dischash{$ondispkey} eq '') { + $markondisp = $dischash{$ondispkey}; + } } if ($markondisp) { $discinfo{$lastkey} = time; } if (defined($dischash{$showkey})) { - $showonlyunread = $dischash{$showkey}; + unless ($dischash{$showkey} eq '') { + $showonlyunread = $dischash{$showkey}; + } } if (defined($dischash{$markkey})) { - $showunmark = $dischash{$markkey}; + unless ($dischash{$markkey} eq '') { + $showunmark = $dischash{$markkey}; + } } if (defined($dischash{$visitkey})) { - $visit = $dischash{$visitkey}; + unless ($dischash{$visitkey} eq '') { + $visit = $dischash{$visitkey}; + } } $visit ++; @@ -324,7 +329,6 @@ sub list_discussion { # open manifest file my $manifest = '/imsmanifest.xml'; my $manifestfilename = $tempexport.$manifest; - print STDERR "manifestfilename is $manifestfilename\n"; if ($manifestfile = Apache::File->new('>'.$manifestfilename)) { $manifestok=1; print $manifestfile qq| @@ -474,7 +478,6 @@ imscp_v1p1.xsd http://www.imsglobal.org/ my $postfilename = $alldiscussion{$_}.'-'.$imsitems{$alldiscussion{$_}}{'timestamp'}.'.html'; if ($manifestok) { if (($depth[$alldiscussion{$_}] <= $currdepth) && ($alldiscussion{$_} != $firstidx)) { - print STDERR "depth is $depth[$alldiscussion{$_}], currdepth is $currdepth, idx is $alldiscussion{$_}, firstidx is $firstidx\n"; print $manifestfile ' '."\n"; } $currdepth = $depth[$alldiscussion{$_}]; @@ -600,7 +603,7 @@ END undef(%oldENV); $discussion .= 'Download the zip file from Discussion Posting Archive
'; if ($copyresult) { - $discussion .= 'The following errors occurred during export - '.$copyresult; + $discussion .= 'The following errors occurred during export -
'.$copyresult; } } else { $discussion .= '
Unfortunately you will not be able to retrieve an archive of the discussion posts at this time, because there was a problem creating a manifest file.
'; @@ -618,15 +621,16 @@ END my $subject = ''; if ($ENV{'form.origpage'}) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['addnewattach','deloldattach','delnewattach','timestamp','idx','subject','comment']); - $subject = &HTML::Entities::encode($ENV{'form.subject'},'<>&"'); - $comment = &HTML::Entities::encode($ENV{'form.comment'},'<>&"'); + $subject = &Apache::lonnet::unescape($ENV{'form.subject'}); + $comment = &Apache::lonnet::unescape($ENV{'form.comment'}); my @keepold = (); &process_attachments(\@currnewattach,\@currdelold,\@keepold); if (@currnewattach > 0) { $attachnum += @currnewattach; } } - $discussion.=(< @@ -665,6 +669,7 @@ ENDDISCUSS $discussion.=$newattachmsg; $discussion.=&generate_preview_button(); } + } } else { if (&discussion_open($status) && &Apache::lonnet::allowed('pch', @@ -1046,12 +1051,14 @@ sub get_post_contents { return $discussion; } } - $$screenname=&Apache::loncommon::screenname( - $$contrib{$idx.':sendername'}, - $$contrib{$idx.':senderdomain'}); - $$plainname=&Apache::loncommon::nickname( - $$contrib{$idx.':sendername'}, - $$contrib{$idx.':senderdomain'}); +# $$screenname=&Apache::loncommon::screenname( +# $$contrib{$idx.':sendername'}, +# $$contrib{$idx.':senderdomain'}); +# $$plainname=&Apache::loncommon::nickname( +# $$contrib{$idx.':sendername'}, +# $$contrib{$idx.':senderdomain'}); + ($$screenname,$$plainname)=($$contrib{$idx.':screenname'}, + $$contrib{$idx.':plainname'}); my $sender=&Apache::loncommon::aboutmewrapper( $$plainname, $$contrib{$idx.':sendername'}, @@ -1149,22 +1156,23 @@ sub replicate_attachments { $i ++; } my ($content,$rtncode); - print STDERR "File to replicate is $$attachrefs{$id}{'filename'} in $1,$2\n"; my $uploadreply = &Apache::lonnet::getuploaded('GET',$$attachrefs{$id}{'filename'},$1,$2,$content,$rtncode); if ($uploadreply eq 'ok') { - my $attachcopy; - if ($attachcopy = Apache::File->new('>'.$destination)) { - print $attachcopy $content; - close($attachcopy); - } else { - $response .= 'Error copying a file attachment to IMS package: '.$!.'
'."\n"; - } + my $attachcopy; + if ($attachcopy = Apache::File->new('>'.$destination)) { + print $attachcopy $content; + close($attachcopy); + } else { + $response .= 'Error copying file attachment - '.$5.' to IMS package: '.$!.'
'."\n"; + } } else { - print STDERR "return code from lonnet was $rtncode\n"; + &Apache::lonnet::logthis("Replication of attachment failed when building IMS export of discussion posts - domain: $1, course: $2, file: $$attachrefs{$id}{'filename'} -error: $rtncode"); + $response .= 'Error copying file attachment - '.$5.' to IMS package: '.$rtncode.'
'."\n"; } } } } + return $response; } sub mail_screen { @@ -1306,8 +1314,8 @@ END } if ($ENV{'form.origpage'}) { - $subject = $ENV{'form.subject'}; - $comment = $ENV{'form.comment'}; + $subject = &Apache::lonnet::unescape($ENV{'form.subject'}); + $comment = &Apache::lonnet::unescape($ENV{'form.comment'}); &process_attachments(\@currnewattach,\@currdelold,\@keepold); } my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(); @@ -1355,7 +1363,7 @@ $htmlheader } if (rec) { - if (typeof(document.mailform.onsubmit)!='undefined') { + if (typeof(document.mailform.onsubmit)=='function') { document.mailform.onsubmit(); } document.mailform.submit(); @@ -1977,45 +1985,6 @@ sub get_post_attachments { 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' }; @@ -2028,6 +1997,7 @@ sub fail_redirect {; Sorry, no recipients ... +
Continue ENDFAILREDIR @@ -2098,6 +2068,7 @@ $roletag $sectag $userpicktag +
Continue ENDREDIR @@ -2106,6 +2077,7 @@ ENDREDIR sub no_redirect_back { my ($r,$feedurl) = @_; my $nofeed=&mt('Sorry, no feedback possible on this resource ...'); + my $continue=&mt('Continue'); $r->print (< Feedback not sent @@ -2121,6 +2093,7 @@ ENDNOREDIR $nofeed +
$continue ENDNOREDIRTWO @@ -2330,7 +2303,13 @@ sub send_msg { 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'}:''))) { @@ -2453,14 +2432,15 @@ sub generate_preview_button { +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;this.form.submit();" /> ENDPREVIEW } sub modify_attachments { my ($r,$currnewattach,$currdelold,$symb,$idx,$attachmenturls)=@_; - my $subject=&clear_out_html($ENV{'form.subject'}); + my $orig_subject = &Apache::lonnet::unescape($ENV{'form.subject'}); + my $subject=&clear_out_html($orig_subject); $subject=~s/\n/\
/g; $subject=&Apache::lontexconvert::msgtexconverted($subject); my $timestamp=$ENV{'form.timestamp'}; @@ -2489,7 +2469,7 @@ $bodytag
- Subject:$subject

+ Subject: $subject

END if ($idx) { if ($attachmenturls) { @@ -2596,7 +2576,7 @@ sub generate_attachments_button { my $response = (< Click to add/remove attachments: $lt{'mnpa'} $numitems $lt{'robb'}
+
Continue ENDREDIR @@ -3189,7 +3170,6 @@ ENDREDIR $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;