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 || $max >= (int)$this->friendships['total'] ) $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 has_friendships() { if ( $this->friendship_count ) return true; return false; } function next_friendship() { $this->current_friendship++; $this->friendship = $this->friendships[$this->current_friendship]; return $this->friendship; } function rewind_friendships() { $this->current_friendship = -1; if ( $this->friendship_count > 0 ) { $this->friendship = $this->friendships[0]; } } function user_friendships() { if ( $this->current_friendship + 1 < $this->friendship_count ) { return true; } elseif ( $this->current_friendship + 1 == $this->friendship_count ) { do_action('loop_end'); // Do some cleaning up after the loop $this->rewind_friendships(); } $this->in_the_loop = false; return false; } function the_friendship() { global $friendship, $bp; $this->in_the_loop = true; $this->friendship = $this->next_friendship(); if ( 'requests' == $this->type ) { $this->friendship = new BP_Friends_Friendship( $this->friendship ); $this->friendship->user_id = ( $this->friendship->friend_user_id == $bp->loggedin_user->id ) ? $this->friendship->initiator_user_id : $this->friendship->friend_user_id; } else { if ( 'newest' == $this->type ) $user_id = $this->friendship; else $user_id = $this->friendship->user_id; $this->friendship = new stdClass; if ( !$this->friendship->friend = wp_cache_get( 'bp_user_' . $user_id, 'bp' ) ) { $this->friendship->friend = new BP_Core_User( $user_id ); wp_cache_set( 'bp_user_' . $user_id, $this->friendship->friend, 'bp' ); } /* Make sure the user_id is available in the friend object. */ $this->friendship->friend->user_id = $user_id; } if ( 0 == $this->current_friendship ) // loop has just started do_action('loop_start'); } } function bp_has_friendships( $args = '' ) { global $bp, $friends_template; $defaults = array( 'type' => 'active', 'user_id' => false, 'per_page' => 10, 'max' => false, 'filter' => false ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); /* The following code will auto set parameters based on the page being viewed. * for example on example.com/members/andy/friends/my-friends/newest/ * $type = 'newest' */ if ( 'my-friends' == $bp->current_action ) { $order = $bp->action_variables[0]; if ( 'newest' == $order ) $type = 'newest'; else if ( 'alphabetically' == $order ) $type = 'alphabetical'; } else if ( 'requests' == $bp->current_action ) { $type = 'requests'; } if ( isset( $_REQUEST['friend-search-box'] ) ) $filter = $_REQUEST['friend-search-box']; $friends_template = new BP_Friendship_Template( $user_id, $type, $per_page, $max, $filter ); return apply_filters( 'bp_has_friendships', $friends_template->has_friendships(), &$friends_template ); } function bp_the_friendship() { global $friends_template; return $friends_template->the_friendship(); } function bp_user_friendships() { global $friends_template; return $friends_template->user_friendships(); } function bp_friend_id() { echo bp_get_friend_id(); } function bp_get_friend_id() { global $friends_template; return apply_filters( 'bp_get_friend_id', $friends_template->friendship->friend->user_id ); } function bp_friend_avatar_thumb() { echo bp_get_friend_avatar_thumb(); } function bp_get_friend_avatar_thumb() { global $friends_template; if ( !$template ) $template = &$friends_template->friendship->friend; return apply_filters( 'bp_get_friend_avatar_thumb', $friends_template->friendship->friend->avatar_thumb ); } function bp_friend_name() { echo bp_get_friend_name(); } function bp_get_friend_name() { global $friends_template; return apply_filters( 'bp_get_friend_name', strip_tags( $friends_template->friendship->friend->user_link ) ); } function bp_friend_link() { echo bp_get_friend_link(); } function bp_get_friend_link() { global $friends_template; return apply_filters( 'bp_get_friend_link', $friends_template->friendship->friend->user_link ); } function bp_friend_url() { echo bp_get_friend_url(); } function bp_get_friend_url() { global $friends_template; return apply_filters( 'bp_get_friend_url', $friends_template->friendship->friend->user_url ); } function bp_friend_last_active() { echo bp_get_friend_last_active(); } function bp_get_friend_last_active() { global $friends_template; return apply_filters( 'bp_get_friend_last_active', $friends_template->friendship->friend->last_active ); } function bp_friend_time_since_requested() { echo bp_get_friend_time_since_requested(); } function bp_get_friend_time_since_requested() { global $friends_template; if ( $friends_template->friendship->date_created != "0000-00-00 00:00:00" ) { return apply_filters( 'bp_friend_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $friends_template->friendship->date_created ) ) ) ); } return false; } function bp_friend_accept_request_link() { echo bp_get_friend_accept_request_link(); } function bp_get_friend_accept_request_link() { global $friends_template, $bp; return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/accept/' . $friends_template->friendship->id, 'friends_accept_friendship' ) ); } function bp_friend_reject_request_link() { echo bp_get_friend_reject_request_link(); } function bp_get_friend_reject_request_link() { global $friends_template, $bp; return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/reject/' . $friends_template->friendship->id, 'friends_reject_friendship' ) ); } function bp_friend_pagination() { echo bp_get_friend_pagination(); } function bp_get_friend_pagination() { global $friends_template; return apply_filters( 'bp_friend_pagination', $friends_template->pag_links ); } function bp_friend_pagination_count() { global $bp, $friends_template; $from_num = intval( ( $friends_template->pag_page - 1 ) * $friends_template->pag_num ) + 1; $to_num = ( $from_num + ( $friends_template->pag_num - 1 ) > $friends_template->total_friend_count ) ? $friends_template->total_friend_count : $from_num + ( $friends_template->pag_num - 1) ; echo sprintf( __( 'Viewing friend %d to %d (of %d friends)', 'buddypress' ), $from_num, $to_num, $friends_template->total_friend_count ); ?> displayed_user->domain . $bp->friends->slug . '/my-friends/search/'; $label = __( 'Filter Friends', 'buddypress' ); ?>
displayed_user->domain . 'my-friends/all-friends' ); } function bp_friend_latest_update_link() { global $bp; echo apply_filters( 'bp_friend_latest_update_link', $bp->displayed_user->domain . 'my-friends/last-updated' ); } function bp_friend_recent_activity_link() { global $bp; echo apply_filters( 'bp_friend_recent_activity_link', $bp->displayed_user->domain . 'my-friends/recently-active' ); } function bp_friend_recent_status_link() { global $bp; echo apply_filters( 'bp_friend_recent_status_link', $bp->displayed_user->domain . 'my-friends/status-updates' ); } function bp_add_friend_button( $potential_friend_id = false ) { echo bp_get_add_friend_button( $potential_friend_id ); } function bp_get_add_friend_button( $potential_friend_id = false ) { global $bp, $friends_template; $button = false; if ( is_user_logged_in() ) { if ( !$potential_friend_id && $friends_template->friendship->friend ) $potential_friend_id = $friends_template->friendship->friend->id; else if ( !$potential_friend_id && !$friends_template->friendship->friend ) $potential_friend_id = $bp->displayed_user->id; if ( $bp->loggedin_user->id == $potential_friend_id ) return false; $friend_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id ); $button = ''; } return apply_filters( 'bp_get_add_friend_button', $button ); } function bp_friends_header_tabs() { global $bp, $create_group_step, $completed_to_step; ?>name ?>
value ?>