Changeset 2919
- Timestamp:
- 04/13/2010 04:01:07 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r2822 r2919 132 132 133 133 /* Get the fullnames of users so we don't have to query in the loop */ 134 if ( function_exists( 'xprofile_install' ) && $activities ) {134 if ( bp_is_active( 'xprofile' ) && $activities ) { 135 135 foreach ( (array)$activities as $activity ) { 136 136 if ( (int)$activity->user_id ) … … 354 354 if ( !$comments = wp_cache_get( 'bp_activity_comments_' . $activity_id ) ) { 355 355 /* Select the user's fullname with the query so we don't have to fetch it for each comment */ 356 if ( function_exists( 'xprofile_install' ) ) {356 if ( bp_is_active( 'xprofile' ) ) { 357 357 $fullname_select = ", pd.value as user_fullname"; 358 358 $fullname_from = ", {$bp->profile->table_name_data} pd "; -
trunk/bp-activity/bp-activity-templatetags.php
r2910 r2919 494 494 global $activities_template, $bp; 495 495 496 /* Strip any legacy time since placeholders -- TODO: Remove this in 1.3 */ 497 $content = str_replace( '<span class="time-since">%s</span>', '', $content ); 496 $meta = '<span class="activity-actions">'; 498 497 499 498 /* Insert the time since. */ 500 $ content .= ' ' .apply_filters( 'bp_activity_time_since', '<span class="time-since">' . sprintf( __( ' %s ago', 'buddypress' ), bp_core_time_since( $activities_template->activity->date_recorded ) ) . '</span>', &$activities_template->activity );499 $meta .= apply_filters( 'bp_activity_time_since', '<span class="time-since">' . sprintf( __( ' %s ago', 'buddypress' ), bp_core_time_since( $activities_template->activity->date_recorded ) ) . '</span>', &$activities_template->activity ); 501 500 502 501 /* Insert the permalink */ 503 $ content.= apply_filters( 'bp_activity_permalink', ' · <a href="' . bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . '" class="view" title="' . __( 'View Thread / Permalink', 'buddypress' ) . '">' . __( 'View', 'buddypress' ) . '</a>', &$activities_template->activity );502 $meta .= apply_filters( 'bp_activity_permalink', ' · <a href="' . bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . '" class="view" title="' . __( 'View Thread / Permalink', 'buddypress' ) . '">' . __( 'View', 'buddypress' ) . '</a>', &$activities_template->activity ); 504 503 505 504 /* Add the delete link if the user has permission on this item */ 506 505 if ( ( is_user_logged_in() && $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || $bp->loggedin_user->is_site_admin ) 507 $content .= apply_filters( 'bp_activity_delete_link', ' · ' . bp_get_activity_delete_link(), &$activities_template->activity ); 508 509 return apply_filters( 'bp_insert_activity_meta', $content ); 506 $meta .= apply_filters( 'bp_activity_delete_link', ' · ' . bp_get_activity_delete_link(), &$activities_template->activity ); 507 508 $meta .= '</span>'; 509 510 return apply_filters( 'bp_insert_activity_meta', $content . ' ' . $meta, $content, $meta ); 510 511 } 511 512 -
trunk/bp-core.php
r2864 r2919 298 298 * built in WordPress profile information 299 299 */ 300 if ( ! function_exists( 'xprofile_install' ) ) {300 if ( !bp_is_active( 'xprofile' ) ) { 301 301 /* Fallback values if xprofile is disabled */ 302 302 $bp->core->profile->slug = 'profile'; … … 1077 1077 1078 1078 if ( !$fullname = wp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' ) ) { 1079 if ( function_exists('xprofile_install') ) {1079 if ( bp_is_active( 'xprofile' ) ) { 1080 1080 $fullname = xprofile_get_field_data( 1, $user_id ); 1081 1081 … … 1267 1267 @setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH ); 1268 1268 } 1269 add_action( ' wp', 'bp_core_setup_message' );1269 add_action( 'bp_init', 'bp_core_setup_message' ); 1270 1270 1271 1271 /** -
trunk/bp-core/admin/bp-core-admin.php
r2863 r2919 33 33 foreach ( (array)$_POST['bp-admin'] as $key => $value ) { 34 34 35 if ( function_exists( 'xprofile_install' ) ) {35 if ( bp_is_active( 'xprofile' ) ) { 36 36 if ( 'bp-xprofile-base-group-name' == $key ) { 37 37 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s WHERE id = 1", $value ) ); … … 62 62 <table class="form-table"> 63 63 <tbody> 64 <?php if ( function_exists( 'xprofile_install' ) ) :?>64 <?php if ( is_active( 'xprofile' ) ) :?> 65 65 <tr> 66 66 <th scope="row"><?php _e( 'Base profile group name', 'buddypress' ) ?>:</th> … … 113 113 </tr> 114 114 <?php endif; ?> 115 <?php if ( function_exists( 'bp_activity_install') ) : ?>115 <?php if ( bp_is_active( 'activity' ) ) : ?> 116 116 <tr> 117 117 <th scope="row"><?php _e( 'Disable activity stream commenting on blog and forum posts?', 'buddypress' ) ?>:</th> -
trunk/bp-core/bp-core-adminbar.php
r2863 r2919 224 224 <li><a href="<?php echo $bp->root_domain . '/' . $bp->members->slug . '/?random-member' ?>"><?php _e( 'Random Member', 'buddypress' ) ?></a></li> 225 225 226 <?php if ( function_exists('groups_install') ) : ?>226 <?php if ( bp_is_active( 'groups' ) ) : ?> 227 227 <li class="alt"><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug . '/?random-group' ?>"><?php _e( 'Random Group', 'buddypress' ) ?></a></li> 228 228 <?php endif; ?> 229 229 230 <?php if ( function_exists('bp_blogs_install') && bp_core_is_multisite() ) : ?>230 <?php if ( bp_is_active( 'blogs' ) && bp_core_is_multisite() ) : ?> 231 231 <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li> 232 232 -
trunk/bp-core/bp-core-catchuri.php
r2865 r2919 256 256 global $bp; 257 257 258 if ( ! function_exists('xprofile_install') )258 if ( !bp_is_active( 'xprofile' ) ) 259 259 bp_core_load_template( apply_filters( 'bp_core_template_display_profile', 'members/single/home' ) ); 260 260 } -
trunk/bp-core/bp-core-classes.php
r2695 r2919 56 56 */ 57 57 function populate() { 58 if ( function_exists( 'xprofile_install' ) )58 if ( bp_is_active( 'xprofile' ) ) 59 59 $this->profile_data = $this->get_profile_data(); 60 60 … … 86 86 global $bp; 87 87 88 if ( function_exists('friends_install') )88 if ( bp_is_active( 'friends' ) ) 89 89 $this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id ); 90 90 91 if ( function_exists('groups_install') ) {91 if ( bp_is_active( 'groups' ) ) { 92 92 $this->total_groups = BP_Groups_Member::total_group_count( $this->id ); 93 93 … … 125 125 $sql['from'] = "FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN " . CUSTOM_USER_META_TABLE . " um ON um.user_id = u.ID"; 126 126 127 if ( $search_terms && function_exists( 'xprofile_install' ) || 'alphabetical' == $type )127 if ( $search_terms && bp_is_active( 'xprofile' ) || 'alphabetical' == $type ) 128 128 $sql['join_profiledata'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id"; 129 129 … … 142 142 $sql['where_alpha'] = "AND pd.field_id = 1"; 143 143 144 if ( $user_id && function_exists( 'friends_install' ) ) {144 if ( $user_id && bp_is_active( 'friends' ) ) { 145 145 $friend_ids = friends_get_friend_user_ids( $user_id ); 146 146 $friend_ids = $wpdb->escape( implode( ',', (array)$friend_ids ) ); … … 154 154 } 155 155 156 if ( $search_terms && function_exists( 'xprofile_install' ) ) {156 if ( $search_terms && bp_is_active( 'xprofile' ) ) { 157 157 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 158 158 $sql['where_searchterms'] = "AND pd.value LIKE '%%$search_terms%%'"; … … 320 320 321 321 /* Fetch the user's full name */ 322 if ( function_exists( 'xprofile_install' ) && 'alphabetical' != $type ) {322 if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) { 323 323 $names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", BP_XPROFILE_FULLNAME_FIELD_NAME ) ); 324 324 for ( $i = 0; $i < count( $paged_users ); $i++ ) { … … 342 342 343 343 /* Fetch whether or not the user is a friend */ 344 if ( function_exists( 'friends_install' ) ) {344 if ( bp_is_active( 'friends' ) ) { 345 345 $friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", $bp->loggedin_user->id, $bp->loggedin_user->id ) ); 346 346 for ( $i = 0; $i < count( $paged_users ); $i++ ) { … … 381 381 } 382 382 } 383 384 var_dump( $paged_users ); 383 385 384 386 return $paged_users; -
trunk/bp-core/bp-core-templatetags.php
r2907 r2919 248 248 function bp_get_member_name() { 249 249 global $members_template; 250 251 var_dump( $members_template ); 250 252 251 253 if ( empty($members_template->member->fullname) ) … … 688 690 } 689 691 690 function bp_user_firstname( ) {691 echo bp_get_user_firstname( );692 function bp_user_firstname( $name = false ) { 693 echo bp_get_user_firstname( $name ); 692 694 } 693 695 function bp_get_user_firstname( $name = false ) { … … 989 991 function bp_search_form_type_select() { 990 992 global $bp; 991 993 992 994 // Eventually this won't be needed and a page will be built to integrate all search results. 993 995 $selection_box = '<select name="search-which" id="search-which" style="width: auto">'; -
trunk/bp-forums.php
r2863 r2919 356 356 357 357 /* Fetch fullname for the topic's last poster */ 358 if ( function_exists( 'xprofile_install' ) ) {358 if ( bp_is_active( 'xprofile' ) ) { 359 359 $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, pd.value FROM {$bp->profile->table_name_data} pd, {$bbdb->topics} t WHERE pd.user_id = t.topic_last_poster AND pd.field_id = 1 AND t.topic_id IN ( {$topic_ids} )" ) ); 360 360 for ( $i = 0; $i < count( $topics ); $i++ ) { … … 474 474 475 475 /* Fetch fullname for each poster. */ 476 if ( function_exists( 'xprofile_install' ) ) {476 if ( bp_is_active( 'xprofile' ) ) { 477 477 $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id, pd.value FROM {$bp->profile->table_name_data} pd WHERE pd.user_id IN ( {$user_ids} )" ) ); 478 478 for ( $i = 0; $i < count( $posts ); $i++ ) { -
trunk/bp-friends/bp-friends-classes.php
r2362 r2919 157 157 158 158 // filter the user_ids based on the search criteria. 159 if ( function_exists('xprofile_install') ) {159 if ( bp_is_active( 'xprofile' ) ) { 160 160 $sql = "SELECT DISTINCT user_id FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%' {$pag_sql}"; 161 161 $total_sql = "SELECT COUNT(DISTINCT user_id) FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%'"; … … 223 223 224 224 // filter the user_ids based on the search criteria. 225 if ( function_exists('xprofile_install') ) {225 if ( bp_is_active( 'xprofile' ) ) { 226 226 $sql = $wpdb->prepare( "SELECT DISTINCT d.user_id as id FROM {$bp->profile->table_name_data} d, $users_table u WHERE d.user_id = u.id AND d.value LIKE '$filter%%' ORDER BY d.value DESC $pag_sql" ); 227 227 } else { … … 246 246 247 247 // filter the user_ids based on the search criteria. 248 if ( function_exists('xprofile_install') ) {248 if ( bp_is_active( 'xprofile' ) ) { 249 249 $sql = $wpdb->prepare( "SELECT COUNT(DISTINCT d.user_id) FROM {$bp->profile->table_name_data} d, $users_table u WHERE d.user_id = u.id AND d.value LIKE '$filter%%'" ); 250 250 } else { … … 263 263 global $wpdb, $bp; 264 264 265 if ( ! function_exists( 'xprofile_install') )265 if ( !bp_is_active( 'xprofile' ) ) 266 266 return false; 267 267 -
trunk/bp-groups.php
r2866 r2919 1658 1658 'type' => 'active', // active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts 1659 1659 'user_id' => false, // Pass a user_id to limit to only groups that this user is a member of 1660 'include' => false, // Only include these specific groups (group_ids) 1660 1661 'search_terms' => false, // Limit to groups that match these search terms 1661 1662 … … 1668 1669 extract( $params, EXTR_SKIP ); 1669 1670 1670 switch ( $type ) { 1671 case 'active': default: 1672 $groups = BP_Groups_Group::get_active( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1673 break; 1674 case 'newest': 1675 $groups = BP_Groups_Group::get_newest( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1676 break; 1677 case 'popular': 1678 $groups = BP_Groups_Group::get_popular( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1679 break; 1680 case 'alphabetical': 1681 $groups = BP_Groups_Group::get_alphabetically( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1682 break; 1683 case 'random': 1684 $groups = BP_Groups_Group::get_random( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1685 break; 1686 case 'most-forum-topics': 1687 $groups = BP_Groups_Group::get_by_most_forum_topics( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1688 break; 1689 case 'most-forum-posts': 1690 $groups = BP_Groups_Group::get_by_most_forum_posts( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1691 break; 1692 } 1671 $groups = BP_Groups_Group::get( $type, $per_page, $page, $user_id, $search_terms, $include, $populate_extras ); 1693 1672 1694 1673 return apply_filters( 'groups_get_groups', $groups, &$params ); -
trunk/bp-groups/bp-groups-classes.php
r2770 r2919 256 256 } 257 257 258 /* TODO: Merge all these get_() functions into one. */ 259 260 function get_newest( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) { 261 global $wpdb, $bp; 262 263 if ( $limit && $page ) 264 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 258 function get( $type = 'newest', $per_page = null, $page = null, $user_id = false, $search_terms = false, $include = false, $populate_extras = true ) { 259 global $wpdb, $bp; 260 261 $sql = array(); 262 263 $sql['select'] = "SELECT g.*, gm1.meta_value AS total_member_count, gm2.meta_value AS last_activity"; 264 $sql['from'] = " FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2,"; 265 266 if ( !empty( $user_id ) ) 267 $sql['members_from'] = " {$bp->groups->table_name_members} m,"; 268 269 $sql['group_from'] = " {$bp->groups->table_name} g WHERE"; 270 271 if ( !empty( $user_id ) ) 272 $sql['user_where'] = " g.id = m.group_id AND"; 273 274 $sql['where'] = " g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'"; 265 275 266 276 if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) 267 $ hidden_sql = "AND g.status != 'hidden'";277 $sql['hidden'] = " AND g.status != 'hidden'"; 268 278 269 279 if ( $search_terms ) { 270 280 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 271 $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 272 } 273 274 if ( $user_id ) { 275 $user_id = $wpdb->escape( $user_id ); 276 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY g.date_created DESC {$pag_sql}" ); 277 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" ); 278 } else { 279 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY g.date_created DESC {$pag_sql}" ); 280 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" ); 281 } 282 281 $sql['search'] = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 282 } 283 284 if ( !empty( $user_id ) ) 285 $sql['user'] = $wpdb->prepare( " AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $user_id ); 286 287 if ( !empty( $include ) ) { 288 $include = $wpdb->escape( $include ); 289 $sql['include'] = " AND g.id IN ({$include})"; 290 } 291 292 switch ( $type ) { 293 case 'newest': default: 294 $sql['order'] = " ORDER BY g.date_created DESC"; 295 break; 296 case 'active': 297 $sql[] = "ORDER BY last_activity DESC"; 298 break; 299 case 'popular': 300 $sql[] = "ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC"; 301 break; 302 case 'alphabetical': 303 $sql[] = "ORDER BY g.name ASC"; 304 break; 305 case 'random': 306 $sql[] = "ORDER BY rand()"; 307 break; 308 } 309 310 if ( $per_page && $page ) 311 $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page), intval( $per_page ) ); 312 313 /* Get paginated results */ 314 $paged_groups = $wpdb->get_results( join( ' ', (array)$sql ) ); 315 316 $total_sql['select'] = "SELECT COUNT(g.id) FROM {$bp->groups->table_name} g"; 317 318 if ( !empty( $user_id ) ) 319 $total_sql['select'] .= ", {$bp->groups->table_name_members} m"; 320 321 if ( !empty( $sql['hidden'] ) ) 322 $total_sql['where'][] = "g.status != 'hidden'"; 323 324 if ( !empty( $sql['search'] ) ) 325 $total_sql['where'][] = "( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 326 327 if ( !empty( $user_id ) ) 328 $total_sql['where'][] = "m.group_id = g.id AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0"; 329 330 $t_sql = $total_sql['select']; 331 332 if ( !empty( $total_sql['where'] ) ) 333 $t_sql .= " WHERE " . join( ' AND ', (array)$total_sql['where'] ); 334 335 /* Get total group results */ 336 $total_groups = $wpdb->get_var( join( ' ', (array)$t_sql ) ); 337 338 /* Populate some extra information instead of querying each time in the loop */ 283 339 if ( !empty( $populate_extras ) ) { 284 340 foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id; 285 341 $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) ); 286 $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' ); 287 } 288 289 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 290 } 291 292 function get_active( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) { 293 global $wpdb, $bp; 294 295 if ( $limit && $page ) 296 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 297 298 if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) 299 $hidden_sql = "AND g.status != 'hidden'"; 300 301 if ( $search_terms ) { 302 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 303 $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 304 } 305 306 if ( $user_id ) { 307 $user_id = $wpdb->escape( $user_id ); 308 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY last_activity DESC {$pag_sql}" ); 309 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" ); 310 } else { 311 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY last_activity DESC {$pag_sql}" ); 312 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" ); 313 } 314 315 if ( !empty( $populate_extras ) ) { 316 foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id; 317 $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) ); 318 $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' ); 319 } 320 321 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 322 } 323 324 function get_popular( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) { 325 global $wpdb, $bp; 326 327 if ( $limit && $page ) { 328 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 329 } 330 331 if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) 332 $hidden_sql = "AND g.status != 'hidden'"; 333 334 if ( $search_terms ) { 335 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 336 $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 337 } 338 339 if ( $user_id ) { 340 $user_id = $wpdb->escape( $user_id ); 341 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC {$pag_sql}" ); 342 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" ); 343 } else { 344 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC {$pag_sql}" ); 345 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql}" ); 346 } 347 348 if ( !empty( $populate_extras ) ) { 349 foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id; 350 $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) ); 351 $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' ); 352 } 353 354 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 355 } 356 357 function get_alphabetically( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) { 358 global $wpdb, $bp; 359 360 if ( $limit && $page ) 361 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 362 363 if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) 364 $hidden_sql = " AND g.status != 'hidden'"; 365 366 if ( $search_terms ) { 367 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 368 $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 369 } 370 371 if ( $user_id ) { 372 $user_id = $wpdb->escape( $user_id ); 373 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}" ); 374 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" ); 375 } else { 376 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY g.name ASC {$pag_sql}" ); 377 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql}" ); 378 } 379 380 if ( !empty( $populate_extras ) ) { 381 foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id; 382 $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) ); 383 $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' ); 384 } 342 $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, $type ); 343 } 344 345 unset( $sql, $total_sql ); 385 346 386 347 return array( 'groups' => $paged_groups, 'total' => $total_groups ); … … 459 420 } 460 421 461 function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false ) {462 global $wpdb, $bp;463 464 // Default sql WHERE conditions are blank. TODO: generic handler function.465 $where_sql = null;466 $where_conditions = array();467 468 // Limit results to public status469 if ( $only_public )470 $where_conditions[] = $wpdb->prepare( "g.status = 'public'" );471 472 if ( !is_site_admin() )473 $where_conditions[] = $wpdb->prepare( "g.status != 'hidden'");474 475 // Build where sql statement if necessary476 if ( !empty( $where_conditions ) )477 $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );478 479 if ( $limit && $page )480 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );481 482 if ( $sort_by && $order ) {483 $sort_by = $wpdb->escape( $sort_by );484 $order = $wpdb->escape( $order );485 $order_sql = "ORDER BY g.$sort_by $order";486 487 switch ( $sort_by ) {488 default:489 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$where_sql} {$order_sql} {$pag_sql}" );490 break;491 case 'members':492 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'total_member_count' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" );493 break;494 case 'last_active':495 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'last_activity' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" );496 break;497 }498 } else {499 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$where_sql} {$order_sql} {$pag_sql}" );500 }501 502 return $wpdb->get_results($sql);503 }504 505 422 function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true ) { 506 423 global $wpdb, $bp; … … 520 437 521 438 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE '$letter%%' {$hidden_sql} {$search_sql} ORDER BY g.name ASC {$pag_sql}" ) ); 522 523 if ( !empty( $populate_extras ) ) {524 foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;525 $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );526 $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );527 }528 529 return array( 'groups' => $paged_groups, 'total' => $total_groups );530 }531 532 function get_random( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {533 global $wpdb, $bp;534 535 if ( $limit && $page )536 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );537 538 if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )539 $hidden_sql = "AND g.status != 'hidden'";540 541 if ( $search_terms ) {542 $search_terms = like_escape( $wpdb->escape( $search_terms ) );543 $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";544 }545 546 if ( $user_id ) {547 $user_id = $wpdb->escape( $user_id );548 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() {$pag_sql}" );549 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" );550 } else {551 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY rand() {$pag_sql}" );552 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" );553 }554 439 555 440 if ( !empty( $populate_extras ) ) { … … 1013 898 $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) ); 1014 899 1015 if ( function_exists( 'friends_install' ) ) {900 if ( bp_is_active( 'friends' ) ) { 1016 901 $friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", $bp->loggedin_user->id, $bp->loggedin_user->id ) ); 1017 902 for ( $i = 0; $i < count( $members ); $i++ ) { … … 1103 988 global $bp; 1104 989 990 /* When we are viewing a single group, add the group extension nav item */ 991 if ( $this->visbility == 'public' || ( $this->visbility != 'public' && $bp->groups->current_group->user_has_access ) ) { 992 if ( $this->enable_nav_item ) { 993 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item ) 994 bp_core_new_subnav_item( array( 'name' => ( !$this->nav_item_name ) ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => BP_GROUPS_SLUG, 'parent_url' => bp_get_group_permalink( $bp->groups->current_group ), 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array( &$this, '_display_hook' ), 'user_has_access' => $this->enable_nav_item ) ); 995 996 /* When we are viewing the extension display page, set the title and options title */ 997 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && $bp->current_action == $this->slug ) { 998 add_action( 'bp_template_content_header', create_function( '', 'echo "' . attribute_escape( $this->name ) . '";' ) ); 999 add_action( 'bp_template_title', create_function( '', 'echo "' . attribute_escape( $this->name ) . '";' ) ); 1000 } 1001 } 1002 1003 /* Hook the group home widget */ 1004 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) ) 1005 add_action( $this->display_hook, array( &$this, 'widget_display' ) ); 1006 } 1007 1105 1008 if ( $this->enable_create_step ) { 1106 1009 /* Insert the group creation step for the new group extension */ … … 1120 1023 /* Catch the edit screen and forward it to the plugin template */ 1121 1024 if ( $bp->current_component == $bp->groups->slug && 'admin' == $bp->current_action && $this->slug == $bp->action_variables[0] ) { 1122 add_action( 'wp', array( &$this, 'edit_screen_save' ));1025 $this->edit_screen_save(); 1123 1026 add_action( 'groups_custom_edit_steps', array( &$this, 'edit_screen' ) ); 1124 1027 … … 1132 1035 } 1133 1036 } 1134 1135 /* When we are viewing a single group, add the group extension nav item */1136 if ( $this->visbility == 'public' || ( $this->visbility != 'public' && $bp->groups->current_group->user_has_access ) ) {1137 if ( $this->enable_nav_item ) {1138 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item )1139 bp_core_new_subnav_item( array( 'name' => ( !$this->nav_item_name ) ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => BP_GROUPS_SLUG, 'parent_url' => bp_get_group_permalink( $bp->groups->current_group ), 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array( &$this, '_display_hook' ), 'user_has_access' => $this->enable_nav_item ) );1140 1141 /* When we are viewing the extension display page, set the title and options title */1142 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && $bp->current_action == $this->slug ) {1143 add_action( 'bp_template_content_header', create_function( '', 'echo "' . attribute_escape( $this->name ) . '";' ) );1144 add_action( 'bp_template_title', create_function( '', 'echo "' . attribute_escape( $this->name ) . '";' ) );1145 }1146 }1147 1148 /* Hook the group home widget */1149 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )1150 add_action( $this->display_hook, array( &$this, 'widget_display' ) );1151 }1152 1037 } 1153 1038 … … 1165 1050 1166 1051 /* Register the group extension on the plugins_loaded action so we have access to all plugins */ 1167 add_action( ' bp_init', create_function( '', '$extension = new ' . $group_extension_class . '; add_action( "wp", array( &$extension, "_register" ), 2 );' ), 11);1052 add_action( 'init', create_function( '', '$extension = new ' . $group_extension_class . '; add_action( "pre_get_posts", array( &$extension, "_register" ) );' ) ); 1168 1053 } 1169 1054 -
trunk/bp-groups/bp-groups-templatetags.php
r2770 r2919 23 23 var $order; 24 24 25 function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $ populate_extras ) {25 function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $include, $populate_extras ) { 26 26 global $bp; 27 27 … … 36 36 $this->groups = array( $group ); 37 37 } else 38 $this->groups = groups_get_groups( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) );38 $this->groups = groups_get_groups( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'include' => $include, 'populate_extras' => $populate_extras ) ); 39 39 40 40 if ( 'invites' == $type ) { … … 169 169 'slug' => $slug, // Pass a group slug to only return that group 170 170 'search_terms' => $search_terms, // Pass search terms to return only matching groups 171 'include' => false, // Pass comma separated list of group ID's to return only these groups 171 172 172 173 'populate_extras' => true // Get extra meta - is_member, is_banned … … 176 177 extract( $r ); 177 178 178 $groups_template = new BP_Groups_Template( (int)$user_id, $type, (int)$page, (int)$per_page, (int)$max, $slug, $search_terms, (bool)$populate_extras );179 $groups_template = new BP_Groups_Template( (int)$user_id, $type, (int)$page, (int)$per_page, (int)$max, $slug, $search_terms, $include, (bool)$populate_extras ); 179 180 return apply_filters( 'bp_has_groups', $groups_template->has_groups(), &$groups_template ); 180 181 } … … 726 727 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 727 728 728 <?php if ( function_exists( 'friends_install' ) ) : ?>729 <?php if ( bp_is_active( 'friends' ) ) : ?> 729 730 <div class="action"> 730 731 <?php bp_add_friend_button( $admin->user_id ) ?> … … 764 765 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 765 766 766 <?php if ( function_exists( 'friends_install' ) ) : ?>767 <?php if ( bp_is_active( 'friends' ) ) : ?> 767 768 <div class="action"> 768 769 <?php bp_add_friend_button( $mod->user_id ) ?> … … 1034 1035 global $groups_template, $bp; 1035 1036 1036 if ( ! function_exists('friends_install') )1037 if ( !bp_is_active( 'friends' ) ) 1037 1038 return false; 1038 1039 … … 1047 1048 1048 1049 function bp_group_join_button( $group = false ) { 1049 global $bp, $groups_template; 1050 1051 if ( !$group ) 1052 $group =& $groups_template->group; 1053 1054 // If they're not logged in or are banned from the group, no join button. 1055 if ( !is_user_logged_in() || $group->is_banned ) 1056 return false; 1057 1058 if ( !$group->status ) 1059 return false; 1060 1061 if ( 'hidden' == $group->status && !$group->is_member ) 1062 return false; 1063 1064 echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">'; 1065 1066 switch ( $group->status ) { 1067 case 'public': 1068 if ( $group->is_member ) 1069 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1070 else 1071 echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>'; 1072 break; 1073 1074 case 'private': 1075 if ( $group->is_member ) { 1076 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1077 } else { 1078 if ( !bp_group_has_requested_membership( $group ) ) 1079 echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>'; 1050 echo bp_get_group_join_button( $group ); 1051 } 1052 function bp_get_group_join_button( $group = false ) { 1053 global $bp, $groups_template; 1054 1055 if ( !$group ) 1056 $group =& $groups_template->group; 1057 1058 // If they're not logged in or are banned from the group, no join button. 1059 if ( !is_user_logged_in() || $group->is_banned ) 1060 return false; 1061 1062 if ( !$group->status ) 1063 return false; 1064 1065 if ( 'hidden' == $group->status && !$group->is_member ) 1066 return false; 1067 1068 $button = '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">'; 1069 1070 switch ( $group->status ) { 1071 case 'public': 1072 if ( $group->is_member ) 1073 $button .= '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1080 1074 else 1081 echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>'; 1082 } 1083 break; 1084 1085 case 'hidden': 1086 if ( $group->is_member ) 1087 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1088 break; 1089 } 1090 1091 echo '</div>'; 1092 } 1075 $button .= '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>'; 1076 break; 1077 1078 case 'private': 1079 if ( $group->is_member ) { 1080 $button .= '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1081 } else { 1082 if ( !bp_group_has_requested_membership( $group ) ) 1083 $button .= '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>'; 1084 else 1085 $button .= '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>'; 1086 } 1087 break; 1088 1089 case 'hidden': 1090 if ( $group->is_member ) 1091 $button .= '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1092 break; 1093 } 1094 1095 $button .= '</div>'; 1096 1097 return apply_filters( 'bp_get_group_join_button', $button ); 1098 } 1093 1099 1094 1100 function bp_group_status_message( $group = false ) { … … 1640 1646 global $bp; 1641 1647 1642 if ( ! function_exists('friends_install') )1648 if ( !bp_is_active( 'friends' ) ) 1643 1649 return false; 1644 1650
Note: See TracChangeset
for help on using the changeset viewer.