# FILE: adm-msgs.pl
# DESCRIPTION: Administrator's Messages (announcement, about, title, main)
#-------------------------------------------------------------------------------
# DISCUS COPYRIGHT NOTICE
#
# Discus is copyright (c) 2002 by DiscusWare, LLC, all rights reserved.
# The use of Discus is governed by the Discus License Agreement which is
# available from the Discus WWW site at:
#    http://www.discusware.com/discus/license
#
# Pursuant to the Discus License Agreement, this copyright notice may not be
# removed or altered in any way.
#-------------------------------------------------------------------------------

use strict;
use vars qw($GLOBAL_OPTIONS $DCONF $PARAMS);

###
### preview_admin_message
###
### Preview an administrative message (announcement / about)
###

sub preview_admin_message {
	my ($input, $message, $location, $FORMref) = @_;
	my $subst = {};
	$subst->{'general'}->{'location'} = $location;
	$subst->{'general'}->{'message_text'} = $message;
	if ($FORMref->{HTTP_REFERER} =~ m|(\d+)/(\d+)|) {
		$subst->{'general'}->{topic} = $1;
		$subst->{'general'}->{page} = $2;
	}
	$subst->{'FORMref'} = $FORMref;
	$input =~ s/&/&amp;/g;
	$input =~ s/</&lt;/g;
	$input =~ s/>/&gt;/g;
	$input =~ s/"/&quot;/g;
	$subst->{'general'}->{'source'} = $input;
	$subst->{'general'}->{'cancel'} = "$PARAMS->{cgiurl}?action=pm-page_editor&HTTP_REFERER=$FORMref->{HTTP_REFERER}&username=$FORMref->{username}&menu=1" if $location == 0;
	screen_out("adminmsg", $subst);
}

###
### set_announce_message
###
### Save an announcement message
###

sub set_announce_message {
	my ($input_arg) = @_;
	my $hashref = GetPage($input_arg->{topic}, $input_arg->{page}, { lock => 1} );
	$hashref->{'pginfo'}->{'announcement'} = $input_arg->{message};
	return SetPage($hashref, { unlock => 1 });
}

###
### set_about_message
###
### Save an about message
###

sub set_about_message {
	my ($input_arg) = @_;
	my $hashref = GetPage($input_arg->{topic}, $input_arg->{page}, { lock => 1} );
	$hashref->{'pginfo'}->{'about'} = $input_arg->{message};
	return SetPage($hashref, { unlock => 1 });
}

1;
