View Full Version : Mini Mods - Auto-PM to Staff when a User is Banned
Alan @ CIT
06-17-2006, 10:00 PM
AutoPM Staff on Ban
Version 1.0
What does this do?
When one of your moderators or administrators bans a user, this mod will PM all staff (Mods and Admins) letting them know that the user has been banned!
Sounds Great! How do I install?
Installation couldn't be easier. Unzip the attached ZIP file and import the Product XML to your AdminCP as normal. - it adds 2 phrases, and 1 plugin :)
Can I customize the PM text?
Yep! The PM text is stored in a phrase called autopm_on_ban_message. You can edit this to put your own text in.
Note: In the PM message phrase, {1} is the name of the user who has been banned, and {2} is the name of the person who banned them.[/left]
Note 2: The person who bans the user will NOT receive a PM, so if your not receiving a PM, it's likely because you where the one who banned the user! :D
Important: Unfortunately, my leased vBulletin licence has now expired, and I won't be renewing it until September which means I will be unable to reply to this thread, or update this mod until then. I'm hopeful that the great vBulletin.org community will step in to answer any questions in my absence though :) See you all in early September! :D
Alan @ CIT
06-18-2006, 12:07 AM
Known bugs: None!
Christine
06-18-2006, 12:45 AM
Nice!
Easy to hook in a few other things with this like removing thread subscriptions.
Thanks!
D.Ilyin
06-18-2006, 11:53 AM
Alan @ CIT is it posable to add selected group for PM?
For examle admins only or superadmins?
Alan @ CIT
06-18-2006, 11:55 AM
Not in it's current state I'm afraid. An option may be added to a future version.
Thanks,
Alan.
Yorixz
06-19-2006, 08:17 AM
Pretty nice, will you also add the ban reason in the pm in the near future?
klaush
06-19-2006, 12:46 PM
Sounds great. Will this still work with 3.5.4?
bashy
06-25-2006, 09:34 AM
Hi
After reading this post (https://vborg.vbsupport.ru/showpost.php?p=1010038&postcount=2) i went ahead and tried to install this but got this error
I am on 3.5.4
any ideas please?
Database error in vBulletin 3.5.4:
Invalid SQL:
### INSERT QUERY GENERATED BY fetch_query_sql() ###
INSERT INTO plugin
(`active`, `executionorder`, `title`, `hookname`, `phpcode`, `product`)
VALUES
('1', '5', 'AutoPM Staff on Ban', 'userdata_postsave', 'if ($usergroups_changed)\r\n{\r\n // Check to see if the user has just been banned (in the last 10 seconds)\r\n $ban_info_q = \"SELECT ban.userid, user.username\r\n FROM \" . TABLE_PREFIX . \"userban AS ban\r\n LEFT JOIN \" . TABLE_PREFIX . \"user AS user ON (ban.userid = user.userid)\r\n WHERE ban.userid = \" . intval($userid) . \"\r\n AND bandate > \" . (TIMENOW - 10) . \"\r\n ORDER BY bandate DESC\r\n LIMIT 1\";\r\n\r\n if ($ban_info_a = $this->dbobject->query_first($ban_info_q))\r\n {\r\n // Users just been banned, so fetch the list of admins/mods to PM\r\n $recipients_q = \"SELECT users.userid, users.username\r\n FROM \" . TABLE_PREFIX . \"user AS users\r\n LEFT JOIN \" . TABLE_PREFIX . \"administrator AS admins ON (admins.userid = users.userid)\r\n LEFT JOIN \" . TABLE_PREFIX . \"moderator AS mods ON (mods.userid = users.userid)\r\n WHERE users.userid IN (admins.userid)\r\n OR users.userid IN (mods.userid)\";\r\n\r\n $recipients_r = $this->dbobject->query_read($recipients_q);\r\n\r\n while ($recipients_a = $this->dbobject->fetch_array($recipients_r))\r\n {\r\n $pmto_a[$recipients_a[\'userid\']] = $recipients_a[\'username\'];\r\n }\r\n\r\n // Create the final recipients list for the PM, removing the current user from the PM list\r\n unset($pmto_a[$this->registry->userinfo[\'userid\']]);\r\n $recipients = implode(\';\', $pmto_a);\r\n\r\n global $vbphrase;\r\n\r\n // Prepare the message title\r\n $pm_title = construct_phrase(\r\n $vbphrase[\'x_has_been_banned\'],\r\n $ban_info_a[\'username\']\r\n );\r\n\r\n // Prepare the message text\r\n $pm_text = construct_phrase(\r\n $vbphrase[\'autopm_on_ban_message\'],\r\n $ban_info_a[\'username\'],\r\n $this->registry->userinfo[\'username\']\r\n );\r\n\r\n // Send the PM\r\n $force_it_baby[\'adminpermissions\'] = 2;\r\n \r\n $pm =& datamanager_init(\'PM\', $this->registry, ERRTYPE_SILENT);\r\n $pm->set(\'fromuserid\', $this->registry->userinfo[\'userid\']);\r\n $pm->set(\'fromusername\', $this->registry->userinfo[\'username\']);\r\n $pm->set(\'title\', $pm_title);\r\n $pm->set(\'message\', $pm_text);\r\n $pm->set_recipients($recipients, $force_it_baby);\r\n $pm->set(\'dateline\', TIMENOW);\r\n\r\n if (!$pm->errors)\r\n { \r\n // No errors, so send the PM\r\n $pm->save();\r\n }\r\n }\r\n\r\n}', 'cit_pm_on_ban');
MySQL Error : Unknown column 'executionorder' in 'field list'
Error Number : 1054
Date : Sunday, June 25th 2006 @ 04:31:25 AM
Script : http://www.bashys-place.com/forums/admincp/plugin.php
Referrer : http://www.bashys-place.com/forums/admincp/plugin.php?do=productadd
klaush
06-25-2006, 02:29 PM
Same here!
tEChniiQue
06-25-2006, 03:58 PM
I received an error as well...Alan @ CIT I hope you're out there...
Database error in vBulletin 3.5.4:
Invalid SQL:
### INSERT QUERY GENERATED BY fetch_query_sql() ###
INSERT INTO plugin
(`active`, `executionorder`, `title`, `hookname`, `phpcode`, `product`)
VALUES
('1', '5', 'AutoPM Staff on Ban', 'userdata_postsave', 'if ($usergroups_changed)\r\n{\r\n // Check to see if the user has just been banned (in the last 10 seconds)\r\n $ban_info_q = \"SELECT ban.userid, user.username\r\n FROM \" . TABLE_PREFIX . \"userban AS ban\r\n LEFT JOIN \" . TABLE_PREFIX . \"user AS user ON (ban.userid = user.userid)\r\n WHERE ban.userid = \" . intval($userid) . \"\r\n AND bandate > \" . (TIMENOW - 10) . \"\r\n ORDER BY bandate DESC\r\n LIMIT 1\";\r\n\r\n if ($ban_info_a = $this->dbobject->query_first($ban_info_q))\r\n {\r\n // Users just been banned, so fetch the list of admins/mods to PM\r\n $recipients_q = \"SELECT users.userid, users.username\r\n FROM \" . TABLE_PREFIX . \"user AS users\r\n LEFT JOIN \" . TABLE_PREFIX . \"administrator AS admins ON (admins.userid = users.userid)\r\n LEFT JOIN \" . TABLE_PREFIX . \"moderator AS mods ON (mods.userid = users.userid)\r\n WHERE users.userid IN (admins.userid)\r\n OR users.userid IN (mods.userid)\";\r\n\r\n $recipients_r = $this->dbobject->query_read($recipients_q);\r\n\r\n while ($recipients_a = $this->dbobject->fetch_array($recipients_r))\r\n {\r\n $pmto_a[$recipients_a[\'userid\']] = $recipients_a[\'username\'];\r\n }\r\n\r\n // Create the final recipients list for the PM, removing the current user from the PM list\r\n unset($pmto_a[$this->registry->userinfo[\'userid\']]);\r\n $recipients = implode(\';\', $pmto_a);\r\n\r\n global $vbphrase;\r\n\r\n // Prepare the message title\r\n $pm_title = construct_phrase(\r\n $vbphrase[\'x_has_been_banned\'],\r\n $ban_info_a[\'username\']\r\n );\r\n\r\n // Prepare the message text\r\n $pm_text = construct_phrase(\r\n $vbphrase[\'autopm_on_ban_message\'],\r\n $ban_info_a[\'username\'],\r\n $this->registry->userinfo[\'username\']\r\n );\r\n\r\n // Send the PM\r\n $force_it_baby[\'adminpermissions\'] = 2;\r\n \r\n $pm =& datamanager_init(\'PM\', $this->registry, ERRTYPE_SILENT);\r\n $pm->set(\'fromuserid\', $this->registry->userinfo[\'userid\']);\r\n $pm->set(\'fromusername\', $this->registry->userinfo[\'username\']);\r\n $pm->set(\'title\', $pm_title);\r\n $pm->set(\'message\', $pm_text);\r\n $pm->set_recipients($recipients, $force_it_baby);\r\n $pm->set(\'dateline\', TIMENOW);\r\n\r\n if (!$pm->errors)\r\n { \r\n // No errors, so send the PM\r\n $pm->save();\r\n }\r\n }\r\n\r\n}', 'cit_pm_on_ban');
MySQL Error : Unknown column 'executionorder' in 'field list'
Error Number : 1054
Date : Saturday, June 17th 2006 @ 07:56:26 PM
Script : http://www.xtreme-source.com/admincp/plugin.php
Referrer : http://www.xtreme-source.com/admincp...?do=productadd
IP Address : 67.53.37.197
Username : tEChniiQue
Classname : vb_database
Alan @ CIT
06-25-2006, 04:30 PM
Sorry, this modification is only supported on vBulletin 3.6 Beta 2 or above.
Thanks,
Alan.
Adrian Schneider
06-25-2006, 04:32 PM
Hi
After reading this post (https://vborg.vbsupport.ru/showpost.php?p=1010038&postcount=2) i went ahead and tried to install this but got this error
I am on 3.5.4
any ideas please?
Database error in vBulletin 3.5.4:
Invalid SQL:
### INSERT QUERY GENERATED BY fetch_query_sql() ###
INSERT INTO plugin
(`active`, `executionorder`, `title`, `hookname`, `phpcode`, `product`)
VALUES
('1', '5', 'AutoPM Staff on Ban', 'userdata_postsave', 'if ($usergroups_changed)\r\n{\r\n // Check to see if the user has just been banned (in the last 10 seconds)\r\n $ban_info_q = \"SELECT ban.userid, user.username\r\n FROM \" . TABLE_PREFIX . \"userban AS ban\r\n LEFT JOIN \" . TABLE_PREFIX . \"user AS user ON (ban.userid = user.userid)\r\n WHERE ban.userid = \" . intval($userid) . \"\r\n AND bandate > \" . (TIMENOW - 10) . \"\r\n ORDER BY bandate DESC\r\n LIMIT 1\";\r\n\r\n if ($ban_info_a = $this->dbobject->query_first($ban_info_q))\r\n {\r\n // Users just been banned, so fetch the list of admins/mods to PM\r\n $recipients_q = \"SELECT users.userid, users.username\r\n FROM \" . TABLE_PREFIX . \"user AS users\r\n LEFT JOIN \" . TABLE_PREFIX . \"administrator AS admins ON (admins.userid = users.userid)\r\n LEFT JOIN \" . TABLE_PREFIX . \"moderator AS mods ON (mods.userid = users.userid)\r\n WHERE users.userid IN (admins.userid)\r\n OR users.userid IN (mods.userid)\";\r\n\r\n $recipients_r = $this->dbobject->query_read($recipients_q);\r\n\r\n while ($recipients_a = $this->dbobject->fetch_array($recipients_r))\r\n {\r\n $pmto_a[$recipients_a[\'userid\']] = $recipients_a[\'username\'];\r\n }\r\n\r\n // Create the final recipients list for the PM, removing the current user from the PM list\r\n unset($pmto_a[$this->registry->userinfo[\'userid\']]);\r\n $recipients = implode(\';\', $pmto_a);\r\n\r\n global $vbphrase;\r\n\r\n // Prepare the message title\r\n $pm_title = construct_phrase(\r\n $vbphrase[\'x_has_been_banned\'],\r\n $ban_info_a[\'username\']\r\n );\r\n\r\n // Prepare the message text\r\n $pm_text = construct_phrase(\r\n $vbphrase[\'autopm_on_ban_message\'],\r\n $ban_info_a[\'username\'],\r\n $this->registry->userinfo[\'username\']\r\n );\r\n\r\n // Send the PM\r\n $force_it_baby[\'adminpermissions\'] = 2;\r\n \r\n $pm =& datamanager_init(\'PM\', $this->registry, ERRTYPE_SILENT);\r\n $pm->set(\'fromuserid\', $this->registry->userinfo[\'userid\']);\r\n $pm->set(\'fromusername\', $this->registry->userinfo[\'username\']);\r\n $pm->set(\'title\', $pm_title);\r\n $pm->set(\'message\', $pm_text);\r\n $pm->set_recipients($recipients, $force_it_baby);\r\n $pm->set(\'dateline\', TIMENOW);\r\n\r\n if (!$pm->errors)\r\n { \r\n // No errors, so send the PM\r\n $pm->save();\r\n }\r\n }\r\n\r\n}', 'cit_pm_on_ban');
MySQL Error : Unknown column 'executionorder' in 'field list'
Error Number : 1054
Date : Sunday, June 25th 2006 @ 04:31:25 AM
Script : http://www.bashys-place.com/forums/admincp/plugin.php
Referrer : http://www.bashys-place.com/forums/admincp/plugin.php?do=productadd
Guys the "executionorder" field was added in vBulletin 3.6.
bashy
06-25-2006, 05:27 PM
The only reason why i have tried this is because of what you said in another thread....
https://vborg.vbsupport.ru/showthread.php?t=118919 - Should work fine with 3.5.4, but if you have any problems, let me know.
Hence trying this out.......its the part that says "but if you have any problems, let me know"
is why i posted here asking fro help...
Sorry, this modification is only supported on vBulletin 3.6 Beta 2 or above.
Thanks,
Alan.
Alan @ CIT
06-25-2006, 07:08 PM
"should" is the key word in my sentance :)
Thanks,
Alan.
bashy
06-25-2006, 08:02 PM
Fair enough, thanks anyway!!
klaush
06-25-2006, 08:02 PM
"should" is the key word in my sentance :)
Thanks,
Alan.
So, Alan, can you port this to 3.5.x, or is it too difficult?
Alan @ CIT
06-26-2006, 10:28 AM
Sorry, but I have no plans to back-port any of my 3.6 hacks to work with 3.5.x
Thanks,
Alan.
Eagle Creek
08-12-2006, 06:27 PM
Am I able to edit the staff UG's?
Cause I have Admins, S-mods, Beheer, Mods.. They are all part of my forum staff.
looks and seems very nice, Thank You
Ncturnal
08-25-2006, 09:20 PM
How can I limit the people this goes out to, like say just to admins. This was sent to anyone who can mod a particular forum and thus went to a lot of people we really didn't want seeing that message.
juan71287
09-06-2006, 04:21 PM
Alan.... I see that it check every 10 seconds? Am i correct? If I am... Can that be changed to let see... To check ever 1 houre or every day? If so, please tell me what to change in the XML.. Thankx.
Kriminal
09-11-2006, 05:17 PM
Alan.... I see that it check every 10 seconds? Am i correct? If I am... Can that be changed to let see... To check ever 1 houre or every day? If so, please tell me what to change in the XML.. Thankx.
I think you can change (in the XML)
AND bandate > " . (TIMENOW - 10) . "
by
AND bandate > " . (TIMENOW - 3600) . "
to check every 1 hour (60 second x 60 minutes = 3600)
juan71287
09-11-2006, 06:36 PM
Hey thankx man :) I knew it was there but I didnt know what to put cause I am "A DUMB"
Thanxk again.
Kriminal
09-11-2006, 08:04 PM
No problem, but this only will check an hour ago for banned members; so if the query is executed two times in an hour you will receive 2 PMs for the same banned member.
The script is executed by userdata_postsave hook; and I don't know the exact circunstances where it occurs.
Snake
09-17-2006, 12:43 PM
Thank you, thank you!
rezapci
09-17-2006, 04:00 PM
aswesome, thank you <Hug>
coRtALoS
09-28-2006, 03:51 PM
I have staff besides the default groups, is it possible to send the message to them as well?
eNtitY~
12-15-2006, 01:58 AM
Installed, thanks.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.