PDA

View Full Version : $bbuserinfo[buddylist] return -> check -> OK.


Harlequin
05-27-2004, 01:29 PM
Hey guys.

I know I haven't posted in awhile, but certainly due to all of your helpful efforts I've been coding tidbits in a frenzy. So when I tried this out, I collected (what I thought to be) a logical idea in my head.. and when I tried to code it, ultimately it failed (several times.)

Essentially, I've been attempting to use $bbuserinfo[buddylist] to pull the buddylist for a person viewing a page and if $bbuserinfo[userid] = a user in the buddylist of the page owner and the buddylist of the page viewer = the page owner userid, then display something on the page.

It's just a check to verify that both of you are buddies of each other in order to perform an event.

At any rate, is there any simplistic way to perform this? I had a query or two, a str_replace or two, and a bunch of if's in my trial and errors..

Xenon
05-27-2004, 06:11 PM
hmm, ok, lets say you have $userinfo as the userinfo array of the user who belongs to that page, and of course $bbuserinfo as the array for the browsing user.

so all you have to do now is to use that code (taken from fetch_online_status):
if ($bbuserinfo['buddylist'] = trim($bbuserinfo['buddylist']))
{
$bb_buddylist = preg_split('/\s+/', $bbuserinfo['buddylist'], -1, PREG_SPLIT_NO_EMPTY);
}
else
{
$bb_buddylist = array();
}
if ($userinfo['buddylist'] = trim($userinfo['buddylist']))
{
$user_buddylist = preg_split('/\s+/', $bbuserinfo['buddylist'], -1, PREG_SPLIT_NO_EMPTY);
}
else
{
$user_buddylist = array();
}

and then use that conditon:
if (in_array($userinfo['userid'], $bb_buddylist) AND in_array($bbuserinfo['userid'], $user_buddylist))
{
your special code here
}

Harlequin
05-27-2004, 06:22 PM
I'll definitely give that a try, Xenon. Thank you so much.

preg_split and array()/in_array are two things I haven't played with all of that much because I haven't really found the need (until now?) ;)

I guess there's no time like the present to start learnin'. :)

Xenon
05-27-2004, 07:06 PM
You're welcome :)

Yeah, exactly my thoughts, everytime is the best time to learn ;)