Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddypress & CometChat Integration

  • Avatar of foodin65
    foodin65
    Participant

    @foodin65

    Okay Guys and Gals – I need a little MySql & PHP help to get comet chat running.

    I’ve just recently purchased CometChat and Inorder for it to work with a Buddypress install one must manually configure it.

    I’ve got everything working except the friends list.. I don’t know how to tell it to call the online users.

    Here are my instructions from Comet Chat:

    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;

    }

    I don’t know what I need to change in that function so that it’s getting a list of users from buddypress…

    Any ideas?

Viewing 7 replies - 1 through 7 (of 7 total)
  • here’s what you need to do. go buy arrowchat when it comes out. Comet Chat’s support and documentation is crap. Worthless.

    Avatar of edelwater
    edelwater
    Participant

    @edelwater

    did you actually ran ALTER TABLE users ADD lastactivity INTEGER DEFAULT 0; to add an extra field to the users table?

    I don’t understand what you’re saying.

    Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    I think edelwater’s response was to foodin65.

    `
    $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, CONCAT(“.TABLE_PREFIX.DB_USERTABLE.”.”.DB_USERTABLE_USERID.”,’|’,”.TABLE_PREFIX.DB_USERTABLE.”.user_email) avatar, “.TABLE_PREFIX.DB_USERTABLE.”.user_nicename link, cometchat_status.message, cometchat_status.status from “.TABLE_PREFIX.”bp_friends join “.TABLE_PREFIX.DB_USERTABLE.” on “.TABLE_PREFIX.”bp_friends.friend_user_id = “.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.”bp_friends.initiator_user_id = ‘”.mysql_real_escape_string($userid).”‘ and is_confirmed = 1)

    union

    (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, CONCAT(“.TABLE_PREFIX.DB_USERTABLE.”.”.DB_USERTABLE_USERID.”,’|’,”.TABLE_PREFIX.DB_USERTABLE.”.user_email) avatar, “.TABLE_PREFIX.DB_USERTABLE.”.user_nicename link, cometchat_status.message, cometchat_status.status from “.TABLE_PREFIX.”bp_friends join “.TABLE_PREFIX.DB_USERTABLE.” on “.TABLE_PREFIX.”bp_friends.initiator_user_id = “.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.”bp_friends.friend_user_id = ‘”.mysql_real_escape_string($userid).”‘ and is_confirmed = 1 )
    order by username asc
    “);

    if (defined(‘DISPLAY_ALL_USERS’) && DISPLAY_ALL_USERS == 1) {

    $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, CONCAT(“.TABLE_PREFIX.DB_USERTABLE.”.”.DB_USERTABLE_USERID.”,’|’,”.TABLE_PREFIX.DB_USERTABLE.”.user_email) avatar, “.TABLE_PREFIX.DB_USERTABLE.”.user_nicename link, cometchat_status.message, cometchat_status.status from “.TABLE_PREFIX.DB_USERTABLE.” left join cometchat_status on “.TABLE_PREFIX.DB_USERTABLE.”.”.DB_USERTABLE_USERID.” = cometchat_status.userid where “.TABLE_PREFIX.DB_USERTABLE.”.”.DB_USERTABLE_USERID.” ‘”.mysql_real_escape_string($userid).”‘ and (‘”.$time.”‘-“.TABLE_PREFIX.DB_USERTABLE.”.”.DB_USERTABLE_LASTACTIVITY.” < '".((ONLINE_TIMEOUT)*2)."') order by username asc");

    }

    return $sql;
    `

    EXECUTE MYSQL
    `
    ALTER TABLE wp_users ADD COLUMN ‘lastactivity’ INT default 0
    `

    `
    define(‘DB_SERVER’, DB_HOST );
    define(‘DB_PORT’, ‘3306’ );
    define(‘DB_USERNAME’, DB_USER );
    define(‘TABLE_PREFIX’, ‘wp_’ );
    define(‘DB_USERTABLE’, ‘users’ );
    define(‘DB_USERTABLE_NAME’, ‘display_name’ );
    define(‘DB_USERTABLE_USERID’, ‘ID’ );
    define(‘DB_USERTABLE_LASTACTIVITY’, ‘lastactivity’ );

    function getUserID() {
    global $current_user;
    get_currentuserinfo();

    $userid = 0;

    if (!empty($current_user->ID)) {
    $userid = $current_user->ID;
    }

    return $userid;
    }
    `

Viewing 7 replies - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.