version 1.111, 2004/08/01 16:05:14
|
version 1.114, 2004/08/10 18:01:25
|
Line 36 use Apache::loncommon();
|
Line 36 use Apache::loncommon();
|
use Apache::lontexconvert(); |
use Apache::lontexconvert(); |
use Apache::lonlocal; # must not have () |
use Apache::lonlocal; # must not have () |
use Apache::lonhtmlcommon(); |
use Apache::lonhtmlcommon(); |
|
use HTML::LCParser(); |
use Apache::lonspeller(); |
use Apache::lonspeller(); |
|
|
sub discussion_open { |
sub discussion_open { |
Line 64 sub discussion_visible {
|
Line 65 sub discussion_visible {
|
} |
} |
|
|
sub list_discussion { |
sub list_discussion { |
my ($mode,$status,$symb)=@_; |
my ($mode,$status,$symb,$ttarget,$tagstack,$parstack,$parser,$safeeval)=@_; |
my $outputtarget=$ENV{'form.grade_target'}; |
my $outputtarget=$ENV{'form.grade_target'}; |
if (not &discussion_visible($status)) { return ''; } |
if (not &discussion_visible($status)) { return ''; } |
my @bgcols = ("#cccccc","#eeeeee"); |
my @bgcols = ("#cccccc","#eeeeee"); |
Line 268 sub list_discussion {
|
Line 269 sub list_discussion {
|
} |
} |
my ($message,$subject); |
my ($message,$subject); |
if ($idx > 0) { |
if ($idx > 0) { |
if ($contrib{$idx.':message'} =~ /.*::::\Q$numoldver\E::::(.+?)$/si) { |
if ($contrib{$idx.':message'} =~ /^<version num="0">/) { |
$message = $1; |
my %versions = (); |
|
&get_post_versions(\%versions,$contrib{$idx.':message'},$numoldver); |
|
$message = &HTML::Entities::decode($versions{$numoldver}); |
} else { |
} else { |
$message = $contrib{$idx.':message'}; |
$message = $contrib{$idx.':message'}; |
} |
} |
Line 280 sub list_discussion {
|
Line 283 sub list_discussion {
|
$message=~s/\n/\<br \/\>/g; |
$message=~s/\n/\<br \/\>/g; |
$message=&Apache::lontexconvert::msgtexconverted($message); |
$message=&Apache::lontexconvert::msgtexconverted($message); |
if ($idx > 0) { |
if ($idx > 0) { |
if ($contrib{$idx.':subject'} =~ /.*::::\Q$numoldver\E::::(.+?)$/si) { |
if ($contrib{$idx.':subject'} =~ /^<version num="0"/) { |
$subject = $1; |
my %versions = (); |
|
&get_post_versions(\%versions,$contrib{$idx.':subject'},$numoldver); |
|
$subject = &HTML::Entities::decode($versions{$numoldver}); |
} else { |
} else { |
$subject = $contrib{$idx.':subject'}; |
$subject = $contrib{$idx.':subject'}; |
} |
} |
Line 293 sub list_discussion {
|
Line 298 sub list_discussion {
|
$subject=&Apache::lontexconvert::msgtexconverted($subject); |
$subject=&Apache::lontexconvert::msgtexconverted($subject); |
} |
} |
if ($attachmenturls) { |
if ($attachmenturls) { |
my @attachments = (); |
my %attachments = (); |
my %currattach = (); |
my %currattach = (); |
&extract_attachments($attachmenturls,$idx,$numoldver,\$message,\@attachments,\%currattach); |
&extract_attachments($attachmenturls,$idx,$numoldver,\$message,\%attachments,\%currattach); |
} |
} |
if ($message) { |
if ($message) { |
if ($hidden) { |
if ($hidden) { |
Line 677 sub list_discussion {
|
Line 682 sub list_discussion {
|
} |
} |
$discussion .= '</tr></table></td></tr>'; |
$discussion .= '</tr></table></td></tr>'; |
} else { |
} else { |
$discussion.='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'. |
$discussion.='<tex>\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'. |
'\textbf{DISCUSSIONS}\makebox[2 cm][b]{\hrulefill}'. |
'\textbf{DISCUSSIONS}\makebox[2 cm][b]{\hrulefill}'. |
'\vskip 0 mm\noindent\textbf{'.$lt{'cuse'}.'}:\vskip 0 mm'. |
'\vskip 0 mm\noindent\textbf{'.$lt{'cuse'}.'}:\vskip 0 mm'. |
'\noindent\textbf{'.$lt{'disa'}.'}: \textit{'.$currdisp.'}\vskip 0 mm'. |
'\noindent\textbf{'.$lt{'disa'}.'}: \textit{'.$currdisp.'}\vskip 0 mm'. |
'\noindent\textbf{'.$lt{'npce'}.'}: \textit{'.$currmark.'}'; |
'\noindent\textbf{'.$lt{'npce'}.'}: \textit{'.$currmark.'}</tex>'; |
} |
} |
my $numhidden = keys %notshown; |
my $numhidden = keys %notshown; |
if ($numhidden > 0) { |
if ($numhidden > 0) { |
Line 734 sub list_discussion {
|
Line 739 sub list_discussion {
|
unless ( ($notshown{$alldiscussion{$_}} eq '1') || ($shown{$alldiscussion{$_}} == 0) ) { |
unless ( ($notshown{$alldiscussion{$_}} eq '1') || ($shown{$alldiscussion{$_}} == 0) ) { |
if ($outputtarget ne 'tex') { |
if ($outputtarget ne 'tex') { |
$discussion.="\n<tr>"; |
$discussion.="\n<tr>"; |
} else { |
|
$discussion.='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'; |
|
} |
} |
my $thisdepth=$depth[$alldiscussion{$_}]; |
my $thisdepth=$depth[$alldiscussion{$_}]; |
if ($outputtarget ne 'tex') { |
if ($outputtarget ne 'tex') { |
Line 759 sub list_discussion {
|
Line 762 sub list_discussion {
|
$discussionitems[$alldiscussion{$_}]=~s/<\/td><td([^>]*)>/$threadinsert<\/td><td TeXwidth="65 mm" align="left">/; |
$discussionitems[$alldiscussion{$_}]=~s/<\/td><td([^>]*)>/$threadinsert<\/td><td TeXwidth="65 mm" align="left">/; |
$discussionitems[$alldiscussion{$_}]=~s/<a([^>]+)>(Edit|Hide|Delete|Reply|Submissions)<\/a>//g; |
$discussionitems[$alldiscussion{$_}]=~s/<a([^>]+)>(Edit|Hide|Delete|Reply|Submissions)<\/a>//g; |
$discussionitems[$alldiscussion{$_}]=~s/(<b>|<\/b>|<\/a>|<a([^>]+)>)//g; |
$discussionitems[$alldiscussion{$_}]=~s/(<b>|<\/b>|<\/a>|<a([^>]+)>)//g; |
|
|
#FIXME xmlparse can't be safely called from inside xmlparse |
$discussionitems[$alldiscussion{$_}]='<tex>\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}</tex>'.$discussionitems[$alldiscussion{$_}]; |
# due to the global variables that are use, the safe |
if ($_ eq $showposts[-1]) { |
# space etc. I expect this has unforseen issues that |
$discussionitems[$alldiscussion{$_}].='<tex>\keephidden{ENDOFPROBLEM}\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\end{document}</tex>'; |
# need resolving. |
} |
|
$discussion.=$discussionitems[$alldiscussion{$_}]; |
$discussion.=&Apache::lonxml::xmlparse('','tex',$discussionitems[$alldiscussion{$_}]); |
|
} |
} |
} |
} |
} |
} |
Line 824 END
|
Line 826 END
|
</table> |
</table> |
<br /><br /></form> |
<br /><br /></form> |
END |
END |
} |
} |
} |
} |
if ($discussiononly) { |
if ($discussiononly) { |
my $now = time; |
my $now = time; |
Line 896 ENDDISCUSS
|
Line 898 ENDDISCUSS
|
} |
} |
} |
} |
} |
} |
return $discussion; |
return $discussion; |
} |
} |
|
|
sub mail_screen { |
sub mail_screen { |
Line 920 sub mail_screen {
|
Line 922 sub mail_screen {
|
my @currnewattach = (); |
my @currnewattach = (); |
my @currdelold = (); |
my @currdelold = (); |
my @keepold = (); |
my @keepold = (); |
my @attachments = (); |
my %attachments = (); |
my %currattach = (); |
my %currattach = (); |
my $attachnum = 0; |
my $attachnum = 0; |
my $anonchk = (<<END); |
my $anonchk = (<<END); |
Line 966 END
|
Line 968 END
|
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, |
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, |
$ENV{'course.'.$ENV{'request.course.id'}.'.num'}); |
$ENV{'course.'.$ENV{'request.course.id'}.'.num'}); |
unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) { |
unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) { |
|
if ($contrib{$idx.':history'}) { |
|
if ($contrib{$idx.':history'} =~ /:/) { |
|
my @oldversions = split/:/,$contrib{$idx.':history'}; |
|
$numoldver = @oldversions; |
|
} else { |
|
$numoldver = 1; |
|
} |
|
} |
if ($ENV{'form.replydisc'}) { |
if ($ENV{'form.replydisc'}) { |
if ($contrib{$idx.':history'}) { |
if ($contrib{$idx.':history'}) { |
if ($contrib{$idx.':history'} =~ /:/) { |
if ($contrib{$idx.':history'} =~ /:/) { |
Line 977 END
|
Line 987 END
|
} |
} |
my $message; |
my $message; |
if ($idx > 0) { |
if ($idx > 0) { |
if ($contrib{$idx.':message'} =~ /::::\Q$numoldver\E::::(.+?)$/si) { |
if ($contrib{$idx.':message'} =~ /^<version num="0"/) { |
$message = $1; |
my %versions = (); |
|
&get_post_versions(\%versions,$contrib{$idx.':message'},$numoldver); |
|
$message = &HTML::Entities::decode($versions{$numoldver}); |
} else { |
} else { |
$message = $contrib{$idx.':message'}; |
$message = $contrib{$idx.':message'}; |
} |
} |
Line 988 END
|
Line 1000 END
|
$message=~s/\n/\<br \/\>/g; |
$message=~s/\n/\<br \/\>/g; |
$quote='<blockquote>'.&Apache::lontexconvert::msgtexconverted($message).'</blockquote>'; |
$quote='<blockquote>'.&Apache::lontexconvert::msgtexconverted($message).'</blockquote>'; |
if ($idx > 0) { |
if ($idx > 0) { |
if ($contrib{$idx.':subject'} =~ /::::\Q$numoldver\E::::(.+?)$/si) { |
if ($contrib{$idx.':subject'} =~ /^<version num="0"/) { |
$subject = $1; |
my %versions = (); |
|
&get_post_versions(\%versions,$contrib{$idx.':subject'},$numoldver); |
|
$subject = &HTML::Entities::decode($versions{$numoldver}); |
} else { |
} else { |
$subject = $contrib{$idx.':subject'}; |
$subject = $contrib{$idx.':subject'}; |
} |
} |
Line 998 END
|
Line 1012 END
|
$subject = &HTML::Entities::encode($subject,'<>&"'); |
$subject = &HTML::Entities::encode($subject,'<>&"'); |
} else { |
} else { |
$attachmenturls = $contrib{$idx.':attachmenturl'}; |
$attachmenturls = $contrib{$idx.':attachmenturl'}; |
if ($contrib{$idx.':message'} =~ /.*::::(\d+)::::(.*?)$/si) { |
if ($contrib{$idx.':message'} =~ /^<version num="0">/) { |
$numoldver = $1; |
my %versions = (); |
$comment = $2; |
&get_post_versions(\%versions,$contrib{$idx.':message'},$numoldver); |
|
$comment = $versions{$numoldver}; |
} else { |
} else { |
$comment = $contrib{$idx.':message'}; |
$comment = &HTML::Entities::encode($contrib{$idx.':message'},'<>&"'); |
} |
} |
$comment = &HTML::Entities::encode($comment,'<>&"'); |
if ($contrib{$idx.':subject'} =~ /<version num="0">/) { |
if ($contrib{$idx.':subject'} =~ /.*::::\d+::::(.+?)$/si) { |
my %versions = (); |
$subject = $1; |
&get_post_versions(\%versions,$contrib{$idx.':subject'},$numoldver); |
|
$subject = $versions{$numoldver}; |
} else { |
} else { |
$subject = $contrib{$idx.':subject'}; |
$subject = &HTML::Entities::encode($contrib{$idx.':subject'},'<>&"'); |
} |
} |
$subject = &HTML::Entities::encode($subject,'<>&"'); |
|
if (defined($contrib{$idx.':replyto'})) { |
if (defined($contrib{$idx.':replyto'})) { |
$parentmsg = $contrib{$idx.':replyto'}; |
$parentmsg = $contrib{$idx.':replyto'}; |
} |
} |
Line 1145 END
|
Line 1160 END
|
} |
} |
if ($ENV{'form.editdisc'}) { |
if ($ENV{'form.editdisc'}) { |
if ($attachmenturls) { |
if ($attachmenturls) { |
&extract_attachments($attachmenturls,$idx,$numoldver,\$attachmsg,\@attachments,\%currattach,\@currdelold); |
&extract_attachments($attachmenturls,$idx,$numoldver,\$attachmsg,\%attachments,\%currattach,\@currdelold); |
$attachnum = scalar(keys %currattach); |
$attachnum = scalar(keys %currattach); |
foreach (keys %currattach) { |
foreach (keys %currattach) { |
$r->print('<input type="hidden" name="keepold" value="'.$_.'" />'."\n"); |
$r->print('<input type="hidden" name="keepold" value="'.$_.'" />'."\n"); |
Line 1652 END
|
Line 1667 END
|
END |
END |
} |
} |
|
|
sub fail_redirect { |
sub get_post_versions { |
|
my ($versions,$incoming,$numver) = @_; |
|
my $p = HTML::LCParser->new(\$incoming); |
|
my $done = 0; |
|
while ( (my $token = $p->get_tag("version")) && (!$done)) { |
|
my $num = $token->[1]{num}; |
|
my $text = $p->get_text("/version"); |
|
if (defined($numver)) { |
|
if ($num == $numver) { |
|
$$versions{$numver}=$text; |
|
$done = 1; |
|
} |
|
} else { |
|
$$versions{$num}=$text; |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub get_post_attachments { |
|
my ($attachments,$attachmenturls) = @_; |
|
my $num; |
|
my $p = HTML::LCParser->new(\$attachmenturls); |
|
while (my $token = $p->get_tag("attachment","filename","post")) { |
|
if ($token->[0] eq "attachment") { |
|
$num = $token->[1]{id}; |
|
%{$$attachments{$num}} =(); |
|
} elsif ($token->[0] eq "filename") { |
|
$$attachments{$num}{'filename'} = $p->get_text("/filename"); |
|
} elsif ($token->[0] eq "post") { |
|
my $id = $token->[1]{id}; |
|
$$attachments{$num}{$id} = $p->get_text("/post"); |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub fail_redirect {; |
my ($r,$feedurl) = @_; |
my ($r,$feedurl) = @_; |
if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' }; |
if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' }; |
$r->print (<<ENDFAILREDIR); |
$r->print (<<ENDFAILREDIR); |
Line 2014 sub adddiscuss {
|
Line 2066 sub adddiscuss {
|
} |
} |
my $numnewver = $numoldver + 1; |
my $numnewver = $numoldver + 1; |
if (defined($oldcontrib{$oldidx.':subject'})) { |
if (defined($oldcontrib{$oldidx.':subject'})) { |
if ($oldcontrib{$oldidx.':subject'} =~ /::::\d+::::/) { |
if ($oldcontrib{$oldidx.':subject'} =~ /^<version num="0">/) { |
$contrib{'subject'} = $oldcontrib{$oldidx.':subject'}.'::::'.$numnewver.'::::'.$contrib{'subject'}; |
$contrib{'subject'} = '<version num="'.$numnewver.'">'.&HTML::Entities::encode($contrib{'subject'},'<>&"').'</version>'; |
|
$contrib{'subject'} = $oldcontrib{$oldidx.':subject'}.$contrib{'subject'}; |
} else { |
} else { |
$contrib{'subject'} = '::::0::::'.$oldcontrib{$oldidx.':subject'}.'::::1::::'.$contrib{'subject'}; |
$contrib{'subject'} = '<version num="0">'.&HTML::Entities::encode($oldcontrib{$oldidx.':subject'},'<>&"').'</version><version num="1">'.&HTML::Entities::encode($contrib{'subject'},'<>&"').'</version>'; |
} |
} |
} |
} |
if (defined($oldcontrib{$oldidx.':message'})) { |
if (defined($oldcontrib{$oldidx.':message'})) { |
if ($oldcontrib{$oldidx.':message'} =~ /::::\d+::::/) { |
if ($oldcontrib{$oldidx.':message'} =~ /^<version num="0">/) { |
$contrib{'message'} = $oldcontrib{$oldidx.':message'}.'::::'.$numnewver.'::::'.$contrib{'message'}; |
$contrib{'message'} = '<version num="'.$numnewver.'">'.&HTML::Entities::encode($contrib{'message'},'<>&"').'</version>'; |
|
$contrib{'message'} = $oldcontrib{$oldidx.':message'}.$contrib{'message'}; |
} else { |
} else { |
$contrib{'message'} = '::::0::::'.$oldcontrib{$oldidx.':message'}.'::::1::::'.$contrib{'message'}; |
$contrib{'message'} = '<version num="0">'.&HTML::Entities::encode($oldcontrib{$oldidx.':message'},'<>&"').'</version><version num="1">'.&HTML::Entities::encode($contrib{'message'},'<>&"').'</version>'; |
} |
} |
} |
} |
$contrib{'history'} .= $oldcontrib{$oldidx.':timestamp'}; |
$contrib{'history'} .= $oldcontrib{$oldidx.':timestamp'}; |
Line 2102 sub modify_attachments {
|
Line 2156 sub modify_attachments {
|
my $bodytag=&Apache::loncommon::bodytag('Discussion Post Attachments', |
my $bodytag=&Apache::loncommon::bodytag('Discussion Post Attachments', |
'',''); |
'',''); |
my $msg = ''; |
my $msg = ''; |
my @attachments = (); |
my %attachments = (); |
my %currattach = (); |
my %currattach = (); |
if ($idx) { |
if ($idx) { |
&extract_attachments($attachmenturls,$idx,$numoldver,\$msg,\@attachments,\%currattach,$currdelold); |
&extract_attachments($attachmenturls,$idx,$numoldver,\$msg,\%attachments,\%currattach,$currdelold); |
} |
} |
$r->print(<<END); |
$r->print(<<END); |
<html> |
<html> |
Line 2130 END
|
Line 2184 END
|
my @currold = keys %currattach; |
my @currold = keys %currattach; |
if (@currold > 0) { |
if (@currold > 0) { |
$r->print("The following attachments were part of the most recent saved version of this posting.<br />Check the checkboxes for any you wish to remove<br />\n"); |
$r->print("The following attachments were part of the most recent saved version of this posting.<br />Check the checkboxes for any you wish to remove<br />\n"); |
foreach (@currold) { |
foreach my $id (@currold) { |
my $id = $_; |
my $attachurl = &HTML::Entities::decode($attachments{$id}{'filename'}); |
$attachments[$id] =~ m#/([^/]+)$#; |
$attachurl =~ m#/([^/]+)$#; |
$r->print('<input type="checkbox" name="deloldattach" value="'.$_.'" /> '.$1.'<br />'."\n"); |
$r->print('<input type="checkbox" name="deloldattach" value="'.$id.'" /> '.$1.'<br />'."\n"); |
} |
} |
$r->print("<br />"); |
$r->print("<br />"); |
} |
} |
Line 2266 ENDATTACH
|
Line 2320 ENDATTACH
|
|
|
sub extract_attachments { |
sub extract_attachments { |
my ($attachmenturls,$idx,$numoldver,$message,$attachments,$currattach,$currdelold) = @_; |
my ($attachmenturls,$idx,$numoldver,$message,$attachments,$currattach,$currdelold) = @_; |
if ($attachmenturls =~ m/::::\d+:[\.yn\d]+::::/) { |
if ($attachmenturls =~ m/^<attachment id="0">/) { |
@{$attachments} = split/::::\d+:[\.yn\d]+::::/,$attachmenturls; |
&get_post_attachments($attachments,$attachmenturls); |
shift @{$attachments}; |
foreach my $id (sort keys %{$attachments}) { |
my $searchstr = '::::'; |
if (exists($$attachments{$id}{$numoldver})) { |
for (my $i=0; $i<@{$attachments}; $i++) { |
if (defined($currdelold)) { |
if ($attachmenturls =~ m#^\Q$searchstr\E(\d+)(:[\.yn\d]+)::::#) { |
if (@{$currdelold} > 0) { |
my $info = $1.$2; |
unless (grep/^$id$/,@{$currdelold}) { |
my $attachid = $1-1; |
$$currattach{$id} = $$attachments{$id}{$numoldver}; |
$searchstr .= $info.'::::'.$$attachments[$i].'::::'; |
|
if ($info =~ /\.$numoldver([yn])\./) { |
|
if (defined($currdelold)) { |
|
if (@{$currdelold} > 0) { |
|
unless (grep/^$attachid$/,@{$currdelold}) { |
|
my $id = $i; |
|
$$currattach{$id} = $1; |
|
} |
|
} else { |
|
my $id = $i; |
|
$$currattach{$id} = $1; |
|
} |
} |
} else { |
} else { |
my $id = $i; |
$$currattach{$id} = $$attachments{$id}{$numoldver}; |
$$currattach{$id} = $1; |
|
} |
} |
|
} else { |
|
$$currattach{$id} = $$attachments{$id}{$numoldver}; |
} |
} |
} |
} |
} |
} |
my @attached = (sort { $a <=> $b } keys %{$currattach}); |
my @attached = (sort { $a <=> $b } keys %{$currattach}); |
if (@attached == 1) { |
if (@attached == 1) { |
my $id = $attached[0]; |
my $id = $attached[0]; |
$$attachments[$attached[0]]=~m|/([^/]+)$|; |
my $attachurl = &HTML::Entities::decode($$attachments{$id}{'filename'}); |
$$message.='<br /><a href="'.$$attachments[$id].'"><tt>'. |
$attachurl=~m|/([^/]+)$|; |
|
$$message.='<br /><a href="'.$attachurl.'"><tt>'. |
$1.'</tt></a><br />'; |
$1.'</tt></a><br />'; |
&Apache::lonnet::allowuploaded('/adm/feedback', |
&Apache::lonnet::allowuploaded('/adm/feedback', |
$$attachments[$id]); |
$attachurl); |
} elsif (@attached > 1) { |
} elsif (@attached > 1) { |
$$message.='<ol>'; |
$$message.='<ol>'; |
foreach (@attached) { |
foreach (@attached) { |
my $id = $_; |
my $id = $_; |
|
my $attachurl = &HTML::Entities::decode($$attachments{$id}{'filename'}); |
my ($fname) |
my ($fname) |
=($$attachments[$id]=~m|/([^/]+)$|); |
=($attachurl=~m|/([^/]+)$|); |
$$message .= '<li><a href="'.$$attachments[$id]. |
$$message .= '<li><a href="'.$attachurl. |
'"><tt>'. |
'"><tt>'. |
$fname.'</tt></a></li>'; |
$fname.'</tt></a></li>'; |
&Apache::lonnet::allowuploaded('/adm/feedback', |
&Apache::lonnet::allowuploaded('/adm/feedback', |
$$attachments[$id]); |
$attachurl); |
} |
} |
$$message .= '</ol><br />'; |
$$message .= '</ol><br />'; |
} |
} |
Line 2322 sub extract_attachments {
|
Line 2368 sub extract_attachments {
|
': <a href="'.$attachmenturls. |
': <a href="'.$attachmenturls. |
'"><tt>'. |
'"><tt>'. |
$fname.'</tt></a></p>'; |
$fname.'</tt></a></p>'; |
$$attachments[0] = $attachmenturls; |
$$attachments{0} = $attachmenturls; |
$$currattach{'0'} = 'n'; |
$$currattach{'0'} = 'n'; |
&Apache::lonnet::allowuploaded('/adm/feedback', |
&Apache::lonnet::allowuploaded('/adm/feedback', |
$attachmenturls); |
$attachmenturls); |
Line 2333 sub construct_attachmenturl {
|
Line 2379 sub construct_attachmenturl {
|
my ($currnewattach,$keepold,$symb,$idx)=@_; |
my ($currnewattach,$keepold,$symb,$idx)=@_; |
my $oldattachmenturl; |
my $oldattachmenturl; |
my $newattachmenturl; |
my $newattachmenturl; |
my $startnum = 1; |
my $startnum = 0; |
my $currver = 0; |
my $currver = 0; |
if (($ENV{'form.editdisc'}) && ($idx)) { |
if (($ENV{'form.editdisc'}) && ($idx)) { |
my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'}, |
my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'}, |
Line 2351 sub construct_attachmenturl {
|
Line 2397 sub construct_attachmenturl {
|
$currver = 1; |
$currver = 1; |
} |
} |
if ($oldattachmenturl) { |
if ($oldattachmenturl) { |
if ($oldattachmenturl =~ m/::::\d+:[\.yn\d]+::::/) { |
if ($oldattachmenturl =~ m/^<attachment id="0">/) { |
my @attachments = split/::::\d+:[\.yn\d]+::::/,$oldattachmenturl; |
my %attachments = (); |
shift @attachments; |
my $prevver = $currver-1; |
$startnum += @attachments; |
&get_post_attachments(\%attachments,$oldattachmenturl); |
my $searchstr = '::::'; |
my $numattach = keys %attachments; |
$newattachmenturl = '::::'; |
$startnum += $numattach; |
for (my $i=0; $i<@attachments; $i++) { |
foreach my $num (sort {$a <=> $b} keys %attachments) { |
if ($oldattachmenturl =~ m#^\Q$searchstr\E(\d+)(:[\.yn\d]+)::::#) { |
$newattachmenturl .= '<attachment id="'.$num.'"><filename>'.$attachments{$num}{'filename'}.'</filename>'; |
my $attachid = $1 - 1; |
foreach (sort {$a <=> $b} keys %{$attachments{$num}}) { |
$searchstr .= $1.$2.'::::'.$attachments[$i].'::::'; |
$newattachmenturl .= '<post id="'.$_.'">'.$attachments{$num}{$_}.'</post>'; |
$newattachmenturl .= $1.$2; |
} |
if (grep/^$attachid$/,@{$keepold}) { |
if (grep/^$num$/,@{$keepold}) { |
$newattachmenturl .= '.'.$currver.'n.'; |
$newattachmenturl .= '<post id="'.$currver.'">'.$attachments{$num}{$prevver}.'</post>'; |
} |
|
$newattachmenturl .= '::::'.$attachments[$i].'::::'; |
|
} |
} |
|
$newattachmenturl .= '</attachment>'; |
} |
} |
$newattachmenturl =~ s/::::$//; |
|
} else { |
} else { |
$newattachmenturl = '::::1:.0n.'; |
$newattachmenturl = '<attachment id="0"><filename>'.&HTML::Entities::encode($oldattachmenturl).'<post id="0">n</post>'; |
unless (grep/^0$/,@{$keepold}) { |
unless (grep/^0$/,@{$keepold}) { |
$newattachmenturl .= '.1n.'; |
$newattachmenturl .= '<post id="1">n</post>'; |
} |
} |
$newattachmenturl .= '::::'.$oldattachmenturl; |
$newattachmenturl .= '</attachment>'; |
$startnum ++; |
$startnum ++; |
} |
} |
} |
} |
} |
} |
for (my $i=0; $i<@{$currnewattach}; $i++) { |
for (my $i=0; $i<@{$currnewattach}; $i++) { |
my $attachnum = $startnum + $i; |
my $attachnum = $startnum + $i; |
$newattachmenturl .= '::::'.$attachnum.':.'.$currver.'n.::::'.$$currnewattach[$i]; |
$newattachmenturl .= '<attachment id="'.$attachnum.'"><filename>'.&HTML::Entities::encode($$currnewattach[$i]).'</filename><post id="'.$currver.'">n</post></attachment>'; |
} |
} |
return $newattachmenturl; |
return $newattachmenturl; |
} |
} |
Line 2459 END
|
Line 2503 END
|
if ($contrib{$idx.':history'}) { |
if ($contrib{$idx.':history'}) { |
my $attachmenturls = $contrib{$idx.':attachmenturl'}; |
my $attachmenturls = $contrib{$idx.':attachmenturl'}; |
my @postversions = (); |
my @postversions = (); |
|
my %messages = (); |
|
my %subjects = (); |
if ($contrib{$idx.':history'} =~ m/:/) { |
if ($contrib{$idx.':history'} =~ m/:/) { |
@postversions = split/:/,$contrib{$idx.':history'}; |
@postversions = split/:/,$contrib{$idx.':history'}; |
} else { |
} else { |
@postversions = ("$contrib{$idx.':history'}"); |
@postversions = ("$contrib{$idx.':history'}"); |
} |
} |
if (@postversions > 0) { |
if (@postversions > 0) { |
|
&get_post_versions(\%messages,$contrib{$idx.':message'}); |
|
&get_post_versions(\%subjects,$contrib{$idx.':subject'}); |
push @postversions,$contrib{$idx.':timestamp'}; |
push @postversions,$contrib{$idx.':timestamp'}; |
my $screenname=&Apache::loncommon::screenname( |
my $screenname=&Apache::loncommon::screenname( |
$contrib{$idx.':sendername'}, |
$contrib{$idx.':sendername'}, |
Line 2485 END
|
Line 2533 END
|
for (my $i=0; $i<@postversions; $i++) { |
for (my $i=0; $i<@postversions; $i++) { |
my ($timesent,$message,$subject,$attachmsg); |
my ($timesent,$message,$subject,$attachmsg); |
$timesent = &Apache::lonlocal::locallocaltime($postversions[$i]); |
$timesent = &Apache::lonlocal::locallocaltime($postversions[$i]); |
if ($i == @postversions-1) { |
$message=&HTML::Entities::decode($messages{$i}); |
($message)=($contrib{$idx.':message'} =~ /.*::::\Q$i\E::::(.+?)$/si); |
$subject=&HTML::Entities::decode($subjects{$i}); |
($subject)=($contrib{$idx.':subject'} =~ /.*::::\Q$i\E::::(.+?)$/si); |
|
} else { |
|
($message)=($contrib{$idx.':message'} =~ /::::\Q$i\E::::(.+?)::::/si); |
|
($subject)=($contrib{$idx.':subject'} =~ /::::\Q$i\E::::(.+?)::::/si); |
|
} |
|
$message=~s/\n/\<br \/\>/g; |
$message=~s/\n/\<br \/\>/g; |
$message=&Apache::lontexconvert::msgtexconverted($message); |
$message=&Apache::lontexconvert::msgtexconverted($message); |
$subject=~s/\n/\<br \/\>/g; |
$subject=~s/\n/\<br \/\>/g; |
$subject=&Apache::lontexconvert::msgtexconverted($subject); |
$subject=&Apache::lontexconvert::msgtexconverted($subject); |
if ($attachmenturls) { |
if ($attachmenturls) { |
my @attachments = (); |
my %attachments = (); |
my %currattach = (); |
my %currattach = (); |
&extract_attachments($attachmenturls,$idx,$i,\$attachmsg,\@attachments,\%currattach); |
&extract_attachments($attachmenturls,$idx,$i,\$attachmsg,\%attachments,\%currattach); |
} |
} |
if ($attachmsg) { |
if ($attachmsg) { |
$attachmsg = '<br />Attachments:'.$attachmsg.'<br />'; |
$attachmsg = '<br />Attachments:'.$attachmsg.'<br />'; |