--- /dev/null
+package Handle;
+#package Posting::Handle;
+
+################################################################################
+# #
+# File: shared/Posting/Handle.pm #
+# #
+# Authors: Frank Schoenmann <fs@tower.de>, 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;
-# Posting/Write.pm
+package Posting::Write;
-# ====================================================
-# Autor: n.d.p. / 2001-01-29
-# lm : n.d.p. / 2001-02-25
-# ====================================================
-# Funktion:
-# Speicherung eines Postings
-# ====================================================
+################################################################################
+# #
+# File: shared/Posting/Write.pm #
+# #
+# Authors: André Malo <nd@o3media.de>, 2001-02-25 #
+# #
+# Description: Save a posting #
+# #
+################################################################################
use strict;
-package Posting::Write;
-
use vars qw(@EXPORT);
use base qw(Exporter);
lastMessage => $mid,
lastThread => 't'.$param -> {lastThread}});
- save_file ($param -> {forumFile}, $forum) or return $error{forumWrite};}
+ save_file ($param -> {forumFile}, $forum) or return $error{forumWrite};
+ }
- return (0, $thread, $mid);}
+ return (0, $thread, $mid);
+ }
}
# ====================================================
$header -> appendChild ($category);
$header -> appendChild ($subject);
$header -> appendChild ($date);
- $message -> appendChild ($header);
+ $message -> appendChild ($header);
$message;
}
# ====================================================
# end of Posting::Write
-# ====================================================
\ No newline at end of file
+# ====================================================
# Messagebody auslesen
###########################
-sub get_message_body ($$) {
- my ($xml,$mid) = @_;
+sub get_message_body ($$)
+{
+ my ($xml, $mid) = @_;
my $body;
- foreach ($xml -> getElementsByTagName ('ContentList', 1) -> item (0) -> getElementsByTagName ('MessageContent', 0)) {
- if ($_ -> getAttribute ('mid') eq $mid) {
+ foreach ($xml -> getElementsByTagName ('ContentList', 1) -> item (0) -> getElementsByTagName ('MessageContent', 0))
+ {
+ if ($_ -> getAttribute ('mid') eq $mid)
+ {
$body = ($_ -> hasChildNodes)?$_ -> getFirstChild -> getData:'';
- last;}}
+ last;
+ }
+ }
\$body;
}
$message -> setAttribute ('flag', 'deleted') if ($msg -> {deleted});
# Header erzeugen
- my $header = $xml -> createElement ('Header');
+ my $header = $xml -> createElement ('Header');
# alles inside of 'Header'
my $author = $xml -> createElement ('Author');
- my $name = $xml -> createElement ('Name');
- $name -> addText (toUTF8($msg -> {name}));
- my $email = $xml -> createElement ('Email');
+ my $name = $xml -> createElement ('Name');
+ $name -> addText (toUTF8($msg -> {name}));
+
+ my $email = $xml -> createElement ('Email');
my $category = $xml -> createElement ('Category');
$category -> addText (toUTF8($msg -> {cat}));
my $date = $xml -> createElement ('Date');
$date -> setAttribute ('longSec', $msg -> {time});
- $author -> appendChild ($name);
- $author -> appendChild ($email);
+ $author -> appendChild ($name);
+ $author -> appendChild ($email);
$header -> appendChild ($author);
$header -> appendChild ($category);
$header -> appendChild ($subject);
if ($msg -> {kids}) {
for (@{$msg -> {kids}}) {
- $message -> appendChild (&create_message_xml ($xml, $msges, $_));}}
+ $message -> appendChild (&create_message_xml ($xml, $msges, $_));
+ }
+ }
$message;
}
# ====================================================
# end of Posting::_lib
-# ====================================================
\ No newline at end of file
+# ====================================================