1 package Posting
::Handle
;
3 ################################################################################
5 # File: shared/Posting/Handle.pm #
7 # Authors: Frank Schoenmann <fs@tower.de>, 2001-02-27 #
9 # Description: Allow modifications of postings #
11 ################################################################################
16 use base qw(Exporter);
18 @EXPORT = qw(hide_posting recover_posting);
20 use Posting
::_lib
qw(get_message_node);
24 ### hide_posting () ############################################################
26 # Hide a posting: set 'invisible' flag
28 # Params: $forum Path and filename of forum
29 # $tpath Path to thread files
30 # \%hashref Reference: 'thread', 'posting', 'indexFile'
35 my ($forum, $tpath, $info) = @_;
36 my ($tid, $mid, $indexFile) = ('t' . $info->{'thread'},
37 'm' . $info->{'posting'},
38 $info->{'indexFile'});
40 my $tfile = $tpath . '/' . $tid . '.xml';
41 change_posting_visibility
($tfile, $tid, $mid, 1);
42 change_posting_visibility
($forum, $tid, $mid, 1);
45 ### recover_posting() ##########################################################
47 # Recover a posting: delete 'invisible' flag
49 # Params: $forum Path and filename of forum
50 # $tpath Path to thread files
51 # \%hashref Reference: 'thread', 'posting', 'indexFile'
54 sub recover_posting
($$$)
56 my ($forum, $tpath, $info) = @_;
57 my ($tid, $mid, $indexFile) = ('t' . $info->{'thread'},
58 'm' . $info->{'posting'},
59 $info->{'indexFile'});
61 my $tfile = $tpath . '/' . $tid . '.xml';
62 change_posting_visibility
($tfile, $tid, $mid, 0);
63 change_posting_visibility
($forum, $tid, $mid, 0);
66 ### change_posting_visibility () ###############################################
68 # Set a postings visibility flag to $invisible
70 # Params: $fname Filename
73 # $invisible 1 - invisible, 0 - visible
76 sub change_posting_visibility
($$$)
78 my ($fname, $tid, $mid, $invisible) = @_;
80 my $parser = new XML
::DOM
::Parser
;
81 my $xml = $parser->parsefile($fname);
83 # Set flag in given msg
84 my $mnode = get_message_node
($xml, $tid, $mid);
85 $mnode->setAttribute('invisible', $invisible);
87 # Set flag in sub nodes
88 for ($mnode->getElementsByTagName('Message'))
90 $_->setAttribute('invisible', $invisible);
93 $xml->printToFile($fname.'.temp');
94 rename $fname.'.temp', $fname;