Hello I am wanting to setup a view to display heartbeat activity content from a particular set of users.

These users are ones that have a user_relationship of Follow. So I would like to create a view that shows heartbeat activity of the users a particular user has the follow relationship to.

My attempts in views have not gotten me anywhere but confused, is someone doing something like this similar? Even if this is possible to render in code? I have seen this hook_heartbeat_related_uids but have no idea how to implement it anyone have an example?

Cheers heartbeat looks like a great module.

Comments

imp7’s picture

So I checked out a views_php they let you put in a custom filter and I got it to work very hack like in a php views filter;

 $userID = $row->uid;
    global $user;
    $followerer = $user->uid;


    $is_user_following = function ( $currentUserUID , $userFollowingUID ) {
        $result = false;
        $rid = load_rid_by_name ( 'Follow' );

        $params = array (
            'user' => $currentUserUID ,
            'rtid' => $rid ,
        );
        $relations = user_relationships_load ( $params );

        foreach ( $relations as $relation ) {
            if ( $relation->requester_id == $userFollowingUID ) {
                $result = true;
            }
        }

        return $result;
    };


    if ( $is_user_following ( $followerer , $userID ) ) {
        if ( $userID == $followerer ) {
            return TRUE;
        } else {
            return FALSE;
        }
    } else {
        return TRUE;
    }

This is far from best practice, anyone know a better way?

Stalski’s picture

Hi,

Well, the views integration is really basic for the moment. I will try it myself now. (Your approach could work, but it's exactly the same check that heartbeat already does in that hook "heartbeat_related_uids". I am just a bit afraid that it's not cached with that custom_php code.

I can add that I always use the "Relational Activity" stream for that. This stream comes within the heartbeat_defaults module and will take the user_relationships types to indeed be found by the "heartbeat_related_uids".

Heartbeat is rather complex to explain but I will try to explain how heartbeat works with the relationships.
1) The stream "relationsactivity" will make sure that only activity is shown of users which have a relationships with the STREAM->VIEWER
2) Every message template can be configured so its activity inherits "Only me and my relations can see this". This configuration can even be narrowed down for each user profile. So in each query (or stream) the restricted message types for "only me and relations can see this" will be taken into consideration as well.

So this is by default and works well here.

Summary: It works in heartbeat by default, but I'll check how it behaves with the views approach.