View Full Version : DataManager: How to add a user to another user's Ignore List?
PleaseHelp
02-28-2012, 04:30 PM
Hello,
How can you add a user to another user's Ignore List using either the DataManager or one of the vBulletin functions accessible via global.php ?
Thanks!
I think it can be done using the datamanager, but when it's done from the user profile it seems the code boils down to this:
$ignoring_userid = X;
$ignored_userid = Y;
$vbulletin->db->query_write("INSERT IGNORE INTO " . TABLE_PREFIX . "userlist
(userid, relationid, type, friend)
VALUES ($ignoring_userid, $ignored_userid, 'ignore', 'no') ");
build_userlist($ignoring_userid);
(a couple of lines from profile.php, the if ($_POST['do'] == 'doaddlist') section around lines 672 and 798).
PleaseHelp
02-29-2012, 12:16 AM
I think it can be done using the datamanager, but when it's done from the user profile it seems the code boils down to this:
$ignoring_userid = X;
$ignored_userid = Y;
$vbulletin->db->query_write("INSERT IGNORE INTO " . TABLE_PREFIX . "userlist
(userid, relationid, type, friend)
VALUES ($ignoring_userid, $ignored_userid, 'ignore', 'no') ");
build_userlist($ignoring_userid);
(a couple of lines from profile.php, the if ($_POST['do'] == 'doaddlist') section around lines 672 and 798).Many thanks, but it would seem safer to do it with the DataManager rather than a direct query. Any ideas on how to do it with the DM?
Well, it looks like ignored users are kept in two places - one is in the ignorelist column of the usertextfield table. That one can be set using the datamanager. The other one is the userlist table, like is being set by the query posted above. It turns out that build_userlist() takes care of setting the ignorelist via the datamanager, so you'd still have to do a query to create a row in usertextfield.
PleaseHelp
02-29-2012, 03:08 PM
Well, it looks like ignored users are kept in two places - one is in the ignorelist column of the usertextfield table. That one can be set using the datamanager. The other one is the userlist table, like is being set by the query posted above. It turns out that build_userlist() takes care of setting the ignorelist via the datamanager, so you'd still have to do a query to create a row in usertextfield.Thanks. OK, so we would have to do it BOTH with the query code you provided earlier AND with the DataManager, is that correct?
If so, then what is the DataManager code we need to use on top of the query code you already provided?
Thanks again, kh99, you're a huge help around here. Your prompt and thorough responses are always appreciated.
build_userlist() takes care of the datamanager part. If you want to see that code you can look at includes/functions_databuild.php. Since the lists set by the user datamanager are comma-separated lists, if you're adding one userid to a list you have to get the existing list first then build a new list with the added value. Or do like build_userlist() does and query the userlist table to rebuild the comma-separated lists (hope that makes sense).
By the way, since you're only talking about the ignore list, I think you can save some work by callling build_userlist() like this:
build_userlist($ignoring_userid, array('ignore'));
If you leave off the second parameter it will build all lists.
PleaseHelp
02-29-2012, 03:55 PM
build_userlist() takes care of the datamanager part. If you want to see that code you can look at includes/functions_databuild.php. Since the lists set by the user datamanager are comma-separated lists, if you're adding one userid to a list you have to get the existing list first then build a new list with the added value. Or do like build_userlist() does and query the userlist table to rebuild the comma-separated lists (hope that makes sense).
By the way, since you're only talking about the ignore list, I think you can save some work by callling build_userlist() like this:
build_userlist($ignoring_userid, array('ignore'));
If you leave off the second parameter it will build all lists.
OK, so the full code would be:
//how to add a user to another user's ignore list
include('global.php')
$ignoring_userid = X;
$ignored_userid = Y;
$vbulletin->db->query_write("INSERT IGNORE INTO " . TABLE_PREFIX . "userlist
(userid, relationid, type, friend)
VALUES ($ignoring_userid, $ignored_userid, 'ignore', 'no') ");
//datamanager
build_userlist($ignoring_userid);
Is that correct?
I believe that represents everything you need to do to add a user to another user's ignore list, based on looking at the code that does it from the profile. But I haven't actually tried it myself.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.