MyBB Community Forums

Full Version: Need the code for certain MyBB functions.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey, I am integrating my MyBB forum ( http://kh13.com/mybb/ ) with the CometChat chat application ( http://www.cometchat.com/ ). To do this, I need the PHP code for certain MyBB functions. I was hoping someone could help me. I posted it here rather than the plugin section because all I need is the functions.

I need code for the following functions:
getUserID(), which should return the logged in user's ID
getFriendsList(), which should return a list of all online users

And yeah, I think that's it for now. The general integration guide had this to say about both:

Quote:We begin by editing the getUserID() function.
The getUserID() function is used to return the logged in user's ID. Depending on how you have programmed your site, you will have to find out the user ID.

Quote:Next, we modify getFriendsList() function.

The getFriendsList() function returns all the users' details part of the Who's Online list. This list need not necessarily be friends of the logged in user. It may simply be all online users instead. You can customize this to return any set of users.

The default configuration assumes that you have a table called friends with the following fields:

toid integer
fromid integer

All entries are assumed to be two-way i.e. if user A (id:1) and user B (id:2) are friends, then there will be two entries in the table:
----------------------------
 id    toid    fromid
----------------------------
 13       1         2
 14       2         1
----------------------------
function getFriendsList($userid,$time) {
	$sql = ("select DISTINCT ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." userid, 
".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME." username, 
".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTACTIVITY." lastactivity, 
".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." avatar, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." link, 
cometchat_status.message, cometchat_status.status 
from ".TABLE_PREFIX."friends join ".TABLE_PREFIX.DB_USERTABLE." 
on  ".TABLE_PREFIX."friends.toid = ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." 
left join cometchat_status on ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." = cometchat_status.userid 
where ".TABLE_PREFIX."friends.fromid = '".mysql_real_escape_string($userid)."' 
order by username asc");
	return $sql;
}


Just want to note that I would like this to return a list of all online users, not just those in a buddy/friends list or something.

Thanks, and I hope someone can help. If you need to know any more information, let me know.
I've modified config.php to work with MyBB. I've posted it on the CometChat site in the Integrations forum. Here's a link:

http://www.cometchat.com/support/topic/2...tegration/
(2009-12-17, 07:07 AM)whizzosoftware Wrote: [ -> ]I've modified config.php to work with MyBB. I've posted it on the CometChat site in the Integrations forum. Here's a link:

http://www.cometchat.com/support/topic/2...tegration/

Could you modify that to display all online users, rather than those just in the buddy list? Thanks.
(2009-12-17, 07:18 AM)DChiuch Wrote: [ -> ]
(2009-12-17, 07:07 AM)whizzosoftware Wrote: [ -> ]I've modified config.php to work with MyBB. I've posted it on the CometChat site in the Integrations forum. Here's a link:

http://www.cometchat.com/support/topic/2...tegration/

Could you modify that to display all online users, rather than those just in the buddy list? Thanks.

I posted that modification to the CometChat thread as well.