# File: shared/Posting/Admin.pm #
# (was: ~Handle.pm) #
# #
-# Authors: Frank Schoenmann <fs@tower.de>, 2001-03-13 #
-# Andre Malo <nd@o3media.de>, 2001-03-29 #
+# Authors: Frank Schönmann <fs@tower.de> #
+# André Malo <nd@o3media.de> #
# #
# Description: Allow administration of postings #
# #
################################################################################
use strict;
-
-use base qw(Exporter);
-
-@Posting::Admin::EXPORT = qw(hide_posting recover_posting modify_posting add_user_vote level_vote);
+use vars qw(
+ @EXPORT
+);
use Lock qw(:READ);
-use Posting::_lib qw(get_message_node save_file get_all_threads
- create_forum_xml_string);
+use Posting::_lib qw(
+ get_message_node
+ save_file
+ get_all_threads
+ create_forum_xml_string
+);
use XML::DOM;
+################################################################################
+#
+# Version check
+#
+# last modified:
+# $Date$ (GMT)
+# by $Author$
+#
+sub VERSION {(q$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'}
+
+################################################################################
+#
+# Export
+#
+use base qw(Exporter);
+
+@EXPORT = qw(
+ hide_posting
+ recover_posting
+ modify_posting
+ add_user_vote
+ level_vote
+);
+
### add_user_vote () ###########################################################
#
# Increase number of user votes (only in thread file)
# Todo:
# * Lock files before modification
#
-sub add_user_vote()
-{
+sub add_user_vote ($$$) {
my ($forum, $tpath, $info) = @_;
my ($tid, $mid, $percent) = ($info->{'thread'},
$info->{'posting'},
# Todo:
# * Lock files before modification
#
-sub level_vote
-{
+sub level_vote {
my ($forum, $tpath, $info´) = @_;
- my ($tid, $mid, $level, $value) = ($info->{'thread'},
- $info->{'posting'},
- $info->{'level'},
- $info->{'value'});
+ my ($tid, $mid, $level, $value) = (
+ $info->{'thread'},
+ $info->{'posting'},
+ $info->{'level'},
+ $info->{'value'}
+ );
# Thread
my $tfile = $tpath . '/t' . $tid . '.xml';
my $mnode = get_message_node($xml, $tid, $mid);
- if ($value == undef)
- {
+ unless (defined $value) {
removeAttribute($level);
}
- else
- {
+ else {
$mnode->setAttribute($level, $value);
}
# * set flags recursively in forum xml
# * lock files before modification
#
-sub hide_posting($$$)
-{
+sub hide_posting ($$$) {
my ($forum, $tpath, $info) = @_;
my ($tid, $mid, $indexFile) = ($info->{'thread'},
$info->{'posting'},
# * set flags recursive in forum xml
# * lock files before modification
#
-sub recover_posting($$$)
-{
+sub recover_posting ($$$) {
my ($forum, $tpath, $info) = @_;
my ($tid, $mid, $indexFile) = ($info->{'thread'},
$info->{'posting'},
# $invisible 1 - invisible, 0 - visible
# Return: Status code
#
-sub change_posting_visibility($$$$)
+sub change_posting_visibility ($$$$)
{
my ($fname, $tid, $mid, $invisible) = @_;
$mnode->setAttribute('invisible', $invisible);
# Set flag in sub nodes
- for ($mnode->getElementsByTagName('Message'))
- {
+ for ($mnode->getElementsByTagName('Message')) {
$_->setAttribute('invisible', $invisible);
}
# (data = \%hashref: 'subject', 'category', 'body')
# Return: -none-
#
-sub modify_posting($$$)
-{
+sub modify_posting($$$) {
my ($forum, $tpath, $info) = @_;
- my ($tid, $mid, $indexFile, $data) = ($info->{'thread'},
- $info->{'posting'},
- $info->{'indexFile'},
- $info->{'data'});
- my ($subject, $category, $body) = ($data->{'subject'}, $data->{'category'}, $data->{'body'});
+ my ($tid, $mid, $indexFile, $data) = (
+ $info->{'thread'},
+ $info->{'posting'},
+ $info->{'indexFile'},
+ $info->{'data'}
+ );
+
+ my ($subject, $category, $body) = (
+ $data->{'subject'},
+ $data->{'category'},
+ $data->{'body'}
+ );
my %msgdata;
$body && change_posting_body($tfile, 't'.$tid, 'm'.$mid, $body);
# Forum (does not contain msg bodies)
- if ($subject or $category)
- {
+ if ($subject or $category) {
my ($f, $lthread, $lmsg, $dtd, $zlev) = get_all_threads($forum, 1, 0);
- for (@{$f->{$tid}})
- {
- if ($_->{'mid'} == $mid)
- {
+ for (@{$f->{$tid}}) {
+ if ($_->{'mid'} == $mid) {
$subject && $_->{'subject'} = $subject;
$category && $_->{'cat'} = $category;
}
# \%values New values
# Return: Status code
#
-sub change_posting_value($$$$)
-{
+sub change_posting_value($$$$) {
my ($fname, $tid, $mid, $values) = @_;
my $parser = new XML::DOM::Parser;
# Todo:
# * Change body
#
-sub change_posting_body($$$$)
-{
+sub change_posting_body ($$$$) {
my ($fname, $tid, $mid, $body) = @_;
my $parser = new XML::DOM::Parser;
# Let it be true
-1;
\ No newline at end of file
+1;
+
+#
+#
+### end of Posting::Admin ######################################################
\ No newline at end of file