Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-28-2012, 04:30 PM
PleaseHelp PleaseHelp is offline
 
Join Date: Jan 2012
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default DataManager: How to add a user to another user's Ignore List?

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!
Reply With Quote
  #2  
Old 02-28-2012, 07:08 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:

Code:
$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).
Reply With Quote
  #3  
Old 02-29-2012, 12:16 AM
PleaseHelp PleaseHelp is offline
 
Join Date: Jan 2012
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
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:

Code:
$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?
Reply With Quote
  #4  
Old 02-29-2012, 12:55 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 02-29-2012, 03:08 PM
PleaseHelp PleaseHelp is offline
 
Join Date: Jan 2012
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
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.
Reply With Quote
  #6  
Old 02-29-2012, 03:22 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:

Code:
build_userlist($ignoring_userid, array('ignore'));

If you leave off the second parameter it will build all lists.
Reply With Quote
  #7  
Old 02-29-2012, 03:55 PM
PleaseHelp PleaseHelp is offline
 
Join Date: Jan 2012
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
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:

Code:
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:

PHP Code:
//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?
Reply With Quote
  #8  
Old 02-29-2012, 04:16 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:41 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04206 seconds
  • Memory Usage 2,240KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (1)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete