From: fox_two <> Date: Tue, 27 Feb 2001 20:41:00 +0000 (+0000) Subject: change_posting_visibility(): change the visibility of a message (not yet X-Git-Url: https://git.p6c8.net/selfforum.git/commitdiff_plain/0477bd232cbfcfc43a702a7c89fec6acbf99907c change_posting_visibility(): change the visibility of a message (not yet recursive), based on Posting::_lib::get_message_node() hide_posting(): now uses change_posting_visibility() --- diff --git a/selfforum-cgi/shared/Posting/Handle.pm b/selfforum-cgi/shared/Posting/Handle.pm index 67d5c0b..dd05a40 100644 --- a/selfforum-cgi/shared/Posting/Handle.pm +++ b/selfforum-cgi/shared/Posting/Handle.pm @@ -18,7 +18,7 @@ use base qw(Exporter); @EXPORT = qw(hide_posting); -#use Posting::_lib; +use Posting::_lib; use XML::DOM; @@ -33,61 +33,39 @@ use XML::DOM; # sub hide_posting($$$) { - my ($forum, $tpath, $info) = shift; - my ($tid, $pid, $indexFile) = ('t' . $info->{'thread'}, + my ($forum, $tpath, $info) = @_; + my ($tid, $mid, $indexFile) = ('t' . $info->{'thread'}, 'm' . $info->{'posting'}, $info->{'indexFile'}); - { - # Change flag in thread xml file - my $tfile = $tpath . '/' . $tid; - - my $parser = new XML::DOM::Parser; - my $xml = $parser->parsefile($tfile); - - my $msgs = $xml->getElementsByTagName('Message'); - - for (my $i = 0; $i < $msgs->getLength; $i++) - { - my $msg = $msgs->item($i); - - if ($msg->getAttribute('id')->getValue == $pid) - { - $msg->setAttribute('invisible', '1'); - last; - } - } - - # Save thread xml file - $xml->printToFile($tfile . '.temp'); - rename $tfile . '.temp', $tfile; - } - - { - # Change flag in forum xml file - my $parser = new XML::DOM::Parser; - my $xml = $parser->parseFile($forum); + my $tfile = $tpath . '/' . $tid . '.xml'; + change_posting_visibility($tfile, $tid, $mid, 1); + change_posting_visibility($forum, $tid, $mid, 1); +} - my $msgs = $xml->getElementsByTagName('Message'); +### change_posting_visibility () ############################################### +# +# -desc- +# +# Params: $fname Filename +# $tid Thread ID +# $mid Message ID +# $invisible 1 - invisible, 0 - visible +# Return: -none- +# +sub change_posting_visibility($$$) +{ + my ($fname, $tid, $mid, $invisible) = @_; - for (my $i = 0; $i < $msgs->getLength; $i++) - { - my $msg = $msgs->item($i); + my $parser = new XML::DOM::Parser; + my $xml = $parser->parsefile($fname); - if ($msg->getAttribute('id')->getValue == $pid) - { - $msg->setAttribute('invisible', '1'); - last; - } - } + my $mnode = get_message_node($xml, $tid, $mid); + $mnode->setAttribute('invisible', $invisible); - # Save forum xml file - $xml->printToFile($forum . '.temp'); - rename $forum . '.temp', $forum; - } + $xml->printToFile($fname.'.temp'); + rename $fname.'.temp', $fname; } - - 1;