version 1.112, 2004/08/03 21:29:32
|
version 1.113, 2004/08/04 18:04:57
|
Line 298 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 925 sub mail_screen {
|
Line 925 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 1163 END
|
Line 1163 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 1689 sub get_post_versions {
|
Line 1689 sub get_post_versions {
|
return; |
return; |
} |
} |
|
|
sub fail_redirect { |
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 2141 sub modify_attachments {
|
Line 2159 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 2169 END
|
Line 2187 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 2305 ENDATTACH
|
Line 2323 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 2361 sub extract_attachments {
|
Line 2371 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 2372 sub construct_attachmenturl {
|
Line 2382 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 2390 sub construct_attachmenturl {
|
Line 2400 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 2535 END
|
Line 2543 END
|
$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 />'; |