Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Re: [Andy] Ignore User?

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
Subject Author Views Date
Thread Ignore User? afra 4068 Dec 4, 2007, 1:46 PM
Thread Re: [afra] Ignore User?
brewt 3967 Dec 4, 2007, 4:31 PM
Thread Re: [brewt] Ignore User?
afra 3957 Dec 13, 2007, 9:54 AM
Thread Re: [afra] Ignore User?
Andy 3918 Dec 14, 2007, 1:57 AM
Post Re: [Andy] Ignore User?
afra 3912 Dec 14, 2007, 11:41 AM