function bp_friendship_template($user_id, $type, $per_page, $max, $filter) { global $bp; if (!$user_id) { $user_id = $bp->displayed_user->id; } $this->pag_page = isset($_REQUEST['frpage']) ? intval($_REQUEST['frpage']) : 1; $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page; $this->type = $type; switch ($type) { case 'newest': $this->friendships = friends_get_newest($user_id, $this->pag_num, $this->pag_page, $filter); break; case 'alphabetical': $this->friendships = friends_get_alphabetically($user_id, $this->pag_num, $this->pag_page, $filter); break; case 'requests': $this->friendships = friends_get_friendship_requests($user_id); break; case 'active': default: $this->friendships = friends_get_recently_active($user_id, $this->pag_num, $this->pag_page, $filter); break; } if ('requests' == $type) { $this->total_friend_count = $this->friendships['total']; $this->friendships = $this->friendships['requests']; $this->friendship_count = count($this->friendships); } else { if (!$max) { $this->total_friend_count = (int) $this->friendships['total']; } else { $this->total_friend_count = (int) $max; } $this->friendships = $this->friendships['friends']; if ($max) { if ($max >= count($this->friendships)) { $this->friendship_count = count($this->friendships); } else { $this->friendship_count = (int) $max; } } else { $this->friendship_count = count($this->friendships); } } $this->pag_links = paginate_links(array('base' => add_query_arg('frpage', '%#%'), 'format' => '', 'total' => ceil($this->total_friend_count / $this->pag_num), 'current' => $this->pag_page, 'prev_text' => '«', 'next_text' => '»', 'mid_size' => 1)); }
function friends_get_friends_invite_list($user_id = false, $group_id) { global $bp; if (!$user_id) { $user_id = $bp->loggedin_user->id; } $friend_ids = friends_get_alphabetically($user_id); if ((int) $friend_ids['total'] < 1) { return false; } for ($i = 0; $i < count($friend_ids['friends']); $i++) { if (groups_check_user_has_invite($friend_ids['friends'][$i]->user_id, $group_id) || groups_is_user_member($friend_ids['friends'][$i]->user_id, $group_id)) { continue; } $display_name = bp_fetch_user_fullname($friend_ids['friends'][$i]->user_id, false); if ($display_name != ' ') { $friends[] = array('id' => $friend_ids['friends'][$i]->user_id, 'full_name' => $display_name); } } if (!$friends) { return false; } return $friends; }