Ticket #963: group-thumb-avatar-fix.patch
File group-thumb-avatar-fix.patch, 52.4 KB (added by , 15 years ago) |
---|
-
bp-groups-templatetags.php
8 8 <li<?php if ( 'most-popular' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/most-popular""><?php _e( 'Most Popular', 'buddypress' ) ?></a></li> 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' ); 14 14 } 15 15 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: 23 23 _e( 'Recently Active', 'buddypress' ); … … 43 43 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 } 55 55 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" /> 61 61 <?php } else { ?> … … 69 69 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 } 75 75 … … 78 78 } 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 } 84 84 … … 112 112 var $group_count; 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; 136 136 … … 140 140 break; 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 158 158 case 'invites': … … 161 161 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; 167 167 … … 169 169 $this->groups = groups_get_recently_active_for_user( $user_id, $this->pag_num, $this->pag_page, $filter ); 170 170 break; 171 171 } 172 172 173 173 if ( 'invites' == $type ) { 174 174 $this->total_group_count = count($this->groups); 175 175 $this->group_count = count($this->groups); … … 209 209 function has_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; 225 225 if ( $this->group_count > 0 ) { 226 226 $this->group = $this->groups[0]; 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; 233 233 } elseif ( $this->current_group + 1 == $this->group_count ) { … … 239 239 $this->in_the_loop = false; 240 240 return false; 241 241 } 242 242 243 243 function the_group() { 244 244 global $group; 245 245 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 ) { 251 251 if ( !$group = wp_cache_get( 'groups_group_' . $this->group->group_id, 'bp' ) ) { … … 258 258 wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' ); 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'); 266 266 } … … 268 268 269 269 function bp_has_groups( $args = '' ) { 270 270 global $groups_template, $bp; 271 271 272 272 $defaults = array( 273 273 'type' => 'active', 274 274 'user_id' => false, … … 280 280 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/ 286 286 * $type = 'most-popular' … … 303 303 $type = 'single-group'; 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 $groups_template->has_groups(); 312 312 } … … 323 323 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; 332 332 } else { … … 334 334 return true; 335 335 } 336 336 } 337 337 338 338 return false; 339 339 } 340 340 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 } 352 352 … … 366 366 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; 372 372 … … 395 395 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 ) { 401 401 $type = __( "Private Group", "buddypress" ); … … 403 403 $type = ucwords( $group->status ) . ' ' . __( 'Group', 'buddypress' ); 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 409 function bp_group_avatar( ) {410 echo bp_get_group_avatar( );409 function bp_group_avatar( $args = '' ) { 410 echo bp_get_group_avatar( $args ); 411 411 } 412 412 function bp_get_group_avatar( $args = '' ) { 413 413 global $bp, $groups_template; … … 418 418 'height' => false, 419 419 'class' => 'avatar', 420 420 'id' => false, 421 'alt' => __( 'Group avatar', 'buddypress' ) 421 'alt' => __( 'Group avatar', 'buddypress' ) 422 422 ); 423 423 424 424 $r = wp_parse_args( $args, $defaults ); 425 425 extract( $r, EXTR_SKIP ); 426 426 427 427 /* Fetch the avatar from the folder, if not provide backwards compat. */ 428 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 ) ) )429 $avatar = '<img src="' . attribute_escape( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . attribute_escape( $groups_template->group->name ) . '" />';428 return apply_filters( 'bp_get_group_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 ) )); 429 //$avatar = '<img src="' . attribute_escape( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . attribute_escape( $groups_template->group->name ) . '" />'; 430 430 431 return apply_filters( 'bp_get_group_avatar',$avatar );431 //return $avatar ); 432 432 } 433 433 434 function bp_group_avatar_thumb() {435 echo bp_get_group_avatar_thumb();436 }437 function bp_get_group_avatar_thumb( $group = false ) {438 return bp_get_group_avatar( 'type=thumb' );439 }440 441 434 function bp_group_avatar_mini() { 442 435 echo bp_get_group_avatar_mini(); 443 436 } 444 437 function bp_get_group_avatar_mini( $group = false ) { 445 return bp_get_group_avatar( 'type=thumb&width=30&height=30');438 return bp_get_group_avatar( array('type' => 'thumb', 'width' => '30', 'height' => '30' )); 446 439 } 447 440 448 441 function bp_group_last_active( $deprecated = true, $deprecated2 = false ) { 449 442 if ( !$deprecated ) 450 443 return bp_get_group_last_active(); 451 444 else 452 echo bp_get_group_last_active(); 445 echo bp_get_group_last_active(); 453 446 } 454 447 function bp_get_group_last_active( $group = false ) { 455 448 global $groups_template; … … 462 455 if ( empty( $last_active ) ) { 463 456 return __( 'not yet active', 'buddypress' ); 464 457 } else { 465 return apply_filters( 'bp_get_group_last_active', bp_core_time_since( $last_active ) ); 458 return apply_filters( 'bp_get_group_last_active', bp_core_time_since( $last_active ) ); 466 459 } 467 460 } 468 461 469 462 function bp_group_permalink( $deprecated = false, $deprecated2 = true ) { 470 463 if ( !$deprecated2 ) 471 464 return bp_get_group_permalink(); … … 493 486 if ( !$group ) 494 487 $group =& $groups_template->group; 495 488 496 return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' ); 489 return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' ); 497 490 } 498 491 499 492 function bp_group_slug() { … … 544 537 if ( !$group ) 545 538 $group =& $groups_template->group; 546 539 547 return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) ); 540 return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) ); 548 541 } 549 542 550 543 function bp_group_news( $deprecated = false ) { … … 586 579 return __( 'Private', 'buddypress' ); 587 580 } 588 581 } 589 582 590 583 function bp_group_is_public( $deprecated = false ) { 591 584 echo bp_get_group_is_public(); 592 585 } … … 613 606 614 607 function bp_group_is_admin() { 615 608 global $bp; 616 609 617 610 return $bp->is_item_admin; 618 611 } 619 612 620 613 function bp_group_is_mod() { 621 614 global $bp; 622 615 623 616 return $bp->is_item_mod; 624 617 } 625 618 626 619 function bp_group_list_admins( $full_list = true, $group = false ) { 627 620 global $groups_template; 628 621 629 622 if ( !$group ) 630 623 $group =& $groups_template->group; 631 624 632 625 if ( !$admins = &$group->admins ) 633 626 $admins = $group->get_administrators(); 634 627 … … 652 645 <?php } else { ?> 653 646 <span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span> 654 647 <?php } ?> 655 648 656 649 <?php 657 650 } 658 651 659 652 function bp_group_list_mods( $full_list = true, $group = false ) { 660 653 global $groups_template; 661 654 662 655 if ( !$group ) 663 656 $group =& $groups_template->group; 664 657 665 658 $group_mods = groups_get_group_mods( $group->id ); 666 659 667 660 if ( $group_mods ) { 668 661 if ( $full_list ) { ?> 669 662 <ul id="group-mods" class="mods-list"> … … 684 677 <?php } else { ?> 685 678 <span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span> 686 679 <?php } ?> 687 680 688 681 <?php 689 682 } 690 683 … … 693 686 694 687 if ( !$group ) 695 688 $group =& $groups_template->group; 696 689 697 690 if ( !$deprecated ) 698 691 return bp_get_group_all_members_permalink(); 699 692 else … … 719 712 if ( $forum_id && $forum_id != '' ) { 720 713 if ( function_exists( 'bp_forums_setup' ) ) { 721 714 $latest_topics = bp_forums_get_forum_topics( $forum_id ); 722 715 723 716 if ( $latest_topics ) { ?> 724 717 <ul class="item-list" id="recent-forum-topics"><?php 725 718 726 719 $counter = 0; 727 720 728 721 foreach( $latest_topics as $topic ) { 729 722 $alt = ( $counter % 2 == 1 ) ? ' class="alt"' : ''; 730 723 $forum_template->topic = (object)$topic; ?> 731 724 732 725 <li<?php echo $alt ?>> 733 726 <div class="avatar"> 734 727 <?php bp_the_topic_poster_avatar() ?> 735 728 </div> 736 729 737 <a href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a> 730 <a href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a> 738 731 <span class="small">- <?php bp_the_topic_total_post_count() ?> </span> 739 732 <p><span class="activity"><?php echo sprintf( __( 'updated %s ago', 'buddypress' ), bp_the_topic_time_since_last_post( false ) ) ?></span></p> 740 733 741 734 <div class="latest-post"> 742 735 <?php _e( 'Latest by', 'buddypress' ) ?> <?php bp_the_topic_last_poster_name() ?>: 743 736 <?php bp_the_topic_latest_post_excerpt() ?> 744 737 </div> 745 738 </li> 746 739 <?php $counter++ ?> 747 740 748 741 <?php } ?> 749 742 </ul> 750 743 <?php … … 769 762 <form action="<?php echo $action ?>" id="group-search-form" method="post"> 770 763 <label for="<?php echo $name ?>" id="<?php echo $name ?>-label"><?php echo $label ?> <span class="ajax-loader"></span></label> 771 764 <input type="search" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo $value ?>"<?php echo $disabled ?> /> 772 765 773 766 <?php wp_nonce_field( 'group-filter-box', '_wpnonce_group_filter' ) ?> 774 767 </form> 775 768 <?php … … 777 770 778 771 function bp_group_show_no_groups_message() { 779 772 global $bp; 780 773 781 774 if ( !groups_total_groups_for_user( $bp->displayed_user->id ) ) 782 775 return true; 783 776 784 777 return false; 785 778 } 786 779 … … 789 782 } 790 783 function bp_get_group_pagination() { 791 784 global $groups_template; 792 785 793 786 return apply_filters( 'bp_get_group_pagination', $groups_template->pag_links ); 794 787 } 795 788 … … 800 793 $to_num = ( $from_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $from_num + ( $groups_template->pag_num - 1) ; 801 794 802 795 echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $groups_template->total_group_count ); ?> 803 <span class="ajax-loader"></span><?php 796 <span class="ajax-loader"></span><?php 804 797 } 805 798 806 799 function bp_total_group_count() { … … 842 835 843 836 if ( !$group ) 844 837 $group =& $groups_template->group; 845 838 846 839 if ( $group->enable_wire ) 847 840 return true; 848 841 849 842 return false; 850 843 } 851 844 … … 871 864 if ( bp_forums_is_installed_correctly() ) { 872 865 if ( $group->enable_forum ) 873 866 return true; 874 867 875 868 return false; 876 869 } else { 877 870 return false; 878 871 } 879 872 } 880 881 return false; 873 874 return false; 882 875 } 883 876 884 877 function bp_group_show_forum_setting( $group = false ) { … … 886 879 887 880 if ( !$group ) 888 881 $group =& $groups_template->group; 889 882 890 883 if ( $group->enable_forum ) 891 884 echo ' checked="checked"'; 892 885 } … … 896 889 897 890 if ( !$group ) 898 891 $group =& $groups_template->group; 899 892 900 893 if ( $setting == $group->status ) 901 894 echo ' checked="checked"'; 902 895 } 903 896 904 897 function bp_group_admin_memberlist( $admin_list = false, $group = false ) { 905 898 global $groups_template; 906 899 907 900 if ( !$group ) 908 901 $group =& $groups_template->group; 909 902 910 903 $admins = groups_get_group_admins( $group->id ); 911 904 ?> 912 905 <?php if ( $admins ) { ?> … … 922 915 <?php echo bp_core_fetch_avatar( array( 'item_id' => $admin->user_id, 'type' => 'thumb' ) ) ?> 923 916 <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5> 924 917 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 925 918 926 919 <?php if ( function_exists( 'friends_install' ) ) : ?> 927 920 <div class="action"> 928 921 <?php bp_add_friend_button( $admin->user_id ) ?> 929 922 </div> 930 923 <?php endif; ?> 931 </li> 924 </li> 932 925 <?php } ?> 933 926 <?php } ?> 934 927 </ul> … … 940 933 } 941 934 942 935 function bp_group_mod_memberlist( $admin_list = false, $group = false ) { 943 global $groups_template, $group_mods; 936 global $groups_template, $group_mods; 944 937 945 938 if ( !$group ) 946 939 $group =& $groups_template->group; 947 940 948 941 $group_mods = groups_get_group_mods( $group->id ); 949 942 ?> 950 943 <?php if ( $group_mods ) { ?> … … 960 953 <?php echo bp_core_fetch_avatar( array( 'item_id' => $mod->user_id, 'type' => 'thumb' ) ) ?> 961 954 <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5> 962 955 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 963 956 964 957 <?php if ( function_exists( 'friends_install' ) ) : ?> 965 958 <div class="action"> 966 959 <?php bp_add_friend_button( $mod->user_id ) ?> 967 960 </div> 968 961 <?php endif; ?> 969 </li> 970 <?php } ?> 962 </li> 963 <?php } ?> 971 964 <?php } ?> 972 965 </ul> 973 966 <?php } else { ?> … … 991 984 992 985 if ( !$user_id ) 993 986 $user_id = $members_template->member->user_id; 994 987 995 988 echo bp_get_group_member_promote_link( $user_id ); 996 989 } 997 990 function bp_get_group_member_promote_link( $user_id = false, $group = false ) { … … 999 992 1000 993 if ( !$user_id ) 1001 994 $user_id = $members_template->member->user_id; 1002 995 1003 996 if ( !$group ) 1004 997 $group =& $groups_template->group; 1005 998 … … 1025 1018 1026 1019 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' ) ); 1027 1020 } 1028 1021 1029 1022 function bp_group_member_ban_link( $user_id = false, $deprecated = false ) { 1030 1023 global $members_template; 1031 1024 … … 1048 1041 1049 1042 if ( !$user_id ) 1050 1043 $user_id = $members_template->member->user_id; 1051 1052 echo bp_get_group_member_unban_link( $user_id ); 1044 1045 echo bp_get_group_member_unban_link( $user_id ); 1053 1046 } 1054 1047 function bp_get_group_member_unban_link( $user_id = false, $group = false ) { 1055 1048 global $members_template; 1056 1049 1057 1050 if ( !$user_id ) 1058 1051 $user_id = $members_template->member->user_id; 1059 1052 1060 1053 if ( !$group ) 1061 1054 $group =& $groups_template->group; 1062 1055 1063 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' ) ); 1056 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' ) ); 1064 1057 } 1065 1058 1066 1059 function bp_group_admin_tabs( $group = false ) { … … 1068 1061 1069 1062 if ( !$group ) 1070 1063 $group = ( $groups_template->group ) ? $groups_template->group : $bp->groups->current_group; 1071 1064 1072 1065 $current_tab = $bp->action_variables[0]; 1073 1066 ?> 1074 1067 <?php if ( $bp->is_item_admin || $bp->is_item_mod ) { ?> 1075 1068 <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> 1076 1069 <?php } ?> 1077 1070 1078 1071 <?php 1079 1072 if ( !$bp->is_item_admin ) 1080 1073 return false; … … 1086 1079 <?php if ( $groups_template->group->status == 'private' ) : ?> 1087 1080 <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> 1088 1081 <?php endif; ?> 1089 1082 1090 1083 <?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?> 1091 1084 1092 1085 <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> 1093 1086 <?php 1094 1087 } … … 1111 1104 1112 1105 return apply_filters( 'bp_group_form_action', bp_get_group_permalink( $group ) . '/' . $page ); 1113 1106 } 1114 1107 1115 1108 function bp_group_admin_form_action( $page = false, $deprecated = false ) { 1116 1109 echo bp_get_group_admin_form_action( $page ); 1117 1110 } … … 1129 1122 1130 1123 function bp_group_has_requested_membership( $group = false ) { 1131 1124 global $bp, $groups_template; 1132 1125 1133 1126 if ( !$group ) 1134 1127 $group =& $groups_template->group; 1135 1128 1136 1129 if ( groups_check_for_membership_request( $bp->loggedin_user->id, $group->id ) ) 1137 1130 return true; 1138 1131 1139 1132 return false; 1140 1133 } 1141 1134 … … 1144 1137 1145 1138 if ( !$group ) 1146 1139 $group =& $groups_template->group; 1147 1140 1148 1141 if ( groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) 1149 1142 return true; 1150 1143 1151 1144 return false; 1152 1145 } 1153 1146 … … 1160 1153 if ( !$group ) 1161 1154 $group =& $groups_template->group; 1162 1155 1163 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' ) ); 1156 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' ) ); 1164 1157 } 1165 1158 1166 1159 function bp_group_reject_invite_link( $deprecated = false ) { … … 1184 1177 if ( !$group ) 1185 1178 $group =& $groups_template->group; 1186 1179 1187 return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group/yes', 'groups_leave_group' ) ); 1180 return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group/yes', 'groups_leave_group' ) ); 1188 1181 } 1189 1182 1190 1183 function bp_group_leave_reject_link( $deprecated = false ) { … … 1213 1206 1214 1207 function bp_has_friends_to_invite( $group = false ) { 1215 1208 global $groups_template, $bp; 1216 1209 1217 1210 if ( !function_exists('friends_install') ) 1218 1211 return false; 1219 1212 1220 1213 if ( !$group ) 1221 1214 $group =& $groups_template->group; 1222 1215 1223 1216 if ( !friends_check_user_has_friends( $bp->loggedin_user->id ) || !friends_count_invitable_friends( $bp->loggedin_user->id, $group->id ) ) 1224 1217 return false; 1225 1218 1226 1219 return true; 1227 1220 } 1228 1221 1229 1222 function bp_group_join_button( $group = false ) { 1230 1223 global $bp, $groups_template; 1231 1224 1232 1225 if ( !$group ) 1233 1226 $group =& $groups_template->group; 1234 1227 1235 1228 // If they're not logged in or are banned from the group, no join button. 1236 1229 if ( !is_user_logged_in() || groups_is_user_banned( $bp->loggedin_user->id, $group->id ) ) 1237 1230 return false; 1238 1231 1239 1232 if ( !$group->status ) 1240 1233 return false; 1241 1234 1242 1235 echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">'; 1243 1236 1244 1237 switch ( $group->status ) { 1245 1238 case 'public': 1246 1239 if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) 1247 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1240 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1248 1241 else 1249 echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>'; 1242 echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>'; 1250 1243 break; 1251 1244 1252 1245 case 'private': 1253 1246 if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) { 1254 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1247 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1255 1248 } else { 1256 1249 if ( !bp_group_has_requested_membership( $group ) ) 1257 echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>'; 1250 echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>'; 1258 1251 else 1259 echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>'; 1252 echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>'; 1260 1253 } 1261 1254 break; 1262 1255 } 1263 1256 1264 1257 echo '</div>'; 1265 1258 } 1266 1259 1267 1260 function bp_group_status_message( $group = false ) { 1268 1261 global $groups_template; 1269 1262 1270 1263 if ( !$group ) 1271 1264 $group =& $groups_template->group; 1272 1265 1273 1266 if ( 'private' == $group->status ) { 1274 1267 if ( !bp_group_has_requested_membership() ) 1275 1268 if ( is_user_logged_in() ) 1276 1269 _e( 'This is a private group and you must request group membership in order to join.', 'buddypress' ); 1277 1270 else 1278 1271 _e( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' ); 1279 else 1280 _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' ); 1272 else 1273 _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' ); 1281 1274 } else { 1282 1275 _e( 'This is a hidden group and only invited members can join.', 'buddypress' ); 1283 1276 } … … 1293 1286 var $member_count; 1294 1287 var $members; 1295 1288 var $member; 1296 1289 1297 1290 var $in_the_loop; 1298 1291 1299 1292 var $pag_page; 1300 1293 var $pag_num; 1301 1294 var $pag_links; 1302 1295 var $total_group_count; 1303 1296 1304 1297 function bp_groups_group_members_template( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned ) { 1305 1298 global $bp; 1306 1299 1307 1300 $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1; 1308 1301 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 1309 1302 1310 1303 $this->members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned ); 1311 1304 1312 1305 if ( !$max || $max >= (int)$this->members['count'] ) 1313 1306 $this->total_member_count = (int)$this->members['count']; 1314 1307 else 1315 1308 $this->total_member_count = (int)$max; 1316 1309 1317 1310 $this->members = $this->members['members']; 1318 1311 1319 1312 if ( $max ) { 1320 1313 if ( $max >= count($this->members) ) 1321 1314 $this->member_count = count($this->members); … … 1335 1328 'mid_size' => 1 1336 1329 )); 1337 1330 } 1338 1331 1339 1332 function has_members() { 1340 1333 if ( $this->member_count ) 1341 1334 return true; 1342 1335 1343 1336 return false; 1344 1337 } 1345 1338 1346 1339 function next_member() { 1347 1340 $this->current_member++; 1348 1341 $this->member = $this->members[$this->current_member]; 1349 1342 1350 1343 return $this->member; 1351 1344 } 1352 1345 1353 1346 function rewind_members() { 1354 1347 $this->current_member = -1; 1355 1348 if ( $this->member_count > 0 ) { 1356 1349 $this->member = $this->members[0]; 1357 1350 } 1358 1351 } 1359 1360 function members() { 1352 1353 function members() { 1361 1354 if ( $this->current_member + 1 < $this->member_count ) { 1362 1355 return true; 1363 1356 } elseif ( $this->current_member + 1 == $this->member_count ) { … … 1369 1362 $this->in_the_loop = false; 1370 1363 return false; 1371 1364 } 1372 1365 1373 1366 function the_member() { 1374 1367 global $member; 1375 1368 … … 1383 1376 1384 1377 function bp_group_has_members( $args = '' ) { 1385 1378 global $bp, $members_template; 1386 1379 1387 1380 $defaults = array( 1388 1381 'group_id' => $bp->groups->current_group->id, 1389 1382 'per_page' => 10, … … 1396 1389 extract( $r, EXTR_SKIP ); 1397 1390 1398 1391 $members_template = new BP_Groups_Group_Members_Template( $group_id, $per_page, $max, (int)$exclude_admins_mods, (int)$exclude_banned ); 1399 1392 1400 1393 return $members_template->has_members(); 1401 1394 } 1402 1395 1403 1396 function bp_group_members() { 1404 1397 global $members_template; 1405 1398 1406 1399 return $members_template->members(); 1407 1400 } 1408 1401 1409 1402 function bp_group_the_member() { 1410 1403 global $members_template; 1411 1404 1412 1405 return $members_template->the_member(); 1413 1406 } 1414 1407 … … 1418 1411 function bp_get_group_member_avatar() { 1419 1412 global $members_template; 1420 1413 1421 return apply_filters( 'bp_get_group_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->user_id, 'type' => ' thumb' ) ) );1414 return apply_filters( 'bp_get_group_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->user_id, 'type' => 'full' ) ) ); 1422 1415 } 1423 1416 1424 1417 function bp_group_member_avatar_thumb() { … … 1427 1420 function bp_get_group_member_avatar_thumb() { 1428 1421 global $members_template; 1429 1422 1430 return apply_filters( 'bp_get_group_member_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->user_id, 'type' => ' full' ) ) );1423 return apply_filters( 'bp_get_group_member_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->user_id, 'type' => 'thumb' ) ) ); 1431 1424 } 1432 1425 1433 1426 function bp_group_member_avatar_mini( $width = 30, $height = 30 ) { … … 1465 1458 1466 1459 return apply_filters( 'bp_get_group_member_link', bp_core_get_userlink( $members_template->member->user_id ) ); 1467 1460 } 1468 1461 1469 1462 function bp_group_member_is_banned() { 1470 1463 echo bp_get_group_member_is_banned(); 1471 1464 } … … 1483 1476 1484 1477 return apply_filters( 'bp_get_group_member_joined_since', bp_core_get_last_activity( strtotime( $members_template->member->date_modified ), __( 'joined %s ago', 'buddypress') ) ); 1485 1478 } 1486 1479 1487 1480 function bp_group_member_id() { 1488 1481 echo bp_get_group_member_id(); 1489 1482 } … … 1498 1491 1499 1492 if ( $members_template->total_member_count > $members_template->pag_num ) 1500 1493 return true; 1501 1494 1502 1495 return false; 1503 1496 } 1504 1497 … … 1527 1520 global $members_template; 1528 1521 1529 1522 $from_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1; 1530 $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 ); 1523 $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 ); 1531 1524 1532 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 ) ); 1525 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 ) ); 1533 1526 } 1534 1527 1535 1528 function bp_group_member_admin_pagination() { … … 1538 1531 } 1539 1532 function bp_get_group_member_admin_pagination() { 1540 1533 global $members_template; 1541 1534 1542 1535 return $members_template->pag_links; 1543 1536 } 1544 1537 … … 1549 1542 1550 1543 function bp_group_creation_tabs() { 1551 1544 global $bp; 1552 1545 1553 1546 if ( !is_array( $bp->groups->group_creation_steps ) ) 1554 1547 return false; 1555 1548 1556 1549 if ( !$bp->groups->current_create_step ) 1557 1550 $bp->groups->current_create_step = array_shift( array_keys( $bp->groups->group_creation_steps ) ); 1558 1551 1559 1552 $counter = 1; 1560 1553 foreach ( $bp->groups->group_creation_steps as $slug => $step ) { 1561 1554 $is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?> 1562 1555 1563 1556 <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 1564 1557 $counter++; 1565 1558 } 1566 1559 1567 1560 unset( $is_enabled ); 1568 1561 1569 1562 do_action( 'groups_creation_tabs' ); 1570 1563 } 1571 1564 1572 1565 function bp_group_creation_stage_title() { 1573 1566 global $bp; 1574 1567 1575 1568 echo apply_filters( 'bp_group_creation_stage_title', '<span>— ' . $bp->groups->group_creation_steps[$bp->groups->current_create_step]['name'] . '</span>' ); 1576 1569 } 1577 1570 … … 1580 1573 } 1581 1574 function bp_get_group_creation_form_action() { 1582 1575 global $bp; 1583 1576 1584 1577 if ( empty( $bp->action_variables[1] ) ) 1585 1578 $bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) ); 1586 1579 1587 1580 return apply_filters( 'bp_get_group_creation_form_action', $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] ); 1588 1581 } 1589 1582 1590 1583 function bp_is_group_creation_step( $step_slug ) { 1591 1584 global $bp; 1592 1585 1593 1586 /* Make sure we are in the groups component */ 1594 1587 if ( $bp->current_component != BP_GROUPS_SLUG || 'create' != $bp->current_action ) 1595 1588 return false; 1596 1589 1597 1590 /* If this the first step, we can just accept and return true */ 1598 1591 if ( !$bp->action_variables[1] && array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug ) 1599 1592 return true; 1600 1593 1601 1594 /* Before allowing a user to see a group creation step we must make sure previous steps are completed */ 1602 1595 if ( !bp_is_first_group_creation_step() ) { 1603 1596 if ( !bp_are_previous_group_creation_steps_complete( $step_slug ) ) 1604 1597 return false; 1605 1598 } 1606 1599 1607 1600 /* Check the current step against the step parameter */ 1608 1601 if ( $bp->action_variables[1] == $step_slug ) 1609 1602 return true; 1610 1603 1611 1604 return false; 1612 1605 } 1613 1606 1614 1607 function bp_is_group_creation_step_complete( $step_slugs ) { 1615 1608 global $bp; 1616 1609 1617 1610 if ( !$bp->groups->completed_create_steps ) 1618 1611 return false; 1619 1612 1620 1613 if ( is_array( $step_slugs ) ) { 1621 1614 $found = true; 1622 1615 1623 1616 foreach ( $step_slugs as $step_slug ) { 1624 1617 if ( !in_array( $step_slug, $bp->groups->completed_create_steps ) ) 1625 1618 $found = false; 1626 1619 } 1627 1620 1628 1621 return $found; 1629 1622 } else { 1630 return in_array( $step_slugs, $bp->groups->completed_create_steps ); 1623 return in_array( $step_slugs, $bp->groups->completed_create_steps ); 1631 1624 } 1632 1625 1633 1626 return true; … … 1635 1628 1636 1629 function bp_are_previous_group_creation_steps_complete( $step_slug ) { 1637 1630 global $bp; 1638 1631 1639 1632 /* If this is the first group creation step, return true */ 1640 1633 if ( array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug ) 1641 1634 return true; 1642 1635 1643 1636 reset( $bp->groups->group_creation_steps ); 1644 1637 unset( $previous_steps ); 1645 1638 1646 1639 /* Get previous steps */ 1647 1640 foreach ( $bp->groups->group_creation_steps as $slug => $name ) { 1648 1641 if ( $slug == $step_slug ) 1649 1642 break; 1650 1643 1651 1644 $previous_steps[] = $slug; 1652 1645 } 1653 1646 1654 1647 return bp_is_group_creation_step_complete( $previous_steps ); 1655 1648 } 1656 1649 … … 1661 1654 global $bp; 1662 1655 return apply_filters( 'bp_get_new_group_id', $bp->groups->new_group_id ); 1663 1656 } 1664 1657 1665 1658 function bp_new_group_name() { 1666 1659 echo bp_get_new_group_name(); 1667 1660 } … … 1715 1708 } 1716 1709 function bp_get_new_group_avatar( $args = '' ) { 1717 1710 global $bp; 1718 1711 1719 1712 $defaults = array( 1720 1713 'type' => 'full', 1721 1714 'width' => false, 1722 1715 'height' => false, 1723 1716 'class' => 'avatar', 1724 1717 'id' => 'avatar-crop-preview', 1725 'alt' => __( 'Group avatar', 'buddypress' ) 1718 'alt' => __( 'Group avatar', 'buddypress' ) 1726 1719 ); 1727 1720 1728 1721 $r = wp_parse_args( $args, $defaults ); 1729 1722 extract( $r, EXTR_SKIP ); 1730 1723 1731 1724 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 ) ) ); 1732 1725 } 1733 1726 … … 1736 1729 } 1737 1730 function bp_get_group_creation_previous_link() { 1738 1731 global $bp; 1739 1732 1740 1733 foreach ( $bp->groups->group_creation_steps as $slug => $name ) { 1741 1734 if ( $slug == $bp->action_variables[1] ) 1742 1735 break; 1743 1736 1744 1737 $previous_steps[] = $slug; 1745 1738 } 1746 1739 … … 1749 1742 1750 1743 function bp_is_last_group_creation_step() { 1751 1744 global $bp; 1752 1745 1753 1746 $last_step = array_pop( array_keys( $bp->groups->group_creation_steps ) ); 1754 1747 1755 1748 if ( $last_step == $bp->groups->current_create_step ) 1756 1749 return true; 1757 1750 1758 1751 return false; 1759 1752 } 1760 1753 1761 1754 function bp_is_first_group_creation_step() { 1762 1755 global $bp; 1763 1756 1764 1757 $first_step = array_shift( array_keys( $bp->groups->group_creation_steps ) ); 1765 1758 1766 1759 if ( $first_step == $bp->groups->current_create_step ) 1767 1760 return true; 1768 1761 1769 1762 return false; 1770 1763 } 1771 1764 … … 1777 1770 1778 1771 if ( !function_exists('friends_install') ) 1779 1772 return false; 1780 1773 1781 1774 $defaults = array( 1782 1775 'group_id' => false, 1783 1776 'separator' => 'li' … … 1785 1778 1786 1779 $r = wp_parse_args( $args, $defaults ); 1787 1780 extract( $r, EXTR_SKIP ); 1788 1781 1789 1782 if ( !$group_id ) 1790 1783 $group_id = ( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : $bp->groups->current_group->id; 1791 1784 1792 1785 $friends = friends_get_friends_invite_list( $bp->loggedin_user->id, $group_id ); 1793 1786 1794 1787 if ( $friends ) { 1795 1788 $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group_id ); 1796 1789 … … 1800 1793 $checked = ' checked="checked"'; 1801 1794 } else { 1802 1795 $checked = ''; 1803 } 1796 } 1804 1797 } 1805 1798 1806 1799 $items[] = '<' . $separator . '><input' . $checked . ' type="checkbox" name="friends[]" id="f-' . $friends[$i]['id'] . '" value="' . attribute_escape( $friends[$i]['id'] ) . '" /> ' . $friends[$i]['full_name'] . '</' . $separator . '>'; 1807 1800 } 1808 1801 } 1809 1802 1810 1803 return implode( "\n", (array)$items ); 1811 1804 } 1812 1805 … … 1819 1812 var $group_count; 1820 1813 var $groups; 1821 1814 var $group; 1822 1815 1823 1816 var $in_the_loop; 1824 1817 1825 1818 var $pag_page; 1826 1819 var $pag_num; 1827 1820 var $pag_links; 1828 1821 var $total_group_count; 1829 1822 1830 1823 function bp_groups_site_groups_template( $type, $per_page, $max ) { 1831 1824 global $bp; 1832 1825 1833 1826 $this->pag_page = isset( $_REQUEST['gpage'] ) ? intval( $_REQUEST['gpage'] ) : 1; 1834 1827 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 1835 1828 1836 1829 if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) { 1837 1830 $this->groups = BP_Groups_Group::search_groups( $_REQUEST['s'], $this->pag_num, $this->pag_page ); 1838 1831 } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) { … … 1842 1835 case 'random': 1843 1836 $this->groups = BP_Groups_Group::get_random( $this->pag_num, $this->pag_page ); 1844 1837 break; 1845 1838 1846 1839 case 'newest': 1847 1840 $this->groups = BP_Groups_Group::get_newest( $this->pag_num, $this->pag_page ); 1848 1841 break; 1849 1842 1850 1843 case 'popular': 1851 1844 $this->groups = BP_Groups_Group::get_popular( $this->pag_num, $this->pag_page ); 1852 break; 1853 1845 break; 1846 1854 1847 case 'active': default: 1855 1848 $this->groups = BP_Groups_Group::get_active( $this->pag_num, $this->pag_page ); 1856 break; 1849 break; 1857 1850 } 1858 1851 } 1859 1852 1860 1853 if ( !$max || $max >= (int)$this->groups['total'] ) 1861 1854 $this->total_group_count = (int)$this->groups['total']; 1862 1855 else 1863 1856 $this->total_group_count = (int)$max; 1864 1857 1865 1858 $this->groups = $this->groups['groups']; 1866 1859 1867 1860 if ( $max ) { 1868 1861 if ( $max >= count($this->groups) ) 1869 1862 $this->group_count = count($this->groups); … … 1872 1865 } else { 1873 1866 $this->group_count = count($this->groups); 1874 1867 } 1875 1868 1876 1869 if ( (int) $this->total_group_count && (int) $this->pag_num ) { 1877 1870 $this->pag_links = paginate_links( array( 1878 1871 'base' => add_query_arg( 'gpage', '%#%' ), … … 1882 1875 'prev_text' => '«', 1883 1876 'next_text' => '»', 1884 1877 'mid_size' => 1 1885 )); 1878 )); 1886 1879 } 1887 1880 } 1888 1881 1889 1882 function has_groups() { 1890 1883 if ( $this->group_count ) 1891 1884 return true; 1892 1885 1893 1886 return false; 1894 1887 } 1895 1888 1896 1889 function next_group() { 1897 1890 $this->current_group++; 1898 1891 $this->group = $this->groups[$this->current_group]; 1899 1892 1900 1893 return $this->group; 1901 1894 } 1902 1895 1903 1896 function rewind_groups() { 1904 1897 $this->current_group = -1; 1905 1898 if ( $this->group_count > 0 ) { 1906 1899 $this->group = $this->groups[0]; 1907 1900 } 1908 1901 } 1909 1910 function groups() { 1902 1903 function groups() { 1911 1904 if ( $this->current_group + 1 < $this->group_count ) { 1912 1905 return true; 1913 1906 } elseif ( $this->current_group + 1 == $this->group_count ) { … … 1919 1912 $this->in_the_loop = false; 1920 1913 return false; 1921 1914 } 1922 1915 1923 1916 function the_group() { 1924 1917 global $group; 1925 1918 1926 1919 $this->in_the_loop = true; 1927 1920 $this->group = $this->next_group(); 1928 1921 1929 1922 if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) { 1930 1923 $group = new BP_Groups_Group( $this->group->group_id, false, false ); 1931 1924 wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' ); 1932 1925 } 1933 1926 1934 1927 $this->group = $group; 1935 1928 1936 1929 if ( 0 == $this->current_group ) // loop has just started 1937 1930 do_action('loop_start'); 1938 1931 } … … 1940 1933 1941 1934 function bp_rewind_site_groups() { 1942 1935 global $site_groups_template; 1943 1944 $site_groups_template->rewind_groups(); 1936 1937 $site_groups_template->rewind_groups(); 1945 1938 } 1946 1939 1947 1940 function bp_has_site_groups( $args = '' ) { … … 1955 1948 1956 1949 $r = wp_parse_args( $args, $defaults ); 1957 1950 extract( $r, EXTR_SKIP ); 1958 1951 1959 1952 // type: active ( default ) | random | newest | popular 1960 1953 1961 1954 if ( $max ) { 1962 1955 if ( $per_page > $max ) 1963 1956 $per_page = $max; 1964 1957 } 1965 1958 1966 1959 $site_groups_template = new BP_Groups_Site_Groups_Template( $type, $per_page, $max ); 1967 1960 1968 1961 return $site_groups_template->has_groups(); … … 1970 1963 1971 1964 function bp_site_groups() { 1972 1965 global $site_groups_template; 1973 1966 1974 1967 return $site_groups_template->groups(); 1975 1968 } 1976 1969 1977 1970 function bp_the_site_group() { 1978 1971 global $site_groups_template; 1979 1972 1980 1973 return $site_groups_template->the_group(); 1981 1974 } 1982 1975 1983 1976 function bp_site_groups_pagination_count() { 1984 1977 global $bp, $site_groups_template; 1985 1978 1986 1979 $from_num = intval( ( $site_groups_template->pag_page - 1 ) * $site_groups_template->pag_num ) + 1; 1987 1980 $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) ; 1988 1981 1989 1982 echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $site_groups_template->total_group_count ); ?> 1990 <span class="ajax-loader"></span><?php 1983 <span class="ajax-loader"></span><?php 1991 1984 } 1992 1985 1993 1986 function bp_site_groups_pagination_links() { … … 1995 1988 } 1996 1989 function bp_get_site_groups_pagination_links() { 1997 1990 global $site_groups_template; 1998 1991 1999 1992 return apply_filters( 'bp_get_site_groups_pagination_links', $site_groups_template->pag_links ); 2000 1993 } 2001 1994 … … 2004 1997 } 2005 1998 function bp_get_the_site_group_id() { 2006 1999 global $site_groups_template; 2007 2000 2008 2001 return apply_filters( 'bp_get_the_site_group_id', $site_groups_template->group->id ); 2009 2002 } 2010 2003 … … 2022 2015 } 2023 2016 function bp_get_the_site_group_avatar_thumb() { 2024 2017 global $site_groups_template; 2025 2018 2026 2019 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' ) ) ) ); 2027 2020 } 2028 2021 … … 2040 2033 } 2041 2034 function bp_get_the_site_group_link() { 2042 2035 global $site_groups_template; 2043 2036 2044 2037 return apply_filters( 'bp_get_the_site_group_link', bp_get_group_permalink( $site_groups_template->group ) ); 2045 2038 } 2046 2039 … … 2064 2057 2065 2058 function bp_the_site_group_join_button() { 2066 2059 global $site_groups_template; 2067 2060 2068 2061 echo bp_group_join_button( $site_groups_template->group ); 2069 2062 } 2070 2063 … … 2074 2067 function bp_get_the_site_group_description() { 2075 2068 global $site_groups_template; 2076 2069 2077 return apply_filters( 'bp_get_the_site_group_description', bp_get_group_description( $site_groups_template->group ) ); 2070 return apply_filters( 'bp_get_the_site_group_description', bp_get_group_description( $site_groups_template->group ) ); 2078 2071 } 2079 2072 2080 2073 function bp_the_site_group_description_excerpt() { … … 2083 2076 function bp_get_the_site_group_description_excerpt() { 2084 2077 global $site_groups_template; 2085 2078 2086 return apply_filters( 'bp_get_the_site_group_description_excerpt', bp_create_excerpt( bp_get_group_description( $site_groups_template->group, false ), 35 ) ); 2079 return apply_filters( 'bp_get_the_site_group_description_excerpt', bp_create_excerpt( bp_get_group_description( $site_groups_template->group, false ), 35 ) ); 2087 2080 } 2088 2081 2089 2082 function bp_the_site_group_date_created() { 2090 echo bp_get_the_site_group_date_created(); 2083 echo bp_get_the_site_group_date_created(); 2091 2084 } 2092 2085 function bp_get_the_site_group_date_created() { 2093 2086 global $site_groups_template; 2094 2087 2095 return apply_filters( 'bp_get_the_site_group_date_created', bp_core_time_since( $site_groups_template->group->date_created ) ); 2088 return apply_filters( 'bp_get_the_site_group_date_created', bp_core_time_since( $site_groups_template->group->date_created ) ); 2096 2089 } 2097 2090 2098 2091 function bp_the_site_group_member_count() { … … 2104 2097 if ( 1 == (int) $site_groups_template->group->total_member_count ) 2105 2098 return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d member', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) ); 2106 2099 else 2107 return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) ); 2100 return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) ); 2108 2101 } 2109 2102 2110 2103 function bp_the_site_group_type() { … … 2120 2113 if ( isset( $_REQUEST['s'] ) ) { 2121 2114 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />'; 2122 2115 } 2123 2116 2124 2117 if ( isset( $_REQUEST['letter'] ) ) { 2125 2118 echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />'; 2126 2119 } 2127 2120 2128 2121 if ( isset( $_REQUEST['groups_search'] ) ) { 2129 2122 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />'; 2130 2123 } … … 2148 2141 var $request_count; 2149 2142 var $requests; 2150 2143 var $request; 2151 2144 2152 2145 var $in_the_loop; 2153 2146 2154 2147 var $pag_page; 2155 2148 var $pag_num; 2156 2149 var $pag_links; 2157 2150 var $total_request_count; 2158 2151 2159 2152 function bp_groups_membership_requests_template( $group_id, $per_page, $max ) { 2160 2153 global $bp; 2161 2154 2162 2155 $this->pag_page = isset( $_REQUEST['mrpage'] ) ? intval( $_REQUEST['mrpage'] ) : 1; 2163 2156 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 2164 2165 $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page );2166 2157 2158 $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page ); 2159 2167 2160 if ( !$max || $max >= (int)$this->requests['total'] ) 2168 2161 $this->total_request_count = (int)$this->requests['total']; 2169 2162 else 2170 2163 $this->total_request_count = (int)$max; 2171 2164 2172 2165 $this->requests = $this->requests['requests']; 2173 2166 2174 2167 if ( $max ) { 2175 2168 if ( $max >= count($this->requests) ) 2176 2169 $this->request_count = count($this->requests); … … 2190 2183 'mid_size' => 1 2191 2184 )); 2192 2185 } 2193 2186 2194 2187 function has_requests() { 2195 2188 if ( $this->request_count ) 2196 2189 return true; 2197 2190 2198 2191 return false; 2199 2192 } 2200 2193 2201 2194 function next_request() { 2202 2195 $this->current_request++; 2203 2196 $this->request = $this->requests[$this->current_request]; 2204 2197 2205 2198 return $this->request; 2206 2199 } 2207 2200 2208 2201 function rewind_requests() { 2209 2202 $this->current_request = -1; 2210 2203 if ( $this->request_count > 0 ) { 2211 2204 $this->request = $this->requests[0]; 2212 2205 } 2213 2206 } 2214 2215 function requests() { 2207 2208 function requests() { 2216 2209 if ( $this->current_request + 1 < $this->request_count ) { 2217 2210 return true; 2218 2211 } elseif ( $this->current_request + 1 == $this->request_count ) { … … 2224 2217 $this->in_the_loop = false; 2225 2218 return false; 2226 2219 } 2227 2220 2228 2221 function the_request() { 2229 2222 global $request; 2230 2223 … … 2254 2247 2255 2248 function bp_group_membership_requests() { 2256 2249 global $requests_template; 2257 2250 2258 2251 return $requests_template->requests(); 2259 2252 } 2260 2253 2261 2254 function bp_group_the_membership_request() { 2262 2255 global $requests_template; 2263 2256 2264 2257 return $requests_template->the_request(); 2265 2258 } 2266 2259 2267 2260 function bp_group_request_user_avatar_thumb() { 2268 2261 global $requests_template; 2269 2262 2270 2263 echo apply_filters( 'bp_group_request_user_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $requests_template->request->user_id, 'type' => 'thumb' ) ) ); 2271 2264 } 2272 2265 2273 2266 function bp_group_request_reject_link() { 2274 global $requests_template, $groups_template; 2267 global $requests_template, $groups_template; 2275 2268 2276 2269 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' ) ); 2277 2270 } 2278 2271 2279 2272 function bp_group_request_accept_link() { 2280 global $requests_template, $groups_template; 2273 global $requests_template, $groups_template; 2281 2274 2282 2275 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' ) ); 2283 2276 } 2284 2277 2285 2278 function bp_group_request_time_since_requested() { 2286 global $requests_template; 2279 global $requests_template; 2287 2280 2288 2281 echo apply_filters( 'bp_group_request_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $requests_template->request->date_modified ) ) ) ); 2289 2282 } 2290 2283 2291 2284 function bp_group_request_comment() { 2292 2285 global $requests_template; 2293 2286 2294 2287 echo apply_filters( 'bp_group_request_comment', strip_tags( stripslashes( $requests_template->request->comments ) ) ); 2295 2288 } 2296 2289 2297 2290 function bp_group_request_user_link() { 2298 2291 global $requests_template; 2299 2292 2300 2293 echo apply_filters( 'bp_group_request_user_link', bp_core_get_userlink( $requests_template->request->user_id ) ); 2301 2294 } 2302 2295 … … 2310 2303 var $invite_count; 2311 2304 var $invites; 2312 2305 var $invite; 2313 2306 2314 2307 var $in_the_loop; 2315 2308 2316 2309 var $pag_page; 2317 2310 var $pag_num; 2318 2311 var $pag_links; 2319 2312 var $total_invite_count; 2320 2313 2321 2314 function bp_groups_invite_template( $user_id, $group_id ) { 2322 2315 global $bp; 2323 2316 2324 2317 $this->invites = groups_get_invites_for_group( $user_id, $group_id ); 2325 $this->invite_count = count( $this->invites ); 2318 $this->invite_count = count( $this->invites ); 2326 2319 } 2327 2320 2328 2321 function has_invites() { 2329 2322 if ( $this->invite_count ) 2330 2323 return true; 2331 2324 2332 2325 return false; 2333 2326 } 2334 2327 2335 2328 function next_invite() { 2336 2329 $this->current_invite++; 2337 2330 $this->invite = $this->invites[$this->current_invite]; 2338 2331 2339 2332 return $this->invite; 2340 2333 } 2341 2334 2342 2335 function rewind_invites() { 2343 2336 $this->current_invite = -1; 2344 2337 if ( $this->invite_count > 0 ) { 2345 2338 $this->invite = $this->invites[0]; 2346 2339 } 2347 2340 } 2348 2349 function invites() { 2341 2342 function invites() { 2350 2343 if ( $this->current_invite + 1 < $this->invite_count ) { 2351 2344 return true; 2352 2345 } elseif ( $this->current_invite + 1 == $this->invite_count ) { … … 2358 2351 $this->in_the_loop = false; 2359 2352 return false; 2360 2353 } 2361 2354 2362 2355 function the_invite() { 2363 2356 global $invite; 2364 2357 2365 2358 $this->in_the_loop = true; 2366 2359 $user_id = $this->next_invite(); 2367 2360 2368 2361 $this->invite = new stdClass; 2369 2362 $this->invite->user = new BP_Core_User( $user_id ); 2370 2363 $this->invite->group_id = $group_id; // Globaled in bp_group_has_invites() 2371 2364 2372 2365 if ( 0 == $this->current_invite ) // loop has just started 2373 2366 do_action('loop_start'); 2374 2367 } … … 2376 2369 2377 2370 function bp_group_has_invites( $args = '' ) { 2378 2371 global $bp, $invites_template, $group_id; 2379 2372 2380 2373 $defaults = array( 2381 2374 'group_id' => false, 2382 2375 'user_id' => $bp->loggedin_user->id … … 2384 2377 2385 2378 $r = wp_parse_args( $args, $defaults ); 2386 2379 extract( $r, EXTR_SKIP ); 2387 2380 2388 2381 if ( !$group_id ) { 2389 2382 /* Backwards compatibility */ 2390 2383 if ( $bp->groups->current_group ) $group_id = $bp->groups->current_group->id; 2391 2384 if ( $bp->groups->new_group_id ) $group_id = $bp->groups->new_group_id; 2392 2385 } 2393 2386 2394 2387 if ( !$group_id ) 2395 2388 return false; 2396 2389 … … 2400 2393 2401 2394 function bp_group_invites() { 2402 2395 global $invites_template; 2403 2396 2404 2397 return $invites_template->invites(); 2405 2398 } 2406 2399 2407 2400 function bp_group_the_invite() { 2408 2401 global $invites_template; 2409 2402 2410 2403 return $invites_template->the_invite(); 2411 2404 } 2412 2405 … … 2451 2444 } 2452 2445 function bp_get_group_invite_user_remove_invite_url() { 2453 2446 global $invites_template; 2454 2447 2455 2448 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' ); 2456 2449 } 2457 2450