Beispiel #1
0
function groups_get_active($limit = null, $page = 1)
{
    return BP_Groups_Group::get_active($limit, $page);
}
Beispiel #2
0
function groups_get_groups( $args = '' ) {
	global $bp;

	$defaults = array(
		'type' => 'active', // active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts
		'user_id' => false, // Pass a user_id to limit to only groups that this user is a member of
		'search_terms' => false, // Limit to groups that match these search terms

		'per_page' => 20, // The number of results to return per page
		'page' => 1, // The page to return if limiting per page
		'populate_extras' => true, // Fetch meta such as is_banned and is_member
	);

	$params = wp_parse_args( $args, $defaults );
	extract( $params, EXTR_SKIP );

	switch ( $type ) {
		case 'active': default:
			$groups = BP_Groups_Group::get_active( $per_page, $page, $user_id, $search_terms, $populate_extras );
			break;
		case 'newest':
			$groups = BP_Groups_Group::get_newest( $per_page, $page, $user_id, $search_terms, $populate_extras );
			break;
		case 'popular':
			$groups = BP_Groups_Group::get_popular( $per_page, $page, $user_id, $search_terms, $populate_extras );
			break;
		case 'alphabetical':
			$groups = BP_Groups_Group::get_alphabetically( $per_page, $page, $user_id, $search_terms, $populate_extras );
			break;
		case 'random':
			$groups = BP_Groups_Group::get_random( $per_page, $page, $user_id, $search_terms, $populate_extras );
			break;
		case 'most-forum-topics':
			$groups = BP_Groups_Group::get_by_most_forum_topics( $per_page, $page, $user_id, $search_terms, $populate_extras );
			break;
		case 'most-forum-posts':
			$groups = BP_Groups_Group::get_by_most_forum_posts( $per_page, $page, $user_id, $search_terms, $populate_extras );
			break;
	}

	return apply_filters( 'groups_get_groups', $groups, &$params );
}
 function bp_groups_site_groups_template($type, $per_page, $max)
 {
     global $bp;
     $this->pag_page = isset($_REQUEST['gpage']) ? intval($_REQUEST['gpage']) : 1;
     $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page;
     if (isset($_REQUEST['s']) && '' != $_REQUEST['s'] && $type != 'random') {
         $this->groups = BP_Groups_Group::search_groups($_REQUEST['s'], $this->pag_num, $this->pag_page);
     } else {
         if (isset($_REQUEST['letter']) && '' != $_REQUEST['letter']) {
             $this->groups = BP_Groups_Group::get_by_letter($_REQUEST['letter'], $this->pag_num, $this->pag_page);
         } else {
             switch ($type) {
                 case 'random':
                     $this->groups = BP_Groups_Group::get_random($this->pag_num, $this->pag_page);
                     break;
                 case 'newest':
                     $this->groups = BP_Groups_Group::get_newest($this->pag_num, $this->pag_page);
                     break;
                 case 'popular':
                     $this->groups = BP_Groups_Group::get_popular($this->pag_num, $this->pag_page);
                     break;
                 case 'active':
                 default:
                     $this->groups = BP_Groups_Group::get_active($this->pag_num, $this->pag_page);
                     break;
             }
         }
     }
     if (!$max) {
         $this->total_group_count = (int) $this->groups['total'];
     } else {
         $this->total_group_count = (int) $max;
     }
     $this->groups = $this->groups['groups'];
     if ($max) {
         if ($max >= count($this->groups)) {
             $this->group_count = count($this->groups);
         } else {
             $this->group_count = (int) $max;
         }
     } else {
         $this->group_count = count($this->groups);
     }
     $this->pag_links = paginate_links(array('base' => add_query_arg('gpage', '%#%'), 'format' => '', 'total' => ceil((int) $this->total_group_count / (int) $this->pag_num), 'current' => (int) $this->pag_page, 'prev_text' => '«', 'next_text' => '»', 'mid_size' => 1));
 }