I couldn't figure out how to modify the tracker view to add a page for Friends recent posts. Simplest way I could figure out is to extend views_handler_argument_comment_user_uid and transform the incoming user id into the friends user ids. It's relatively simple as it only overrides query() and adds extra_options_form().

If I've missed something obvious, let's hear it. Otherwise I request that this be added to user_relationship_views. Patch is against 6.x-1.0-rc3.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

YK85’s picture

hello cedarm,

Would your custom views handler help to resolve other issues with UR + Views integration such as:

view with ALL pending requests of CURRENT LOGGED IN USER (sent and received)
view with NON-FRIENDS ONLY of CURRENT LOGGED IN USER (aka FILTER OUT friends)

I would appreciate your help!

cedarm’s picture

This patch "Displays *nodes* only if a user relationship posted the node or commented on the node.", so I don't think it's relevant to your issues. If you are trying to create a view of nodes that were either "not posted by a friend or no friends have commented on", something similar to this patch could probably be written. I'd have to think more about the query before saying for sure.

If you're trying to create a view of Users (friends or non-friends), and not of Nodes, you may be able to do it with what UR already provides. It's been a while since I looked at it. Post a support request in another issue.

p.s. Can you try this patch out and report back? I'd like to get it committed.

YK85’s picture

yes, sorry for not clarifying. I would like to create a view that shows the fields of the content profile node of users that:
1) does have a relationship with current logged in user
2) does not have a relationship with current logged in user
3) have a pending relationship with the current logged in user (requests sent by current logged in user and received by current logged in user)

I would truly appreciate your help in implementing this views handlers!

robby.smith’s picture

Great work cedarm!

Would you be able to kindly create an additonal arg for 'User relationship nodes' and allow option of relationship is 'approved' or 'pending' or 'no relationship'? I believe this is related to yaz085's request - but this would vastly improve UR and Views integration.

Thanks!

cedarm’s picture

Sorry I don't have any serious time I can put into this right now. Two things need to happen: 1. Figure out what SQL achieves these options, 2. Implement the UI for the options. The UI is relatively easy, if I remember correctly. The SQL may be more tricky. Let's see, the last line of the patch is the meat of what it does:

    $this->query->add_where(0, "$this->table_alias.uid IN (" . $placeholders . ") OR
      ((SELECT COUNT(*) FROM {comments} c WHERE c.uid IN (" . $placeholders . ") AND c.nid = $this->table_alias.nid) > 0)",
      $args);

The $placeholders variable contains '%d,%d,%d,%d' for however many associates the user has (four relationships/friends), while $args is an array of user ids (5,7,20,24,5,7,20,24 for example). The user ids are duplicated because $placeholders is used twice.

I think the pending relationships case is already taken care of. All that needs to happen is limit the list if user ids to non-approved (pending) relationships. This is already built into the UI.

For the no relationships query I think we want

    $this->query->add_where(0, "$this->table_alias.uid NOT IN (" . $placeholders . ") OR
      ((SELECT COUNT(*) FROM {comments} c WHERE c.uid IN (" . $placeholders . ") AND c.nid = $this->table_alias.nid) = 0)",
      $args);

Does this make sense? If so, all we need to do is add a "Negate" option. A simple checkbox would suffice, but I'm thinking for our user's sake it should be two radio buttons that spell out what's what:

  (*) Display nodes only if a user relationship posted the node or commented on the node
  ( ) Don't display nodes if a user relationship posted the node or commented on the node

Thoughts?

Bilmar’s picture

+1 subscribing

YK85’s picture

kindly bumping - the stuff here seems it will help UR become better =)

mrf’s picture

Component: Code » Views
webchick’s picture

jthorson’s picture

Status: Needs review » Active
mrf’s picture

Status: Active » Needs review