]> git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Posting/Handle.pm
forum.dtd fixed, lockfiles removed from repository
[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) = shift;
37 my ($tid, $pid, $indexFile) = ('t' . $info->{'thread'},
38 'm' . $info->{'posting'},
39 $info->{'indexFile'});
40
41 {
42 # Change flag in thread xml file
43 my $tfile = $tpath . '/' . $tid;
44
45 my $parser = new XML::DOM::Parser;
46 my $xml = $parser->parsefile($tfile);
47
48 my $msgs = $xml->getElementsByTagName('Message');
49
50 for (my $i = 0; $i < $msgs->getLength; $i++)
51 {
52 my $msg = $msgs->item($i);
53
54 if ($msg->getAttribute('id')->getValue == $pid)
55 {
56 $msg->setAttribute('invisible', '1');
57 last;
58 }
59 }
60
61 # Save thread xml file
62 $xml->printToFile($tfile . '.temp');
63 rename $tfile . '.temp', $tfile;
64 }
65
66 {
67 # Change flag in forum xml file
68 my $parser = new XML::DOM::Parser;
69 my $xml = $parser->parseFile($forum);
70
71 my $msgs = $xml->getElementsByTagName('Message');
72
73 for (my $i = 0; $i < $msgs->getLength; $i++)
74 {
75 my $msg = $msgs->item($i);
76
77 if ($msg->getAttribute('id')->getValue == $pid)
78 {
79 $msg->setAttribute('invisible', '1');
80 last;
81 }
82 }
83
84 # Save forum xml file
85 $xml->printToFile($forum . '.temp');
86 rename $forum . '.temp', $forum;
87 }
88 }
89
90
91
92
93 1;

patrick-canterino.de