Home : Products : Gossamer Forum : Development, Plugins and Globals :

Products: Gossamer Forum: Development, Plugins and Globals: Re: [hoefti] Advice on adding functionality: Edit Log

Here is the list of edits for this post
Re: [hoefti] Advice on adding functionality
Here's updated code that fixed a couple problems, and should work properly:

Code:
sub {
if ($IN->param('report_post')) {
my ($forum_id, $reporter, $post_id) = @_;
require GForum::Forum;
my $forum = GForum::Forum::get($forum_id);
my $moderators = GForum::Forum->moderators($forum_id)->{forum_moderators};
my @emails = map $_->{user_email}, @$moderators;

# Now @emails contains the e-mail addresses of the forum\'s moderators, if any.

if (!@emails) { # comment out this "if" if you always want the admin to get an e-mail
push @emails, $CFG->{admin_email}; # If no moderators, use the admin e-mail
}

require GT::Mail;
my $reporter_escaped = $IN->escape($reporter);
for (@emails) {
my $mailer = GT::Mail->new(
To => join(', ', @emails),
From => "Moderator Notification <$CFG->{admin_email}>",
Subject => "$forum->{cat_full_name}: $forum->{forum_name} moderator notification",
msg => qq|
$reporter has requested that a moderator be notified regarding about a post in
the $forum->{cat_full_name}: $forum->{forum_name} forum.

The post is located here:
$CFG->{cgi_root_url}/gforum.cgi?post=$post_id#$post_id

User details:
$CFG->{cgi_root_url}/gforum.cgi?username=$reporter_escaped
Forum:
$CFG->{cgi_root_url}/gforum.cgi?forum=$forum_id
|,
($CFG->{smtp_server} ? (smtp => $CFG->{smtp_server}) : (sendmail => $CFG->{mail_path}))
)->send;
}
return { moderator_notified => 1 };
}
else {
return {}
}
}

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com

Last edited by:

Jagerman: Mar 25, 2004, 10:19 AM

Edit Log: