I added a block to user_relationships activity which shows 'my friends activity' which is any activity by users with whom you have a 'user relationship'.

I also changed the user_loads to simple queries in this module because user_load is overkill and was slowing me to a crawl (because the site has 15000 organic groups and user load looks up everyone's ogs). But I think this should be a performance improvement for anyone.

CommentFileSizeAuthor
urblock.patch4.44 KBjody lynn

Comments

robertdouglass’s picture

Version: 5.x-3.x-dev » 5.x-3.0-beta

I like this block and I started adding it to the latest iteration of my code. It made me realize though that I made a mistake of dropping the uid from activity table, and I'm going to have to add it back in. The target_uid in activity_targets is great, but not enough information to get your buddies' public messages. So I'll have an update for this tomorrow, I'm guessing.

icecreamyou’s picture

+1 for this, although it's so far off in the latest dev I can't even figure out how to apply it manually.

robertdouglass’s picture

Status: Needs review » Active

The patch is not especially relevant. To really solve the problem you need to start with a patch that reintroduces the activity initiator's uid into the activity table.

d0t101101’s picture

I could really use this functionality for my site, and hope to see this feature added to the official module.
.

jaydub’s picture

Status: Active » Needs review
icecreamyou’s picture

Version: 5.x-3.0-beta » 5.x-3.0-beta2
icecreamyou’s picture

Title: user_relationshipsactivity changes » block to show activity of user relationships

Wouldn't this do it? There's no reason to introduce a new column in the tables. (Note: I haven't really tested this, but the meat is basically just copied from activity.module and the rest is an SQL query I built to identify the user's "friends" (rtid = 2).)

Of course, if you want to test this outside of the module, just replace the return array part at the end with print theme('activity_block', $activities, $more_link);

EDIT: just tested, and it produces two SQL errors and one implode() error in activity.module. I probably won't have time to look into it until this weekend.

  global $user;
  $user_rel = db_query("
  SELECT u.uid
  FROM {users} AS u
  LEFT JOIN {user_relationships} AS ur ON (u.uid = ur.requester_id OR u.uid = ur.requestee_id)
  WHERE (u.uid = ur.requester_id OR u.uid = ur.requestee_id)
    AND (ur.requester_id = %d OR ur.requestee_id = %d)
    AND (ur.approved = 1)
    AND (ur.rtid = 2)
  GROUP BY (u.uid)
  ", $user->uid, $user->uid);
  $friends = array();
  while ($value = db_fetch_array($user_rel)) {
    $friends[] = $value['uid'];
  }
  $delta = 'all';
  if (user_access('view public activity')) {
    $activity =  activity_get_activity($friends, NULL, variable_get('activity_block_'. $delta, 5) + 1);
    if ($count = count($activity)) {
      if ($count > variable_get('activity_block_'. $delta, 5)) {
        $more_link = theme('activity_more_link', 'activity');
        array_pop($activity);
      }
      $activites = array();
      foreach ($activity as $item) {
        $activities[] = theme('activity', activity_token_replace($item), $item);
      }
      return array(
        'subject' => t('Recent activity'),
        'content' => theme('activity_block', $activities, $more_link)
      );
    }
  }
icecreamyou’s picture

Version: 5.x-3.0-beta2 » 5.x-3.x-dev
Component: Code » Activity Contrib
Category: task » feature
Status: Needs review » Needs work

I figured out what the problem was. I wrote the code for a site on which I hadn't yet installed Activity; on that site, the "Friend" relationship has rtid=2 as is reflected in the code. But I was testing this on a different site at which the "Friend" relationship has rtid=1. So, this code is ready and working, although I hate to RTBC my own patch.

Of course, if this were to be added into the user_relationshipsactivity module, there would also have to be a way to set the relationship type. The form element can be built using this code:

    $result = db_query("SELECT plural_name, rtid FROM {user_relationship_types}");
    while ($row = db_fetch_array($result)) {
      $i = $row['rtid'];
      $fbsur[$i] = $row['plural_name'];
    }
    $form['fbs_misc']['activity_ur_type'] = array(
      '#type' => 'select',
      '#title' => t('User Relationship types to use for this block'),
      '#default_value' => variable_get('activity_ur_type', array(1)),
      '#description' => t("Choose which User Relationship types you want to use for the User Relationship Activity block.  Only activity updates from users with whom the current user has one or more of these kinds of relationships will be shown.  If you do not select a relationship type, all types will be used."),
      '#options' => $fbsur,
      '#multiple' => TRUE;
    );

It may be simpler just to take out the rtid line altogether and make the block show status updates for all relationships. The problem is that the whole point of this block is for increased privacy, and if one-way relationships exist, then anyone can see anyone's status and there's no point in having a separate block.

icecreamyou’s picture

Status: Needs work » Needs review

Oops - changing back to CNR.

icecreamyou’s picture

Status: Needs review » Needs work

Alright, I take it back again. More than half of the statuses that should appear don't, and we get the bullet points for them anyway. Plus the roles are often wrong.

...but I have no idea how to fix this. Ideas welcome!

jaydub’s picture

The new 5.4 branch and the new 6.x branch have a menu tab
on the activity page '/activity' for any User Relationship relationship
types you have setup. An activity block for each UR type is also
available as you've requested. Note that you should not test this
out on a production site as many token patterns have changed
and no upgrade functions have been written at this point.

#314433: Activity 6.1 & 5.4

jaydub’s picture

Version: 5.x-3.x-dev » 5.x-4.x-dev
jaydub’s picture

the -dev snapshots (Jan 2009) have improved support for User Relationships.

rickh’s picture

Version: 5.x-4.x-dev » 6.x-1.2
Category: feature » support
Priority: Normal » Critical

I know this topic has not been touched on in a while, but is there any way to take the current relationship tab containing the user's reltionships activity and placing it into a panel or view? I am trying to create a "news feed" for users using the activity module and I'm not getting anywhere. I apologise if i sound like a moron but I'm pretty new to drupal.

Thanks for any help in advance.

icecreamyou’s picture

Version: 6.x-1.2 » 5.x-4.x-dev
Category: support » feature
Priority: Critical » Normal

Please keep issues to their original topics.

sirkitree’s picture

Status: Needs work » Closed (won't fix)

5.x unsupported please see 6.x-2