tags:

views:

25

answers:

1

I'm trying to gain a truth value to gain panel visibility. I have a view in place in a panel to display a listing of heartbeat messages that belong to a user. The display works but I cannot figure out how to restrict access to the panel based on the user who is viewing the panel. Goal is I want the panel to only be visible to friends and some people with certain roles. The roles I can handle but I don't know enough about PHP to get it working based on friendship status. I vaguely guess it would be something like:

logged user is twoway with user being viewed based on current uid argument.

I know my example is nothing like the actual code but as I said I don't have much to go on here.

A: 

This should get you going.

global $user;

$friend_list = get_friend_list($page_uid_argument);

if (in_array($user->uid, $friend_list)) {
  // show messages
}

Where get_friend_list() is a generic function that grabs the user to user relationships based on UID, and returns an array of UIDs. I don't know what you are using codewise/modules.

Kevin
Basically I have a view in a panel on a Profile panel page. The view is just a listing of heartbeat messages related to the user being displayed. There are already options on the panel for displaying the panel based on role, logged user and basic permissions for the content. What I would like is to block a user who is not a friend of the the currently displayed user. The panel gives you the option to block or show the panel based on PHP code. If the code returns true the panel will display. Thankyou for your help though, you have me on the right track.
I have found another similar code that returns a value based on the author of the page being looked at. Could I adjust for my purpose.
global $user; // If a node is being watched... if( arg(0) == 'node' # CHANGE "1" WITH THE RELATION TYPE ID! return ($status == 'TW_BOTH'); # Or whatever Status you'd like to check!}