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-ms_m.pl < prev    next >
Text File  |  2009-11-06  |  2KB  |  45 lines

  1. # FILE: fcn-ms_m.pl
  2. # DESCRIPTION: Message Management (miscellaneous functions)
  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. ### reorder_messages
  20. ###
  21. ### Reorders messages on a page
  22. ###
  23.  
  24. sub reorder_messages {
  25.     my ($arg) = @_;
  26.     my $file = GetPage($arg->{topic}, $arg->{page}, { lock => 1 });
  27.     @{$file->{messages}} = sort { $arg->{order}->{ $a->{number} } <=> $arg->{order}->{ $b->{number} } } @{$file->{messages}};
  28.     $file->{general}->{subtopic_raw} = 1;
  29.     $file->{general}->{messages_raw} = 0;
  30.     SetPage($file, { unlock => 1 });
  31.     my @morder = ();
  32.     foreach my $l (@{$file->{messages}}) {
  33.         push @morder, $l->{number};
  34.     }
  35.     dreq("fcn-tree");
  36.     my $uh = { post_list => join(",",@morder), page => $arg->{page} };
  37.     my $tree = read_tree($arg->{topic}, { no_unlock => 1 });
  38.     $tree = tree_record_update($tree, undef, $uh);
  39.     write_tree($arg->{topic}, $tree, { no_lock => 1 });
  40.     topic_tree_to_main($tree) if $arg->{topic} == $arg->{page};
  41.     return \@morder;
  42. }
  43.  
  44. 1;
  45.