Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-24-2008, 01:59 AM
Jenosavel Jenosavel is offline
 
Join Date: Jun 2008
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Limiting Maximum Friends

My vbulletin forum is going to be integrated along with a web game that has graphics intensive friends options. Because of this I need to be able to lower the maximum allowed friends a user can have. However, I can't seem to find any way to set this through the admin control panel, nor can I find any variables in the php code which control this.

I know in version 3.6.7 you could search for the "> 1000" bit of code and adjust the limit through that. However 3.7.1, what I'm working with now, doesn't seem to have that anymore.

Does anyone know if there's even a limit on the number of friends a user can have in 3.7.1? And if there is, how would one go about adjusting it?
Reply With Quote
  #2  
Old 06-25-2008, 05:25 PM
Jenosavel Jenosavel is offline
 
Join Date: Jun 2008
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, seeing as no one's responded, I'm going to assume no one knew a quick way to go about creating a friends cap. I ended up creating one, though it's not pretty and requires editing the profile.php file.


To start with, anywhere at the top of profile.php where the global variables are being declared, add one of your own to use as your maximum cap. Obviously set it to whatever you want your cap to be.
PHP Code:
$friendlimit 1000
After that there are three sections of code we'll need to edit in various places: Request addlist, Post addlist, and Post updatelist. They each get used at different times, it seems, so there is quite a bit of code repetition.

$_REQUEST['do'] == 'addlist'
Near the top, just before
PHP Code:
if ($vbulletin->GPC['userlist'] == 'buddy' OR $vbulletin->GPC['userlist'] == 'friend'
you'll need to add in
PHP Code:
$numresult $db->query_read("
    SELECT COUNT(*) AS friendcount FROM " 
TABLE_PREFIX "userlist AS userlist 
    WHERE userlist.userid = " 
$vbulletin->userinfo['userid'] . 
    AND friend = 'yes'
"
);
$numarray $db->fetch_array($numresult);
$myfriendcount $numarray["friendcount"];
global 
$friendlimit


Then a little further down, just inside of this if statement
PHP Code:
if ($vbulletin->GPC['userlist'] == 'friend'
you need to add
PHP Code:
if ($myfriendcount >= $friendlimit)
    eval(
print_standard_redirect("You cannot have more than $friendlimit friends."falsetrue));
else 



$_POST['do'] == 'doaddlist'
This code is almost identical to the previous section, and so are the pieces we're going to add.

At the beginning, just after this referrer check
PHP Code:
if ($vbulletin->url == $vbulletin->options['forumhome'] . '.php')
{
    
$vbulletin->url 'member.php?' $vbulletin->session->vars['sessionurl'] . "u=$userinfo[userid]";

Add in the same query from above
PHP Code:
$numresult $db->query_read("
    SELECT COUNT(*) AS friendcount FROM " 
TABLE_PREFIX "userlist AS userlist 
    WHERE userlist.userid = " 
$vbulletin->userinfo['userid'] . 
    AND friend = 'yes'
"
);
$numarray $db->fetch_array($numresult);
$myfriendcount $numarray["friendcount"];
global 
$friendlimit


Then inside the 'friend' part of the case statement
PHP Code:
switch ($vbulletin->GPC['userlist'])
{
    case 
'friend'
Add the count check again.
PHP Code:
if ($myfriendcount >= $friendlimit)
    eval(
print_standard_redirect("You cannot have more than $friendlimit friends."falsetrue)); 



$_POST['do'] == 'updatelist'
This one is a bit different than the previous two and requires more edits.

Pretty much right at the 'profile_updatelist_start' hook, add the query again:
PHP Code:
$numresult $db->query_read("
    SELECT COUNT(*) AS friendcount FROM " 
TABLE_PREFIX "userlist AS userlist 
    WHERE userlist.userid = " 
$vbulletin->userinfo['userid'] . 
    AND friend = 'yes'
"
);
$numarray $db->fetch_array($numresult);
$myfriendcount $numarray["friendcount"];
global 
$friendlimit


Then, after the last AND of this if statement, but before the closing parenthesis
PHP Code:
if
(
    
$vbulletin->GPC_exists['makefriends']
    AND 
$vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_friends']
    AND 
$vbulletin->userinfo['permissions']['genericpermissions2'] & $vbulletin->bf_ugp_genericpermissions2['canusefriends']
    AND 
$userinfo['permissions']['genericpermissions2'] & $vbulletin->bf_ugp_genericpermissions2['canusefriends']

Add the line
PHP Code:
AND $myfriendcount $friendlimit 


Now, right before this if statement
PHP Code:
if
(
    !(
$vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_friends'])
    OR !(
$vbulletin->userinfo['permissions']['genericpermissions2'] & $vbulletin->bf_ugp_genericpermissions2['canusefriends'])
    OR !(
$userinfo['permissions']['genericpermissions2'] & $vbulletin->bf_ugp_genericpermissions2['canusefriends'])
    OR 
$vbulletin->userinfo['userid'] == $userinfo['userid']
)
{
    continue;

Add the following
PHP Code:
if ($myfriendcount >= $friendlimit)
    break;
else 



Lastly, find the line
PHP Code:
if ($vbulletin->GPC['incomingaction'] == 'accept'
And replace it with
PHP Code:
if ($vbulletin->GPC['incomingaction'] == 'accept' && ($myfriendcount $friendlimit)) 



That seems to be catching all paths to friend adding and filtering it appropriately.
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 04:17 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03447 seconds
  • Memory Usage 2,211KB
  • Queries Executed 11 (?)
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
  • (16)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)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_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