home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / FAQ / discus_admin_1357211388 / source / fcn-msdl.pl < prev    next >
Text File  |  2009-11-06  |  3KB  |  84 lines

  1. # FILE: fcn-msdl.pl
  2. # DESCRIPTION: Message Management (Delete Message)
  3. #-------------------------------------------------------------------------------
  4. # DISCUS COPYRIGHT NOTICE
  5. #
  6. # Discus is copyright (c) 2002 by DiscusWare, LLC, all rights reserved.
  7. # The use of Discus is governed by the Discus License Agreement which is
  8. # available from the Discus WWW site at:
  9. #    http://www.discusware.com/discus/license
  10. #
  11. # Pursuant to the Discus License Agreement, this copyright notice may not be
  12. # removed or altered in any way.
  13. #-------------------------------------------------------------------------------
  14.  
  15. use strict;
  16. use vars qw($GLOBAL_OPTIONS $DCONF $PARAMS);
  17.  
  18. ###
  19. ### remove_message
  20. ###
  21. ### Removes messages from a page.
  22. ###
  23.  
  24. sub remove_message {
  25.     my ($arg, $tree_file_in, $cat_array, $file_in) = @_;
  26.     my $p = {};
  27.     $p->{lock} = 1;
  28.     $p->{no_error} = 1 if $PARAMS->{no_exit} == 1;
  29.     my $file = defined $file_in ? $file_in : GetPage($arg->{topic}, $arg->{page}, $p);
  30.     return undef if $file->{head}->{topic_number} != $arg->{topic};
  31.     my $_mr = 0; my @_ag = (); my @_nm = (); my @_nn = (); my @_nnt = ();
  32.     foreach my $msgref (@{ $file->{messages} }) {
  33.         if ($arg->{td}->{"*"} || $arg->{td}->{$msgref->{number}}) {
  34.             $_mr += 1;
  35.             my $text = $msgref->{text};
  36.             if (! $arg->{no_delete_attachments} ) {
  37.                 push @_ag, map { $_->{filename} } @{attachment_scan($text)};
  38.             }
  39.             push @_nn, $msgref;
  40.             push @_nnt, $msgref->{number};
  41.         } else {
  42.             push @_nm, $msgref;
  43.         }
  44.     }
  45.     $file->{messages} = \@_nm;
  46.     $file->{general}->{subtopic_raw} = 1;
  47.     $file->{general}->{messages_raw} = 0;
  48.     SetPage($file, { unlock => 1 }) if ! defined $file_in;
  49.     dreq("fcn-tree");
  50.     my $tree = defined $tree_file_in ? $tree_file_in : read_tree($arg->{topic}, { no_unlock => 1 });
  51.     ($tree, $cat_array) = tree_remove_message($tree, $cat_array, [ {page => $arg->{page}, messages => join(",", @_nnt)} ]);
  52.     if (! defined $tree_file_in) {
  53.         write_tree($arg->{topic}, $tree, { no_lock => 1 });
  54.         topic_tree_to_main($tree);
  55.     }
  56.     my $dirname = (-e "$DCONF->{message_dir}/$arg->{topic}" ? "$DCONF->{message_dir}/$arg->{topic}" : "$DCONF->{secdir}/$arg->{topic}");
  57.     foreach my $u (@_ag) {
  58.         unlink "$dirname/$u";
  59.     }
  60.     if (! defined $arg->{no_log_action}) {
  61.         dreq("fcn-logs");
  62.         if ($DCONF->{pro} && $GLOBAL_OPTIONS->{database} == 1) {
  63.             my $dbh = db_connect();
  64.             delete_entry ({ files_already_locked => $arg->{files_already_locked}, database => "log", dbh => $dbh, messages => $arg->{td} });
  65.             delete_entry ({ files_already_locked => $arg->{files_already_locked}, database => "search", dbh => $dbh, messages => $arg->{td} });
  66.         } else {
  67.             delete_entry ({ files_already_locked => $arg->{files_already_locked}, messages => $arg->{td}, topic => $arg->{topic} });
  68.         }
  69.     }
  70.     if (! defined $arg->{no_page_update}) {
  71.         pages_upward_update($tree, $cat_array, [ $arg->{page} ], undef );
  72.         dreq("topic-pg"); regenerate_topic_page();
  73.     }
  74.     return {
  75.         tree => $tree,
  76.         cat_array => $cat_array,
  77.         oldfile => $file,
  78.     };
  79. }
  80.  
  81.  
  82.  
  83. 1;
  84.