Module: Block User
Posted by Thomas Seifert
|
Module: Block User January 30, 2011 07:08AM |
Admin Registered: 24 years ago Posts: 9,240 |
Module : Block User Author : Thomas Seifert Allows administrators to handle misbehaving or spammy users by: - blocking them in a specific (sub-)forum (no post possible) - blocking them in the whole phorum (no post possible) - disabling them (no login possible) - deleting all their posts That action can be done by clicking a link in the user profile and selecting the options on the followup page. Installation: ------------- - Unpack the archive; - Move the directory "block_user" to the directory "mods" within your Phorum installation; - Login as administrator in Phorum's administrative interface and go to the "Modules" section; - Enable the module "Block User". Notes: ------ As deleting all messages of a user is a time consuming task in the database the deletion is only done up to 100 messages for the user. Usually spam users don't have that many messages (yet).
Thomas Seifert
|
Re: Module: Block User September 10, 2011 06:56PM |
Registered: 16 years ago Posts: 15 |
This did not work for me. array_keys() seems to be returning index values, not message ids as keys. I have to suspect it is a problem with phorum_db_search. It also seems (to me) that the first value in the array for a message is the message id (I'm not a phorum expert by any means). So I use reset() to grab it and pass it to the delete function call.
I modified the delete loop as follows (sorry but the code indents got lost in my copy/paste):
original code (in this mod):
if(!empty($_POST['delete_posts'])) {
$userposts = phorum_db_search('', $uid, false, 0, 100, 'USER_ID', 0, 'ALL');
$message_ids = array_keys($userposts['rows']);
$deleted=0;
foreach($message_ids as $mid) {
//phorum_db_delete_message($mid,PHORUM_DELETE_MESSAGE);
$deleted++;
}
$okmsgs[]=str_replace('%postcount%',$deleted,$PHORUM["DATA"]["LANG"]["mod_block_user"]['MsgDeletePosts']);
}
my corrected code:
if(!empty($_POST['delete_posts'])) {
$userposts = phorum_db_search('', $uid, false, 0, 100, 'USER_ID', 0, 'ALL');
$usermessages = $userposts['rows'];
$deleted=0;
foreach($usermessages as $usermessage) {
$mid = reset($usermessage);
phorum_db_delete_message($mid,PHORUM_DELETE_MESSAGE);
$deleted++;
}
$okmsgs[]=str_replace('%postcount%',$deleted,$PHORUM["DATA"]["LANG"]["mod_block_user"]['MsgDeletePosts']);
}
Paul
I modified the delete loop as follows (sorry but the code indents got lost in my copy/paste):
original code (in this mod):
if(!empty($_POST['delete_posts'])) {
$userposts = phorum_db_search('', $uid, false, 0, 100, 'USER_ID', 0, 'ALL');
$message_ids = array_keys($userposts['rows']);
$deleted=0;
foreach($message_ids as $mid) {
//phorum_db_delete_message($mid,PHORUM_DELETE_MESSAGE);
$deleted++;
}
$okmsgs[]=str_replace('%postcount%',$deleted,$PHORUM["DATA"]["LANG"]["mod_block_user"]['MsgDeletePosts']);
}
my corrected code:
if(!empty($_POST['delete_posts'])) {
$userposts = phorum_db_search('', $uid, false, 0, 100, 'USER_ID', 0, 'ALL');
$usermessages = $userposts['rows'];
$deleted=0;
foreach($usermessages as $usermessage) {
$mid = reset($usermessage);
phorum_db_delete_message($mid,PHORUM_DELETE_MESSAGE);
$deleted++;
}
$okmsgs[]=str_replace('%postcount%',$deleted,$PHORUM["DATA"]["LANG"]["mod_block_user"]['MsgDeletePosts']);
}
Paul
|
Re: Module: Block User September 11, 2011 02:41AM |
Admin Registered: 24 years ago Posts: 9,240 |
|
Re: Module: Block User September 11, 2011 08:55AM |
Registered: 16 years ago Posts: 15 |
|
Re: Module: Block User September 11, 2011 10:15AM |
Admin Registered: 24 years ago Posts: 9,240 |
|
Re: Module: Block User March 27, 2012 06:18AM |
Registered: 17 years ago Posts: 40 |
|
Re: Module: Block User March 27, 2012 03:55PM |
Admin Registered: 24 years ago Posts: 9,240 |
|
Re: Module: Block User March 28, 2012 01:39AM |
Registered: 17 years ago Posts: 40 |
Thank You, Thomas for your early reply.
Really, smart mod. Suppose it would be useful to make the mod accessible not only for admins, but for moderators also. In that case what should I do to make it possible? I think it's not too complicated, but have not found yet solution for the problem.
That's the first question, the second one is:
if so, isn't it possible to give the moderators some tool for forgiving poor punished user?
Thank You, very much
Really, smart mod. Suppose it would be useful to make the mod accessible not only for admins, but for moderators also. In that case what should I do to make it possible? I think it's not too complicated, but have not found yet solution for the problem.
That's the first question, the second one is:
if so, isn't it possible to give the moderators some tool for forgiving poor punished user?
Thank You, very much
|
Re: Module: Block User March 29, 2012 12:50AM |
Admin Registered: 24 years ago Posts: 9,240 |
Sorry, only registered users may post in this forum.