X-Git-Url: https://git.p6c8.net/selfforum.git/blobdiff_plain/aaff267fdddc495df3bfa2fc0eb0d20a76b6d220..bca3eed65c50f585248ae3a1cc8bb6a74e4e8bb8:/selfforum-cgi/shared/Posting/Admin.pm?ds=inline diff --git a/selfforum-cgi/shared/Posting/Admin.pm b/selfforum-cgi/shared/Posting/Admin.pm index f3a4330..a075f56 100644 --- a/selfforum-cgi/shared/Posting/Admin.pm +++ b/selfforum-cgi/shared/Posting/Admin.pm @@ -5,8 +5,8 @@ package Posting::Admin; # File: shared/Posting/Admin.pm # # (was: ~Handle.pm) # # # -# Authors: Frank Schoenmann , 2001-03-13 # -# Andre Malo , 2001-03-29 # +# Authors: Frank Schönmann # +# André Malo # # # # Description: Allow administration of postings # # # @@ -18,17 +18,44 @@ package Posting::Admin; ################################################################################ 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) @@ -41,8 +68,7 @@ use XML::DOM; # 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'}, @@ -73,13 +99,14 @@ sub add_user_vote() # 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'; @@ -89,12 +116,10 @@ sub level_vote my $mnode = get_message_node($xml, $tid, $mid); - if ($value == undef) - { + unless (defined $value) { removeAttribute($level); } - else - { + else { $mnode->setAttribute($level, $value); } @@ -114,8 +139,7 @@ sub level_vote # * 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'}, @@ -158,8 +182,7 @@ sub hide_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'}, @@ -199,7 +222,7 @@ sub recover_posting($$$) # $invisible 1 - invisible, 0 - visible # Return: Status code # -sub change_posting_visibility($$$$) +sub change_posting_visibility ($$$$) { my ($fname, $tid, $mid, $invisible) = @_; @@ -211,8 +234,7 @@ sub change_posting_visibility($$$$) $mnode->setAttribute('invisible', $invisible); # Set flag in sub nodes - for ($mnode->getElementsByTagName('Message')) - { + for ($mnode->getElementsByTagName('Message')) { $_->setAttribute('invisible', $invisible); } @@ -229,14 +251,20 @@ sub change_posting_visibility($$$$) # (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; @@ -250,14 +278,11 @@ sub modify_posting($$$) $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; } @@ -282,8 +307,7 @@ sub modify_posting($$$) # \%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; @@ -315,8 +339,7 @@ sub change_posting_value($$$$) # Todo: # * Change body # -sub change_posting_body($$$$) -{ +sub change_posting_body ($$$$) { my ($fname, $tid, $mid, $body) = @_; my $parser = new XML::DOM::Parser; @@ -331,4 +354,8 @@ sub change_posting_body($$$$) # Let it be true -1; \ No newline at end of file +1; + +# +# +### end of Posting::Admin ###################################################### \ No newline at end of file