function bp_get_new_group_invite_friend_list($args = '') { global $bp; if (!bp_is_active('friends')) { return false; } $defaults = array('group_id' => false, 'separator' => 'li'); $r = wp_parse_args($args, $defaults); extract($r, EXTR_SKIP); if (empty($group_id)) { $group_id = !empty($bp->groups->new_group_id) ? $bp->groups->new_group_id : $bp->groups->current_group->id; } if ($friends = friends_get_friends_invite_list(bp_loggedin_user_id(), $group_id)) { $invites = groups_get_invites_for_group(bp_loggedin_user_id(), $group_id); for ($i = 0, $count = count($friends); $i < $count; ++$i) { $checked = ''; if (!empty($invites)) { if (in_array($friends[$i]['id'], $invites)) { $checked = ' checked="checked"'; } } $items[] = '<' . $separator . '><input' . $checked . ' type="checkbox" name="friends[]" id="f-' . $friends[$i]['id'] . '" value="' . esc_attr($friends[$i]['id']) . '" /> ' . $friends[$i]['full_name'] . '</' . $separator . '>'; } } if (!empty($items)) { return implode("\n", (array) $items); } return false; }
/** * Return a list of friends who can be invited to a group * * @since 1.0.0 * * @param array $args Array of arguments for friends list output. * @return mixed HTML list of checkboxes, or false */ function bp_get_new_group_invite_friend_list($args = array()) { // Bail if no friends component. if (!bp_is_active('friends')) { return false; } // Parse arguments. $r = wp_parse_args($args, array('user_id' => bp_loggedin_user_id(), 'group_id' => false, 'separator' => 'li')); // No group passed, so look for new or current group ID's. if (empty($r['group_id'])) { $bp = buddypress(); $r['group_id'] = !empty($bp->groups->new_group_id) ? $bp->groups->new_group_id : $bp->groups->current_group->id; } // Setup empty items array. $items = array(); // Get user's friends who are not in this group already. $friends = friends_get_friends_invite_list($r['user_id'], $r['group_id']); if (!empty($friends)) { // Get already invited users. $invites = groups_get_invites_for_group($r['user_id'], $r['group_id']); for ($i = 0, $count = count($friends); $i < $count; ++$i) { $checked = in_array((int) $friends[$i]['id'], (array) $invites); $items[] = '<' . $r['separator'] . '><label for="f-' . esc_attr($friends[$i]['id']) . '"><input' . checked($checked, true, false) . ' type="checkbox" name="friends[]" id="f-' . esc_attr($friends[$i]['id']) . '" value="' . esc_attr($friends[$i]['id']) . '" /> ' . esc_html($friends[$i]['full_name']) . '</label></' . $r['separator'] . '>'; } } /** * Filters the array of friends who can be invited to a group. * * @since 2.4.0 * * @param array $items Array of friends. * @param array $r Parsed arguments from bp_get_new_group_invite_friend_list() * @param array $args Unparsed arguments from bp_get_new_group_invite_friend_list() */ $invitable_friends = apply_filters('bp_get_new_group_invite_friend_list', $items, $r, $args); if (!empty($invitable_friends) && is_array($invitable_friends)) { $retval = implode("\n", $invitable_friends); } else { $retval = false; } return $retval; }
function kleo_bp_get_new_group_invite_friend_list($args = '') { global $bp; if (!bp_is_active('friends')) { return false; } $defaults = array('group_id' => false, 'separator' => 'li'); $r = wp_parse_args($args, $defaults); extract($r, EXTR_SKIP); if (empty($group_id)) { $group_id = !empty($bp->groups->new_group_id) ? $bp->groups->new_group_id : $bp->groups->current_group->id; } if ($friends = friends_get_friends_invite_list(bp_loggedin_user_id(), $group_id)) { $invites = groups_get_invites_for_group(bp_loggedin_user_id(), $group_id); for ($i = 0, $count = count($friends); $i < $count; ++$i) { $checked = ''; if (!empty($invites)) { if (in_array($friends[$i]['id'], $invites)) { $checked = ' checked="checked"'; } } $items[] = '<' . $separator . '>' . '<label class="mark-item">' . '<input class="checkbox-cb"' . $checked . ' type="checkbox" name="friends[]" id="f-' . $friends[$i]['id'] . '" value="' . esc_attr($friends[$i]['id']) . '" /> ' . '<span class="checkbox-mark"></span>' . '</label>' . '<div class="item-avatar rounded">' . get_avatar($friends[$i]['id']) . '</div>' . '<div class="invite-list-content"><h4>' . bp_core_get_userlink($friends[$i]['id']) . '</h4>' . '<span class="activity">' . bp_get_last_activity($friends[$i]['id']) . '</span>' . '<span class="group-invites-status"></span></div>' . '</' . $separator . '>'; } } if (!empty($items)) { return implode("\n", (array) $items); } return false; }
function bp_get_new_group_invite_friend_list( $args = '' ) { global $bp; if ( !function_exists('friends_install') ) return false; $defaults = array( 'group_id' => false, 'separator' => 'li' ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); if ( !$group_id ) $group_id = ( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : $bp->groups->current_group->id; $friends = friends_get_friends_invite_list( $bp->loggedin_user->id, $group_id ); if ( $friends ) { $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group_id ); for ( $i = 0; $i < count( $friends ); $i++ ) { if ( $invites ) { if ( in_array( $friends[$i]['id'], $invites ) ) { $checked = ' checked="checked"'; } else { $checked = ''; } } $items[] = '<' . $separator . '><input' . $checked . ' type="checkbox" name="friends[]" id="f-' . $friends[$i]['id'] . '" value="' . esc_attr( $friends[$i]['id'] ) . '" /> ' . $friends[$i]['full_name'] . '</' . $separator . '>'; } } return implode( "\n", (array)$items ); }
function bp_group_list_invite_friends() { global $bp, $group_obj, $invites; if (!function_exists('friends_install')) { return false; } $friends = friends_get_friends_invite_list($bp->loggedin_user->id, $group_obj->id); if ($friends) { $invites = groups_get_invites_for_group($bp->loggedin_user->id, $group_obj->id); ?> <div id="invite-list"> <ul> <?php for ($i = 0; $i < count($friends); $i++) { if ($invites) { if (in_array($friends[$i]['id'], $invites)) { $checked = ' checked="checked"'; } else { $checked = ''; } } ?> <li><input<?php echo $checked; ?> type="checkbox" name="friends[]" id="f-<?php echo $friends[$i]['id']; ?> " value="<?php echo attribute_escape($friends[$i]['id']); ?> " /> <?php echo $friends[$i]['full_name']; ?> </li> <?php } ?> </ul> </div> <?php } else { _e('No friends to invite.', 'buddypress'); } }