Changeset 2077 for trunk/bp-groups/bp-groups-templatetags.php
- Timestamp:
- 11/02/2009 07:54:21 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-templatetags.php
r2055 r2077 9 9 <li<?php if ( 'admin-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/admin-of""><?php _e( 'Administrator Of', 'buddypress' ) ?></a></li> 10 10 <li<?php if ( 'mod-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/mod-of""><?php _e( 'Moderator Of', 'buddypress' ) ?></a></li> 11 <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li> 11 <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li> 12 12 <?php 13 13 do_action( 'groups_header_tabs' ); … … 16 16 function bp_groups_filter_title() { 17 17 global $bp; 18 18 19 19 $current_filter = $bp->action_variables[0]; 20 20 21 21 switch ( $current_filter ) { 22 22 case 'recently-active': default: … … 44 44 function bp_is_group_admin_screen( $slug ) { 45 45 global $bp; 46 46 47 47 if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action ) 48 48 return false; 49 49 50 50 if ( $bp->action_variables[0] == $slug ) 51 51 return true; 52 52 53 53 return false; 54 54 } … … 56 56 function bp_group_current_avatar() { 57 57 global $bp; 58 58 59 59 if ( $bp->groups->current_group->avatar_full ) { ?> 60 60 <img src="<?php echo attribute_escape( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" /> … … 70 70 if ( !empty( $_FILES ) || !bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'no_grav' => true ) ) ) 71 71 return false; 72 72 73 73 return true; 74 74 } … … 79 79 function bp_get_group_avatar_delete_link() { 80 80 global $bp; 81 81 82 82 return apply_filters( 'bp_get_group_avatar_delete_link', wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-avatar/delete', 'bp_group_avatar_delete' ) ); 83 83 } … … 113 113 var $groups; 114 114 var $group; 115 115 116 116 var $in_the_loop; 117 117 118 118 var $pag_page; 119 119 var $pag_num; 120 120 var $pag_links; 121 121 var $total_group_count; 122 122 123 123 var $single_group = false; 124 124 125 125 var $sort_by; 126 126 var $order; 127 127 128 128 function bp_groups_user_groups_template( $user_id, $type, $per_page, $max, $slug, $filter ) { 129 129 global $bp; 130 130 131 131 if ( !$user_id ) 132 132 $user_id = $bp->displayed_user->id; 133 133 134 134 $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : 1; 135 135 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; … … 141 141 142 142 case 'popular': 143 $this->groups = groups_get_most_popular_for_user( $user_id, $this->pag_num, $this->pag_page, $filter ); 143 $this->groups = groups_get_most_popular_for_user( $user_id, $this->pag_num, $this->pag_page, $filter ); 144 144 break; 145 145 146 146 case 'admin-of': 147 $this->groups = groups_get_user_is_admin_of( $user_id, $this->pag_num, $this->pag_page, $filter ); 148 break; 147 $this->groups = groups_get_user_is_admin_of( $user_id, $this->pag_num, $this->pag_page, $filter ); 148 break; 149 149 150 150 case 'mod-of': 151 $this->groups = groups_get_user_is_mod_of( $user_id, $this->pag_num, $this->pag_page, $filter ); 151 $this->groups = groups_get_user_is_mod_of( $user_id, $this->pag_num, $this->pag_page, $filter ); 152 152 break; 153 153 154 154 case 'alphabetical': 155 $this->groups = groups_get_alphabetically_for_user( $user_id, $this->pag_num, $this->pag_page, $filter ); 155 $this->groups = groups_get_alphabetically_for_user( $user_id, $this->pag_num, $this->pag_page, $filter ); 156 156 break; 157 157 … … 162 162 case 'single-group': 163 163 $group = new stdClass; 164 $group->group_id = BP_Groups_Group::get_id_from_slug($slug); 164 $group->group_id = BP_Groups_Group::get_id_from_slug($slug); 165 165 $this->groups = array( $group ); 166 166 break; … … 170 170 break; 171 171 } 172 172 173 173 if ( 'invites' == $type ) { 174 174 $this->total_group_count = count($this->groups); … … 210 210 if ( $this->group_count ) 211 211 return true; 212 212 213 213 return false; 214 214 } 215 215 216 216 function next_group() { 217 217 $this->current_group++; 218 218 $this->group = $this->groups[$this->current_group]; 219 219 220 220 return $this->group; 221 221 } 222 222 223 223 function rewind_groups() { 224 224 $this->current_group = -1; … … 227 227 } 228 228 } 229 230 function user_groups() { 229 230 function user_groups() { 231 231 if ( $this->current_group + 1 < $this->group_count ) { 232 232 return true; … … 240 240 return false; 241 241 } 242 242 243 243 function the_group() { 244 244 global $group; … … 246 246 $this->in_the_loop = true; 247 247 $this->group = $this->next_group(); 248 248 249 249 // If this is a single group then instantiate group meta when creating the object. 250 250 if ( $this->single_group ) { … … 259 259 } 260 260 } 261 261 262 262 $this->group = $group; 263 263 264 264 if ( 0 == $this->current_group ) // loop has just started 265 265 do_action('loop_start'); … … 269 269 function bp_has_groups( $args = '' ) { 270 270 global $groups_template, $bp; 271 271 272 272 $defaults = array( 273 273 'type' => 'active', … … 281 281 $r = wp_parse_args( $args, $defaults ); 282 282 extract( $r, EXTR_SKIP ); 283 283 284 284 /* The following code will auto set parameters based on the page being viewed. 285 285 * for example on example.com/members/andy/groups/my-groups/most-popular/ … … 304 304 $slug = $bp->groups->current_group->slug; 305 305 } 306 306 307 307 if ( isset( $_REQUEST['group-filter-box'] ) ) 308 308 $filter = $_REQUEST['group-filter-box']; 309 309 310 310 $groups_template = new BP_Groups_User_Groups_Template( $user_id, $type, $per_page, $max, $slug, $filter ); 311 311 return apply_filters( 'bp_has_groups', $groups_template->has_groups(), &$groups_template ); … … 324 324 function bp_group_is_visible( $group = false ) { 325 325 global $bp, $groups_template; 326 326 327 327 if ( !$group ) 328 328 $group =& $groups_template->group; 329 329 330 330 if ( 'public' == $group->status ) { 331 331 return true; … … 335 335 } 336 336 } 337 337 338 338 return false; 339 339 } … … 341 341 function bp_group_has_news( $group = false ) { 342 342 global $groups_template; 343 343 344 344 if ( !$group ) 345 345 $group =& $groups_template->group; 346 346 347 347 if ( empty( $group->news ) ) 348 348 return false; 349 349 350 350 return true; 351 351 } … … 367 367 return apply_filters( 'bp_get_group_id', $group->id ); 368 368 } 369 369 370 370 function bp_group_name( $deprecated = true, $deprecated2 = false ) { 371 371 global $groups_template; … … 396 396 if ( 'public' == $group->status ) { 397 397 $type = __( "Public Group", "buddypress" ); 398 } else if ( 'hidden' == $group->status ) { 398 } else if ( 'hidden' == $group->status ) { 399 399 $type = __( "Hidden Group", "buddypress" ); 400 400 } else if ( 'private' == $group->status ) { … … 404 404 } 405 405 406 return apply_filters( 'bp_get_group_type', $type ); 406 return apply_filters( 'bp_get_group_type', $type ); 407 407 } 408 408 … … 416 416 $group =& $groups_template->group; 417 417 418 return apply_filters( 'bp_get_group_status', $group->status ); 418 return apply_filters( 'bp_get_group_status', $group->status ); 419 419 } 420 420 … … 431 431 'class' => 'avatar', 432 432 'id' => false, 433 'alt' => __( 'Group avatar', 'buddypress' ) 433 'alt' => __( 'Group avatar', 'buddypress' ) 434 434 ); 435 435 436 436 $r = wp_parse_args( $args, $defaults ); 437 437 extract( $r, EXTR_SKIP ); 438 438 439 439 /* Fetch the avatar from the folder, if not provide backwards compat. */ 440 440 if ( !$avatar = bp_core_fetch_avatar( array( 'item_id' => $groups_template->group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height ) ) ) … … 462 462 return bp_get_group_last_active(); 463 463 else 464 echo bp_get_group_last_active(); 464 echo bp_get_group_last_active(); 465 465 } 466 466 function bp_get_group_last_active( $group = false ) { … … 475 475 return __( 'not yet active', 'buddypress' ); 476 476 } else { 477 return apply_filters( 'bp_get_group_last_active', bp_core_time_since( $last_active ) ); 478 } 479 } 480 477 return apply_filters( 'bp_get_group_last_active', bp_core_time_since( $last_active ) ); 478 } 479 } 480 481 481 function bp_group_permalink( $deprecated = false, $deprecated2 = true ) { 482 482 if ( !$deprecated2 ) … … 506 506 $group =& $groups_template->group; 507 507 508 return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' ); 508 return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' ); 509 509 } 510 510 … … 557 557 $group =& $groups_template->group; 558 558 559 return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) ); 559 return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) ); 560 560 } 561 561 … … 599 599 } 600 600 } 601 601 602 602 function bp_group_is_public( $deprecated = false ) { 603 603 echo bp_get_group_is_public(); … … 626 626 function bp_group_is_admin() { 627 627 global $bp; 628 628 629 629 return $bp->is_item_admin; 630 630 } … … 632 632 function bp_group_is_mod() { 633 633 global $bp; 634 634 635 635 return $bp->is_item_mod; 636 636 } … … 638 638 function bp_group_list_admins( $full_list = true, $group = false ) { 639 639 global $groups_template; 640 640 641 641 if ( !$group ) 642 642 $group =& $groups_template->group; 643 643 644 644 if ( !$admins = &$group->admins ) 645 645 $admins = $group->get_administrators(); … … 665 665 <span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span> 666 666 <?php } ?> 667 667 668 668 <?php 669 669 } … … 671 671 function bp_group_list_mods( $full_list = true, $group = false ) { 672 672 global $groups_template; 673 673 674 674 if ( !$group ) 675 675 $group =& $groups_template->group; 676 676 677 677 $group_mods = groups_get_group_mods( $group->id ); 678 678 679 679 if ( $group_mods ) { 680 680 if ( $full_list ) { ?> … … 697 697 <span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span> 698 698 <?php } ?> 699 699 700 700 <?php 701 701 } … … 706 706 if ( !$group ) 707 707 $group =& $groups_template->group; 708 708 709 709 if ( !$deprecated ) 710 710 return bp_get_group_all_members_permalink(); … … 731 731 <label for="<?php echo $name ?>" id="<?php echo $name ?>-label"><?php echo $label ?></label> 732 732 <input type="search" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo $value ?>"<?php echo $disabled ?> /> 733 733 734 734 <?php wp_nonce_field( 'group-filter-box', '_wpnonce_group_filter' ) ?> 735 735 </form> … … 739 739 function bp_group_show_no_groups_message() { 740 740 global $bp; 741 741 742 742 if ( !groups_total_groups_for_user( $bp->displayed_user->id ) ) 743 743 return true; 744 744 745 745 return false; 746 746 } … … 751 751 function bp_get_group_pagination() { 752 752 global $groups_template; 753 753 754 754 return apply_filters( 'bp_get_group_pagination', $groups_template->pag_links ); 755 755 } … … 762 762 763 763 echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $groups_template->total_group_count ); ?> 764 <span class="ajax-loader"></span><?php 764 <span class="ajax-loader"></span><?php 765 765 } 766 766 … … 804 804 if ( !$group ) 805 805 $group =& $groups_template->group; 806 806 807 807 if ( $group->enable_wire ) 808 808 return true; 809 809 810 810 return false; 811 811 } … … 833 833 if ( $group->enable_forum ) 834 834 return true; 835 835 836 836 return false; 837 837 } else { … … 839 839 } 840 840 } 841 842 return false; 841 842 return false; 843 843 } 844 844 … … 848 848 if ( !$group ) 849 849 $group =& $groups_template->group; 850 850 851 851 if ( $group->enable_forum ) 852 852 echo ' checked="checked"'; … … 858 858 if ( !$group ) 859 859 $group =& $groups_template->group; 860 860 861 861 if ( $setting == $group->status ) 862 862 echo ' checked="checked"'; … … 865 865 function bp_group_admin_memberlist( $admin_list = false, $group = false ) { 866 866 global $groups_template; 867 867 868 868 if ( !$group ) 869 869 $group =& $groups_template->group; 870 870 871 871 $admins = groups_get_group_admins( $group->id ); 872 872 ?> … … 884 884 <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5> 885 885 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 886 886 887 887 <?php if ( function_exists( 'friends_install' ) ) : ?> 888 888 <div class="action"> … … 890 890 </div> 891 891 <?php endif; ?> 892 </li> 892 </li> 893 893 <?php } ?> 894 894 <?php } ?> … … 902 902 903 903 function bp_group_mod_memberlist( $admin_list = false, $group = false ) { 904 global $groups_template, $group_mods; 904 global $groups_template, $group_mods; 905 905 906 906 if ( !$group ) 907 907 $group =& $groups_template->group; 908 908 909 909 $group_mods = groups_get_group_mods( $group->id ); 910 910 ?> … … 922 922 <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5> 923 923 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 924 924 925 925 <?php if ( function_exists( 'friends_install' ) ) : ?> 926 926 <div class="action"> … … 928 928 </div> 929 929 <?php endif; ?> 930 </li> 931 <?php } ?> 930 </li> 931 <?php } ?> 932 932 <?php } ?> 933 933 </ul> … … 1001 1001 return apply_filters( 'bp_get_group_member_demote_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/manage-members/demote/' . $user_id, 'groups_demote_member' ) ); 1002 1002 } 1003 1003 1004 1004 function bp_group_member_ban_link( $user_id = false, $deprecated = false ) { 1005 1005 global $members_template; … … 1024 1024 if ( !$user_id ) 1025 1025 $user_id = $members_template->member->user_id; 1026 1027 echo bp_get_group_member_unban_link( $user_id ); 1026 1027 echo bp_get_group_member_unban_link( $user_id ); 1028 1028 } 1029 1029 function bp_get_group_member_unban_link( $user_id = false, $group = false ) { … … 1032 1032 if ( !$user_id ) 1033 1033 $user_id = $members_template->member->user_id; 1034 1035 if ( !$group ) 1036 $group =& $groups_template->group; 1037 1038 return apply_filters( 'bp_get_group_member_unban_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/manage-members/unban/' . $user_id, 'groups_unban_member' ) ); 1034 1035 if ( !$group ) 1036 $group =& $groups_template->group; 1037 1038 return apply_filters( 'bp_get_group_member_unban_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/manage-members/unban/' . $user_id, 'groups_unban_member' ) ); 1039 1039 } 1040 1040 … … 1044 1044 if ( !$group ) 1045 1045 $group = ( $groups_template->group ) ? $groups_template->group : $bp->groups->current_group; 1046 1046 1047 1047 $current_tab = $bp->action_variables[0]; 1048 1048 ?> … … 1050 1050 <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li> 1051 1051 <?php } ?> 1052 1052 1053 1053 <?php 1054 1054 if ( !$bp->is_item_admin ) … … 1062 1062 <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li> 1063 1063 <?php endif; ?> 1064 1064 1065 1065 <?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?> 1066 1066 1067 1067 <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li> 1068 1068 <?php … … 1087 1087 return apply_filters( 'bp_group_form_action', bp_get_group_permalink( $group ) . '/' . $page ); 1088 1088 } 1089 1089 1090 1090 function bp_group_admin_form_action( $page = false, $deprecated = false ) { 1091 1091 echo bp_get_group_admin_form_action( $page ); … … 1105 1105 function bp_group_has_requested_membership( $group = false ) { 1106 1106 global $bp, $groups_template; 1107 1107 1108 1108 if ( !$group ) 1109 1109 $group =& $groups_template->group; 1110 1110 1111 1111 if ( groups_check_for_membership_request( $bp->loggedin_user->id, $group->id ) ) 1112 1112 return true; 1113 1113 1114 1114 return false; 1115 1115 } … … 1120 1120 if ( !$group ) 1121 1121 $group =& $groups_template->group; 1122 1122 1123 1123 if ( groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) 1124 1124 return true; 1125 1125 1126 1126 return false; 1127 1127 } … … 1136 1136 $group =& $groups_template->group; 1137 1137 1138 return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/accept/' . $group->id, 'groups_accept_invite' ) ); 1138 return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/accept/' . $group->id, 'groups_accept_invite' ) ); 1139 1139 } 1140 1140 … … 1160 1160 $group =& $groups_template->group; 1161 1161 1162 return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group/yes', 'groups_leave_group' ) ); 1162 return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group/yes', 'groups_leave_group' ) ); 1163 1163 } 1164 1164 … … 1189 1189 function bp_has_friends_to_invite( $group = false ) { 1190 1190 global $groups_template, $bp; 1191 1191 1192 1192 if ( !function_exists('friends_install') ) 1193 1193 return false; … … 1195 1195 if ( !$group ) 1196 1196 $group =& $groups_template->group; 1197 1197 1198 1198 if ( !friends_check_user_has_friends( $bp->loggedin_user->id ) || !friends_count_invitable_friends( $bp->loggedin_user->id, $group->id ) ) 1199 1199 return false; 1200 1200 1201 1201 return true; 1202 1202 } … … 1204 1204 function bp_group_join_button( $group = false ) { 1205 1205 global $bp, $groups_template; 1206 1206 1207 1207 if ( !$group ) 1208 1208 $group =& $groups_template->group; 1209 1209 1210 1210 // If they're not logged in or are banned from the group, no join button. 1211 1211 if ( !is_user_logged_in() || groups_is_user_banned( $bp->loggedin_user->id, $group->id ) ) … … 1214 1214 if ( !$group->status ) 1215 1215 return false; 1216 1216 1217 1217 echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">'; 1218 1218 1219 1219 switch ( $group->status ) { 1220 1220 case 'public': 1221 1221 if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) 1222 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1222 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1223 1223 else 1224 echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>'; 1224 echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>'; 1225 1225 break; 1226 1226 1227 1227 case 'private': 1228 1228 if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) { 1229 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1229 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1230 1230 } else { 1231 1231 if ( !bp_group_has_requested_membership( $group ) ) 1232 echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>'; 1232 echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>'; 1233 1233 else 1234 echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>'; 1234 echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>'; 1235 1235 } 1236 1236 break; 1237 1237 } 1238 1238 1239 1239 echo '</div>'; 1240 1240 } … … 1242 1242 function bp_group_status_message( $group = false ) { 1243 1243 global $groups_template; 1244 1244 1245 1245 if ( !$group ) 1246 1246 $group =& $groups_template->group; 1247 1247 1248 1248 if ( 'private' == $group->status ) { 1249 1249 if ( !bp_group_has_requested_membership() ) … … 1252 1252 else 1253 1253 _e( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' ); 1254 else 1255 _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' ); 1254 else 1255 _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' ); 1256 1256 } else { 1257 1257 _e( 'This is a hidden group and only invited members can join.', 'buddypress' ); … … 1269 1269 var $members; 1270 1270 var $member; 1271 1271 1272 1272 var $in_the_loop; 1273 1273 1274 1274 var $pag_page; 1275 1275 var $pag_num; 1276 1276 var $pag_links; 1277 1277 var $total_group_count; 1278 1278 1279 1279 function bp_groups_group_members_template( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned ) { 1280 1280 global $bp; 1281 1281 1282 1282 $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1; 1283 1283 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 1284 1284 1285 1285 $this->members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned ); 1286 1286 1287 1287 if ( !$max || $max >= (int)$this->members['count'] ) 1288 1288 $this->total_member_count = (int)$this->members['count']; … … 1291 1291 1292 1292 $this->members = $this->members['members']; 1293 1293 1294 1294 if ( $max ) { 1295 1295 if ( $max >= count($this->members) ) … … 1311 1311 )); 1312 1312 } 1313 1313 1314 1314 function has_members() { 1315 1315 if ( $this->member_count ) … … 1318 1318 return false; 1319 1319 } 1320 1320 1321 1321 function next_member() { 1322 1322 $this->current_member++; 1323 1323 $this->member = $this->members[$this->current_member]; 1324 1324 1325 1325 return $this->member; 1326 1326 } 1327 1327 1328 1328 function rewind_members() { 1329 1329 $this->current_member = -1; … … 1332 1332 } 1333 1333 } 1334 1335 function members() { 1334 1335 function members() { 1336 1336 if ( $this->current_member + 1 < $this->member_count ) { 1337 1337 return true; … … 1345 1345 return false; 1346 1346 } 1347 1347 1348 1348 function the_member() { 1349 1349 global $member; … … 1359 1359 function bp_group_has_members( $args = '' ) { 1360 1360 global $bp, $members_template; 1361 1361 1362 1362 $defaults = array( 1363 1363 'group_id' => $bp->groups->current_group->id, … … 1377 1377 function bp_group_members() { 1378 1378 global $members_template; 1379 1379 1380 1380 return $members_template->members(); 1381 1381 } … … 1383 1383 function bp_group_the_member() { 1384 1384 global $members_template; 1385 1385 1386 1386 return $members_template->the_member(); 1387 1387 } … … 1440 1440 return apply_filters( 'bp_get_group_member_link', bp_core_get_userlink( $members_template->member->user_id ) ); 1441 1441 } 1442 1442 1443 1443 function bp_group_member_is_banned() { 1444 1444 echo bp_get_group_member_is_banned(); … … 1458 1458 return apply_filters( 'bp_get_group_member_joined_since', bp_core_get_last_activity( strtotime( $members_template->member->date_modified ), __( 'joined %s ago', 'buddypress') ) ); 1459 1459 } 1460 1460 1461 1461 function bp_group_member_id() { 1462 1462 echo bp_get_group_member_id(); … … 1473 1473 if ( $members_template->total_member_count > $members_template->pag_num ) 1474 1474 return true; 1475 1475 1476 1476 return false; 1477 1477 } … … 1502 1502 1503 1503 $from_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1; 1504 $to_num = ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1 ); 1505 1506 return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %d to %d (of %d members)', 'buddypress' ), $from_num, $to_num, $members_template->total_member_count ) ); 1504 $to_num = ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1 ); 1505 1506 return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %d to %d (of %d members)', 'buddypress' ), $from_num, $to_num, $members_template->total_member_count ) ); 1507 1507 } 1508 1508 … … 1513 1513 function bp_get_group_member_admin_pagination() { 1514 1514 global $members_template; 1515 1515 1516 1516 return $members_template->pag_links; 1517 1517 } … … 1524 1524 function bp_group_creation_tabs() { 1525 1525 global $bp; 1526 1526 1527 1527 if ( !is_array( $bp->groups->group_creation_steps ) ) 1528 1528 return false; 1529 1529 1530 1530 if ( !$bp->groups->current_create_step ) 1531 1531 $bp->groups->current_create_step = array_shift( array_keys( $bp->groups->group_creation_steps ) ); … … 1534 1534 foreach ( $bp->groups->group_creation_steps as $slug => $step ) { 1535 1535 $is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?> 1536 1536 1537 1537 <li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->loggedin_user->domain . $bp->groups->slug ?>/create/step/<?php echo $slug ?>"><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php endif; ?></li><?php 1538 1538 $counter++; 1539 1539 } 1540 1540 1541 1541 unset( $is_enabled ); 1542 1542 1543 1543 do_action( 'groups_creation_tabs' ); 1544 1544 } … … 1546 1546 function bp_group_creation_stage_title() { 1547 1547 global $bp; 1548 1548 1549 1549 echo apply_filters( 'bp_group_creation_stage_title', '<span>— ' . $bp->groups->group_creation_steps[$bp->groups->current_create_step]['name'] . '</span>' ); 1550 1550 } … … 1555 1555 function bp_get_group_creation_form_action() { 1556 1556 global $bp; 1557 1557 1558 1558 if ( empty( $bp->action_variables[1] ) ) 1559 1559 $bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) ); 1560 1560 1561 1561 return apply_filters( 'bp_get_group_creation_form_action', $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] ); 1562 1562 } … … 1564 1564 function bp_is_group_creation_step( $step_slug ) { 1565 1565 global $bp; 1566 1566 1567 1567 /* Make sure we are in the groups component */ 1568 1568 if ( $bp->current_component != BP_GROUPS_SLUG || 'create' != $bp->current_action ) 1569 1569 return false; 1570 1570 1571 1571 /* If this the first step, we can just accept and return true */ 1572 1572 if ( !$bp->action_variables[1] && array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug ) 1573 1573 return true; 1574 1574 1575 1575 /* Before allowing a user to see a group creation step we must make sure previous steps are completed */ 1576 1576 if ( !bp_is_first_group_creation_step() ) { … … 1578 1578 return false; 1579 1579 } 1580 1580 1581 1581 /* Check the current step against the step parameter */ 1582 1582 if ( $bp->action_variables[1] == $step_slug ) 1583 1583 return true; 1584 1584 1585 1585 return false; 1586 1586 } … … 1588 1588 function bp_is_group_creation_step_complete( $step_slugs ) { 1589 1589 global $bp; 1590 1590 1591 1591 if ( !$bp->groups->completed_create_steps ) 1592 1592 return false; … … 1594 1594 if ( is_array( $step_slugs ) ) { 1595 1595 $found = true; 1596 1596 1597 1597 foreach ( $step_slugs as $step_slug ) { 1598 1598 if ( !in_array( $step_slug, $bp->groups->completed_create_steps ) ) 1599 1599 $found = false; 1600 1600 } 1601 1601 1602 1602 return $found; 1603 1603 } else { 1604 return in_array( $step_slugs, $bp->groups->completed_create_steps ); 1604 return in_array( $step_slugs, $bp->groups->completed_create_steps ); 1605 1605 } 1606 1606 … … 1610 1610 function bp_are_previous_group_creation_steps_complete( $step_slug ) { 1611 1611 global $bp; 1612 1612 1613 1613 /* If this is the first group creation step, return true */ 1614 1614 if ( array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug ) 1615 1615 return true; 1616 1616 1617 1617 reset( $bp->groups->group_creation_steps ); 1618 1618 unset( $previous_steps ); 1619 1619 1620 1620 /* Get previous steps */ 1621 1621 foreach ( $bp->groups->group_creation_steps as $slug => $name ) { 1622 1622 if ( $slug == $step_slug ) 1623 1623 break; 1624 1624 1625 1625 $previous_steps[] = $slug; 1626 1626 } 1627 1627 1628 1628 return bp_is_group_creation_step_complete( $previous_steps ); 1629 1629 } … … 1636 1636 return apply_filters( 'bp_get_new_group_id', $bp->groups->new_group_id ); 1637 1637 } 1638 1638 1639 1639 function bp_new_group_name() { 1640 1640 echo bp_get_new_group_name(); … … 1690 1690 function bp_get_new_group_avatar( $args = '' ) { 1691 1691 global $bp; 1692 1692 1693 1693 $defaults = array( 1694 1694 'type' => 'full', … … 1697 1697 'class' => 'avatar', 1698 1698 'id' => 'avatar-crop-preview', 1699 'alt' => __( 'Group avatar', 'buddypress' ) 1699 'alt' => __( 'Group avatar', 'buddypress' ) 1700 1700 ); 1701 1701 1702 1702 $r = wp_parse_args( $args, $defaults ); 1703 1703 extract( $r, EXTR_SKIP ); 1704 1704 1705 1705 return apply_filters( 'bp_get_new_group_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'width' => $width, 'height' => $height, 'class' => $class ) ) ); 1706 1706 } … … 1711 1711 function bp_get_group_creation_previous_link() { 1712 1712 global $bp; 1713 1713 1714 1714 foreach ( $bp->groups->group_creation_steps as $slug => $name ) { 1715 1715 if ( $slug == $bp->action_variables[1] ) 1716 1716 break; 1717 1717 1718 1718 $previous_steps[] = $slug; 1719 1719 } … … 1724 1724 function bp_is_last_group_creation_step() { 1725 1725 global $bp; 1726 1726 1727 1727 $last_step = array_pop( array_keys( $bp->groups->group_creation_steps ) ); 1728 1728 1729 1729 if ( $last_step == $bp->groups->current_create_step ) 1730 1730 return true; 1731 1731 1732 1732 return false; 1733 1733 } … … 1735 1735 function bp_is_first_group_creation_step() { 1736 1736 global $bp; 1737 1737 1738 1738 $first_step = array_shift( array_keys( $bp->groups->group_creation_steps ) ); 1739 1739 1740 1740 if ( $first_step == $bp->groups->current_create_step ) 1741 1741 return true; 1742 1742 1743 1743 return false; 1744 1744 } … … 1752 1752 if ( !function_exists('friends_install') ) 1753 1753 return false; 1754 1754 1755 1755 $defaults = array( 1756 1756 'group_id' => false, … … 1760 1760 $r = wp_parse_args( $args, $defaults ); 1761 1761 extract( $r, EXTR_SKIP ); 1762 1762 1763 1763 if ( !$group_id ) 1764 1764 $group_id = ( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : $bp->groups->current_group->id; 1765 1765 1766 1766 $friends = friends_get_friends_invite_list( $bp->loggedin_user->id, $group_id ); 1767 1767 1768 1768 if ( $friends ) { 1769 1769 $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group_id ); … … 1775 1775 } else { 1776 1776 $checked = ''; 1777 } 1777 } 1778 1778 } 1779 1779 1780 1780 $items[] = '<' . $separator . '><input' . $checked . ' type="checkbox" name="friends[]" id="f-' . $friends[$i]['id'] . '" value="' . attribute_escape( $friends[$i]['id'] ) . '" /> ' . $friends[$i]['full_name'] . '</' . $separator . '>'; 1781 1781 } 1782 1782 } 1783 1783 1784 1784 return implode( "\n", (array)$items ); 1785 1785 } … … 1794 1794 var $groups; 1795 1795 var $group; 1796 1796 1797 1797 var $in_the_loop; 1798 1798 1799 1799 var $pag_page; 1800 1800 var $pag_num; 1801 1801 var $pag_links; 1802 1802 var $total_group_count; 1803 1803 1804 1804 function bp_groups_site_groups_template( $type, $per_page, $max ) { 1805 1805 global $bp; 1806 1806 1807 1807 /* TODO: Move $_REQUEST vars out of here */ 1808 1808 1809 1809 $this->pag_page = isset( $_REQUEST['gpage'] ) ? intval( $_REQUEST['gpage'] ) : 1; 1810 1810 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; … … 1814 1814 } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) { 1815 1815 $this->groups = BP_Groups_Group::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page ); 1816 1816 1817 1817 } else { 1818 1818 switch ( $type ) { 1819 1819 case 'active': default: 1820 1820 $this->groups = groups_get_active( $this->pag_num, $this->pag_page ); 1821 break; 1821 break; 1822 1822 1823 1823 case 'alphabetical': default: 1824 1824 $this->groups = groups_get_alphabetically( $this->pag_num, $this->pag_page ); 1825 break; 1826 1827 case 'random': 1825 break; 1826 1827 case 'random': 1828 1828 $this->groups = groups_get_random_groups( $this->pag_num, $this->pag_page ); 1829 1829 break; 1830 1830 1831 1831 case 'newest': 1832 1832 $this->groups = groups_get_newest( $this->pag_num, $this->pag_page ); … … 1835 1835 case 'popular': 1836 1836 $this->groups = groups_get_popular( $this->pag_num, $this->pag_page ); 1837 break; 1837 break; 1838 1838 1839 1839 case 'most-forum-topics': 1840 1840 $this->groups = groups_get_by_most_forum_topics( $this->pag_num, $this->pag_page ); 1841 1841 break; 1842 1842 1843 1843 case 'most-forum-posts': 1844 1844 $this->groups = groups_get_by_most_forum_posts( $this->pag_num, $this->pag_page ); … … 1846 1846 } 1847 1847 } 1848 1848 1849 1849 if ( !$max || $max >= (int)$this->groups['total'] ) 1850 1850 $this->total_group_count = (int)$this->groups['total']; … … 1853 1853 1854 1854 $this->groups = $this->groups['groups']; 1855 1855 1856 1856 if ( $max ) { 1857 1857 if ( $max >= count($this->groups) ) … … 1862 1862 $this->group_count = count($this->groups); 1863 1863 } 1864 1864 1865 1865 if ( (int) $this->total_group_count && (int) $this->pag_num ) { 1866 1866 $this->pag_links = paginate_links( array( … … 1872 1872 'next_text' => '»', 1873 1873 'mid_size' => 1 1874 )); 1875 } 1876 } 1877 1874 )); 1875 } 1876 } 1877 1878 1878 function has_groups() { 1879 1879 if ( $this->group_count ) 1880 1880 return true; 1881 1881 1882 1882 return false; 1883 1883 } 1884 1884 1885 1885 function next_group() { 1886 1886 $this->current_group++; 1887 1887 $this->group = $this->groups[$this->current_group]; 1888 1888 1889 1889 return $this->group; 1890 1890 } 1891 1891 1892 1892 function rewind_groups() { 1893 1893 $this->current_group = -1; … … 1896 1896 } 1897 1897 } 1898 1899 function groups() { 1898 1899 function groups() { 1900 1900 if ( $this->current_group + 1 < $this->group_count ) { 1901 1901 return true; … … 1909 1909 return false; 1910 1910 } 1911 1911 1912 1912 function the_group() { 1913 1913 global $group; … … 1915 1915 $this->in_the_loop = true; 1916 1916 $this->group = $this->next_group(); 1917 1917 1918 1918 if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) { 1919 1919 $group = new BP_Groups_Group( $this->group->group_id, false, false ); 1920 1920 wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' ); 1921 1921 } 1922 1922 1923 1923 $this->group = $group; 1924 1924 1925 1925 if ( 0 == $this->current_group ) // loop has just started 1926 1926 do_action('loop_start'); … … 1930 1930 function bp_rewind_site_groups() { 1931 1931 global $site_groups_template; 1932 1933 $site_groups_template->rewind_groups(); 1932 1933 $site_groups_template->rewind_groups(); 1934 1934 } 1935 1935 … … 1945 1945 $r = wp_parse_args( $args, $defaults ); 1946 1946 extract( $r, EXTR_SKIP ); 1947 1947 1948 1948 // type: active ( default ) | random | newest | popular 1949 1949 1950 1950 if ( $max ) { 1951 1951 if ( $per_page > $max ) 1952 1952 $per_page = $max; 1953 1953 } 1954 1954 1955 1955 $site_groups_template = new BP_Groups_Site_Groups_Template( $type, $per_page, $max ); 1956 1956 return apply_filters( 'bp_has_site_groups', $site_groups_template->has_groups(), &$site_groups_template ); … … 1959 1959 function bp_site_groups() { 1960 1960 global $site_groups_template; 1961 1961 1962 1962 return $site_groups_template->groups(); 1963 1963 } … … 1965 1965 function bp_the_site_group() { 1966 1966 global $site_groups_template; 1967 1967 1968 1968 return $site_groups_template->the_group(); 1969 1969 } … … 1971 1971 function bp_site_groups_pagination_count() { 1972 1972 global $bp, $site_groups_template; 1973 1973 1974 1974 $from_num = intval( ( $site_groups_template->pag_page - 1 ) * $site_groups_template->pag_num ) + 1; 1975 1975 $to_num = ( $from_num + ( $site_groups_template->pag_num - 1 ) > $site_groups_template->total_group_count ) ? $site_groups_template->total_group_count : $from_num + ( $site_groups_template->pag_num - 1) ; 1976 1976 1977 1977 echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $site_groups_template->total_group_count ); ?> 1978 <span class="ajax-loader"></span><?php 1978 <span class="ajax-loader"></span><?php 1979 1979 } 1980 1980 … … 1984 1984 function bp_get_site_groups_pagination_links() { 1985 1985 global $site_groups_template; 1986 1986 1987 1987 return apply_filters( 'bp_get_site_groups_pagination_links', $site_groups_template->pag_links ); 1988 1988 } … … 1993 1993 function bp_get_the_site_group_id() { 1994 1994 global $site_groups_template; 1995 1995 1996 1996 return apply_filters( 'bp_get_the_site_group_id', $site_groups_template->group->id ); 1997 1997 } … … 2011 2011 function bp_get_the_site_group_avatar_thumb() { 2012 2012 global $site_groups_template; 2013 2013 2014 2014 return apply_filters( 'bp_get_the_site_group_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $site_groups_template->group->id, 'object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) ); 2015 2015 } … … 2029 2029 function bp_get_the_site_group_link() { 2030 2030 global $site_groups_template; 2031 2031 2032 2032 return apply_filters( 'bp_get_the_site_group_link', bp_get_group_permalink( $site_groups_template->group ) ); 2033 2033 } … … 2041 2041 return apply_filters( 'bp_get_the_site_group_name', bp_get_group_name( $site_groups_template->group ) ); 2042 2042 } 2043 2043 2044 2044 2045 2045 function bp_the_site_group_last_active() { … … 2054 2054 function bp_the_site_group_join_button() { 2055 2055 global $site_groups_template; 2056 2056 2057 2057 echo bp_group_join_button( $site_groups_template->group ); 2058 2058 } … … 2064 2064 global $site_groups_template; 2065 2065 2066 return apply_filters( 'bp_get_the_site_group_description', bp_get_group_description( $site_groups_template->group ) ); 2066 return apply_filters( 'bp_get_the_site_group_description', bp_get_group_description( $site_groups_template->group ) ); 2067 2067 } 2068 2068 … … 2073 2073 global $site_groups_template; 2074 2074 2075 return apply_filters( 'bp_get_the_site_group_description_excerpt', bp_create_excerpt( bp_get_group_description( $site_groups_template->group, false ), 25 ) ); 2075 return apply_filters( 'bp_get_the_site_group_description_excerpt', bp_create_excerpt( bp_get_group_description( $site_groups_template->group, false ), 25 ) ); 2076 2076 } 2077 2077 2078 2078 function bp_the_site_group_date_created() { 2079 echo bp_get_the_site_group_date_created(); 2079 echo bp_get_the_site_group_date_created(); 2080 2080 } 2081 2081 function bp_get_the_site_group_date_created() { 2082 2082 global $site_groups_template; 2083 2083 2084 return apply_filters( 'bp_get_the_site_group_date_created', bp_core_time_since( $site_groups_template->group->date_created ) ); 2084 return apply_filters( 'bp_get_the_site_group_date_created', bp_core_time_since( $site_groups_template->group->date_created ) ); 2085 2085 } 2086 2086 … … 2094 2094 return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d member', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) ); 2095 2095 else 2096 return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) ); 2096 return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) ); 2097 2097 } 2098 2098 … … 2124 2124 if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) ) 2125 2125 return false; 2126 2126 2127 2127 if ( !$site_groups_template->group->forum_counts ) 2128 2128 $site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id ); … … 2132 2132 $total_topics = sprintf( __( '%d topic', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics ); 2133 2133 else 2134 $total_topics = sprintf( __( '%d topics', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics ); 2134 $total_topics = sprintf( __( '%d topics', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics ); 2135 2135 } else { 2136 2136 $total_topics = (int) $site_groups_template->group->forum_counts[0]->topics; 2137 2137 } 2138 2138 2139 2139 return apply_filters( 'bp_get_the_site_group_forum_topic_count', $total_topics, (bool)$showtext ); 2140 2140 } … … 2145 2145 function bp_get_the_site_group_forum_post_count( $args = '' ) { 2146 2146 global $site_groups_template; 2147 2147 2148 2148 $defaults = array( 2149 2149 'showtext' => false … … 2152 2152 $r = wp_parse_args( $args, $defaults ); 2153 2153 extract( $r, EXTR_SKIP ); 2154 2154 2155 2155 if ( !$forum_id = groups_get_groupmeta( $site_groups_template->group->id, 'forum_id' ) ) 2156 2156 return false; … … 2158 2158 if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) ) 2159 2159 return false; 2160 2160 2161 2161 if ( !$site_groups_template->group->forum_counts ) 2162 2162 $site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id ); … … 2166 2166 $total_posts = sprintf( __( '%d post', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts ); 2167 2167 else 2168 $total_posts = sprintf( __( '%d posts', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts ); 2168 $total_posts = sprintf( __( '%d posts', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts ); 2169 2169 } else { 2170 2170 $total_posts = (int) $site_groups_template->group->forum_counts[0]->posts; 2171 2171 } 2172 2172 2173 2173 return apply_filters( 'bp_get_the_site_group_forum_post_count', $total_posts, (bool)$showtext ); 2174 2174 } … … 2178 2178 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />'; 2179 2179 } 2180 2180 2181 2181 if ( isset( $_REQUEST['letter'] ) ) { 2182 2182 echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />'; 2183 2183 } 2184 2184 2185 2185 if ( isset( $_REQUEST['groups_search'] ) ) { 2186 2186 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />'; … … 2206 2206 var $requests; 2207 2207 var $request; 2208 2208 2209 2209 var $in_the_loop; 2210 2210 2211 2211 var $pag_page; 2212 2212 var $pag_num; 2213 2213 var $pag_links; 2214 2214 var $total_request_count; 2215 2215 2216 2216 function bp_groups_membership_requests_template( $group_id, $per_page, $max ) { 2217 2217 global $bp; 2218 2218 2219 2219 $this->pag_page = isset( $_REQUEST['mrpage'] ) ? intval( $_REQUEST['mrpage'] ) : 1; 2220 2220 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 2221 2222 $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page ); 2221 2222 $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page ); 2223 2223 2224 2224 if ( !$max || $max >= (int)$this->requests['total'] ) … … 2228 2228 2229 2229 $this->requests = $this->requests['requests']; 2230 2230 2231 2231 if ( $max ) { 2232 2232 if ( $max >= count($this->requests) ) … … 2248 2248 )); 2249 2249 } 2250 2250 2251 2251 function has_requests() { 2252 2252 if ( $this->request_count ) 2253 2253 return true; 2254 2254 2255 2255 return false; 2256 2256 } 2257 2257 2258 2258 function next_request() { 2259 2259 $this->current_request++; 2260 2260 $this->request = $this->requests[$this->current_request]; 2261 2261 2262 2262 return $this->request; 2263 2263 } 2264 2264 2265 2265 function rewind_requests() { 2266 2266 $this->current_request = -1; … … 2269 2269 } 2270 2270 } 2271 2272 function requests() { 2271 2272 function requests() { 2273 2273 if ( $this->current_request + 1 < $this->request_count ) { 2274 2274 return true; … … 2282 2282 return false; 2283 2283 } 2284 2284 2285 2285 function the_request() { 2286 2286 global $request; … … 2312 2312 function bp_group_membership_requests() { 2313 2313 global $requests_template; 2314 2314 2315 2315 return $requests_template->requests(); 2316 2316 } … … 2318 2318 function bp_group_the_membership_request() { 2319 2319 global $requests_template; 2320 2320 2321 2321 return $requests_template->the_request(); 2322 2322 } … … 2324 2324 function bp_group_request_user_avatar_thumb() { 2325 2325 global $requests_template; 2326 2326 2327 2327 echo apply_filters( 'bp_group_request_user_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $requests_template->request->user_id, 'type' => 'thumb' ) ) ); 2328 2328 } 2329 2329 2330 2330 function bp_group_request_reject_link() { 2331 global $requests_template, $groups_template; 2331 global $requests_template, $groups_template; 2332 2332 2333 2333 echo apply_filters( 'bp_group_request_reject_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/reject/' . $requests_template->request->id, 'groups_reject_membership_request' ) ); … … 2335 2335 2336 2336 function bp_group_request_accept_link() { 2337 global $requests_template, $groups_template; 2337 global $requests_template, $groups_template; 2338 2338 2339 2339 echo apply_filters( 'bp_group_request_accept_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/accept/' . $requests_template->request->id, 'groups_accept_membership_request' ) ); … … 2341 2341 2342 2342 function bp_group_request_time_since_requested() { 2343 global $requests_template; 2343 global $requests_template; 2344 2344 2345 2345 echo apply_filters( 'bp_group_request_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $requests_template->request->date_modified ) ) ) ); … … 2348 2348 function bp_group_request_comment() { 2349 2349 global $requests_template; 2350 2350 2351 2351 echo apply_filters( 'bp_group_request_comment', strip_tags( stripslashes( $requests_template->request->comments ) ) ); 2352 2352 } … … 2354 2354 function bp_group_request_user_link() { 2355 2355 global $requests_template; 2356 2356 2357 2357 echo apply_filters( 'bp_group_request_user_link', bp_core_get_userlink( $requests_template->request->user_id ) ); 2358 2358 } … … 2368 2368 var $invites; 2369 2369 var $invite; 2370 2370 2371 2371 var $in_the_loop; 2372 2372 2373 2373 var $pag_page; 2374 2374 var $pag_num; 2375 2375 var $pag_links; 2376 2376 var $total_invite_count; 2377 2377 2378 2378 function bp_groups_invite_template( $user_id, $group_id ) { 2379 2379 global $bp; 2380 2380 2381 2381 $this->invites = groups_get_invites_for_group( $user_id, $group_id ); 2382 $this->invite_count = count( $this->invites ); 2383 } 2384 2382 $this->invite_count = count( $this->invites ); 2383 } 2384 2385 2385 function has_invites() { 2386 2386 if ( $this->invite_count ) 2387 2387 return true; 2388 2388 2389 2389 return false; 2390 2390 } 2391 2391 2392 2392 function next_invite() { 2393 2393 $this->current_invite++; 2394 2394 $this->invite = $this->invites[$this->current_invite]; 2395 2395 2396 2396 return $this->invite; 2397 2397 } 2398 2398 2399 2399 function rewind_invites() { 2400 2400 $this->current_invite = -1; … … 2403 2403 } 2404 2404 } 2405 2406 function invites() { 2405 2406 function invites() { 2407 2407 if ( $this->current_invite + 1 < $this->invite_count ) { 2408 2408 return true; … … 2416 2416 return false; 2417 2417 } 2418 2418 2419 2419 function the_invite() { 2420 2420 global $invite; … … 2422 2422 $this->in_the_loop = true; 2423 2423 $user_id = $this->next_invite(); 2424 2424 2425 2425 $this->invite = new stdClass; 2426 2426 $this->invite->user = new BP_Core_User( $user_id ); 2427 2427 $this->invite->group_id = $group_id; // Globaled in bp_group_has_invites() 2428 2428 2429 2429 if ( 0 == $this->current_invite ) // loop has just started 2430 2430 do_action('loop_start'); … … 2434 2434 function bp_group_has_invites( $args = '' ) { 2435 2435 global $bp, $invites_template, $group_id; 2436 2436 2437 2437 $defaults = array( 2438 2438 'group_id' => false, … … 2442 2442 $r = wp_parse_args( $args, $defaults ); 2443 2443 extract( $r, EXTR_SKIP ); 2444 2444 2445 2445 if ( !$group_id ) { 2446 2446 /* Backwards compatibility */ … … 2448 2448 if ( $bp->groups->new_group_id ) $group_id = $bp->groups->new_group_id; 2449 2449 } 2450 2450 2451 2451 if ( !$group_id ) 2452 2452 return false; … … 2458 2458 function bp_group_invites() { 2459 2459 global $invites_template; 2460 2460 2461 2461 return $invites_template->invites(); 2462 2462 } … … 2464 2464 function bp_group_the_invite() { 2465 2465 global $invites_template; 2466 2466 2467 2467 return $invites_template->the_invite(); 2468 2468 } … … 2509 2509 function bp_get_group_invite_user_remove_invite_url() { 2510 2510 global $invites_template; 2511 2511 2512 2512 return wp_nonce_url( site_url( BP_GROUPS_SLUG . '/' . $invites_template->invite->group_id . '/invites/remove/' . $invites_template->invite->user->id ), 'groups_invite_uninvite_user' ); 2513 2513 }
Note: See TracChangeset
for help on using the changeset viewer.