Changeset 10373 for trunk/src/bp-groups/bp-groups-template.php
- Timestamp:
- 11/22/2015 04:58:34 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-template.php
r10342 r10373 197 197 function __construct( $args = array() ){ 198 198 199 // Backward compatibility with old method of passing arguments 199 // Backward compatibility with old method of passing arguments. 200 200 if ( ! is_array( $args ) || func_num_args() > 1 ) { 201 201 _deprecated_argument( __METHOD__, '1.7', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); … … 265 265 } 266 266 267 // backwards compatibility - the 'group_id' variable is not part of the267 // Backwards compatibility - the 'group_id' variable is not part of the 268 268 // BP_Groups_Group object, but we add it here for devs doing checks against it 269 269 // … … 271 271 // 272 272 // this is subject to removal in a future release; devs should check against 273 // $group->id instead 273 // $group->id instead. 274 274 $group->group_id = $group->id; 275 275 … … 326 326 } 327 327 328 // Build pagination links 328 // Build pagination links. 329 329 if ( (int) $this->total_group_count && (int) $this->pag_num ) { 330 330 $pag_args = array( … … 420 420 */ 421 421 do_action('group_loop_end'); 422 // Do some cleaning up after the loop 422 // Do some cleaning up after the loop. 423 423 $this->rewind_groups(); 424 424 } … … 499 499 global $groups_template; 500 500 501 /* **501 /* 502 502 * Defaults based on the current page & overridden by parsed $args 503 503 */ … … 506 506 $search_terms = false; 507 507 508 // When looking your own groups, check for two action variables 508 // When looking your own groups, check for two action variables. 509 509 if ( bp_is_current_action( 'my-groups' ) ) { 510 510 if ( bp_is_action_variable( 'most-popular', 0 ) ) { … … 514 514 } 515 515 516 // When looking at invites, set type to invites 516 // When looking at invites, set type to invites. 517 517 } elseif ( bp_is_current_action( 'invites' ) ) { 518 518 $type = 'invites'; 519 519 520 // When looking at a single group, set the type and slug 520 // When looking at a single group, set the type and slug. 521 521 } elseif ( bp_get_current_group_slug() ) { 522 522 $type = 'single-group'; … … 524 524 } 525 525 526 // Default search string (too soon to escape here) 526 // Default search string (too soon to escape here). 527 527 $search_query_arg = bp_core_get_component_search_query_arg( 'groups' ); 528 528 if ( ! empty( $_REQUEST[ $search_query_arg ] ) ) { … … 534 534 } 535 535 536 // Parse defaults and requested arguments 536 // Parse defaults and requested arguments. 537 537 $r = bp_parse_args( $args, array( 538 538 'type' => $type, … … 554 554 ), 'has_groups' ); 555 555 556 // Setup the Groups template global 556 // Setup the Groups template global. 557 557 $groups_template = new BP_Groups_Template( array( 558 558 'type' => $r['type'], … … 610 610 * 611 611 * @param object|bool $group Optional. Group object. Default: current group in loop. 612 *613 612 * @return bool 614 613 */ … … 648 647 * @param object|bool $group Optional. Group object. 649 648 * Default: current group in loop. 650 *651 649 * @return int 652 650 */ … … 684 682 * 685 683 * @param array $classes Array of custom classes. 686 *687 684 * @return string Row class of the group. 688 685 */ … … 690 687 global $groups_template; 691 688 692 // Add even/odd classes, but only if there's more than 1 group 689 // Add even/odd classes, but only if there's more than 1 group. 693 690 if ( $groups_template->group_count > 1 ) { 694 691 $pos_in_loop = (int) $groups_template->current_group; 695 692 $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd'; 696 693 697 // If we've only one group in the loop, don't bother with odd and even 694 // If we've only one group in the loop, don't bother with odd and even. 698 695 } else { 699 696 $classes[] = 'bp-single-group'; … … 703 700 $classes[] = sanitize_key( $groups_template->group->status ); 704 701 705 // User's group role 702 // User's group role. 706 703 if ( bp_is_user_active() ) { 707 704 708 // Admin 705 // Admin. 709 706 if ( bp_group_is_admin() ) { 710 707 $classes[] = 'is-admin'; 711 708 } 712 709 713 // Moderator 710 // Moderator. 714 711 if ( bp_group_is_mod() ) { 715 712 $classes[] = 'is-mod'; 716 713 } 717 714 718 // Member 715 // Member. 719 716 if ( bp_group_is_member() ) { 720 717 $classes[] = 'is-member'; … … 757 754 * @param object|bool $group Optional. Group object. 758 755 * Default: current group in loop. 759 *760 756 * @return string 761 757 */ … … 792 788 * @param object|bool $group Optional. Group object. 793 789 * Default: current group in loop. 794 *795 790 * @return string 796 791 */ … … 835 830 * @param object|bool $group Optional. Group object. 836 831 * Default: current group in loop. 837 *838 832 * @return string 839 833 */ … … 874 868 * @see bp_core_fetch_avatar() For a description of arguments and return values. 875 869 876 * @param array $args{870 * @param array|string $args { 877 871 * Arguments are listed here with an explanation of their defaults. 878 872 * For more information about the arguments, see {@link bp_core_fetch_avatar()}. … … 895 889 } 896 890 897 // Parse the arguments 891 // Parse the arguments. 898 892 $r = bp_parse_args( $args, array( 899 893 'type' => 'full', … … 905 899 ) ); 906 900 907 // Fetch the avatar from the folder 901 // Fetch the avatar from the folder. 908 902 $avatar = bp_core_fetch_avatar( array( 909 903 'item_id' => $groups_template->group->id, … … 919 913 ) ); 920 914 921 // If No avatar found, provide some backwards compatibility 915 // If No avatar found, provide some backwards compatibility. 922 916 if ( empty( $avatar ) ) { 923 917 $avatar = '<img src="' . esc_url( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />'; … … 953 947 * @param object|bool $group Optional. Group object. 954 948 * Default: current group in loop. 955 *956 949 * @return string 957 950 */ … … 981 974 * @param object|bool $group Optional. Group object. 982 975 * Default: current group in loop. 983 *984 976 * @return string 985 977 */ … … 996 988 997 989 /** 998 * Should we use the group's cover image header 990 * Should we use the group's cover image header. 999 991 * 1000 992 * @since 2.4.0 … … 1021 1013 * @param object|bool $group Optional. Group object. 1022 1014 * Default: current group in loop. 1023 *1024 1015 * @return string 1025 1016 */ … … 1066 1057 * @param object|bool $group Optional. Group object. 1067 1058 * Default: current group in loop. 1068 *1069 1059 * @return string 1070 1060 */ … … 1100 1090 * @param object|bool $group Optional. Group object. 1101 1091 * Default: current group in loop. 1102 *1103 1092 * @return string 1104 1093 */ … … 1134 1123 * @param object|bool $group Optional. Group object. 1135 1124 * Default: current group in loop. 1136 *1137 1125 * @return string 1138 1126 */ … … 1168 1156 * @param object|bool $group Optional. Group object. 1169 1157 * Default: current group in loop. 1170 *1171 1158 * @return string 1172 1159 */ … … 1206 1193 * @param object|bool $group Optional. Group object. 1207 1194 * Default: current group in loop. 1208 *1209 1195 * @return string 1210 1196 */ … … 1246 1232 * Defaults to the group currently being 1247 1233 * iterated on in the groups loop. 1248 *1249 1234 * @return string Excerpt. 1250 1235 */ … … 1285 1270 * @param object|bool $group Optional. Group object. 1286 1271 * Default: current group in loop. 1287 *1288 1272 * @return string 1289 1273 */ … … 1320 1304 * @param object|bool $group Optional. Group object. 1321 1305 * Default: current group in loop. 1322 * 1323 * @return unknown 1306 * @return mixed 1324 1307 */ 1325 1308 function bp_get_group_is_public( $group = false ) { … … 1347 1330 * @param object|bool $group Optional. Group object. 1348 1331 * Default: current group in loop. 1349 *1350 1332 * @return string 1351 1333 */ … … 1381 1363 * @param object|bool $group Optional. Group object. 1382 1364 * Default: current group in loop. 1383 *1384 1365 * @return string 1385 1366 */ … … 1415 1396 * @param object|bool $group Optional. Group object. 1416 1397 * Default: current group in loop. 1417 *1418 1398 * @return int 1419 1399 */ … … 1449 1429 * @param object|bool $group Optional. Group object. 1450 1430 * Default: current group in loop. 1451 *1452 1431 * @return string 1453 1432 */ … … 1475 1454 * Default: current group in loop. 1476 1455 * @param int $user_id ID of the user. 1477 *1478 1456 * @return bool 1479 1457 */ … … 1589 1567 } 1590 1568 1591 // fetch group admins if 'populate_extras' flag is false1569 // Fetch group admins if 'populate_extras' flag is false. 1592 1570 if ( empty( $group->args['populate_extras'] ) ) { 1593 1571 $query = new BP_Group_Member_Query( array( … … 1629 1607 } 1630 1608 1631 // fetch group mods if 'populate_extras' flag is false1609 // Fetch group mods if 'populate_extras' flag is false. 1632 1610 if ( empty( $group->args['populate_extras'] ) ) { 1633 1611 $query = new BP_Group_Member_Query( array( … … 1759 1737 * @param object|bool $group Optional. Group object. 1760 1738 * Default: current group in loop. 1761 *1762 1739 * @return string 1763 1740 */ … … 1784 1761 * No longer used in BuddyPress. 1785 1762 * 1786 * @todo Deprecate 1763 * @todo Deprecate. 1787 1764 */ 1788 1765 function bp_group_search_form() { … … 1807 1784 * No longer used in BuddyPress. 1808 1785 * 1809 * @todo Deprecate 1786 * @todo Deprecate. 1810 1787 * 1811 1788 * @return bool True if the displayed user has no groups, otherwise false. … … 1932 1909 * @param object|bool $group Optional. Group object. 1933 1910 * Default: current group in loop. 1934 *1935 1911 * @return int 1936 1912 */ … … 1995 1971 * @param object|bool $group Optional. Group object. 1996 1972 * Default: current group in loop. 1997 *1998 1973 * @return string 1999 1974 */ … … 2201 2176 * 2202 2177 * @param string $setting The setting you want to check against ('members', 2203 * 2178 * 'mods', or 'admins'). 2204 2179 * @param object|bool $group Optional. Group object. Default: current group in loop. 2205 2180 */ … … 2230 2205 * check. Default: the displayed group, or the current group 2231 2206 * in the loop. 2232 *2233 2207 * @return bool|string Returns false when no group can be found. Otherwise 2234 2208 * returns the group invite status, from among 'members', … … 2242 2216 2243 2217 if ( isset( $bp->groups->current_group->id ) ) { 2244 // Default to the current group first 2218 // Default to the current group first. 2245 2219 $group_id = $bp->groups->current_group->id; 2246 2220 } elseif ( isset( $groups_template->group->id ) ) { 2247 // Then see if we're in the loop 2221 // Then see if we're in the loop. 2248 2222 $group_id = $groups_template->group->id; 2249 2223 } else { … … 2254 2228 $invite_status = groups_get_groupmeta( $group_id, 'invite_status' ); 2255 2229 2256 // Backward compatibility. When 'invite_status' is not set, fall back to a default value 2230 // Backward compatibility. When 'invite_status' is not set, fall back to a default value. 2257 2231 if ( !$invite_status ) { 2258 2232 $invite_status = apply_filters( 'bp_group_invite_status_fallback', 'members' ); … … 2297 2271 2298 2272 if ( $user_id ) { 2299 // Users with the 'bp_moderate' cap can always send invitations 2273 // Users with the 'bp_moderate' cap can always send invitations. 2300 2274 if ( user_can( $user_id, 'bp_moderate' ) ) { 2301 2275 $can_send_invites = true; … … 2497 2471 * 2498 2472 * @param object|bool $group Optional. Group object. Default: current group in loop. 2499 *2500 2473 * @return array Info about group admins (user_id + date_modified). 2501 2474 */ … … 2616 2589 * member in a member loop. 2617 2590 * @param object|bool $group Optional. Group object. Default: current group. 2618 *2619 2591 * @return string 2620 2592 */ … … 2661 2633 * Default: current member in a member loop. 2662 2634 * @param object|bool $group Optional. Group object. Default: current group. 2663 *2664 2635 * @return string 2665 2636 */ … … 2702 2673 * Default: current member in a member loop. 2703 2674 * @param object|bool $group Optional. Group object. Default: current group. 2704 *2705 2675 * @return string 2706 2676 */ … … 2747 2717 * Default: current member in a member loop. 2748 2718 * @param object|bool $group Optional. Group object. Default: current group. 2749 *2750 2719 * @return string 2751 2720 */ … … 2800 2769 * @param string $subnav_item subnav item params. 2801 2770 * @param string $selected_item Surrent selected tab. 2802 *2803 2771 * @return string HTML output 2804 2772 */ … … 2862 2830 * @param object|bool $group Optional. Group object. 2863 2831 * Default: current group in the loop. 2864 *2865 2832 * @return string 2866 2833 */ … … 2896 2863 * @param object|bool $group Optional. Group object. 2897 2864 * Default: current group in the loop. 2898 *2899 2865 * @return string 2900 2866 */ … … 2925 2891 * @param object|bool $group Optional. Group object. 2926 2892 * Default: current group in the loop. 2927 *2928 2893 * @return bool 2929 2894 */ … … 2949 2914 * @param object|bool $group Optional. Group to check is_member. 2950 2915 * Default: current group in the loop. 2951 *2952 2916 * @return bool If user is member of group or not. 2953 2917 */ … … 2955 2919 global $groups_template; 2956 2920 2957 // Site admins always have access 2921 // Site admins always have access. 2958 2922 if ( bp_current_user_can( 'bp_moderate' ) ) { 2959 2923 return true; … … 2979 2943 * @param object|bool $group Optional. Group data object. 2980 2944 * Default: the current group in the groups loop. 2981 *2982 2945 * @return bool True if the user has an outstanding invite, otherwise false. 2983 2946 */ … … 3018 2981 * @param BP_Groups_Group|bool $group Group to check if user is banned. 3019 2982 * @param int $user_id The user ID to check. 3020 *3021 2983 * @return bool True if user is banned. False if user isn't banned. 3022 2984 */ … … 3024 2986 global $groups_template; 3025 2987 3026 // Site admins always have access 2988 // Site admins always have access. 3027 2989 if ( bp_current_user_can( 'bp_moderate' ) ) { 3028 2990 return false; 3029 2991 } 3030 2992 3031 // check groups loop first3032 // @see BP_Groups_Group::get_group_extras() 2993 // Check groups loop first 2994 // @see BP_Groups_Group::get_group_extras(). 3033 2995 if ( ! empty( $groups_template->in_the_loop ) && isset( $groups_template->group->is_banned ) ) { 3034 2996 $retval = $groups_template->group->is_banned; 3035 2997 3036 // not in loop2998 // Not in loop. 3037 2999 } else { 3038 // Default to not banned 3000 // Default to not banned. 3039 3001 $retval = false; 3040 3002 … … 3073 3035 * @param object|bool $group Optional. Group object. 3074 3036 * Default: Current group in the loop. 3075 *3076 3037 * @return string 3077 3038 */ … … 3106 3067 * @param object|bool $group Optional. Group object. 3107 3068 * Default: Current group in the loop. 3108 *3109 3069 * @return string 3110 3070 */ … … 3139 3099 * @param object|bool $group Optional. Group object. 3140 3100 * Default: Current group in the loop. 3141 *3142 3101 * @return string 3143 3102 */ … … 3170 3129 * @param object|bool $group Optional. Group object. 3171 3130 * Default: Current group in the loop. 3172 *3173 3131 * @return string 3174 3132 */ … … 3201 3159 * @param object|bool $group Optional. Group object. 3202 3160 * Default: current group in the loop. 3203 *3204 3161 * @return string 3205 3162 */ … … 3226 3183 * @param object|bool $group Optional. Group object. 3227 3184 * Default: current group in the loop. 3228 *3229 3185 * @return bool 3230 3186 */ … … 3266 3222 * @param BP_Groups_Group|bool $group The BP Groups_Group object if 3267 3223 * passed, boolean false if not passed. 3268 *3269 3224 * @return string HTML code for the button. 3270 3225 */ … … 3319 3274 * 3320 3275 * @param object|bool $group Single group object. 3321 *3322 3276 * @return mixed 3323 3277 */ … … 3325 3279 global $groups_template; 3326 3280 3327 // Set group to current loop group if none passed 3281 // Set group to current loop group if none passed. 3328 3282 if ( empty( $group ) ) { 3329 3283 $group =& $groups_template->group; 3330 3284 } 3331 3285 3332 // Don't show button if not logged in or previously banned 3286 // Don't show button if not logged in or previously banned. 3333 3287 if ( ! is_user_logged_in() || bp_group_is_user_banned( $group ) ) { 3334 3288 return false; 3335 3289 } 3336 3290 3337 // Group creation was not completed or status is unknown 3291 // Group creation was not completed or status is unknown. 3338 3292 if ( empty( $group->status ) ) { 3339 3293 return false; 3340 3294 } 3341 3295 3342 // Already a member 3296 // Already a member. 3343 3297 if ( ! empty( $group->is_member ) ) { 3344 3298 3345 // Stop sole admins from abandoning their group 3299 // Stop sole admins from abandoning their group. 3346 3300 $group_admins = groups_get_group_admins( $group->id ); 3347 3301 if ( ( 1 == count( $group_admins ) ) && ( bp_loggedin_user_id() === (int) $group_admins[0]->user_id ) ) { … … 3349 3303 } 3350 3304 3351 // Setup button attributes 3305 // Setup button attributes. 3352 3306 $button = array( 3353 3307 'id' => 'leave_group', … … 3363 3317 ); 3364 3318 3365 // Not a member 3319 // Not a member. 3366 3320 } else { 3367 3321 3368 // Show different buttons based on group status 3322 // Show different buttons based on group status. 3369 3323 switch ( $group->status ) { 3370 3324 case 'hidden' : … … 3389 3343 3390 3344 // Member has outstanding invitation - 3391 // show an "Accept Invitation" button 3345 // show an "Accept Invitation" button. 3392 3346 if ( $group->is_invited ) { 3393 3347 $button = array( … … 3405 3359 3406 3360 // Member has requested membership but request is pending - 3407 // show a "Request Sent" button 3361 // show a "Request Sent" button. 3408 3362 } elseif ( $group->is_pending ) { 3409 3363 $button = array( … … 3421 3375 3422 3376 // Member has not requested membership yet - 3423 // show a "Request Membership" button 3377 // show a "Request Membership" button. 3424 3378 } else { 3425 3379 $button = array( … … 3515 3469 */ 3516 3470 function bp_get_group_create_nav_item() { 3517 // Get the create a group button 3471 // Get the create a group button. 3518 3472 $create_group_button = bp_get_group_create_button(); 3519 3473 3520 // Make sure the button is available 3474 // Make sure the button is available. 3521 3475 if ( empty( $create_group_button ) ) { 3522 3476 return; … … 3541 3495 * @since 2.2.0 3542 3496 * 3543 * @uses bp_group_create_nav_item() to output the create a Group nav item. 3497 * @uses bp_group_create_nav_item() to output the create a Group nav item. 3498 * 3544 3499 * @return string HTML Output 3545 3500 */ 3546 3501 function bp_group_backcompat_create_nav_item() { 3547 // Bail if the Groups nav item is already used by bp-legacy 3502 // Bail if the Groups nav item is already used by bp-legacy. 3548 3503 if ( has_action( 'bp_groups_directory_group_filter', 'bp_legacy_theme_group_create_nav', 999 ) ) { 3549 3504 return; 3550 3505 } 3551 3506 3552 // Bail if the theme is not filtering the Groups directory title 3507 // Bail if the theme is not filtering the Groups directory title. 3553 3508 if ( ! has_filter( 'bp_groups_directory_header' ) ) { 3554 3509 return; … … 3566 3521 * 3567 3522 * @global BP_Groups_Template $groups_template Groups template object. 3523 * 3568 3524 * @param object $group Group to get status message for. Optional; defaults to current group. 3569 3525 */ … … 3571 3527 global $groups_template; 3572 3528 3573 // Group not passed so look for loop 3529 // Group not passed so look for loop. 3574 3530 if ( empty( $group ) ) { 3575 3531 $group =& $groups_template->group; 3576 3532 } 3577 3533 3578 // Group status is not set (maybe outside of group loop?) 3534 // Group status is not set (maybe outside of group loop?). 3579 3535 if ( empty( $group->status ) ) { 3580 3536 $message = __( 'This group is not currently accessible.', 'buddypress' ); 3581 3537 3582 // Group has a status 3538 // Group has a status. 3583 3539 } else { 3584 3540 switch( $group->status ) { 3585 3541 3586 // Private group 3542 // Private group. 3587 3543 case 'private' : 3588 3544 if ( ! bp_group_has_requested_membership( $group ) ) { … … 3602 3558 break; 3603 3559 3604 // Hidden group 3560 // Hidden group. 3605 3561 case 'hidden' : 3606 3562 default : … … 3656 3612 * 3657 3613 * @since 1.0.0 3614 * 3658 3615 * @return type 3659 3616 */ … … 3688 3645 * 3689 3646 * @param int $user_id User ID to get group membership count. 3690 *3691 3647 * @return int 3692 3648 */ … … 3705 3661 } 3706 3662 3707 /* *Group Members *************************************************************/3663 /* Group Members *************************************************************/ 3708 3664 3709 3665 class BP_Groups_Group_Members_Template { … … 3726 3682 * An array of optional arguments. 3727 3683 * @type int $group_id ID of the group whose members are being 3728 * 3684 * queried. Default: current group ID. 3729 3685 * @type int $page Page of results to be queried. Default: 1. 3730 3686 * @type int $per_page Number of items to return per page of … … 3742 3698 public function __construct( $args = array() ) { 3743 3699 3744 // Backward compatibility with old method of passing arguments 3700 // Backward compatibility with old method of passing arguments. 3745 3701 if ( ! is_array( $args ) || func_num_args() > 1 ) { 3746 3702 _deprecated_argument( __METHOD__, '2.0.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); … … 3787 3743 } 3788 3744 3789 // Assemble the base URL for pagination 3745 // Assemble the base URL for pagination. 3790 3746 $base_url = trailingslashit( bp_get_group_permalink( $current_group ) . bp_current_action() ); 3791 3747 if ( bp_action_variable() ) { … … 3798 3754 $members_args['per_page'] = $this->pag_num; 3799 3755 3800 // Get group members for this loop 3756 // Get group members for this loop. 3801 3757 $this->members = groups_get_group_members( $members_args ); 3802 3758 … … 3807 3763 } 3808 3764 3809 // Reset members array for subsequent looping 3765 // Reset members array for subsequent looping. 3810 3766 $this->members = $this->members['members']; 3811 3767 … … 3866 3822 do_action( 'loop_end', $this ); 3867 3823 3868 // Do some cleaning up after the loop 3824 // Do some cleaning up after the loop. 3869 3825 $this->rewind_members(); 3870 3826 } … … 3878 3834 $this->member = $this->next_member(); 3879 3835 3880 // loop has just started3836 // Loop has just started. 3881 3837 if ( 0 == $this->current_member ) { 3882 3838 … … 3977 3933 * @since 1.0.0 3978 3934 * 3979 * @param array|string $args {@see bp_core_fetch_avatar()} 3935 * @param array|string $args {@see bp_core_fetch_avatar()}. 3980 3936 */ 3981 3937 function bp_group_member_avatar( $args = '' ) { … … 3987 3943 * @since 1.0.0 3988 3944 * 3989 * @param array|string $args {@see bp_core_fetch_avatar()} 3990 * 3945 * @param array|string $args {@see bp_core_fetch_avatar()}. 3991 3946 * @return string 3992 3947 */ … … 4017 3972 * @since 1.0.0 4018 3973 * 4019 * @param array|string $args {@see bp_core_fetch_avatar()} 4020 */ 4021 3974 * @param array|string $args {@see bp_core_fetch_avatar()}. 3975 */ 4022 3976 function bp_group_member_avatar_thumb( $args = '' ) { 4023 3977 echo bp_get_group_member_avatar_thumb( $args ); … … 4028 3982 * @since 1.0.0 4029 3983 * 4030 * @param array|string $args {@see bp_core_fetch_avatar()} 4031 * 3984 * @param array|string $args {@see bp_core_fetch_avatar()}. 4032 3985 * @return string 4033 3986 */ … … 4071 4024 * @param int $width Width of avatar to fetch. 4072 4025 * @param int $height Height of avatar to fetch. 4073 *4074 4026 * @return string 4075 4027 */ … … 4399 4351 * 4400 4352 * @since 2.0.0 4401 *4402 * @return string html output4403 4353 */ 4404 4354 function bp_groups_members_template_part() { … … 4437 4387 * 4438 4388 * @since 2.0.0 4439 *4440 * @return string html output4441 4389 */ 4442 4390 function bp_groups_members_filter() { … … 4470 4418 } 4471 4419 4472 /* **************************************************************************4420 /* 4473 4421 * Group Creation Process Template Tags 4474 * */4422 */ 4475 4423 4476 4424 /** … … 4482 4430 * @uses bp_get_option() To retrieve value of 'bp_restrict_group_creation'. Defaults to 0. 4483 4431 * @uses bp_current_user_can() To determine if current user if super admin. 4484 *4485 4432 * @return bool True if user can create groups. False otherwise. 4486 4433 */ 4487 4434 function bp_user_can_create_groups() { 4488 4435 4489 // Super admin can always create groups 4436 // Super admin can always create groups. 4490 4437 if ( bp_current_user_can( 'bp_moderate' ) ) { 4491 4438 return true; 4492 4439 } 4493 4440 4494 // Get group creation option, default to 0 (allowed) 4441 // Get group creation option, default to 0 (allowed). 4495 4442 $restricted = (int) bp_get_option( 'bp_restrict_group_creation', 0 ); 4496 4443 4497 // Allow by default 4444 // Allow by default. 4498 4445 $can_create = true; 4499 4446 … … 4581 4528 function bp_is_group_creation_step( $step_slug ) { 4582 4529 4583 // Make sure we are in the groups component 4530 // Make sure we are in the groups component. 4584 4531 if ( ! bp_is_groups_component() || ! bp_is_current_action( 'create' ) ) { 4585 4532 return false; … … 4588 4535 $bp = buddypress(); 4589 4536 4590 // If this the first step, we can just accept and return true 4537 // If this the first step, we can just accept and return true. 4591 4538 $keys = array_keys( $bp->groups->group_creation_steps ); 4592 4539 if ( !bp_action_variable( 1 ) && array_shift( $keys ) == $step_slug ) { … … 4595 4542 4596 4543 // Before allowing a user to see a group creation step we must make sure 4597 // previous steps are completed 4544 // previous steps are completed. 4598 4545 if ( !bp_is_first_group_creation_step() ) { 4599 4546 if ( !bp_are_previous_group_creation_steps_complete( $step_slug ) ) { … … 4602 4549 } 4603 4550 4604 // Check the current step against the step parameter 4551 // Check the current step against the step parameter. 4605 4552 if ( bp_is_action_variable( $step_slug ) ) { 4606 4553 return true; … … 4637 4584 $bp = buddypress(); 4638 4585 4639 // If this is the first group creation step, return true 4586 // If this is the first group creation step, return true. 4640 4587 $keys = array_keys( $bp->groups->group_creation_steps ); 4641 4588 if ( array_shift( $keys ) == $step_slug ) { … … 4647 4594 $previous_steps = array(); 4648 4595 4649 // Get previous steps 4596 // Get previous steps. 4650 4597 foreach ( (array) $bp->groups->group_creation_steps as $slug => $name ) { 4651 4598 if ( $slug === $step_slug ) { … … 4761 4708 * @see bp_core_fetch_avatar() For more information on accepted arguments 4762 4709 * 4763 * @param array $args See bp_core_fetch_avatar()4710 * @param array|string $args See bp_core_fetch_avatar(). 4764 4711 */ 4765 4712 function bp_new_group_avatar( $args = '' ) { … … 4773 4720 * @see bp_core_fetch_avatar() For a description of arguments and return values. 4774 4721 * 4775 * @param array $args{4722 * @param array|string $args { 4776 4723 * Arguments are listed here with an explanation of their defaults. 4777 4724 * For more information about the arguments, see {@link bp_core_fetch_avatar()}. … … 4788 4735 function bp_get_new_group_avatar( $args = '' ) { 4789 4736 4790 // Parse arguments 4737 // Parse arguments. 4791 4738 $r = bp_parse_args( $args, array( 4792 4739 'type' => 'full', … … 4799 4746 ), 'get_new_group_avatar' ); 4800 4747 4801 // Merge parsed arguments with object specific data 4748 // Merge parsed arguments with object specific data. 4802 4749 $r = array_merge( $r, array( 4803 4750 'item_id' => bp_get_current_group_id(), … … 4806 4753 ) ); 4807 4754 4808 // Get the avatar 4755 // Get the avatar. 4809 4756 $avatar = bp_core_fetch_avatar( $r ); 4810 4757 … … 4840 4787 $steps = array_keys( $bp->groups->group_creation_steps ); 4841 4788 4842 // Loop through steps 4789 // Loop through steps. 4843 4790 foreach ( $steps as $slug ) { 4844 4791 4845 // Break when the current step is found 4792 // Break when the current step is found. 4846 4793 if ( bp_is_action_variable( $slug ) ) { 4847 4794 break; 4848 4795 } 4849 4796 4850 // Add slug to previous steps 4797 // Add slug to previous steps. 4851 4798 $previous_steps[] = $slug; 4852 4799 } 4853 4800 4854 // Generate the URL for the previous step 4801 // Generate the URL for the previous step. 4855 4802 $group_directory = bp_get_groups_directory_permalink(); 4856 4803 $create_step = 'create/step/'; … … 4911 4858 * @since 1.1.0 4912 4859 * 4913 * @param string $step Step to compare4914 * @return bool 4860 * @param string $step Step to compare. 4861 * @return bool True if yes, False if no 4915 4862 */ 4916 4863 function bp_is_last_group_creation_step( $step = '' ) { 4917 4864 4918 // Use current step, if no step passed 4865 // Use current step, if no step passed. 4919 4866 if ( empty( $step ) ) { 4920 4867 $step = bp_get_groups_current_create_step(); 4921 4868 } 4922 4869 4923 // Get the last step 4870 // Get the last step. 4924 4871 $bp = buddypress(); 4925 4872 $steps = array_keys( $bp->groups->group_creation_steps ); 4926 4873 $l_step = array_pop( $steps ); 4927 4874 4928 // Compare last step to step 4875 // Compare last step to step. 4929 4876 $retval = ( $l_step === $step ); 4930 4877 … … 4946 4893 * @since 1.1.0 4947 4894 * 4948 * @param string $step Step to compare4949 * @return bool 4895 * @param string $step Step to compare. 4896 * @return bool True if yes, False if no 4950 4897 */ 4951 4898 function bp_is_first_group_creation_step( $step = '' ) { 4952 4899 4953 // Use current step, if no step passed 4900 // Use current step, if no step passed. 4954 4901 if ( empty( $step ) ) { 4955 4902 $step = bp_get_groups_current_create_step(); 4956 4903 } 4957 4904 4958 // Get the first step 4905 // Get the first step. 4959 4906 $bp = buddypress(); 4960 4907 $steps = array_keys( $bp->groups->group_creation_steps ); 4961 4908 $f_step = array_shift( $steps ); 4962 4909 4963 // Compare first step to step 4910 // Compare first step to step. 4964 4911 $retval = ( $f_step === $step ); 4965 4912 … … 4980 4927 * 4981 4928 * @since 1.0.0 4929 * 4930 * @param array $args Array of arguments for friends list output. 4982 4931 */ 4983 4932 function bp_new_group_invite_friend_list( $args = array() ) { … … 4989 4938 * @since 1.0.0 4990 4939 * 4991 * @param array $args4940 * @param array $args Array of arguments for friends list output. 4992 4941 * @return mixed HTML list of checkboxes, or false 4993 4942 */ 4994 4943 function bp_get_new_group_invite_friend_list( $args = array() ) { 4995 4944 4996 // Bail if no friends component 4945 // Bail if no friends component. 4997 4946 if ( ! bp_is_active( 'friends' ) ) { 4998 4947 return false; 4999 4948 } 5000 4949 5001 // Parse arguments 4950 // Parse arguments. 5002 4951 $r = wp_parse_args( $args, array( 5003 4952 'user_id' => bp_loggedin_user_id(), … … 5006 4955 ) ); 5007 4956 5008 // No group passed, so look for new or current group ID's 4957 // No group passed, so look for new or current group ID's. 5009 4958 if ( empty( $r['group_id'] ) ) { 5010 4959 $bp = buddypress(); … … 5014 4963 } 5015 4964 5016 // Setup empty items array 4965 // Setup empty items array. 5017 4966 $items = array(); 5018 4967 5019 // Get user's friends who are not in this group already 4968 // Get user's friends who are not in this group already. 5020 4969 $friends = friends_get_friends_invite_list( $r['user_id'], $r['group_id'] ); 5021 4970 5022 4971 if ( ! empty( $friends ) ) { 5023 4972 5024 // Get already invited users 4973 // Get already invited users. 5025 4974 $invites = groups_get_invites_for_group( $r['user_id'], $r['group_id'] ); 5026 4975 … … 5132 5081 * @since 1.1.0 5133 5082 * 5134 * @param string $slug 5135 * 5083 * @param string $slug Admin screen slug. 5136 5084 * @return bool 5137 5085 */ … … 5180 5128 * 5181 5129 * @since 1.0.0 5182 * @param string $type thumb or full ?5130 * 5183 5131 * @uses bp_get_group_current_avatar() to get the avatar of the current group. 5132 * 5133 * @param string $type Thumb or full. 5184 5134 */ 5185 5135 function bp_group_current_avatar( $type = 'thumb' ) { … … 5191 5141 * @since 2.0.0 5192 5142 * 5193 * @param string $type thumb or full ?5143 * @param string $type Thumb or full. 5194 5144 * @return string $tab The current tab's slug. 5195 5145 */ … … 5220 5170 * @since 1.1.0 5221 5171 * 5222 * @param int|bool $group_id 5223 * 5172 * @param int|bool $group_id Group ID to check. 5224 5173 * @return boolean 5225 5174 */ … … 5276 5225 } 5277 5226 5278 /* *Group Membership Requests *************************************************/5227 /* Group Membership Requests *************************************************/ 5279 5228 5280 5229 class BP_Groups_Membership_Requests_Template { … … 5305 5254 public function __construct( $args = array() ) { 5306 5255 5307 // Backward compatibility with old method of passing arguments 5256 // Backward compatibility with old method of passing arguments. 5308 5257 if ( ! is_array( $args ) || func_num_args() > 1 ) { 5309 5258 _deprecated_argument( __METHOD__, '2.0.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); … … 5338 5287 'page' => $this->pag_page, 5339 5288 5340 // These filters ensure we only get pending requests 5289 // These filters ensure we only get pending requests. 5341 5290 'is_confirmed' => false, 5342 5291 'inviter_id' => 0, … … 5346 5295 $this->request_count = count( $this->requests ); 5347 5296 5348 // Compatibility with legacy format of request data objects 5297 // Compatibility with legacy format of request data objects. 5349 5298 foreach ( $this->requests as $rk => $rv ) { 5350 5299 // For legacy reasons, the 'id' property of each 5351 5300 // request must match the membership id, not the ID of 5352 // the user (as it's returned by BP_Group_Member_Query) 5301 // the user (as it's returned by BP_Group_Member_Query). 5353 5302 $this->requests[ $rk ]->user_id = $rv->ID; 5354 5303 $this->requests[ $rk ]->id = $rv->membership_id; 5355 5304 5356 // Miscellaneous values 5305 // Miscellaneous values. 5357 5306 $this->requests[ $rk ]->group_id = $r['group_id']; 5358 5307 } … … 5417 5366 */ 5418 5367 do_action( 'group_request_loop_end' ); 5419 // Do some cleaning up after the loop 5368 // Do some cleaning up after the loop. 5420 5369 $this->rewind_requests(); 5421 5370 } … … 5429 5378 $this->request = $this->next_request(); 5430 5379 5431 // loop has just started5380 // Loop has just started. 5432 5381 if ( 0 == $this->current_request ) { 5433 5382 … … 5664 5613 public function __construct( $args = array() ) { 5665 5614 5666 // Backward compatibility with old method of passing arguments 5615 // Backward compatibility with old method of passing arguments. 5667 5616 if ( ! is_array( $args ) || func_num_args() > 1 ) { 5668 5617 _deprecated_argument( __METHOD__, '2.0.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); … … 5695 5644 'page' => $this->pag_page, 5696 5645 5697 // These filters ensure we get only pending invites 5646 // These filters ensure we get only pending invites. 5698 5647 'is_confirmed' => false, 5699 5648 'inviter_id' => $r['user_id'], … … 5706 5655 5707 5656 // If per_page is set to 0 (show all results), don't generate 5708 // pag_links 5657 // pag_links. 5709 5658 if ( ! empty( $this->pag_num ) ) { 5710 5659 $this->pag_links = paginate_links( array( … … 5841 5790 } 5842 5791 5843 // Set the global (for use in BP_Groups_Invite_Template::the_invite()) 5792 // Set the global (for use in BP_Groups_Invite_Template::the_invite()). 5844 5793 if ( empty( $group_id ) ) { 5845 5794 $group_id = $r['group_id']; … … 6026 5975 function bp_groups_activity_feed() { 6027 5976 6028 // Bail if not viewing a single group or activity is not active 5977 // Bail if not viewing a single group or activity is not active. 6029 5978 if ( ! bp_is_active( 'groups' ) || ! bp_is_active( 'activity' ) || ! bp_is_group() ) { 6030 5979 return; … … 6049 5998 * 6050 5999 * @since 1.5.0 6000 * 6051 6001 * @return string 6052 6002 */ … … 6214 6164 * @param string $query_args 6215 6165 * @param bool $nonce 6216 *6217 6166 * @return string 6218 6167 */ … … 6228 6177 * @param string $query_args 6229 6178 * @param bool $nonce 6230 *6231 6179 * @return string 6232 6180 */ … … 6236 6184 $url = ''; 6237 6185 6238 // Must be a group 6186 // Must be a group. 6239 6187 if ( ! empty( $current_group->id ) ) { 6240 6188 … … 6246 6194 } 6247 6195 6248 // Add a slash at the end of our user url 6196 // Add a slash at the end of our user url. 6249 6197 $url = trailingslashit( $url ); 6250 6198 6251 // Add possible query args 6199 // Add possible query args. 6252 6200 if ( !empty( $query_args ) && is_array( $query_args ) ) { 6253 6201 $url = add_query_arg( $query_args, $url );
Note: See TracChangeset
for help on using the changeset viewer.