X-Git-Url: https://git.p6c8.net/selfforum.git/blobdiff_plain/2d3c4193d4513ad3e59e224279f233c250920d6c..9f19cb68669296f87eefd27f8e9765deeef85106:/selfforum-cgi/shared/Posting/Handle.pm diff --git a/selfforum-cgi/shared/Posting/Handle.pm b/selfforum-cgi/shared/Posting/Handle.pm new file mode 100644 index 0000000..67d5c0b --- /dev/null +++ b/selfforum-cgi/shared/Posting/Handle.pm @@ -0,0 +1,93 @@ +package Handle; +#package Posting::Handle; + +################################################################################ +# # +# File: shared/Posting/Handle.pm # +# # +# Authors: Frank Schoenmann , 2001-02-27 # +# # +# Description: Allow modifications of postings # +# # +################################################################################ + +use strict; + +use vars qw(@EXPORT); +use base qw(Exporter); + +@EXPORT = qw(hide_posting); + +#use Posting::_lib; + +use XML::DOM; + +### hide_posting () ############################################################ +# +# Hide a posting: set 'invisible' flag +# +# Params: $forum Path and filename of forum +# $tpath Path to thread files +# \%hashref Reference: 'thread', 'posting', 'indexFile' +# Return: Boolean +# +sub hide_posting($$$) +{ + my ($forum, $tpath, $info) = shift; + my ($tid, $pid, $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 $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 forum xml file + $xml->printToFile($forum . '.temp'); + rename $forum . '.temp', $forum; + } +} + + + + +1;