Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Ignore User?

Quote Reply
Ignore User?
Hi,

We love Gossamer Forum over at http://prongs.org/.../gforum.cgi?forum=1;

I was wondering if there is a way for members on the forum to ignore a user - ie. If a user is chosen to be ignored, their posts will not be shown up? I don't think there is a plugin as such - would this be hard to implement?

Thank you
Quote Reply
Re: [afra] Ignore User? In reply to
No, there currently isn't a plugin that does this, but it's something we're thinking of adding to gforum 2.

Implementation wise, it would be relatively easy to do a simple version of it. Each user would have a list of users they have ignored, and in the forum list and the forum post templates, it would check these lists to see if the post was from one of those users.

Adrian
Quote Reply
Re: [brewt] Ignore User? In reply to
Thank you for your reply. I just need a bit of help implementing this code side. I have this:

CREATE TABLE gforum_IgnoreUser
(user_id int(10) unsigned NOT NULL,
user_to_ignore_id int(10) unsigned NOT NULL,
PRIMARY KEY(user_id, user_to_ignore_id));


How do I even start to create a new page for people to add this? And the message display? Do I have to do a database hit for each member who has a message?

All help is appreciated - thank you!
Quote Reply
Re: [afra] Ignore User? In reply to
Hi,

Creating the table is the easy bit :P You would then need a script, lets say "ignore.cgi" - with something like this in it:

Code:
#!/usr/bin/perl5

use strict;
use lib '/path/to/gformu/admin';
use GForum qw/:forum :user $DB $IN $CFG $USER $GUEST %HIDDEN $TEMPLATE_SET/;
use GForum::Template;
use GForum::Authenticate;

GForum::init('/path/to/gformu/admin');

my $action = $IN->param('action');

if (!$action) {
show_ignore_list();
} elsif ($action eq "add") {
show_add();
} elsif ($action eq "add2") {
do_add();
}

sub show_ignore_list {
# show them a list of tnheir currently ignored users =)
}

sub show_add {
# show a template, with a place for them to enter the user they want to block
}

sub do_add {
# actually add the entry to your new table you have
}

Thats just a start - its gonna be a lot more complex than that =)

Then, you would need to somehow filter out the users posts, based on their blocked list - and thats where it gets a bit more tricky =)

Depending if there is enough interest, I *MAY* turn this into a plugin for people - as it certainly would make a cool feature Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Ignore User? In reply to
Well I worked on this last night for a small bit - I didn't spend too much time on it - just brisked through it. Any input is appreciated.

First the table:

Code:
CREATE TABLE gforum_IgnoreUser
(
ignore_id int primary key auto_increment,
user_id_fk int(10) unsigned NOT NULL,
user_to_ignore_id int(10) unsigned NOT NULL,
UNIQUE KEY(user_id_fk, user_to_ignore_id)
);

Then, I am sure this is the wrong way to do it but I didn't immediately see where the definitions were generated. In defs/gforum_IgnoreUser.def:

Code:
{
'ai' => 'ignore_id',
'cols' => {
'ignore_id' => {
'form_size' => '10',
'form_type' => 'TEXT',
'not_null' => '1',
'pos' => '1',
'protect' => '1',
'type' => 'INT',
'unsigned' => '1'
},
'user_id_fk' => {
'form_size' => '10',
'form_type' => 'TEXT',
'not_null' => '1',
'pos' => '2',
'protect' => '1',
'type' => 'INT',
'unsigned' => '1'
},
'user_to_ignore_id' => {
'form_size' => '10',
'form_type' => 'TEXT',
'not_null' => '1',
'pos' => '2',
'protect' => '1',
'type' => 'INT',
'unsigned' => '1'
},
},
'fk' => {
'gforum_User' => {
'user_to_ignore_id' => 'user_id'
}
},
'fk_tables' => [],
'index' => {
'o_gm' => [
'user_id_fk',
'user_to_ignore_id'
]
},
'pk' => [
'user_id',
'user_to_ignore_id'

],
'subclass' => {},
'unique' => {}
};

Then, in GForum/Ignore.pm:

Code:
package GForum::Ignore;
use strict;
use GForum qw/:user $DB $USER $IN $CFG/;
use GT::Date;

sub add_ignore{
shift;
my ( $do, $func ) = @_;
my $uid = $IN->param('user_id');
$DB->table('IgnoreUser')->insert({ user_id_fk => $USER->{user_id}, user_to_ignore_id => $uid }) if $uid and $USER;
GForum::do_func($IN->param('redo'));
}


sub disable_ignore {
shift;
my ( $do, $func ) = @_;
my $uid = $IN->param('user_id');
$DB->table('IgnoreUser')->delete(GT::SQL::Condition->new(user_id_fk=> '=' => $USER->{user_id}, user_to_ignore_id => '=' => $uid)) if $uid and $USER;
GForum::do_func($IN->param('redo'));
}

sub list_ignored {
shift;
my ($do, $func) = @_;
my $page = $func->{page};

# Retrieve Users From the IgnoreUser table that have been ignored by this particular user.
my $cond = new GT::SQL::Condition;
$cond->add(user_id_fk => '=' => $USER->{user_id});
my $ou = $DB->table('IgnoreUser' => 'User');
my $sth = $ou->select($cond);

my $users = [];

while (my $rec = $sth->fetchrow_hashref) {
push @$users, $rec;
}

return(
$page->{ignore} => {
ignored_users => $users,
has_ignored_users => scalar @$users,
}
);
}

1;

(Have not coded adding ignore - will add that - shouldn't be hard )

And finally, tell everything about Ignore.pm in admin/GForum/Config/Data.pm:

Code:
'add_ignore' => {
'action' => 'function',
'customizable' => {
'description' => '1',
'page' => '1'
},
'description' => 'Enable user account ignore',
'function' => 'GForum::Ignore::add_ignore',
},

'disable_ignore' => {
'action' => 'function',
'customizable' => {
'description' => '1',
'page' => '1'
},
'description' => 'Disabling user account ignore',
'function' => 'GForum::Ignore::disable_ignore',
},

'ignore' => {
'action' => 'function',
'customizable' => {
'description' => '1',
'disabled' => '1',
'hidden' => '1',
'min_user_status' => '1',
'page' => '1',
'page-add' => '1',
'page-del' => '1',
'user_groups' => '1',
'user_groups-add' => '1',
'user_groups-del' => '1'
},
'description' => 'Ignore',
'function' => 'GForum::Ignore::list_ignored',
'page' => {
'ignore' => 'ignore.html'
}
},

So that basic functionality is there and the url /gforum.cgi?do=ignore; shows the ignored list. And there is a ignore.html in the admin/templates/default/ directory:

Code:
<%GForum::Utils::new_alternation('ignored_users')%>
<% loop ignored_users%>
<tr bgcolor="<%GForum::Utils::alternation('ignored_users', $odd_color, $even_color)%>">
<td style="border-right:1px solid <%dark_beige%>">
<%body_font%>
<% if user_id%>
<a href="gforum.cgi?username=<%GT::CGI::escape($user_username)%>;<%hidden_query%>"><%nbsp user_username%></a>
<small>(<a href="gforum.cgi?do=disable_ignore;redo=<%this_do%>;user_id=<%user_id%>;<%hidden_query%>">Disable Ignore</a>)</small>

<% else%>
<%nbsp user_username%>
<% endif%>
<%/body_font%>
</td>
<td style="border-right:1px solid <%dark_beige%>">
<%body_font%><%user_title%><%/body_font%>
</td>
</tr>
<% endloop%>

My only last question is how do I put this to use to where it ignores the post if it's created by someone on their ignore list... Perhaps have a hash in the $USER variable? Any suggestions?

Thank you - I don't care about selling the plugin or anything (seems silly). Just want help...

Last edited by:

afra: Dec 14, 2007, 12:39 PM