url: http://www.example.com/relationships/uid/rtid

The relationships page currently returns the one relationship that's listed for that row in the db table, but when the implications module is installed, it's useful to have the implied relationships listed as well. For example, with relationships "co-worker" and "manager", it's useful to know that user x is a "co-worker" and a "manager" while user y is just a "co-worker".

Attached is a patch that implements this. I wrote a generic API function that serves as a fairly generic query builder to get a user's relationships and refactored the code to take advantage of it (e.g. in user_relationships_user()).

Please note that the query must NOT have a space before the SELECT for the pager_query function to work (the "A" flag is used on the preg_replace() that generates the count query). For consistency, I removed the leading space from user_relationships_user_relationship_load(), but this does make the following lines of the query not align perfectly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gwen’s picture

FileSize
6.78 KB

Whoops, I was using the $user variable in the theme function instead of user loading the real user, so you'd see your own relationships on other people's pages. A new patch is attached.

sprsquish’s picture

Status: Needs review » Needs work

Despite the Implications plugin being included in the core module, it's still considered a plugin. As such the core should have no awareness whatsoever of plugin. My suggestion would be to create a theme function in the implications module called something like "theme_user_relationships_page_with_implications."

Also I think that the query builder is too complicated. I think paging should be left to the view code, and thus left in the theme function. As for the rest, the user hook loads all relevant data into the user node. Pulling the relationship with a specific user or a specific relationship type can be achieved through by looping over the relationships array attached to the user node.

gwen’s picture

Status: Needs work » Needs review
FileSize
4.11 KB

Here's a patch written more to your specs. I created a helper function to get the relationship names b/c we may want to use it again to theme out the pending requests page.

sprsquish’s picture

Status: Needs review » Closed (fixed)