# FILE: contact.pl
# DESCRIPTION: Contact Moderators
#-------------------------------------------------------------------------------
# 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);

###
### contact_control
###
### Controls contact information functions
###

sub contact_control {
	dreq("template");
	my $FORMref = parse_form($ENV{'QUERY_STRING'}, $ENV{'CONTENT_LENGTH'});
	contact_first($FORMref) if $FORMref->{action} eq "";
}

###
### contact_first
###
### Lists moderators on the board
###

sub contact_first {
	my ($FORMref) = @_;
	dreq("authpass", "fcn-priv");
	my $ml = read_account_file("passwd", undef, { returnformat => "single_array" } );
	my @mod = sort { $a->{user} cmp $b->{user} } @{ $ml };
	my $tpf = read_privilege_file();
	my $x = read_tree(undef, { no_lock => 1, no_unlock => 1, zero_ok => 1 });
	my $cookie = "";
	if ($DCONF->{pro} && $GLOBAL_OPTIONS->{topics_to_show} == 1) {
		dreq("authwrap-PRO");
		($x, $cookie) = tree_list_simple_prune($x, $FORMref);
	}
	foreach my $m (@mod) {
		my $y = $tpf->{by_mod}->{$m->{user}};
		my @k = grep($y->{$_->{topic}} == 1, @{ $x });
		$m->{topics} = \@k;
	}
	@mod = grep($_->{user} ne $DCONF->{superuser}, @mod) if $GLOBAL_OPTIONS->{contact_hide_admin};
	my $subst = {};
	$subst->{moderators} = \@mod;
	screen_out("contact1", $subst, $cookie);
}

1;
