]> git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Posting/Handle.pm
dd05a40b4341e96bbe66cf1b8c4f77e42971b72f
[selfforum.git] / selfforum-cgi / shared / Posting / Handle.pm
1 package Handle;
2 #package Posting::Handle;
3
4 ################################################################################
5 # #
6 # File: shared/Posting/Handle.pm #
7 # #
8 # Authors: Frank Schoenmann <fs@tower.de>, 2001-02-27 #
9 # #
10 # Description: Allow modifications of postings #
11 # #
12 ################################################################################
13
14 use strict;
15
16 use vars qw(@EXPORT);
17 use base qw(Exporter);
18
19 @EXPORT = qw(hide_posting);
20
21 use Posting::_lib;
22
23 use XML::DOM;
24
25 ### hide_posting () ############################################################
26 #
27 # Hide a posting: set 'invisible' flag
28 #
29 # Params: $forum Path and filename of forum
30 # $tpath Path to thread files
31 # \%hashref Reference: 'thread', 'posting', 'indexFile'
32 # Return: Boolean
33 #
34 sub hide_posting($$$)
35 {
36 my ($forum, $tpath, $info) = @_;
37 my ($tid, $mid, $indexFile) = ('t' . $info->{'thread'},
38 'm' . $info->{'posting'},
39 $info->{'indexFile'});
40
41 my $tfile = $tpath . '/' . $tid . '.xml';
42 change_posting_visibility($tfile, $tid, $mid, 1);
43 change_posting_visibility($forum, $tid, $mid, 1);
44 }
45
46 ### change_posting_visibility () ###############################################
47 #
48 # -desc-
49 #
50 # Params: $fname Filename
51 # $tid Thread ID
52 # $mid Message ID
53 # $invisible 1 - invisible, 0 - visible
54 # Return: -none-
55 #
56 sub change_posting_visibility($$$)
57 {
58 my ($fname, $tid, $mid, $invisible) = @_;
59
60 my $parser = new XML::DOM::Parser;
61 my $xml = $parser->parsefile($fname);
62
63 my $mnode = get_message_node($xml, $tid, $mid);
64 $mnode->setAttribute('invisible', $invisible);
65
66 $xml->printToFile($fname.'.temp');
67 rename $fname.'.temp', $fname;
68 }
69
70
71 1;

patrick-canterino.de