From: fox_two <> Date: Tue, 27 Feb 2001 20:05:42 +0000 (+0000) Subject: Handle.pm initial release. Style changes. X-Git-Url: https://git.p6c8.net/selfforum.git/commitdiff_plain/9f19cb68669296f87eefd27f8e9765deeef85106?hp=2d3c4193d4513ad3e59e224279f233c250920d6c Handle.pm initial release. Style changes. --- 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; diff --git a/selfforum-cgi/shared/Posting/Write.pm b/selfforum-cgi/shared/Posting/Write.pm index 72a5b25..7e6ba97 100644 --- a/selfforum-cgi/shared/Posting/Write.pm +++ b/selfforum-cgi/shared/Posting/Write.pm @@ -1,17 +1,17 @@ -# 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 , 2001-02-25 # +# # +# Description: Save a posting # +# # +################################################################################ use strict; -package Posting::Write; - use vars qw(@EXPORT); use base qw(Exporter); @@ -165,9 +165,11 @@ sub write_posting ($) { 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); + } } # ==================================================== @@ -217,7 +219,7 @@ sub create_message ($$) { $header -> appendChild ($category); $header -> appendChild ($subject); $header -> appendChild ($date); - $message -> appendChild ($header); + $message -> appendChild ($header); $message; } @@ -276,4 +278,4 @@ sub create_new_thread ($) { # ==================================================== # end of Posting::Write -# ==================================================== \ No newline at end of file +# ==================================================== diff --git a/selfforum-cgi/shared/Posting/_lib.pm b/selfforum-cgi/shared/Posting/_lib.pm index 587ed9a..e8065ab 100644 --- a/selfforum-cgi/shared/Posting/_lib.pm +++ b/selfforum-cgi/shared/Posting/_lib.pm @@ -70,14 +70,19 @@ sub get_message_header ($) { # 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; } @@ -163,14 +168,15 @@ sub create_message_xml ($$$) { $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})); @@ -181,8 +187,8 @@ sub create_message_xml ($$$) { 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); @@ -191,7 +197,9 @@ sub create_message_xml ($$$) { if ($msg -> {kids}) { for (@{$msg -> {kids}}) { - $message -> appendChild (&create_message_xml ($xml, $msges, $_));}} + $message -> appendChild (&create_message_xml ($xml, $msges, $_)); + } + } $message; } @@ -505,4 +513,4 @@ sub long_hr_time ($) { # ==================================================== # end of Posting::_lib -# ==================================================== \ No newline at end of file +# ====================================================