Hi,

I think I might be missing something here. How does User Relationships integrate with Facebook Status? The reason why : is currently anyone that has permission to view FB status can see the blocks (updates) of everyone.

What I really would like is only the 'connections' in User Relationships to see the wonderful Facebook Status updates ..

Is that an additional module, or totally understanding the capabilities here?

Look so forward to your reply, and thank you.
Lilian

Comments

icecreamyou’s picture

Status: Active » Closed (fixed)

Please read the documentation if you have a question like this in the future.

You need to use the Facebook Status UR Recent Updates block. (You also need to set which relationship(s) should be used on the settings page.)

liliplanet’s picture

Status: Closed (fixed) » Active

Facebook Statuses : 6.x-1.x-dev

Thank you for your reply. Have read the documentation, and yes, have User Relationships 6.x-1.x-dev installed with implication as 'Friend'.

Yet, still have no Facebook Status UR Recent Updates block available.

Have deleted and re-installed the module, and sorry, I just do not see that block available.

In User Relationships have the following enabled:

UR-API
UR-UI
UR-Views

I enable UR-Blocks, but that did not create the block either.

All permissions are correct.

Obviously missing something obvious :)

Is it maybe that one of the following need to be enabled?

UR-Elaborations
UR-Implications
UR-Mailer
UR-Node Access

Perhaps I should go back to 6.x-1.0-beta1?

Look forward to your reply, and again, thank you.
Lilian

icecreamyou’s picture

Status: Active » Postponed (maintainer needs more info)

Perhaps this is obvious, but it only shows up if the current user actually has relationships, and if the user's friends have statuses, and if the current user has permission to see it.

Any errors in your log?

Apparently there's been some development in the 6.x branch since I committed the code and it may not be working any more, although I don't think this is the case.

If worst comes to worst you should be able to just stick this somewhere on your own.

  //Change $ur_rtid to the RTID of the relationship type you want to use before executing this code.
  $ur_rtid = 1;
  $content = facebook_status_get_rel_status($ur_rtid);
  $content = facebook_status_list_render($content);
  if ($content) {
    $content = '<div class="facebook_status_block_rel">'. $content .'</div>';
    echo $content;
  }
liliplanet’s picture

IceCreamYou, thank you so much for your response ..

I created a block with the above code and the relationship type is 1, so that's all good.

Logged in as another user (that has a relationship with me) and added a facebook status. Logged back in as myself, and still no block with the updates.

Just to mention, the 'Facebook Status Recent Update's block is available for all with permission to see the block, but I actually only want FB Statuses with relationships.

I think where the problem lays is that the 'Facebook Status UR Recent Updates' block is not even available for selection in admin/blocks.

No errors in the log files.

IceCreamYou, perhaps any other idea of how I could fix this please? Would absolutely wonderful for my film community.

Again thank you, and look forward to hearing from you.
Lilian

icecreamyou’s picture

SQL version and type? PHP version?

I'm not using the module on 6.x so I have no idea whether this problem shows up for other people, and I have no way to debug. Without further information, I may have to postpone this or assume it's a user error.

Presumably this just shows an empty array? And also make sure that the RTID is one, if I remember correctly the first RTID is actually zero but I could be wrong about that.

  $content = facebook_status_get_rel_status(1);
  echo '<pre>';
  var_dump($content);
  echo '</pre>';
liliplanet’s picture

Most appreciate your reply.

Output of the code reports NULL.

SQL Version: 5.0
PHP Version: PHP5

I've tried changing RTID to 0, still the same, no output.

What a pity, this would have absolutely wonderful. Will keep checking in for any updates.

Again, thank you for your wonderful module.

icecreamyou’s picture

Presumably that's MySQL?

Run this code and see what results you get.

facebook_status_get_ur_status_test();
function facebook_status_get_ur_status_test($ur_rtid = -1, $number = 0, $grouping = TRUE) {
  if (!is_numeric($number) || $number < 0) {
    $number = 0;
  }
  if (!$number) {
    $number = variable_get('facebook_status_max_num_block_stats', 5);
  }
  echo '<p>Number: '. $number .'</p>';
  if ($ur_rtid == -2) {
    $ur_rtid = variable_get('facebook_status_ur_type', -1);
  }
  if ($ur_rtid == -1) {
    $fbsur = facebook_status_rel_types(0);
  }
  else if (is_numeric($ur_rtid)) {
    $fbsur = array($ur_rtid => $ur_rtid);
  }
  var_dump($fbsur);
  global $user;
  $uid_list = array();
  if (db_result(db_query("SELECT COUNT(*) FROM {user_relationship_types}"))) {
    echo '<p>Relationship types exist.</p>';
    foreach ($fbsur as $ur_rtid => $value) {
      //Dynamically build queries based on whether the relevant relationship type is one-way and/or requires approval.
      $ur_object = db_fetch_array(db_query("SELECT is_oneway, requires_approval FROM {user_relationship_types} WHERE rtid = %d", $ur_rtid));
      if ($ur_object['is_oneway'] == 1) {
        $ur_oneway_fbjoin = "fb.uid = ur.requester_id";
        $ur_oneway_urwhere = "ur.requester_id = ". $user->uid;
      }
      else {
        $ur_oneway_fbjoin = "(fb.uid = ur.requester_id OR fb.uid = ur.requestee_id)";
        $ur_oneway_urwhere = "(ur.requester_id = ". $user->uid ." OR ur.requestee_id = ". $user->uid .")";
      }
      if ($ur_object['requires_approval'] = 1) {
        $ur_requires_approval = "AND (ur.approved = 1)";
      }
      else {
        $ur_requires_approval = "";
      }
      $disallow = "";
      foreach (variable_get('facebook_status_clear_user', array(0)) as $value) {
        $disallow .= " AND fb.uid != ". $value;
      }
      $user_rel = db_query("
      SELECT fb.uid
      FROM {facebook_status} as fb
      LEFT JOIN {user_relationships} AS ur
        ON %s
      WHERE %s
        %s
        AND (ur.rtid = %d)
        %s
        AND fb.uid <> %d
      GROUP BY uid
      ", $ur_oneway_fbjoin, $ur_oneway_urwhere, $ur_requires_approval, $ur_rtid, $disallow, $user->uid);

      while ($row = db_fetch_array($user_rel)) {
        //Don't include current user.
        if ($row['uid'] != $user->uid) {
          $uid_list[] = $row['uid'];
        }
      }
    }
    echo '<pre>$uid_list non-unique: ';
    var_dump($uid_list);
    echo '</pre>';
    $uid_list = array_unique($uid_list);
    echo '<pre>$uid_list unique: ';
    var_dump($uid_list);
    echo '</pre>';
    if ($grouping) {
      $number = -abs($number);
    }
    else {
      $number = abs($number);
    }
    echo '<p>Number: '. $number .'</p>';
    $results = facebook_status_get_status($uid_list, $number);
    echo '<pre>Results: ';
    var_dump($results);
    echo '</pre>';
    return;
  }
  else {
    echo 'There are no relationship types.';
    return;
  }
  echo 'Process failed.';
}
liliplanet’s picture

You think we might be able to figure this out, oh thank you IceCreamYou.

After running the code:

Number: 5
NULL

Relationship types exist.

Warning: Invalid argument supplied for foreach() in /home/lilifilm/public_html/includes/common.inc(1648) : eval()'d code on line 25

$uid_list non-unique: array(0) {
}

$uid_list unique: array(0) {
}

Number: -5

Results: NULL

Does this perhaps put us in the right direction? It would truly wonderful it we could make it work.

Thank you so much IceCreamYou.

icecreamyou’s picture

It looks like facebook_status_rel_types() is not returning anything for you.

  //Also try running this query in your DB and see if it comes up with anything.
  $fbsur_result = db_query("SELECT plural_name, rtid FROM {user_relationship_types}");
  $fbsur = array();
  while ($row = db_fetch_array($fbsur_result)) {
    echo '<pre>';
    print_r($row);
    echo '</pre>';
    $i = $row['rtid'];
    $fbsur[$i] = $row['plural_name'];
  }
  echo '<pre>';
  var_dump($fbsur);
  echo '</pre>';
liliplanet’s picture

I really appreciate this IceCreamYou.

Results as follows:


Array
(
    [plural_name] => Friends
    [rtid] => 1
)

array(1) {
  [1]=>
  string(7) "Friends"
}

Does that help? Thank you again, so much.

icecreamyou’s picture

Very strange... what do you get from this?

$foo = facebook_status_rel_types();
echo '<pre>';
print_r($foo);
echo '</pre>';
liliplanet’s picture

Thank you again IceCreamYou, it is now morning in South Africa ...

For the latest ... it's just blank :)

If I gave you access to my system, do you think that would help us perhaps? May I contact you via your contact form?

icecreamyou’s picture

This is the function that is returning NULL for you and causing the problems:

function facebook_status_rel_types($advf = 0) {
  if (module_exists('user_relationships')) {
    return facebook_status_ur_types($advf);
  }
  return;
}

facebook_status_ur_types() is the same as the code in comment#9 without the debug code--and it apparently works correctly. That means that only two things could be causing the error: a spelling error in a variable, or your system is not recognizing that UR is installed. I've checked the variables and they're correct.

If this code displays "UR exists" when you run it, your problem can probably be fixed by refreshing all of your system caches. If it displays "UR does not exist" then you've installed UR incorrectly. (If it doesn't display anything, you've got larger problems.) I probably can't help you beyond this point.

if (module_exists('user_relationships')) {
  echo "UR exists";
}
else {
  echo "UR does not exist";
}

Giving me access to your site might--but probably wouldn't--help. It would be particularly useless if I didn't have the ability to run PHP code, and I recommend that you never give anyone that ability. Even if you decide to trust me, you don't know whether you can trust that I won't leave my account open in a public location (not that I would, but you get the point) or whether I'm a college kid with a scheming roommate or whatever (I'm not).

Regardless of whether you can make it work, I will be rewriting the module at some point for a 2.x branch, and you may find that your problem resolves itself at that point.

If nothing else works, try this.

  $number = variable_get('facebook_status_max_num_block_stats', 5);
  $ur_rtid = 1;
  global $user;
  $ur_object = db_fetch_array(db_query("SELECT is_oneway, requires_approval FROM {user_relationship_types} WHERE rtid = %d", $ur_rtid));
  if ($ur_object['is_oneway'] == 1) {
    $ur_oneway_fbjoin = "fb.uid = ur.requester_id";
    $ur_oneway_urwhere = "ur.requester_id = ". $user->uid;
  }
  else {
    $ur_oneway_fbjoin = "(fb.uid = ur.requester_id OR fb.uid = ur.requestee_id)";
    $ur_oneway_urwhere = "(ur.requester_id = ". $user->uid ." OR ur.requestee_id = ". $user->uid .")";
  }
  if ($ur_object['requires_approval'] = 1) {
    $ur_requires_approval = "AND (ur.approved = 1)";
  }
  else {
    $ur_requires_approval = "";
  }
  $disallow = "";
  foreach (variable_get('facebook_status_clear_user', array(0)) as $value) {
    $disallow .= " AND fb.uid != ". $value;
  }
  $user_rel = db_query("
  SELECT fb.uid
  FROM {facebook_status} as fb
  LEFT JOIN {user_relationships} AS ur
    ON %s
  WHERE %s
    %s
    AND (ur.rtid = %d)
    %s
    AND fb.uid <> %d
  GROUP BY uid
  ", $ur_oneway_fbjoin, $ur_oneway_urwhere, $ur_requires_approval, $ur_rtid, $disallow, $user->uid);

  while ($row = db_fetch_array($user_rel)) {
    //Don't include current user.
    if ($row['uid'] != $user->uid) {
      $uid_list[] = $row['uid'];
    }
  }
  $uid_list = array_unique($uid_list);
  $number = -abs($number);
  $status_list = facebook_status_get_status($uid_list, $number);
  $content = facebook_status_list_render($status_list);
  if ($content) {
    echo '<div class="facebook_status_block_rel">'. $content .'</div>';
  }
liliplanet’s picture

Fantastic! The last post works!

When I tried

<?php
if (module_exists('user_relationships')) {
  echo "UR exists";
}
else {
  echo "UR does not exist";
}
?>

It said that 'Ur does not exist .. but as mentioned the code in your post at the bottom works :)

IceCreamYou, should I use that code as a block? Is that the correct version?

You are an angel, and truly appreciate your time and kindness in making this work.

Lilian

icecreamyou’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Yes, you can put that code in a block. I'm glad it works.

Your system appears to think that you do not have UR installed... might want to check into that. Specifically, make sure that Status is set to 1 for user_relationships in the system table in your database.

liliplanet’s picture

Thank you so much IceCreamYou! You really stuck with me to sort this out, and beyond appreciative ..

Wishing you a Wonderful Valentines Day!

Again, thank you for your fabulous module.
Lilian

Mike Kennedy’s picture

I dont know if this matters but I am having the same exact same issue the Facebook Status UR Recent Updates block does not show up as an option in my site building. I have installed everything properly and unfortunately these are my options. Am I missing something?

Facebook-style Statuses Latest Status Updates
Facebook-style Statuses
Facebook-style Statuses Conversation/Mentions
Facebook-style Statuses Popular Tags
Facebook-style Statuses Profile

Unfortunately the code above doesnt work for me

icecreamyou’s picture

This issue is for FBSS 1.x. You are using FBSS 2.x, which works completely differently. You have to use Views to build your own list of statuses if you want UR integration per the documentation.