/**
     * Displays the widget.
     */
    function widget($args, $instance)
    {
        // do not do anything if user isn't logged in
        if (!is_user_logged_in()) {
            return;
        }
        if (empty($instance['max_users'])) {
            $instance['max_users'] = 16;
        }
        // logged-in user isn't following anyone, so stop!
        if (!($following = bp_get_following_ids(array('user_id' => bp_loggedin_user_id())))) {
            return false;
        }
        // show the users the logged-in user is following
        if (bp_has_members(array('include' => $following, 'max' => $instance['max_users'], 'populate_extras' => false))) {
            do_action('bp_before_following_widget');
            echo $args['before_widget'];
            echo $args['before_title'] . $instance['title'] . $args['after_title'];
            ?>

			<div class="avatar-block">
				<?php 
            while (bp_members()) {
                bp_the_member();
                ?>
					<div class="item-avatar">
						<a href="<?php 
                bp_member_permalink();
                ?>
" title="<?php 
                bp_member_name();
                ?>
"><?php 
                bp_member_avatar();
                ?>
</a>
					</div>
				<?php 
            }
            ?>
			</div>

			<?php 
            echo $args['after_widget'];
            ?>

			<?php 
            do_action('bp_after_following_widget');
            ?>

	<?php 
        }
    }
示例#2
0
function bpChat_displayGroupChatAdmin()
{
    global $bp;
    global $members_template;
    ?>
<script>
    jQuery(document).ready(function() {
            jQuery('div#item-nav').before("<div id='bp-group-chat-online'><p id='bp-group-chat-online-text'><?php 
    _e("Admin is offline", "bp-chat");
    ?>
</p></div>");
<?php 
    if (function_exists('bp_has_members')) {
        if (bp_has_members('user_id=0&type=online&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] . '&populate_extras=0')) {
            while (bp_members()) {
                bp_the_member();
                if ($members_template->member->id == $bp->groups->current_group->admins[0]->user_id && ($bp->groups->current_group->admins[0]->is_admin == 1 || $bp->groups->current_group->admins[0]->is_mod == 1)) {
                    ?>
		jQuery('div#bp-group-chat-online').html("<p id='bp-group-chat-online-text'><?php 
                    _e("Admin is online", "bp-chat");
                    ?>
</p>");
		if ( (int)get_site_option( 'bp-chat-setting-disable-shoutbox-chat' ) == 0 ) {
			jQuery('#shoutboxwrapper').show('slow');
		}
<?php 
                }
            }
        } else {
            ?>
            jQuery('div#bp-group-chat-online').html("<p id='bp-group-chat-online-text'><?php 
            _e("There are no admin users currently online", "bp-chat");
            ?>
</p>");
<?php 
        }
    }
    ?>
        jQuery('div#bp-group-chat-online').append("<?php 
    echo "<br />";
    ?>
");
    });
    </script>
<?php 
}
 /**
  * @ticket BP6996
  */
 public function test_should_contain_member_type_classes()
 {
     buddypress()->members->types = array();
     bp_register_member_type('foo');
     bp_register_member_type('bar');
     $u = $this->factory->user->create();
     bp_set_member_type($u, 'bar');
     if (bp_has_members(array('include' => array($u)))) {
         while (bp_members()) {
             bp_the_member();
             $found = bp_get_member_class();
         }
     }
     global $members_template;
     unset($members_template);
     buddypress()->members->types = array();
     $this->assertContains('member-type-bar', $found);
     $this->assertNotContains('member-type-foo', $found);
 }
    ?>
</h2>
			</div><!--#counter-->
		<?php 
}
?>
	
		
	
		<?php 
if (of_get_option('members_avatars')) {
    ?>
 
         		<div id="intro-mem">          
			<?php 
    if (bp_has_members('max=12&type=' . of_get_option('members_type_select'))) {
        ?>
         
                    		<?php 
        while (bp_members()) {
            bp_the_member();
            ?>
 
					<?php 
            if (bp_get_user_has_avatar()) {
                ?>
                     
                        			<div class="item-avatar">
							<a href="<?php 
                bp_member_permalink();
                ?>
示例#5
0
 function get_members()
 {
     // Depends on BuddyPress
     if (!class_exists('BuddyPress')) {
         return false;
     }
     // Try to retrieve the widget from the cache
     $widget = wp_cache_get('online_members', 'apoc');
     if ($widget) {
         $this->html = $widget;
         $this->cached = true;
     } else {
         // Setup query args
         $args = array('type' => 'online', 'per_page' => $this->number, 'populate_extras' => false);
         // If topics are found, build the HTML
         if (bp_has_members($args)) {
             $this->html = $this->build_html();
             // Store the new HTML in the cache with 1 minute expiration
             wp_cache_set('online_members', $this->html, 'apoc', 60);
         }
     }
 }
示例#6
0
?>

<?php
    function edit_view_link( $view_link ){
        return str_replace( __( 'View', 'buddypress' ), __( '+ more', 'yit' ), $view_link );
    }

    add_filter('bp_get_member_latest_update', 'edit_view_link');

    wp_enqueue_script( 'jquery-masonry' );
?>

<?php do_action( 'bp_before_members_loop' ); ?>

<?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?>

    <div id="pag-top" class="pagination">

        <div class="pag-count" id="member-dir-count-top">

            <?php bp_members_pagination_count(); ?>

        </div>

        <div class="pagination-links" id="member-dir-pag-top">

            <?php bp_members_pagination_links(); ?>

        </div>
示例#7
0
    }
    ?>

	</div>
	
	<?php 
    if (bp_group_has_moderators()) {
        ?>
		<div class="bp-widget">
			<h4><?php 
        _e('Moderators', 'buddypress');
        ?>
</h4>		
			
			<?php 
        if (bp_has_members('&include=' . bp_group_mod_ids())) {
            ?>
				<ul id="mods-list" class="item-list">
				
					<?php 
            while (bp_members()) {
                bp_the_member();
                ?>
					
					<li>
						<?php 
                echo bp_core_fetch_avatar(array('item_id' => bp_get_member_user_id(), 'type' => 'thumb', 'width' => 30, 'height' => 30, 'alt' => __('Profile picture of %s', 'buddypress')));
                ?>
						<h5>
							<a href="<?php 
                bp_member_permalink();
示例#8
0
/**
 * Get a list of friends that a user can invite into this group.
 *
 * Excludes friends that are already in the group, and banned friends if the
 * user is not a group admin.
 *
 * @since BuddyPress (1.0.0)
 *
 * @param int $user_id User ID whose friends to see can be invited. Default:
 *        ID of the logged-in user.
 * @param int $group_id Group to check possible invitations against.
 * @return mixed False if no friends, array of users if friends.
 */
function friends_get_friends_invite_list($user_id = 0, $group_id = 0)
{
    // Default to logged in user id
    if (empty($user_id)) {
        $user_id = bp_loggedin_user_id();
    }
    // Only group admins can invited previously banned users
    $user_is_admin = (bool) groups_is_user_admin($user_id, $group_id);
    // Assume no friends
    $friends = array();
    // Default args
    $args = apply_filters('bp_friends_pre_get_invite_list', array('user_id' => $user_id, 'type' => 'alphabetical', 'per_page' => 0));
    // User has friends
    if (bp_has_members($args)) {
        /**
         * Loop through all friends and try to add them to the invitation list.
         *
         * Exclude friends that:
         *     1. are already members of the group
         *     2. are banned from this group if the current user is also not a
         *        group admin.
         */
        while (bp_members()) {
            // Load the member
            bp_the_member();
            // Get the user ID of the friend
            $friend_user_id = bp_get_member_user_id();
            // Skip friend if already in the group
            if (groups_is_user_member($friend_user_id, $group_id)) {
                continue;
            }
            // Skip friend if not group admin and user banned from group
            if (false === $user_is_admin && groups_is_user_banned($friend_user_id, $group_id)) {
                continue;
            }
            // Friend is safe, so add it to the array of possible friends
            $friends[] = array('id' => $friend_user_id, 'full_name' => bp_get_member_name());
        }
    }
    // If no friends, explicitly set to false
    if (empty($friends)) {
        $friends = false;
    }
    // Allow friends to be filtered
    return apply_filters('bp_friends_get_invite_list', $friends, $user_id, $group_id);
}
 /**
  * Display results
  */
 public function results()
 {
     //Show/hide members with no location in the results. Default set to false
     $this->show_non_located_users = apply_filters('show_users_without_location', false, $this->form);
     //prevent BuddyPress from using its own "paged" value for the current page
     if (!empty($_REQUEST['upage'])) {
         unset($_REQUEST['upage']);
     }
     /*
     $xp_ids = array();
     
     //query the xprofile fields. This is done in a saperate function
     if ( apply_filters( 'gmw_fl_do_xprofile_query', true ) ) {
         
         $xprofile_users = gmw_fl_query_xprofile_fields( $this->form ,$_GET );
     
         //if fields entered but no users returned abort the query
         if ( $xprofile_users['status'] == 'no_ids_found' ) {
     
             $xp_ids = 0;
     
         //if users returned. add them to query
         } elseif ( $xprofile_users['status'] == 'ids_found' ) {
     
             $xp_ids = $xprofile_users['ids'];
         }
     }
     */
     //query args
     $this->form['query_args'] = apply_filters('gmw_fl_search_query_args', array('type' => 'distance', 'per_page' => $this->form['get_per_page'], 'page' => $this->form['paged']), $this->form);
     //modify the form values before query
     $this->form = apply_filters('gmw_fl_form_before_members_query', $this->form, $this->settings);
     $this->form = apply_filters("gmw_fl_form_before_members_query_{$this->form['ID']}", $this->form, $this->settings);
     //modify BP users query
     add_action('bp_pre_user_query', array($this, 'gmwBpQuery'));
     //modify WP User query
     add_action('pre_user_query', array($this, 'gmwWpQuery'));
     //enqueue stylesheet and get results template file
     $results_template = $this->search_results();
     if (bp_has_members($this->form['query_args'])) {
         global $members_template;
         $members_template = apply_filters('gmw_fl_members_before_members_loop', $members_template, $this->form, $this->settings);
         //setup member count
         $this->form['member_count'] = $this->form['paged'] == 1 ? 1 : $this->form['get_per_page'] * ($this->form['paged'] - 1) + 1;
         $this->form['results'] = $members_template->members;
         $this->form['total_results'] = $members_template->total_member_count;
         $this->form['max_pages'] = $this->form['total_results'] / $this->form['get_per_page'];
         echo '<div id="buddypress">';
         //load results template file to display list of members
         if (isset($this->form['search_results']['display_members']) && !$this->form['in_widget']) {
             add_action('gmw_search_results_loop_item_start', array($this, 'modify_member'), 10);
             $gmw = $this->form;
             include $results_template;
             /*
              * if we do not display list of members we still need to have a loop
              * and add some information to each members in order to be able to
              * display it on the map
              */
         } elseif ($this->form['search_results']['display_map'] != 'na') {
             while (bp_members()) {
                 bp_the_member();
                 self::modify_member();
             }
         }
         echo '</div>';
     }
     remove_action('bp_pre_user_query', array($this, 'gmwBpQuery'));
     remove_action('pre_user_query', array($this, 'gmwWpQuery'));
 }
    /**
     * Display the Members widget.
     *
     * @since 1.0.3
     *
     * @see WP_Widget::widget() for description of parameters.
     *
     * @param array $args     Widget arguments.
     * @param array $instance Widget settings, as saved by the user.
     */
    public function widget($args, $instance)
    {
        global $members_template;
        // Get widget settings.
        $settings = $this->parse_settings($instance);
        /**
         * Filters the title of the Members widget.
         *
         * @since 1.8.0
         * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
         *
         * @param string $title    The widget title.
         * @param array  $settings The settings for the particular instance of the widget.
         * @param string $id_base  Root ID for all widgets of this type.
         */
        $title = apply_filters('widget_title', $settings['title'], $settings, $this->id_base);
        $title = $settings['link_title'] ? '<a href="' . bp_get_members_directory_permalink() . '">' . $title . '</a>' : $title;
        /**
         * Filters the separator of the member widget links.
         *
         * @since 2.4.0
         *
         * @param string $separator Separator string. Default '|'.
         */
        $separator = apply_filters('bp_members_widget_separator', '|');
        // Output before widget HTMl, title (and maybe content before & after it).
        echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title'];
        // Setup args for querying members.
        $members_args = array('user_id' => 0, 'type' => $settings['member_default'], 'per_page' => $settings['max_members'], 'max' => $settings['max_members'], 'populate_extras' => true, 'search_terms' => false);
        // Back up the global.
        $old_members_template = $members_template;
        ?>

		<?php 
        if (bp_has_members($members_args)) {
            ?>

			<div class="item-options" id="members-list-options">
				<a href="<?php 
            bp_members_directory_permalink();
            ?>
" id="newest-members" <?php 
            if ('newest' === $settings['member_default']) {
                ?>
class="selected"<?php 
            }
            ?>
><?php 
            esc_html_e('Newest', 'buddypress');
            ?>
</a>
				<span class="bp-separator" role="separator"><?php 
            echo esc_html($separator);
            ?>
</span>
				<a href="<?php 
            bp_members_directory_permalink();
            ?>
" id="recently-active-members" <?php 
            if ('active' === $settings['member_default']) {
                ?>
class="selected"<?php 
            }
            ?>
><?php 
            esc_html_e('Active', 'buddypress');
            ?>
</a>

				<?php 
            if (bp_is_active('friends')) {
                ?>
					<span class="bp-separator" role="separator"><?php 
                echo esc_html($separator);
                ?>
</span>
					<a href="<?php 
                bp_members_directory_permalink();
                ?>
" id="popular-members" <?php 
                if ('popular' === $settings['member_default']) {
                    ?>
class="selected"<?php 
                }
                ?>
><?php 
                esc_html_e('Popular', 'buddypress');
                ?>
</a>

				<?php 
            }
            ?>

			</div>

			<ul id="members-list" class="item-list" aria-live="polite" aria-relevant="all" aria-atomic="true">

				<?php 
            while (bp_members()) {
                bp_the_member();
                ?>

					<li class="vcard">
						<div class="item-avatar">
							<a href="<?php 
                bp_member_permalink();
                ?>
" title="<?php 
                bp_member_name();
                ?>
"><?php 
                bp_member_avatar();
                ?>
</a>
						</div>

						<div class="item">
							<div class="item-title fn"><a href="<?php 
                bp_member_permalink();
                ?>
" title="<?php 
                bp_member_name();
                ?>
"><?php 
                bp_member_name();
                ?>
</a></div>
							<div class="item-meta">
								<?php 
                if ('newest' == $settings['member_default']) {
                    ?>
									<span class="activity" data-livestamp="<?php 
                    bp_core_iso8601_date(bp_get_member_registered(array('relative' => false)));
                    ?>
"><?php 
                    bp_member_registered();
                    ?>
</span>
								<?php 
                } elseif ('active' == $settings['member_default']) {
                    ?>
									<span class="activity" data-livestamp="<?php 
                    bp_core_iso8601_date(bp_get_member_last_active(array('relative' => false)));
                    ?>
"><?php 
                    bp_member_last_active();
                    ?>
</span>
								<?php 
                } else {
                    ?>
									<span class="activity"><?php 
                    bp_member_total_friend_count();
                    ?>
</span>
								<?php 
                }
                ?>
							</div>
						</div>
					</li>

				<?php 
            }
            ?>

			</ul>

			<?php 
            wp_nonce_field('bp_core_widget_members', '_wpnonce-members', false);
            ?>

			<input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php 
            echo esc_attr($settings['max_members']);
            ?>
" />

		<?php 
        } else {
            ?>

			<div class="widget-error">
				<?php 
            esc_html_e('No one has signed up yet!', 'buddypress');
            ?>
			</div>

		<?php 
        }
        ?>

		<?php 
        echo $args['after_widget'];
        // Restore the global.
        $members_template = $old_members_template;
    }
示例#11
0
 * BuddyPress - Members Loop
 *
 * Querystring is set via AJAX in _inc/ajax.php - bp_legacy_theme_object_filter()
 *
 * @package BuddyPress
 * @subpackage bp-legacy
 */
global $bp, $members_template, $wpdb;
?>

<?php 
do_action('bp_before_members_loop');
?>

<?php 
if (bp_has_members(bp_ajax_querystring('members') . '&type=alphabetical&per_page=999')) {
    ?>

	<?php 
    do_action('bp_before_directory_members_list');
    ?>

	<ul id="members-list" class="item-list" role="main">

	<?php 
    while (bp_members()) {
        bp_the_member();
        $groups = '';
        $user_id = bp_get_member_user_id();
        $group_ids = $wpdb->get_results("SELECT group_id FROM wp_bp_groups_members WHERE user_id={$user_id}");
        foreach ($group_ids as $group) {
/**
 * AJAX request handler for Members widgets.
 *
 * @since 1.0.0
 *
 * @see BP_Core_Members_Widget
 */
function bp_core_ajax_widget_members()
{
    check_ajax_referer('bp_core_widget_members');
    // Setup some variables to check.
    $filter = !empty($_POST['filter']) ? $_POST['filter'] : 'recently-active-members';
    $max_members = !empty($_POST['max-members']) ? absint($_POST['max-members']) : 5;
    // Determine the type of members query to perform.
    switch ($filter) {
        // Newest activated.
        case 'newest-members':
            $type = 'newest';
            break;
            // Popular by friends.
        // Popular by friends.
        case 'popular-members':
            if (bp_is_active('friends')) {
                $type = 'popular';
            } else {
                $type = 'active';
            }
            break;
            // Default.
        // Default.
        case 'recently-active-members':
        default:
            $type = 'active';
            break;
    }
    // Setup args for querying members.
    $members_args = array('user_id' => 0, 'type' => $type, 'per_page' => $max_members, 'max' => $max_members, 'populate_extras' => true, 'search_terms' => false);
    // Query for members.
    if (bp_has_members($members_args)) {
        ?>
		<?php 
        echo '0[[SPLIT]]';
        // Return valid result. TODO: remove this.
        ?>
		<?php 
        while (bp_members()) {
            bp_the_member();
            ?>
			<li class="vcard">
				<div class="item-avatar">
					<a href="<?php 
            bp_member_permalink();
            ?>
"><?php 
            bp_member_avatar();
            ?>
</a>
				</div>

				<div class="item">
					<div class="item-title fn"><a href="<?php 
            bp_member_permalink();
            ?>
" title="<?php 
            bp_member_name();
            ?>
"><?php 
            bp_member_name();
            ?>
</a></div>
					<?php 
            if ('active' === $type) {
                ?>
						<div class="item-meta"><span class="activity"><?php 
                bp_member_last_active();
                ?>
</span></div>
					<?php 
            } elseif ('newest' === $type) {
                ?>
						<div class="item-meta"><span class="activity"><?php 
                bp_member_registered();
                ?>
</span></div>
					<?php 
            } elseif (bp_is_active('friends')) {
                ?>
						<div class="item-meta"><span class="activity"><?php 
                bp_member_total_friend_count();
                ?>
</span></div>
					<?php 
            }
            ?>
				</div>
			</li>

		<?php 
        }
        ?>

	<?php 
    } else {
        ?>
		<?php 
        echo "-1[[SPLIT]]<li>";
        ?>
		<?php 
        esc_html_e('There were no members found, please try another filter.', 'buddypress');
        ?>
		<?php 
        echo "</li>";
        ?>
	<?php 
    }
}
示例#13
0
文件: members-loop.php 项目: 6226/wp
/**
 * BuddyPress - Members Loop
 *
 * Querystring is set via AJAX in _inc/ajax.php - bp_legacy_theme_object_filter()
 *
 * @package BuddyPress
 * @subpackage bp-legacy
 */
?>

<?php 
do_action('bp_before_members_loop');
?>

<?php 
if (bp_has_members(bp_ajax_querystring('members') . '&per_page=' . sq_option('bp_members_perpage', 24))) {
    ?>

	<div id="pag-top" class="pagination">

		<div class="pag-count" id="member-dir-count-top">

			<?php 
    bp_members_pagination_count();
    ?>

		</div>

		<div class="pagination-links" id="member-dir-pag-top">

			<?php 
示例#14
0
function buat_get_user_template($type)
{
    $filtered_users = buat_gather_user_ids($type);
    if (bp_has_members("include={$filtered_users}&type=alphabetical")) {
        ?>
 
    <div class="pagination">
 
        <div class="pag-count" id="member-dir-count">
            <?php 
        bp_members_pagination_count();
        ?>
        </div>
 
        <div class="pagination-links" id="member-dir-pag">
            <?php 
        bp_members_pagination_links();
        ?>
        </div>
 
    </div>
 
    <?php 
        do_action('bp_before_directory_members_list');
        ?>
 
    <ul id="members-list" class="item-list" style="list-style-type:none; margin: 0; width: auto">
    <?php 
        while (bp_members()) {
            bp_the_member();
            ?>
 
        <li>
            <div class="item-avatar">
                <a href="<?php 
            bp_member_permalink();
            ?>
"><?php 
            bp_member_avatar();
            ?>
</a>
            </div>
 
            <div class="item">
                <div class="item-title">
                    <a href="<?php 
            bp_member_permalink();
            ?>
"><?php 
            bp_member_name();
            ?>
</a>
                    <?php 
            if (bp_get_member_latest_update()) {
                ?>
                        <span class="update"> - <?php 
                bp_member_latest_update('length=10');
                ?>
</span>
                    <?php 
            }
            ?>
                </div>
                <div class="item-meta"><span class="activity"><?php 
            bp_member_last_active();
            ?>
</span></div>
 
                <?php 
            do_action('bp_directory_members_item');
            ?>
 
                <?php 
            /***
             * If you want to show specific profile fields here you can,
             * but it'll add an extra query for each member in the loop
             * (only one regadless of the number of fields you show):
             *
             * bp_member_profile_data( 'field=the field name' );
             */
            ?>
            </div>
 
            <div class="action">
                <?php 
            do_action('bp_directory_members_actions');
            ?>
            </div>
 
            <div class="clear"></div>
        </li>
 
    <?php 
        }
        ?>
    </ul>
 
    <?php 
        do_action('bp_after_directory_members_list');
        ?>
 
    <?php 
        bp_member_hidden_fields();
        ?>
 
<?php 
    } else {
        ?>
 
    <div id="message" class="info">
        <p><?php 
        _e("Sorry, no members were found.", 'buddypress');
        ?>
</p>
    </div>
 
<?php 
    }
}
示例#15
0
 function kleo_bp_member_stats($field = false, $value = false, $online = false)
 {
     global $wpdb;
     if (!$field || !$value) {
         return;
     }
     $where = " WHERE name = '" . $field . "' AND value = '" . esc_sql($value) . "'";
     $sql = "SELECT " . $wpdb->base_prefix . "bp_xprofile_data.user_id FROM " . $wpdb->base_prefix . "bp_xprofile_data\n\t\t\t\tJOIN " . $wpdb->base_prefix . "bp_xprofile_fields ON " . $wpdb->base_prefix . "bp_xprofile_data.field_id = " . $wpdb->base_prefix . "bp_xprofile_fields.id\n\t\t\t\t{$where}";
     $match_ids = $wpdb->get_col($sql);
     if (!$online) {
         return count($match_ids);
     }
     if (!$match_ids) {
         $match_ids = array(0);
     }
     if (!empty($match_ids)) {
         $include_members = '&include=' . join(",", $match_ids);
     } else {
         $include_members = '';
     }
     $i = 0;
     if (bp_has_members('user_id=0&type=online&per_page=999999999&populate_extras=0' . $include_members)) {
         while (bp_members()) {
             bp_the_member();
             $i++;
         }
     }
     return apply_filters('kleo_bp_member_stats', $i, $value);
 }
    /**
     * Display the Recently Active widget.
     *
     * @see WP_Widget::widget() for description of parameters.
     *
     * @param array $args     Widget arguments.
     * @param array $instance Widget settings, as saved by the user.
     */
    public function widget($args, $instance)
    {
        global $members_template;
        // Get widget settings.
        $settings = $this->parse_settings($instance);
        /**
         * Filters the title of the Recently Active widget.
         *
         * @since 1.8.0
         * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
         *
         * @param string $title    The widget title.
         * @param array  $settings The settings for the particular instance of the widget.
         * @param string $id_base  Root ID for all widgets of this type.
         */
        $title = apply_filters('widget_title', $settings['title'], $settings, $this->id_base);
        echo $args['before_widget'];
        echo $args['before_title'] . $title . $args['after_title'];
        // Setup args for querying members.
        $members_args = array('user_id' => 0, 'type' => 'active', 'per_page' => $settings['max_members'], 'max' => $settings['max_members'], 'populate_extras' => true, 'search_terms' => false);
        // Back up global.
        $old_members_template = $members_template;
        ?>

		<?php 
        if (bp_has_members($members_args)) {
            ?>

			<div class="avatar-block">

				<?php 
            while (bp_members()) {
                bp_the_member();
                ?>

					<div class="item-avatar">
						<a href="<?php 
                bp_member_permalink();
                ?>
" title="<?php 
                bp_member_name();
                ?>
"><?php 
                bp_member_avatar();
                ?>
</a>
					</div>

				<?php 
            }
            ?>

			</div>

		<?php 
        } else {
            ?>

			<div class="widget-error">
				<?php 
            esc_html_e('There are no recently active members', 'buddypress');
            ?>
			</div>

		<?php 
        }
        ?>

		<?php 
        echo $args['after_widget'];
        // Restore the global.
        $members_template = $old_members_template;
    }
示例#17
0
<?php

/**
 * BuddyPress - Users Friends
 *
 * @package BuddyPress
 * @subpackage bp-legacy
 */
$n_members_to_show = 4;
$n_members_shown = 0;
if (bp_has_members('user_id=' . bp_displayed_user_id())) {
    ?>
    <h5 class="side-header">Friends</h5>  
    <div id="side-resources">
        <ul id="member-list" class="item-list" role="main">
            <?php 
    while (bp_members()) {
        bp_the_member();
        ?>
                <?php 
        // limit number of members to show in the list
        if ($n_members_shown < $n_members_to_show) {
            ?>
                    <li>
                        <a href="<?php 
            bp_member_permalink();
            ?>
"><?php 
            bp_member_avatar();
            ?>
</a>
示例#18
0
    function widget($args, $instance)
    {
        extract($args);
        echo $before_widget;
        echo $before_title . $instance['title'] . $after_title;
        ?>

		<?php 
        if (bp_has_members('user_id=0&type=active&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] . '&populate_extras=0')) {
            ?>
			<div class="avatar-block">
				<?php 
            while (bp_members()) {
                bp_the_member();
                ?>
					<div class="item-avatar">
						<a href="<?php 
                bp_member_permalink();
                ?>
" title="<?php 
                bp_member_name();
                ?>
"><?php 
                bp_member_avatar();
                ?>
</a>
					</div>
				<?php 
            }
            ?>
			</div>
		<?php 
        } else {
            ?>

			<div class="widget-error">
				<?php 
            _e('There are no recently active members', 'buddypress');
            ?>
			</div>

		<?php 
        }
        ?>

		<?php 
        echo $after_widget;
        ?>
	<?php 
    }
    /**
     * Display the widget.
     *
     * @param array $args Widget arguments.
     * @param array $instance The widget settings, as saved by the user.
     */
    function widget($args, $instance)
    {
        extract($args);
        if (!bp_displayed_user_id()) {
            return;
        }
        $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
        wp_enqueue_script('bp_core_widget_friends-js', buddypress()->plugin_url . "bp-friends/js/widget-friends{$min}.js", array('jquery'), bp_get_version());
        $user_id = bp_displayed_user_id();
        $link = trailingslashit(bp_displayed_user_domain() . bp_get_friends_slug());
        $instance['title'] = sprintf(__('%s&#8217;s Friends', 'buddypress'), bp_get_displayed_user_fullname());
        if (empty($instance['friend_default'])) {
            $instance['friend_default'] = 'active';
        }
        $title = apply_filters('widget_title', $instance['title']);
        echo $before_widget;
        $title = $instance['link_title'] ? '<a href="' . esc_url($link) . '">' . esc_html($title) . '</a>' : esc_html($title);
        echo $before_title . $title . $after_title;
        $members_args = array('user_id' => absint($user_id), 'type' => sanitize_text_field($instance['friend_default']), 'max' => absint($instance['max_friends']), 'populate_extras' => 1);
        ?>

		<?php 
        if (bp_has_members($members_args)) {
            ?>
			<div class="item-options" id="friends-list-options">
				<a href="<?php 
            bp_members_directory_permalink();
            ?>
" id="newest-friends" <?php 
            if ($instance['friend_default'] == 'newest') {
                ?>
class="selected"<?php 
            }
            ?>
><?php 
            _e('Newest', 'buddypress');
            ?>
</a>
				| <a href="<?php 
            bp_members_directory_permalink();
            ?>
" id="recently-active-friends" <?php 
            if ($instance['friend_default'] == 'active') {
                ?>
class="selected"<?php 
            }
            ?>
><?php 
            _e('Active', 'buddypress');
            ?>
</a>
				| <a href="<?php 
            bp_members_directory_permalink();
            ?>
" id="popular-friends" <?php 
            if ($instance['friend_default'] == 'popular') {
                ?>
class="selected"<?php 
            }
            ?>
><?php 
            _e('Popular', 'buddypress');
            ?>
</a>
			</div>

			<ul id="friends-list" class="item-list">
				<?php 
            while (bp_members()) {
                bp_the_member();
                ?>
					<li class="vcard">
						<div class="item-avatar">
							<a href="<?php 
                bp_member_permalink();
                ?>
" title="<?php 
                bp_member_name();
                ?>
"><?php 
                bp_member_avatar();
                ?>
</a>
						</div>

						<div class="item">
							<div class="item-title fn"><a href="<?php 
                bp_member_permalink();
                ?>
" title="<?php 
                bp_member_name();
                ?>
"><?php 
                bp_member_name();
                ?>
</a></div>
							<div class="item-meta">
								<span class="activity">
								<?php 
                if ('newest' == $instance['friend_default']) {
                    bp_member_registered();
                }
                if ('active' == $instance['friend_default']) {
                    bp_member_last_active();
                }
                if ('popular' == $instance['friend_default']) {
                    bp_member_total_friend_count();
                }
                ?>
								</span>
							</div>
						</div>
					</li>

				<?php 
            }
            ?>
			</ul>
			<?php 
            wp_nonce_field('bp_core_widget_friends', '_wpnonce-friends');
            ?>
			<input type="hidden" name="friends_widget_max" id="friends_widget_max" value="<?php 
            echo absint($instance['max_friends']);
            ?>
" />

		<?php 
        } else {
            ?>

			<div class="widget-error">
				<?php 
            _e('Sorry, no members were found.', 'buddypress');
            ?>
			</div>

		<?php 
        }
        ?>

		<?php 
        echo $after_widget;
        ?>
	<?php 
    }
/**
 * Get a list of friends that a user can invite into this group.
 *
 * Excludes friends that are already in the group, and banned friends if the
 * user is not a group admin.
 *
 * @since 1.0.0
 *
 * @param int $user_id  User ID whose friends to see can be invited. Default:
 *                      ID of the logged-in user.
 * @param int $group_id Group to check possible invitations against.
 * @return mixed False if no friends, array of users if friends.
 */
function friends_get_friends_invite_list($user_id = 0, $group_id = 0)
{
    // Default to logged in user id.
    if (empty($user_id)) {
        $user_id = bp_loggedin_user_id();
    }
    // Only group admins can invited previously banned users.
    $user_is_admin = (bool) groups_is_user_admin($user_id, $group_id);
    // Assume no friends.
    $friends = array();
    /**
     * Filters default arguments for list of friends a user can invite into this group.
     *
     * @since 1.5.4
     *
     * @param array $value Array of default parameters for invite list.
     */
    $args = apply_filters('bp_friends_pre_get_invite_list', array('user_id' => $user_id, 'type' => 'alphabetical', 'per_page' => 0));
    // User has friends.
    if (bp_has_members($args)) {
        /**
         * Loop through all friends and try to add them to the invitation list.
         *
         * Exclude friends that:
         *     1. are already members of the group
         *     2. are banned from this group if the current user is also not a
         *        group admin.
         */
        while (bp_members()) {
            // Load the member.
            bp_the_member();
            // Get the user ID of the friend.
            $friend_user_id = bp_get_member_user_id();
            // Skip friend if already in the group.
            if (groups_is_user_member($friend_user_id, $group_id)) {
                continue;
            }
            // Skip friend if not group admin and user banned from group.
            if (false === $user_is_admin && groups_is_user_banned($friend_user_id, $group_id)) {
                continue;
            }
            // Friend is safe, so add it to the array of possible friends.
            $friends[] = array('id' => $friend_user_id, 'full_name' => bp_get_member_name());
        }
    }
    // If no friends, explicitly set to false.
    if (empty($friends)) {
        $friends = false;
    }
    /**
     * Filters the list of potential friends that can be invited to this group.
     *
     * @since 1.5.4
     *
     * @param array|bool $friends  Array friends available to invite or false for no friends.
     * @param int        $user_id  ID of the user checked for who they can invite.
     * @param int        $group_id ID of the group being checked on.
     */
    return apply_filters('bp_friends_get_invite_list', $friends, $user_id, $group_id);
}
示例#21
0
$output = $anim1 = '';
extract(shortcode_atts(array('type' => 'newest', 'number' => 12, 'perline' => '', 'animation' => '', 'rounded' => "", 'class' => ''), $atts));
$params = array('type' => $type, 'per_page' => $number);
if ($perline != '') {
    $class .= ' ' . $perline . '-thumbs';
}
if ($animation != '') {
    $anim1 = ' animate-when-almost-visible';
    $class .= ' kleo-thumbs-animated th-' . $animation;
}
if ($rounded == 'rounded') {
    $class .= ' rounded';
}
if (function_exists('bp_is_active')) {
    // begin bp members loop
    if (bp_has_members($params)) {
        $output .= '<div class="wpb_wrapper">';
        $output .= '<div class="kleo-gallery' . $anim1 . '">';
        $output .= '<div class="kleo-thumbs-images ' . $class . '">';
        while (bp_members()) {
            bp_the_member();
            $output .= '<a href="' . bp_get_member_permalink() . '" title="' . bp_get_member_name() . '">';
            $output .= bp_get_member_avatar(array('type' => 'full', 'width' => '250', 'height' => '250'));
            $output .= kleo_get_img_overlay();
            $output .= '</a>';
        }
        $output .= '</div>';
        $output .= '</div>';
        $output .= '</div>';
    }
} else {
示例#22
0
 /**
  * @group bp_get_member_profile_data
  */
 public function test_bp_get_member_profile_data_inside_loop()
 {
     $u = $this->factory->user->create();
     $g = $this->factory->xprofile_group->create();
     $f = $this->factory->xprofile_field->create(array('field_group_id' => $g, 'name' => 'Neato'));
     xprofile_set_field_data($f, $u, 'foo');
     if (bp_has_members()) {
         while (bp_members()) {
             bp_the_member();
             $found = bp_get_member_profile_data(array('user_id' => $u, 'field' => 'Neato'));
         }
     }
     // Cleanup
     unset($GLOBALS['members_template']);
     $this->assertSame('foo', $found);
 }
示例#23
0
        $post_class = "column dt-sc-one-half";
        break;
    case "one-third-column":
        $columns = 3;
        $post_class = "column dt-sc-one-third";
        break;
    case "one-fourth-column":
        $columns = 4;
        $post_class = "column dt-sc-one-fourth";
        break;
    default:
        $columns = 4;
        $post_class = "column dt-sc-one-fourth";
        break;
}
if (bp_has_members(bp_ajax_querystring('members') . '&per_page=' . $dt_per_page)) {
    $i = 1;
    ?>
	<?php 
    do_action('bp_before_directory_members_list');
    ?>
		<?php 
    while (bp_members()) {
        bp_the_member();
        $temp_class = "";
        if ($i == 1) {
            $temp_class = $post_class . " first";
        } else {
            $temp_class = $post_class;
        }
        if ($i == $columns) {
 protected function generate_html($template_type = '')
 {
     $group_ids = array();
     foreach ($this->search_results['items'] as $item_id => $item) {
         $group_ids[] = $item_id;
     }
     //now we have all the posts
     //lets do a groups loop
     if (bp_has_members(array('include' => $group_ids, 'per_page' => count($group_ids)))) {
         while (bp_members()) {
             bp_the_member();
             $result_item = array('id' => bp_get_member_user_id(), 'type' => $this->type, 'title' => bp_get_member_name(), 'html' => buddyboss_global_search_buffer_template_part('loop/member', $template_type, false));
             $this->search_results['items'][bp_get_member_user_id()] = $result_item;
         }
     }
 }
/**
 * Process AJAX pagination or filtering for the Friends widget.
 *
 * @since 1.9.0
 */
function bp_core_ajax_widget_friends()
{
    check_ajax_referer('bp_core_widget_friends');
    switch ($_POST['filter']) {
        case 'newest-friends':
            $type = 'newest';
            break;
        case 'recently-active-friends':
            $type = 'active';
            break;
        case 'popular-friends':
            $type = 'popular';
            break;
    }
    $members_args = array('user_id' => bp_displayed_user_id(), 'type' => $type, 'max' => absint($_POST['max-friends']), 'populate_extras' => 1);
    if (bp_has_members($members_args)) {
        ?>
		<?php 
        echo '0[[SPLIT]]';
        // Return valid result. TODO: remove this.
        ?>
		<?php 
        while (bp_members()) {
            bp_the_member();
            ?>
			<li class="vcard">
				<div class="item-avatar">
					<a href="<?php 
            bp_member_permalink();
            ?>
"><?php 
            bp_member_avatar();
            ?>
</a>
				</div>

				<div class="item">
					<div class="item-title fn"><a href="<?php 
            bp_member_permalink();
            ?>
" title="<?php 
            bp_member_name();
            ?>
"><?php 
            bp_member_name();
            ?>
</a></div>
					<?php 
            if ('active' == $type) {
                ?>
						<div class="item-meta"><span class="activity"><?php 
                bp_member_last_active();
                ?>
</span></div>
					<?php 
            } elseif ('newest' == $type) {
                ?>
						<div class="item-meta"><span class="activity"><?php 
                bp_member_registered();
                ?>
</span></div>
					<?php 
            } elseif (bp_is_active('friends')) {
                ?>
						<div class="item-meta"><span class="activity"><?php 
                bp_member_total_friend_count();
                ?>
</span></div>
					<?php 
            }
            ?>
				</div>
			</li>
		<?php 
        }
        ?>

	<?php 
    } else {
        ?>
		<?php 
        echo "-1[[SPLIT]]<li>";
        ?>
		<?php 
        _e('There were no members found, please try another filter.', 'buddypress');
        ?>
		<?php 
        echo "</li>";
        ?>
	<?php 
    }
}
示例#26
0
<?php

do_action('bp_before_member_friend_requests_content');
?>

<?php 
if (bp_has_members('type=alphabetical&include=' . bp_get_friendship_requests())) {
    ?>

	<div id="pag-top" class="pagination no-ajax">

		<div class="pag-count" id="member-dir-count-top">

			<?php 
    bp_members_pagination_count();
    ?>

		</div>

		<div class="pagination-links" id="member-dir-pag-top">

			<?php 
    bp_members_pagination_links();
    ?>

		</div>

	</div>

	<ul id="friend-list" class="item-list" role="main">
		<?php 
示例#27
0
 /**
  * @group friends_check_friendship_status
  */
 public function test_friends_check_friendship_status_in_members_loop()
 {
     $now = time();
     $u1 = $this->factory->user->create(array('last_activity' => date('Y-m-d H:i:s', $now)));
     $u2 = $this->factory->user->create(array('last_activity' => date('Y-m-d H:i:s', $now - 100)));
     $u3 = $this->factory->user->create(array('last_activity' => date('Y-m-d H:i:s', $now - 200)));
     $u4 = $this->factory->user->create(array('last_activity' => date('Y-m-d H:i:s', $now - 300)));
     $u5 = $this->factory->user->create(array('last_activity' => date('Y-m-d H:i:s', $now - 400)));
     friends_add_friend($u1, $u2, true);
     friends_add_friend($u1, $u3, false);
     friends_add_friend($u4, $u1, false);
     $old_user = get_current_user_id();
     $this->set_current_user($u1);
     $found = array();
     if (bp_has_members()) {
         while (bp_members()) {
             bp_the_member();
             $found[bp_get_member_user_id()] = friends_check_friendship_status($u1, bp_get_member_user_id());
         }
     }
     $expected = array($u1 => 'not_friends', $u2 => 'is_friend', $u3 => 'pending', $u4 => 'awaiting_response', $u5 => 'not_friends');
     $this->assertSame($expected, $found);
     // clean up
     $GLOBALS['members_template'] = null;
     $this->set_current_user($old_user);
 }
示例#28
0
    /**
     * Display the Recently Active widget.
     *
     * @see WP_Widget::widget() for description of parameters.
     *
     * @param array $args Widget arguments.
     * @param array $instance Widget settings, as saved by the user.
     */
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        echo $before_widget;
        echo $before_title . $title . $after_title;
        $members_args = array('user_id' => 0, 'type' => 'active', 'per_page' => $instance['max_members'], 'max' => $instance['max_members'], 'populate_extras' => true, 'search_terms' => false);
        ?>

		<?php 
        if (bp_has_members($members_args)) {
            ?>
			<div class="avatar-block">
				<?php 
            while (bp_members()) {
                bp_the_member();
                ?>
					<div class="item-avatar">
						<a href="<?php 
                bp_member_permalink();
                ?>
" title="<?php 
                bp_member_name();
                ?>
"><?php 
                bp_member_avatar();
                ?>
</a>
					</div>
				<?php 
            }
            ?>
			</div>
		<?php 
        } else {
            ?>

			<div class="widget-error">
				<?php 
            _e('There are no recently active members', 'buddypress');
            ?>
			</div>

		<?php 
        }
        ?>

		<?php 
        echo $after_widget;
        ?>
	<?php 
    }
<?php

if (bp_has_members("include={$_POST['userid']}&max=1")) {
    ?>

    <?php 
    while (bp_members()) {
        bp_the_member();
        global $members_template;
        ?>

        <?php 
        /* The loop for the member you're showing a hovercard for is set up. Place hovercard code here */
        ?>

        <div class="tipsy-avatar">
            <img src="<?php 
        echo bp_core_fetch_avatar(array('item_id' => bp_get_member_user_id(), 'type' => 'full', 'width' => 100, 'height' => 100, 'html' => false));
        ?>
">
        </div>

        <div class='tipsy-content'>

            <div class="user">

                <h3>
                    <?php 
        // iexpert_skype_status( xprofile_get_field_data( 'skype', bp_get_member_user_id() ) );
        ?>
示例#30
0
<?php

do_action('bp_before_member_friend_requests_content');
?>

<?php 
if (bp_has_members('include=' . bp_get_friendship_requests())) {
    ?>
	<div id="pag-top" class="pagination no-ajax">
		<div class="pag-count" id="member-dir-count-top">
			<?php 
    bp_members_pagination_count();
    ?>
		</div>
		<div class="pagination-links" id="member-dir-pag-top">
			<?php 
    bp_members_pagination_links();
    ?>
		</div>
	</div>

	<ul id="friend-list" class="item-list" role="main">
		<?php 
    while (bp_members()) {
        bp_the_member();
        ?>
			<li id="friendship-<?php 
        bp_friend_friendship_id();
        ?>
">
				<div class="item-avatar">