function get_status_sql($link_owner_user_id = false, $format_string = '%s')
 {
     global $bp;
     // if user is the site admin or is logged in and viewing their own links, then no limitations
     if (is_super_admin() || bp_is_my_profile()) {
         // return an empty string
         return '';
     } else {
         // everyone can see the public links
         $status_opts = array(self::STATUS_PUBLIC);
         // if logged in user is a friend, show friends only links too
         if (bp_links_is_friends_enabled()) {
             if ($link_owner_user_id && $link_owner_user_id != $bp->loggedin_user->id && friends_check_friendship($link_owner_user_id, $bp->loggedin_user->id)) {
                 $status_opts[] = self::STATUS_FRIENDS;
             }
         }
         // return the sql string
         return sprintf($format_string, sprintf('status IN (%s)', join(',', $status_opts)));
     }
 }
Example #2
0
					<li><?php 
_e('Any site member can see this link, and comment on it.', 'buddypress-links');
?>
</li>
					<li><?php 
_e('This link will be listed in the links directory and in search results.', 'buddypress-links');
?>
</li>
					<li><?php 
_e('Link content and activity will be visible to any site member.', 'buddypress-links');
?>
</li>
				</ul>

			<?php 
if (bp_links_is_friends_enabled()) {
    ?>
			<label>
				<input type="radio" name="link-status" value="<?php 
    echo BP_Links_Link::STATUS_FRIENDS;
    ?>
"<?php 
    if (BP_Links_Link::STATUS_FRIENDS == bp_get_link_details_form_status()) {
        ?>
 checked="checked"<?php 
    }
    ?>
 />
				<?php 
    _e('This is a friends-only link', 'buddypress-links');
    ?>
Example #3
0
function bp_links_is_link_visibile($link_id_or_obj, $user_id = null)
{
    global $bp;
    // owners and site admins can always see the link
    if ($bp->is_item_admin) {
        return true;
    }
    if ($link_id_or_obj instanceof BP_Links_Link) {
        $link = $link_id_or_obj;
    } else {
        $link = new BP_Links_Link($link_id_or_obj);
    }
    if (empty($user_id) && is_user_logged_in()) {
        $user_id = $bp->loggedin_user->id;
    }
    // who else can see this link?
    // check friendship last because of DB hit
    switch ($link->status) {
        case BP_Links_Link::STATUS_PUBLIC:
            return true;
        case BP_Links_Link::STATUS_HIDDEN:
            return false;
        case BP_Links_Link::STATUS_FRIENDS:
            return $user_id && bp_links_is_friends_enabled() ? friends_check_friendship($user_id, $link->user_id) : false;
        default:
            return false;
    }
}