Hi all,

i want to hide the shoutbox for the users that are not friends. In my first attempt, i've used tpl.php, where i have:

			echo '<div class="fbstatus">' . $profile['facebook_status'] . '</div>';

i'm not sure if there is a better way to embed, or if there is a posibility to embed shoutbox and view separately.

Ok, i've added this code in my first attempt:

if($friends != 0) echo '<div class="fbstatus">' . $profile['facebook_status'] . '</div>';

doing a previous chekings and returning $friends = 0 for none friends of the actual browsing user.

The approach is rudimentary, i know. I want to include in a module but, which hooks do i have to "touch" to modify the shoutbox? Is the embeding code which i use right? Can be done separetely, shoutbox and shouts, as i was asking?

Thanks a lot in advance.

Comments

icecreamyou’s picture

Category: feature » support
Priority: Major » Normal
Status: Active » Fixed

The easiest way to do this is to implement hook_facebook_status_user_access_alter(), e.g.:

/**
 * Implementation of hook_facebook_status_user_access_alter().
 */
function MYMODULE_facebook_status_user_access_alter(&$allow, $op, $args) {
  if ($op == 'add') {
    global $user;
    $recipient = isset($args[0]) ? $args[0] : $user;
    $type = isset($args[1]) ? $args[1] : 'user';
    $sender = isset($args[2]) ? $args[2] : $user;
    $context = facebook_status_determine_context($type);

    // are_friends() is pseudocode
    if ($type == 'user' && !are_friends($sender, $recipient)) {
      $allow = FALSE;
    }
  }
}
alexmoreno’s picture

hello icecreamyou, and firstly thanks a lot for this great module.

i'm gonna try this, and i'll tell how it was, thanks a lot.

Is the way which i was doing the embedding correct? Using the $profile['facebook_status'] is correct?

There is not too much information about.

Thanks a lot again.

icecreamyou’s picture

Yeah, that's the right way to do it in the theming layer. Although generally instead of putting business logic in the template itself, you should do any computation (like determining whether two users are friends) in template.php. See also https://drupal.org/node/223430

alexmoreno’s picture

thanks a lot IceCreamYou, i'll put my hands on it this week :-)

Have a nice week end.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.