Skip to:
Content

BuddyPress.org

Changeset 10373


Ignore:
Timestamp:
11/22/2015 04:58:34 AM (9 years ago)
Author:
tw2113
Message:

More docs cleanup for BP-Groups component.

See #6401.

Location:
trunk/src/bp-groups
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-actions.php

    r10276 r10373  
    2929
    3030    if ( ! $user_has_access && 'hidden' !== $current_group->status ) {
    31         // Always allow access to home and request-membership
     31        // Always allow access to home and request-membership.
    3232        if ( bp_is_current_action( 'home' ) || bp_is_current_action( 'request-membership' ) ) {
    3333            $user_has_access = true;
    3434
    35         // User doesn't have access, so set up redirect args
     35        // User doesn't have access, so set up redirect args.
    3636        } elseif ( is_user_logged_in() ) {
    3737            $no_access_args = array(
     
    4343    }
    4444
    45     // Protect the admin tab from non-admins
     45    // Protect the admin tab from non-admins.
    4646    if ( bp_is_current_action( 'admin' ) && ! bp_is_item_admin() ) {
    4747        $user_has_access = false;
     
    9595function groups_action_create_group() {
    9696
    97     // If we're not at domain.org/groups/create/ then return false
     97    // If we're not at domain.org/groups/create/ then return false.
    9898    if ( !bp_is_groups_component() || !bp_is_current_action( 'create' ) )
    9999        return false;
     
    109109    $bp = buddypress();
    110110
    111     // Make sure creation steps are in the right order
     111    // Make sure creation steps are in the right order.
    112112    groups_action_sort_creation_steps();
    113113
    114     // If no current step is set, reset everything so we can start a fresh group creation
     114    // If no current step is set, reset everything so we can start a fresh group creation.
    115115    $bp->groups->current_create_step = bp_action_variable( 1 );
    116116    if ( !bp_get_groups_current_create_step() ) {
     
    126126    }
    127127
    128     // If this is a creation step that is not recognized, just redirect them back to the first screen
     128    // If this is a creation step that is not recognized, just redirect them back to the first screen.
    129129    if ( bp_get_groups_current_create_step() && empty( $bp->groups->group_creation_steps[bp_get_groups_current_create_step()] ) ) {
    130130        bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' );
     
    132132    }
    133133
    134     // Fetch the currently completed steps variable
     134    // Fetch the currently completed steps variable.
    135135    if ( isset( $_COOKIE['bp_completed_create_steps'] ) && !isset( $reset_steps ) )
    136136        $bp->groups->completed_create_steps = json_decode( base64_decode( stripslashes( $_COOKIE['bp_completed_create_steps'] ) ) );
    137137
    138     // Set the ID of the new group, if it has already been created in a previous step
     138    // Set the ID of the new group, if it has already been created in a previous step.
    139139    if ( isset( $_COOKIE['bp_new_group_id'] ) ) {
    140140        $bp->groups->new_group_id = (int) $_COOKIE['bp_new_group_id'];
    141141        $bp->groups->current_group = groups_get_group( array( 'group_id' => $bp->groups->new_group_id ) );
    142142
    143         // Only allow the group creator to continue to edit the new group
     143        // Only allow the group creator to continue to edit the new group.
    144144        if ( ! bp_is_group_creator( $bp->groups->current_group, bp_loggedin_user_id() ) ) {
    145145            bp_core_add_message( __( 'Only the group creator may continue editing this group.', 'buddypress' ), 'error' );
     
    148148    }
    149149
    150     // If the save, upload or skip button is hit, lets calculate what we need to save
     150    // If the save, upload or skip button is hit, lets calculate what we need to save.
    151151    if ( isset( $_POST['save'] ) ) {
    152152
    153         // Check the nonce
     153        // Check the nonce.
    154154        check_admin_referer( 'groups_create_save_' . bp_get_groups_current_create_step() );
    155155
     
    175175                $group_enable_forum = 0;
    176176            } else {
    177                 // Create the forum if enable_forum = 1
     177                // Create the forum if enable_forum = 1.
    178178                if ( bp_is_active( 'forums' ) && !groups_get_groupmeta( $bp->groups->new_group_id, 'forum_id' ) ) {
    179179                    groups_new_group_forum();
     
    247247            $bp->groups->completed_create_steps[] = bp_get_groups_current_create_step();
    248248
    249         // Reset cookie info
     249        // Reset cookie info.
    250250        setcookie( 'bp_new_group_id', $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH );
    251251        setcookie( 'bp_completed_create_steps', base64_encode( json_encode( $bp->groups->completed_create_steps ) ), time()+60*60*24, COOKIEPATH );
    252252
    253253        // If we have completed all steps and hit done on the final step we
    254         // can redirect to the completed group
     254        // can redirect to the completed group.
    255255        $keys = array_keys( $bp->groups->group_creation_steps );
    256256        if ( count( $bp->groups->completed_create_steps ) == count( $keys ) && bp_get_groups_current_create_step() == array_pop( $keys ) ) {
     
    298298    }
    299299
    300     // Remove invitations
     300    // Remove invitations.
    301301    if ( 'group-invites' === bp_get_groups_current_create_step() && ! empty( $_REQUEST['user_id'] ) && is_numeric( $_REQUEST['user_id'] ) ) {
    302302        if ( ! check_admin_referer( 'groups_invite_uninvite_user' ) ) {
     
    316316    }
    317317
    318     // Group avatar is handled separately
     318    // Group avatar is handled separately.
    319319    if ( 'group-avatar' == bp_get_groups_current_create_step() && isset( $_POST['upload'] ) ) {
    320320        if ( ! isset( $bp->avatar_admin ) ) {
     
    323323
    324324        if ( !empty( $_FILES ) && isset( $_POST['upload'] ) ) {
    325             // Normally we would check a nonce here, but the group save nonce is used instead
    326 
    327             // Pass the file to the avatar upload handler
     325            // Normally we would check a nonce here, but the group save nonce is used instead.
     326            // Pass the file to the avatar upload handler.
    328327            if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
    329328                $bp->avatar_admin->step = 'crop-image';
    330329
    331                 // Make sure we include the jQuery jCrop file for image cropping
     330                // Make sure we include the jQuery jCrop file for image cropping.
    332331                add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' );
    333332            }
    334333        }
    335334
    336         // If the image cropping is done, crop the image and save a full/thumb version
     335        // If the image cropping is done, crop the image and save a full/thumb version.
    337336        if ( isset( $_POST['avatar-crop-submit'] ) && isset( $_POST['upload'] ) ) {
    338             // Normally we would check a nonce here, but the group save nonce is used instead
    339 
     337            // Normally we would check a nonce here, but the group save nonce is used instead.
    340338            if ( !bp_core_avatar_handle_crop( array( 'object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
    341339                bp_core_add_message( __( 'There was an error saving the group profile photo, please try uploading again.', 'buddypress' ), 'error' );
     
    364362        return false;
    365363
    366     // Nonce check
     364    // Nonce check.
    367365    if ( !check_admin_referer( 'groups_join_group' ) )
    368366        return false;
     
    370368    $bp = buddypress();
    371369
    372     // Skip if banned or already a member
     370    // Skip if banned or already a member.
    373371    if ( !groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) && !groups_is_user_banned( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
    374372
    375         // User wants to join a group that is not public
     373        // User wants to join a group that is not public.
    376374        if ( $bp->groups->current_group->status != 'public' ) {
    377375            if ( !groups_check_user_has_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
     
    381379        }
    382380
    383         // User wants to join any group
     381        // User wants to join any group.
    384382        if ( !groups_join_group( $bp->groups->current_group->id ) )
    385383            bp_core_add_message( __( 'There was an error joining the group.', 'buddypress' ), 'error' );
     
    417415    }
    418416
    419     // Nonce check
     417    // Nonce check.
    420418    if ( ! check_admin_referer( 'groups_leave_group' ) ) {
    421419        return false;
    422420    }
    423421
    424     // User wants to leave any group
     422    // User wants to leave any group.
    425423    if ( groups_is_user_member( bp_loggedin_user_id(), bp_get_current_group_id() ) ) {
    426424        $bp = buddypress();
    427425
    428         // Stop sole admins from abandoning their group
     426        // Stop sole admins from abandoning their group.
    429427        $group_admins = groups_get_group_admins( bp_get_current_group_id() );
    430428
     
    473471    }
    474472
    475     // Sort the steps by their position key
     473    // Sort the steps by their position key.
    476474    ksort($temp);
    477475    unset($bp->groups->group_creation_steps);
     
    510508function groups_action_group_feed() {
    511509
    512     // get current group
     510    // Get current group.
    513511    $group = groups_get_current_group();
    514512
     
    516514        return false;
    517515
    518     // if group isn't public or if logged-in user is not a member of the group, do
    519     // not output the group activity feed
     516    // If group isn't public or if logged-in user is not a member of the group, do
     517    // not output the group activity feed.
    520518    if ( ! bp_group_is_visible( $group ) ) {
    521519        return false;
    522520    }
    523521
    524     // setup the feed
     522    // Set up the feed.
    525523    buddypress()->activity->feed = new BP_Activity_Feed( array(
    526524        'id'            => 'group',
  • trunk/src/bp-groups/bp-groups-activity.php

    r10148 r10373  
    5454    // These actions are for the legacy forums
    5555    // Since the bbPress plugin also shares the same 'forums' identifier, we also
    56     // check for the legacy forums loader class to be extra cautious
     56    // check for the legacy forums loader class to be extra cautious.
    5757    if ( bp_is_active( 'forums' ) && class_exists( 'BP_Forums_Component' ) ) {
    5858        bp_activity_set_action(
     
    9191 * @param string $action   Static activity action.
    9292 * @param object $activity Activity data object.
    93  *
    9493 * @return string
    9594 */
     
    123122 * @param string $action   Static activity action.
    124123 * @param object $activity Activity data object.
    125  *
    126124 * @return string
    127125 */
     
    138136
    139137    // Legacy filters (do not follow parameter patterns of other activity
    140     // action filters, and requires apply_filters_ref_array())
     138    // action filters, and requires apply_filters_ref_array()).
    141139    if ( has_filter( 'groups_activity_membership_accepted_action' ) ) {
    142140        $action = apply_filters_ref_array( 'groups_activity_membership_accepted_action', array( $action, $user_link, &$group ) );
    143141    }
    144142
    145     // Another legacy filter
     143    // Another legacy filter.
    146144    if ( has_filter( 'groups_activity_accepted_invite_action' ) ) {
    147145        $action = apply_filters_ref_array( 'groups_activity_accepted_invite_action', array( $action, $activity->user_id, &$group ) );
     
    166164 * @param  string $action   Static activity action.
    167165 * @param  object $activity Activity data object.
    168  *
    169166 * @return string
    170167 */
     
    221218 *
    222219 * @param array $activities Array of activity items.
    223  *
    224220 * @return array
    225221 */
     
    243239        // TEMPORARY - Once the 'populate_extras' issue is solved
    244240        // in the groups component, we can do this with groups_get_groups()
    245         // rather than manually
     241        // rather than manually.
    246242        $uncached_ids = array();
    247243        foreach ( $group_ids as $group_id ) {
     
    271267 * @since 2.2.0
    272268 *
    273  * @param array $retval Empty array by default
    274  * @param array $filter Current activity arguments
     269 * @param array $retval Empty array by default.
     270 * @param array $filter Current activity arguments.
    275271 *
    276272 * @return array
     
    278274function bp_groups_filter_activity_scope( $retval = array(), $filter = array() ) {
    279275
    280     // Determine the user_id
     276    // Determine the user_id.
    281277    if ( ! empty( $filter['user_id'] ) ) {
    282278        $user_id = $filter['user_id'];
     
    287283    }
    288284
    289     // Determine groups of user
     285    // Determine groups of user.
    290286    $groups = groups_get_user_groups( $user_id );
    291287    if ( empty( $groups['groups'] ) ) {
     
    318314        $show_hidden,
    319315
    320         // overrides
     316        // Overrides.
    321317        'override' => array(
    322318            'filter'      => array( 'user_id' => 0 ),
     
    355351    }
    356352
    357     // Set the default for hide_sitewide by checking the status of the group
     353    // Set the default for hide_sitewide by checking the status of the group.
    358354    $hide_sitewide = false;
    359355    if ( !empty( $args['item_id'] ) ) {
     
    391387 * @param int $group_id Optional. The ID of the group whose last_activity is
    392388 *                      being updated. Default: the current group's ID.
    393  *
    394389 * @return bool|null False on failure.
    395390 */
     
    419414 * @param int $user_id  ID of the user joining the group.
    420415 * @param int $group_id ID of the group.
    421  *
    422416 * @return bool|null False on failure.
    423417 */
    424418function bp_groups_membership_accepted_add_activity( $user_id, $group_id ) {
    425419
    426     // Bail if Activity is not active
     420    // Bail if Activity is not active.
    427421    if ( ! bp_is_active( 'activity' ) ) {
    428422        return false;
    429423    }
    430424
    431     // Get the group so we can get it's name
     425    // Get the group so we can get it's name.
    432426    $group = groups_get_group( array( 'group_id' => $group_id ) );
    433427
     
    443437    $action = apply_filters_ref_array( 'groups_activity_membership_accepted_action', array( sprintf( __( '%1$s joined the group %2$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $user_id, &$group ) );
    444438
    445     // Record in activity streams
     439    // Record in activity streams.
    446440    groups_record_activity( array(
    447441        'action'  => $action,
     
    461455 * @param  BP_Groups_Group $old_group      Group object before the details had been changed.
    462456 * @param  bool            $notify_members True if the admin has opted to notify group members, otherwise false.
    463  *
    464457 * @return int|bool The ID of the activity on success. False on error.
    465458 */
     
    475468    }
    476469
    477     // If the admin has opted not to notify members, don't post an activity item either
     470    // If the admin has opted not to notify members, don't post an activity item either.
    478471    if ( empty( $notify_members ) ) {
    479472        return;
     
    557550function bp_groups_leave_group_delete_recent_activity( $group_id, $user_id ) {
    558551
    559     // Bail if Activity component is not active
     552    // Bail if Activity component is not active.
    560553    if ( ! bp_is_active( 'activity' ) ) {
    561554        return;
    562555    }
    563556
    564     // Get the member's group membership information
     557    // Get the member's group membership information.
    565558    $membership = new BP_Groups_Member( $user_id, $group_id );
    566559
    567     // Check the time period, and maybe delete their recent group activity
     560    // Check the time period, and maybe delete their recent group activity.
    568561    if ( time() <= strtotime( '+5 minutes', (int) strtotime( $membership->date_modified ) ) ) {
    569562        bp_activity_delete( array(
  • trunk/src/bp-groups/bp-groups-admin.php

    r10360 r10373  
    1818if ( !class_exists( 'WP_List_Table' ) ) require( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
    1919
    20 // per_page screen option. Has to be hooked in extremely early.
     20// The per_page screen option. Has to be hooked in extremely early.
    2121if ( is_admin() && ! empty( $_REQUEST['page'] ) && 'bp-groups' == $_REQUEST['page'] )
    2222    add_filter( 'set-screen-option', 'bp_groups_admin_screen_options', 10, 3 );
     
    2929function bp_groups_add_admin_menu() {
    3030
    31     // Add our screen
     31    // Add our screen.
    3232    $hook = add_menu_page(
    3333        _x( 'Groups', 'Admin Groups page title', 'buddypress' ),
     
    5353 *
    5454 * @param array $custom_menus Array of BP top-level menu items.
    55  *
    5655 * @return array Menu item array, with Groups added.
    5756 */
     
    7675    global $bp_groups_list_table;
    7776
    78     // Build redirection URL
     77    // Build redirection URL.
    7978    $redirect_to = remove_query_arg( array( 'action', 'action2', 'gid', 'deleted', 'error', 'updated', 'success_new', 'error_new', 'success_modified', 'error_modified' ), $_SERVER['REQUEST_URI'] );
    8079
    81     // Decide whether to load the dev version of the CSS and JavaScript
     80    // Decide whether to load the dev version of the CSS and JavaScript.
    8281    $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : 'min.';
    8382
     
    9392    do_action( 'bp_groups_admin_load', $doaction );
    9493
    95     // Edit screen
     94    // Edit screen.
    9695    if ( 'do_delete' == $doaction && ! empty( $_GET['gid'] ) ) {
    9796
     
    112111
    113112    } elseif ( 'edit' == $doaction && ! empty( $_GET['gid'] ) ) {
    114         // columns screen option
     113        // Columns screen option.
    115114        add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) );
    116115
     
    123122        ) );
    124123
    125         // Help panel - sidebar links
     124        // Help panel - sidebar links.
    126125        get_current_screen()->set_help_sidebar(
    127126            '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
     
    142141        do_action( 'bp_groups_admin_meta_boxes' );
    143142
    144         // Enqueue JavaScript files
     143        // Enqueue JavaScript files.
    145144        wp_enqueue_script( 'postbox' );
    146145        wp_enqueue_script( 'dashboard' );
    147146
    148     // Index screen
     147    // Index screen.
    149148    } else {
    150         // Create the Groups screen list table
     149        // Create the Groups screen list table.
    151150        $bp_groups_list_table = new BP_Groups_List_Table();
    152151
    153         // per_page screen option
     152        // The per_page screen option.
    154153        add_screen_option( 'per_page', array( 'label' => _x( 'Groups', 'Groups per page (screen options)', 'buddypress' )) );
    155154
    156         // Help panel - overview text
     155        // Help panel - overview text.
    157156        get_current_screen()->add_help_tab( array(
    158157            'id'      => 'bp-groups-overview',
     
    171170        ) );
    172171
    173         // Help panel - sidebar links
     172        // Help panel - sidebar links.
    174173        get_current_screen()->set_help_sidebar(
    175174            '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
     
    180179    $bp = buddypress();
    181180
    182     // Enqueue CSS and JavaScript
     181    // Enqueue CSS and JavaScript.
    183182    wp_enqueue_script( 'bp_groups_admin_js', $bp->plugin_url . "bp-groups/admin/js/admin.{$min}js", array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), bp_get_version(), true );
    184183    wp_localize_script( 'bp_groups_admin_js', 'BP_Group_Admin', array(
     
    195194
    196195    if ( $doaction && 'save' == $doaction ) {
    197         // Get group ID
     196        // Get group ID.
    198197        $group_id = isset( $_REQUEST['gid'] ) ? (int) $_REQUEST['gid'] : '';
    199198
     
    203202        ), $redirect_to );
    204203
    205         // Check this is a valid form submission
     204        // Check this is a valid form submission.
    206205        check_admin_referer( 'edit-group_' . $group_id );
    207206
    208         // Get the group from the database
     207        // Get the group from the database.
    209208        $group = groups_get_group( 'group_id=' . $group_id );
    210209
    211         // If the group doesn't exist, just redirect back to the index
     210        // If the group doesn't exist, just redirect back to the index.
    212211        if ( empty( $group->slug ) ) {
    213212            wp_redirect( $redirect_to );
     
    215214        }
    216215
    217         // Check the form for the updated properties
    218 
    219         // Store errors
     216        // Check the form for the updated properties.
     217        // Store errors.
    220218        $error = 0;
    221219        $success_new = $error_new = $success_modified = $error_modified = array();
    222220
    223221        // Group name and description are handled with
    224         // groups_edit_base_group_details()
     222        // groups_edit_base_group_details().
    225223        if ( !groups_edit_base_group_details( $group_id, $_POST['bp-groups-name'], $_POST['bp-groups-description'], 0 ) ) {
    226224            $error = $group_id;
    227225
    228             // using negative integers for different error messages... eek!
     226            // Using negative integers for different error messages... eek!
    229227            if ( empty( $_POST['bp-groups-name'] ) && empty( $_POST['bp-groups-description'] ) ) {
    230228                $error = -3;
     
    236234        }
    237235
    238         // Enable discussion forum
     236        // Enable discussion forum.
    239237        $enable_forum   = ( isset( $_POST['group-show-forum'] ) ) ? 1 : 0;
    240238
     
    263261        }
    264262
    265         // Process new members
     263        // Process new members.
    266264        $user_names = array();
    267265
     
    276274
    277275                // Make sure the user exists before attempting
    278                 // to add to the group
     276                // to add to the group.
    279277                $user = get_user_by( 'slug', $un );
    280278
     
    291289        }
    292290
    293         // Process member role changes
     291        // Process member role changes.
    294292        if ( ! empty( $_POST['bp-groups-role'] ) && ! empty( $_POST['bp-groups-existing-role'] ) ) {
    295293
    296294            // Before processing anything, make sure you're not
    297             // attempting to remove the all user admins
     295            // attempting to remove the all user admins.
    298296            $admin_count = 0;
    299297            foreach ( (array) $_POST['bp-groups-role'] as $new_role ) {
     
    311309            } else {
    312310
    313                 // Process only those users who have had their roles changed
     311                // Process only those users who have had their roles changed.
    314312                foreach ( (array) $_POST['bp-groups-role'] as $user_id => $new_role ) {
    315313
     
    321319                            case 'mod' :
    322320                                // Admin to mod is a demotion. Demote to
    323                                 // member, then fall through
     321                                // member, then fall through.
    324322                                if ( 'admin' == $existing_role ) {
    325323                                    groups_demote_member( $user_id, $group_id );
     
    328326                            case 'admin' :
    329327                                // If the user was banned, we must
    330                                 // unban first
     328                                // unban first.
    331329                                if ( 'banned' == $existing_role ) {
    332330                                    groups_unban_member( $user_id, $group_id );
     
    334332
    335333                                // At this point, each existing_role
    336                                 // is a member, so promote
     334                                // is a member, so promote.
    337335                                $result = groups_promote_member( $user_id, $group_id, $new_role );
    338336
     
    362360                        }
    363361
    364                         // Store the success or failure
     362                        // Store the success or failure.
    365363                        if ( $result ) {
    366364                            $success_modified[] = $user_id;
     
    382380        do_action( 'bp_group_admin_edit_after', $group_id );
    383381
    384         // Create the redirect URL
    385 
     382        // Create the redirect URL.
    386383        if ( $error ) {
    387             // This means there was an error updating group details
     384            // This means there was an error updating group details.
    388385            $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to );
    389386        } else {
    390             // Group details were update successfully
     387            // Group details were update successfully.
    391388            $redirect_to = add_query_arg( 'updated', 1, $redirect_to );
    392389        }
     
    438435 * @param string $option    Screen option name.
    439436 * @param string $new_value Screen option form value.
    440  *
    441437 * @return string Option value. False to abandon update.
    442438 */
     
    445441        return $value;
    446442
    447     // Per page
     443    // Per page.
    448444    $new_value = (int) $new_value;
    449445    if ( $new_value < 1 || $new_value > 999 )
     
    459455 */
    460456function bp_groups_admin() {
    461     // Decide whether to load the index or edit screen
     457    // Decide whether to load the index or edit screen.
    462458    $doaction = bp_admin_list_table_current_bulk_action();
    463459
    464     // Display the single group edit screen
     460    // Display the single group edit screen.
    465461    if ( 'edit' == $doaction && ! empty( $_GET['gid'] ) ) {
    466462        bp_groups_admin_edit();
    467463
    468     // Display the group deletion confirmation screen
     464    // Display the group deletion confirmation screen.
    469465    } elseif ( 'delete' == $doaction && ! empty( $_GET['gid'] ) ) {
    470466        bp_groups_admin_delete();
    471467
    472     // Otherwise, display the groups index screen
     468    // Otherwise, display the groups index screen.
    473469    } else {
    474470        bp_groups_admin_index();
     
    488484    $messages = array();
    489485
    490     // If the user has just made a change to a group, build status messages
     486    // If the user has just made a change to a group, build status messages.
    491487    if ( !empty( $_REQUEST['no_admins'] ) || ! empty( $_REQUEST['error'] ) || ! empty( $_REQUEST['updated'] ) || ! empty( $_REQUEST['error_new'] ) || ! empty( $_REQUEST['success_new'] ) || ! empty( $_REQUEST['error_modified'] ) || ! empty( $_REQUEST['success_modified'] ) ) {
    492488        $no_admins        = ! empty( $_REQUEST['no_admins']        ) ? 1                                             : 0;
     
    546542    $is_error = ! empty( $no_admins ) || ! empty( $errors ) || ! empty( $error_new ) || ! empty( $error_modified );
    547543
    548     // Get the group from the database
     544    // Get the group from the database.
    549545    $group      = groups_get_group( 'group_id=' . $_GET['gid'] );
    550546
     
    552548    $group_name = isset( $group->name ) ? apply_filters( 'bp_get_group_name', $group->name ) : '';
    553549
    554     // Construct URL for form
     550    // Construct URL for form.
    555551    $form_url = remove_query_arg( array( 'action', 'deleted', 'no_admins', 'error', 'error_new', 'success_new', 'error_modified', 'success_modified' ), $_SERVER['REQUEST_URI'] );
    556552    $form_url = add_query_arg( 'action', 'save', $form_url );
     
    576572        </h1>
    577573
    578         <?php // If the user has just made a change to an group, display the status messages ?>
     574        <?php // If the user has just made a change to an group, display the status messages. ?>
    579575        <?php if ( !empty( $messages ) ) : ?>
    580576            <div id="moderated" class="<?php echo ( $is_error ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "</p><p>", $messages ); ?></p></div>
     
    652648        'include'     => $group_ids,
    653649        'show_hidden' => true,
    654         'per_page'    => null, // Return all results
     650        'per_page'    => null, // Return all results.
    655651    ) );
    656652
    657     // Create a new list of group ids, based on those that actually exist
     653    // Create a new list of group ids, based on those that actually exist.
    658654    $gids = array();
    659655    foreach ( $groups['groups'] as $group ) {
     
    697693    $messages = array();
    698694
    699     // If the user has just made a change to a group, build status messages
     695    // If the user has just made a change to a group, build status messages.
    700696    if ( ! empty( $_REQUEST['deleted'] ) ) {
    701697        $deleted  = ! empty( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0;
     
    706702    }
    707703
    708     // Prepare the group items for display
     704    // Prepare the group items for display.
    709705    $bp_groups_list_table->prepare_items();
    710706
     
    733729        </h1>
    734730
    735         <?php // If the user has just made a change to an group, display the status messages ?>
     731        <?php // If the user has just made a change to an group, display the status messages. ?>
    736732        <?php if ( !empty( $messages ) ) : ?>
    737733            <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div>
    738734        <?php endif; ?>
    739735
    740         <?php // Display each group on its own row ?>
     736        <?php // Display each group on its own row. ?>
    741737        <?php $bp_groups_list_table->views(); ?>
    742738
     
    800796 *
    801797 * @since 1.7.0
     798 *
     799 * @param BP_Groups_Group $item The BP_Groups_Group object for the current group.
    802800 */
    803801function bp_groups_admin_edit_metabox_add_new_members( $item ) {
     
    821819    // Pull up a list of group members, so we can separate out the types
    822820    // We'll also keep track of group members here to place them into a
    823     // JavaScript variable, which will help with group member autocomplete
     821    // JavaScript variable, which will help with group member autocomplete.
    824822    $members = array(
    825823        'admin'  => array(),
     
    851849    }
    852850
    853     // Echo out the JavaScript variable
     851    // Echo out the JavaScript variable.
    854852    echo '<script type="text/javascript">var group_id = "' . esc_js( $item->id ) . '";</script>';
    855853
    856     // Loop through each member type
     854    // Loop through each member type.
    857855    foreach ( $members as $member_type => $type_users ) : ?>
    858856
     
    10081006 * @param BP_Group_Member_Query $query       A BP_Group_Member_Query object.
    10091007 * @param string                $member_type member|mod|admin|banned.
    1010  *
    10111008 * @return string Pagination links HTML.
    10121009 */
     
    10181015    }
    10191016
    1020     // The key used to paginate this member type in the $_GET global
     1017    // The key used to paginate this member type in the $_GET global.
    10211018    $qs_key = $member_type . '_page';
    10221019    $url_base = remove_query_arg( array( $qs_key, 'updated', 'success_modified' ), $_SERVER['REQUEST_URI'] );
     
    10251022    $per_page = 10; // @todo Make this customizable?
    10261023
    1027     // Don't show anything if there's no pagination
     1024    // Don't show anything if there's no pagination.
    10281025    if ( 1 === $page && $query->total_users <= $per_page ) {
    10291026        return $pagination;
     
    10651062 *
    10661063 * @param array $user_ids Array of user IDs.
    1067  *
    10681064 * @return array Array of user_logins corresponding to $user_ids.
    10691065 */
     
    10871083function bp_groups_admin_autocomplete_handler() {
    10881084
    1089     // Bail if user user shouldn't be here, or is a large network
     1085    // Bail if user user shouldn't be here, or is a large network.
    10901086    if ( ! current_user_can( 'bp_moderate' ) || ( is_multisite() && wp_is_large_network( 'users' ) ) ) {
    10911087        wp_die( -1 );
     
    11121108
    11131109            $matches[] = array(
    1114                 // translators: 1: user_login, 2: user_email
     1110                // Translators: 1: user_login, 2: user_email.
    11151111                'label' => sprintf( __( '%1$s (%2$s)', 'buddypress' ), $user->name, $user->ID ),
    11161112                'value' => $user->ID,
     
    11331129     * The type of view currently being displayed.
    11341130     *
    1135      * e.g. "All", "Pending", "Approved", "Spam"...
     1131     * E.g. "All", "Pending", "Approved", "Spam"...
    11361132     *
    11371133     * @since 1.7.0
     
    11861182        $screen = get_current_screen();
    11871183
    1188         // Option defaults
     1184        // Option defaults.
    11891185        $include_id   = false;
    11901186        $search_terms = false;
    11911187
    1192         // Set current page
     1188        // Set current page.
    11931189        $page = $this->get_pagenum();
    11941190
    1195         // Set per page from the screen options
     1191        // Set per page from the screen options.
    11961192        $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$screen->id}_per_page" ) );
    11971193
     
    12021198        }
    12031199
    1204         // Order by - default to newest
     1200        // Order by - default to newest.
    12051201        $orderby = 'last_activity';
    12061202        if ( ! empty( $_REQUEST['orderby'] ) ) {
     
    12291225            $include_id = (int) $_REQUEST['gid'];
    12301226
    1231         // Set the current view
     1227        // Set the current view.
    12321228        if ( isset( $_GET['group_status'] ) && in_array( $_GET['group_status'], array( 'public', 'private', 'hidden' ) ) ) {
    12331229            $this->view = $_GET['group_status'];
    12341230        }
    12351231
    1236         // We'll use the ids of group types for the 'include' param
     1232        // We'll use the ids of group types for the 'include' param.
    12371233        $this->group_type_ids = BP_Groups_Group::get_group_type_ids();
    12381234
    1239         // Pass a dummy array if there are no groups of this type
     1235        // Pass a dummy array if there are no groups of this type.
    12401236        $include = false;
    12411237        if ( 'all' != $this->view && isset( $this->group_type_ids[ $this->view ] ) ) {
     
    12431239        }
    12441240
    1245         // Get group type counts for display in the filter tabs
     1241        // Get group type counts for display in the filter tabs.
    12461242        $this->group_counts = array();
    12471243        foreach ( $this->group_type_ids as $group_type => $group_ids ) {
     
    12701266        }
    12711267
    1272         // Set raw data to display
     1268        // Set raw data to display.
    12731269        $this->items = $groups;
    12741270
    1275         // Store information needed for handling table pagination
     1271        // Store information needed for handling table pagination.
    12761272        $this->set_pagination_args( array(
    12771273            'per_page'    => $per_page,
     
    13071303     */
    13081304    protected function get_default_primary_column_name() {
    1309         // comment column is mapped to Group's name
     1305        // Comment column is mapped to Group's name.
    13101306        return 'comment';
    13111307    }
     
    13241320     *
    13251321     * @since 1.7.0
    1326     */
     1322     */
    13271323    public function display() {
    13281324        $this->display_tablenav( 'top' ); ?>
     
    14981494     * @since 2.3.4 Visibility set to public for compatibility with WP < 4.0.0.
    14991495     *
    1500      * @param array $actions The list of actions
    1501      * @param bool $always_visible Whether the actions should be always visible
     1496     * @param array $actions        The list of actions.
     1497     * @param bool  $always_visible Whether the actions should be always visible.
    15021498     * @return string
    15031499     */
     
    15591555    public function column_comment( $item = array() ) {
    15601556
    1561         // Preorder items: Edit | Delete | View
     1557        // Preorder items: Edit | Delete | View.
    15621558        $actions = array(
    15631559            'edit'   => '',
     
    15661562        );
    15671563
    1568         // We need the group object for some BP functions
     1564        // We need the group object for some BP functions.
    15691565        $item_obj = (object) $item;
    15701566
    1571         // Build actions URLs
     1567        // Build actions URLs.
    15721568        $base_url   = bp_get_admin_url( 'admin.php?page=bp-groups&amp;gid=' . $item['id'] );
    15731569        $delete_url = wp_nonce_url( $base_url . "&amp;action=delete", 'bp-groups-delete' );
     
    15851581        $group_name = apply_filters_ref_array( 'bp_get_group_name', array( $item['name'] ), $item );
    15861582
    1587         // Rollover actions
    1588 
    1589         // Edit
     1583        // Rollover actions.
     1584        // Edit.
    15901585        $actions['edit']   = sprintf( '<a href="%s">%s</a>', esc_url( $edit_url   ), __( 'Edit',   'buddypress' ) );
    15911586
    1592         // Delete
     1587        // Delete.
    15931588        $actions['delete'] = sprintf( '<a href="%s">%s</a>', esc_url( $delete_url ), __( 'Delete', 'buddypress' ) );
    15941589
    1595         // Visit
     1590        // Visit.
    15961591        $actions['view']   = sprintf( '<a href="%s">%s</a>', esc_url( $view_url   ), __( 'View',   'buddypress' ) );
    15971592
     
    16061601        $actions = apply_filters( 'bp_groups_admin_comment_row_actions', array_filter( $actions ), $item );
    16071602
    1608         // Get group name and avatar
     1603        // Get group name and avatar.
    16091604        $avatar = '';
    16101605
     
    16591654
    16601655        // @todo This should be abstracted out somewhere for the whole
    1661         // Groups component
     1656        // Groups component.
    16621657        switch ( $status ) {
    16631658            case 'public' :
     
    17321727     * @param array  $item        Information about the current row.
    17331728     * @param string $column_name The column name.
    1734      *
    17351729     * @return string
    17361730     */
  • trunk/src/bp-groups/bp-groups-adminbar.php

    r10148 r10373  
    2626    $bp = buddypress();
    2727
    28     // Only show if viewing a group
     28    // Only show if viewing a group.
    2929    if ( ! bp_is_group() || bp_is_group_create() ) {
    3030        return false;
    3131    }
    3232
    33     // Only show this menu to group admins and super admins
     33    // Only show this menu to group admins and super admins.
    3434    if ( ! bp_current_user_can( 'bp_moderate' ) && ! bp_group_is_admin() ) {
    3535        return false;
    3636    }
    3737
    38     // Unique ID for the 'Edit Group' menu
     38    // Unique ID for the 'Edit Group' menu.
    3939    $bp->group_admin_menu_id = 'group-admin';
    4040
    41     // Add the top-level Group Admin button
     41    // Add the top-level Group Admin button.
    4242    $wp_admin_bar->add_menu( array(
    4343        'id'    => $bp->group_admin_menu_id,
     
    4646    ) );
    4747
    48     // Index of the Manage tabs parent slug
     48    // Index of the Manage tabs parent slug.
    4949    $nav_index = $bp->groups->current_group->slug . '_manage';
    5050
    51     // Check if current group has Manage tabs
     51    // Check if current group has Manage tabs.
    5252    if ( empty( $bp->bp_options_nav[ $nav_index ] ) ) {
    5353        return;
    5454    }
    5555
    56     // Build the Group Admin menus
     56    // Build the Group Admin menus.
    5757    foreach ( $bp->bp_options_nav[ $nav_index ] as $menu ) {
    5858        /**
     
    6666            $title = sprintf( _x( 'Edit Group %s', 'Group WP Admin Bar manage links', 'buddypress' ), $menu['name'] );
    6767
    68             // Title is specific for delete
     68            // Title is specific for delete.
    6969            if ( 'delete-group' == $menu['slug'] ) {
    7070                $title = sprintf( _x( '%s Group', 'Group WP Admin Bar delete link', 'buddypress' ), $menu['name'] );
  • trunk/src/bp-groups/bp-groups-cache.php

    r10148 r10373  
    2323 * $group_ids and adds it to WP cache. This improves efficiency when using
    2424 * groupmeta within a loop context.
    25  *
    2625 *
    2726 * @param int|string|array|bool $group_ids Accepts a single group_id, or a
     
    7877 * @since 2.0.0
    7978 *
    80  * @param int $meta_id
    81  * @param int $group_id
     79 * @param int $meta_id Meta ID.
     80 * @param int $group_id Group ID.
    8281 */
    8382function bp_groups_delete_group_cache_on_metadata_change( $meta_id, $group_id ) {
     
    9695 */
    9796function bp_groups_clear_group_creator_cache( $group_id, $group_obj ) {
    98     // Clears the 'total groups' for this user
     97    // Clears the 'total groups' for this user.
    9998    groups_clear_group_user_object_cache( $group_obj->id, $group_obj->creator_id );
    10099}
     
    110109 */
    111110function bp_groups_clear_group_members_caches( $group_obj, $user_ids ) {
    112     // Clears the 'total groups' cache for each member in a group
     111    // Clears the 'total groups' cache for each member in a group.
    113112    foreach ( (array) $user_ids as $user_id )
    114113        groups_clear_group_user_object_cache( $group_obj->id, $user_id );
     
    200199 * @since 2.1.0
    201200 *
    202  * @param BP_Groups_Member $member
     201 * @param BP_Groups_Member $member Member object.
    203202 */
    204203function groups_clear_group_administrator_cache_on_member_save( BP_Groups_Member $member ) {
  • trunk/src/bp-groups/bp-groups-filters.php

    r10184 r10373  
    1010defined( 'ABSPATH' ) || exit;
    1111
    12 // Filter bbPress template locations
    13 
     12// Filter bbPress template locations.
    1413add_filter( 'bp_groups_get_directory_template', 'bp_add_template_locations' );
    1514add_filter( 'bp_get_single_group_template',    'bp_add_template_locations' );
     
    5150add_filter( 'groups_group_description_before_save', 'force_balance_tags' );
    5251
    53 // Trim trailing spaces from name and description when saving
     52// Trim trailing spaces from name and description when saving.
    5453add_filter( 'groups_group_name_before_save',        'trim' );
    5554add_filter( 'groups_group_description_before_save', 'trim' );
    5655
    57 // Escape output of new group creation details
     56// Escape output of new group creation details.
    5857add_filter( 'bp_get_new_group_id',          'esc_attr'     );
    5958add_filter( 'bp_get_new_group_name',        'esc_attr'     );
    6059add_filter( 'bp_get_new_group_description', 'esc_textarea' );
    6160
    62 // Format numberical output
     61// Format numberical output.
    6362add_filter( 'bp_get_total_group_count',          'bp_core_number_format' );
    6463add_filter( 'bp_get_group_total_for_member',     'bp_core_number_format' );
     
    7170 * @since 1.1.0
    7271 *
    73  * @param string $content
    74  *
     72 * @param string $content Content to filter.
    7573 * @return string
    7674 */
     
    8785    $allowed_tags = wp_kses_allowed_html( 'buddypress-groups' );
    8886
    89     // Add our own tags allowed in group descriptions
     87    // Add our own tags allowed in group descriptions.
    9088    $allowed_tags['a']['class']    = array();
    9189    $allowed_tags['img']           = array();
     
    107105    $tags = apply_filters( 'bp_groups_filter_kses', $allowed_tags );
    108106
    109     // Return KSES'ed content, allowing the above tags
     107    // Return KSES'ed content, allowing the above tags.
    110108    return wp_kses( $content, $tags );
    111109}
     
    126124 * Add fields to bbPress query for group-specific data.
    127125 *
    128  * @param string $sql
    129  *
     126 * @param string $sql SQL statement to amend.
    130127 * @return string
    131128 */
     
    138135 * Add JOINed tables to bbPress query for group-specific data.
    139136 *
    140  * @param string $sql
    141  *
     137 * @param string $sql SQL statement to amend.
    142138 * @return string
    143139 */
     
    153149 * Add WHERE clauses to bbPress query for group-specific data and access protection.
    154150 *
    155  * @param string $sql
     151 * @param string $sql SQL Statement to amend.
    156152 *
    157153 * @return string
     
    159155function groups_add_forum_where_sql( $sql = '' ) {
    160156
    161     // Define locale variable
     157    // Define locale variable.
    162158    $parts = array();
    163159
    164     // Set this for groups
     160    // Set this for groups.
    165161    $parts['groups'] = "(gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id)";
    166162
     
    173169     * Decide if private are visible
    174170     */
     171
    175172    // Are we in our own profile?
    176173    if ( bp_is_my_profile() )
     
    181178        unset( $parts['private'] );
    182179
    183     // No need to filter on a single item
     180    // No need to filter on a single item.
    184181    elseif ( bp_is_single_item() )
    185182        unset( $parts['private'] );
    186183
    187     // Check the SQL filter that was passed
     184    // Check the SQL filter that was passed.
    188185    if ( !empty( $sql ) )
    189186        $parts['passed'] = $sql;
    190187
    191     // Assemble Voltron
     188    // Assemble Voltron.
    192189    $parts_string = implode( ' AND ', $parts );
    193190
    194191    $bp = buddypress();
    195192
    196     // Set it to the global filter
     193    // Set it to the global filter.
    197194    $bp->groups->filter_sql = $parts_string;
    198195
    199     // Return the global filter
     196    // Return the global filter.
    200197    return $bp->groups->filter_sql;
    201198}
     
    204201 * Modify bbPress caps for bp-forums.
    205202 *
    206  * @param bool $value
    207  * @param string $cap
    208  * @param array $args
     203 * @param bool   $value Original value for current_user_can check.
     204 * @param string $cap   Capability checked.
     205 * @param array  $args  Arguments for the caps.
    209206 *
    210207 * @return bool
     
    238235 *
    239236 * @see BB_Query::_filter_sql()
     237 *
     238 * @param string $sql SQL statement.
     239 * @return string
    240240 */
    241241function groups_filter_forums_root_page_sql( $sql ) {
     
    262262 * @param bool $load_mentions    True to load mentions assets, false otherwise.
    263263 * @param bool $mentions_enabled True if mentions are enabled.
    264  *
    265264 * @return bool True if mentions scripts should be loaded.
    266265 */
  • trunk/src/bp-groups/bp-groups-forums.php

    r10148 r10373  
    6666 *
    6767 * @param int $group_id Group id, passed from groups_details_updated.
    68  *
    6968 * @return mixed
    7069 */
     
    112111 * @param mixed  $page      The page number where the new forum post should reside.
    113112 *                          Default: false.
    114  *
    115113 * @return mixed The new forum post ID on success. Boolean false on failure.
    116114 */
     
    221219 * @param string $topic_tags  A comma-delimited string of topic tags.
    222220 * @param int    $forum_id    The forum ID this forum topic resides in.
    223  *
    224221 * @return mixed The new topic object on success. Boolean false on failure.
    225222 */
     
    342339 * @param string $topic_text  The text for the forum topic.
    343340 * @param mixed  $topic_tags  A comma-delimited string of topic tags. Optional.
    344  *
    345341 * @return mixed The topic object on success. Boolean false on failure.
    346342 */
     
    364360    }
    365361
    366     // Get the corresponding activity item
     362    // Get the corresponding activity item.
    367363    if ( bp_is_active( 'activity' ) ) {
    368364        $id = bp_activity_get_activity_id( array(
     
    421417 * @param int    $topic_id  The topic ID of the existing forum topic.
    422418 * @param mixed  $page      The page number where the new forum post should reside. Optional.
    423  *
    424419 * @return mixed The forum post ID on success. Boolean false on failure.
    425420 */
     
    454449    }
    455450
    456     // Get the corresponding activity item
     451    // Get the corresponding activity item.
    457452    if ( bp_is_active( 'activity' ) ) {
    458453        $id = bp_activity_get_activity_id( array(
     
    507502 *
    508503 * @param int $topic_id The ID of the topic to be deleted.
    509  *
    510504 * @return bool True if the delete routine went through properly.
    511505 */
     
    513507    $bp = buddypress();
    514508
    515     // Before deleting the thread, get the post ids so that their activity items can be deleted
     509    // Before deleting the thread, get the post ids so that their activity items can be deleted.
    516510    $posts  = bp_forums_get_topic_posts( array( 'topic_id' => $topic_id, 'per_page' => -1 ) );
    517511    $action = bp_forums_delete_topic( array( 'topic_id' => $topic_id ) );
     
    528522        do_action( 'groups_before_delete_group_forum_topic', $topic_id );
    529523
    530         // Delete the corresponding activity stream items
     524        // Delete the corresponding activity stream items.
    531525        if ( bp_is_active( 'activity' ) ) {
    532526
    533             // The activity item for the initial topic
     527            // The activity item for the initial topic.
    534528            bp_activity_delete( array(
    535529                'item_id'           => bp_get_current_group_id(),
     
    539533            ) );
    540534
    541             // The activity item for each post
     535            // The activity item for each post.
    542536            foreach ( (array) $posts as $post ) {
    543537                bp_activity_delete( array(
     
    574568 *                           value isn't used in the function but is passed along
    575569 *                           to do_action() hooks.
    576  *
    577570 * @return bool True on success.
    578571 */
     
    593586        do_action( 'groups_before_delete_group_forum_post', $post_id, $topic_id );
    594587
    595         // Delete the corresponding activity stream item
     588        // Delete the corresponding activity stream item.
    596589        if ( bp_is_active( 'activity' ) ) {
    597590            bp_activity_delete( array(
     
    624617 * @param string $type Either 'newest', 'popular', 'unreplied', 'tags'.
    625618 *                     Default: 'newest'.
    626  *
    627619 * @return int The topic count.
    628620 */
     
    647639 *                                  'all'. Default: 'public'.
    648640 * @param string|bool $search_terms Optional. Limit by a search term.
    649  *
    650641 * @return int The topic count.
    651642 */
  • trunk/src/bp-groups/bp-groups-functions.php

    r10351 r10373  
    3636 *
    3737 * @param array|string $args {
    38  *  Array of al arguments.
    39  *  @type int  $group_id        ID of the group.
    40  *  @type bool $load_users      No longer used.
    41  *  @type bool $populate_extras Whether to fetch membership data and other
    42  *                              extra information about the group.
    43  *                              Default: false.
     38 *     Array of al arguments.
     39 *     @type int  $group_id        ID of the group.
     40 *     @type bool $load_users      No longer used.
     41 *     @type bool $populate_extras Whether to fetch membership data and other
     42 *                                 extra information about the group.
     43 *                                 Default: false.
    4444 * }
    4545 * @return BP_Groups_Group $group The group object.
     
    8484 *     @type string   $slug         The group slug.
    8585 *     @type string   $status       The group's status. Accepts 'public', 'private' or
    86                                     'hidden'. Defaults to 'public'.
     86 *                                  'hidden'. Defaults to 'public'.
    8787 *     @type int      $enable_forum Optional. Whether the group has a forum enabled.
    8888 *                                  If the legacy forums are enabled for this group
     
    110110    extract( $args, EXTR_SKIP );
    111111
    112     // Pass an existing group ID
     112    // Pass an existing group ID.
    113113    if ( ! empty( $group_id ) ) {
    114114        $group = groups_get_group( array( 'group_id' => (int) $group_id ) );
     
    117117        $description = ! empty( $description ) ? $description : $group->description;
    118118
    119         // Groups need at least a name
     119        // Groups need at least a name.
    120120        if ( empty( $name ) ) {
    121121            return false;
    122122        }
    123123
    124     // Create a new group
     124    // Create a new group.
    125125    } else {
    126         // Instantiate new group object
     126        // Instantiate new group object.
    127127        $group = new BP_Groups_Group;
    128128    }
    129129
    130     // Set creator ID
     130    // Set creator ID.
    131131    if ( $creator_id ) {
    132132        $group->creator_id = (int) $creator_id;
     
    139139    }
    140140
    141     // Validate status
     141    // Validate status.
    142142    if ( ! groups_is_valid_status( $status ) ) {
    143143        return false;
    144144    }
    145145
    146     // Set group name
     146    // Set group name.
    147147    $group->name         = $name;
    148148    $group->description  = $description;
     
    152152    $group->date_created = $date_created;
    153153
    154     // Save group
     154    // Save group.
    155155    if ( ! $group->save() ) {
    156156        return false;
    157157    }
    158158
    159     // If this is a new group, set up the creator as the first member and admin
     159    // If this is a new group, set up the creator as the first member and admin.
    160160    if ( empty( $group_id ) ) {
    161161        $member                = new BP_Groups_Member;
     
    217217 * @param bool   $notify_members Whether to send an email notification to group
    218218 *                               members about changes in these details.
    219  *
    220219 * @return bool True on success, false on failure.
    221220 */
     
    263262 * @param string|bool $invite_status Optional. Who is allowed to send invitations
    264263 *                                   to the group. 'members', 'mods', or 'admins'.
    265  *
    266264 * @return bool True on success, false on failure.
    267265 */
     
    271269    $group->enable_forum = $enable_forum;
    272270
    273     /***
     271    /**
    274272     * Before we potentially switch the group status, if it has been changed to public
    275273     * from private and there are outstanding membership requests, auto-accept those requests.
     
    278276        groups_accept_all_pending_membership_requests( $group->id );
    279277
    280     // Now update the status
     278    // Now update the status.
    281279    $group->status = $status;
    282280
     
    291289    }
    292290
    293     // Set the invite status
     291    // Set the invite status.
    294292    if ( $invite_status )
    295293        groups_update_groupmeta( $group->id, 'invite_status', $invite_status );
     
    315313 *
    316314 * @param int $group_id ID of the group to delete.
    317  *
    318315 * @return bool True on success, false on failure.
    319316 */
     
    329326    do_action( 'groups_before_delete_group', $group_id );
    330327
    331     // Get the group object
     328    // Get the group object.
    332329    $group = groups_get_group( array( 'group_id' => $group_id ) );
    333330
    334     // Bail if group cannot be deleted
     331    // Bail if group cannot be deleted.
    335332    if ( ! $group->delete() ) {
    336333        return false;
    337334    }
    338335
    339     // Remove all outstanding invites for this group
     336    // Remove all outstanding invites for this group.
    340337    groups_delete_all_group_invites( $group_id );
    341338
     
    356353 *
    357354 * @param string $status Status to check.
    358  *
    359355 * @return bool True if status is allowed, otherwise false.
    360356 */
     
    369365 *
    370366 * @param string $slug Group slug to check.
    371  *
    372367 * @return string $slug A unique and sanitized slug.
    373368 */
     
    395390 *
    396391 * @param int $group_id The numeric ID of the group.
    397  *
    398392 * @return string The group's slug.
    399393 */
     
    409403 *
    410404 * @param string $group_slug The group's slug.
    411  *
    412405 * @return int The ID.
    413406 */
     
    424417 * @param int $user_id  Optional. ID of the user. Defaults to the currently
    425418 *                      logged-in user.
    426  *
    427419 * @return bool True on success, false on failure.
    428420 */
     
    465457 * @param int $user_id  Optional. ID of the user. Defaults to the currently
    466458 *                      logged-in user.
    467  *
    468459 * @return bool True on success, false on failure.
    469460 */
     
    481472        groups_delete_membership_request( null, $user_id, $group_id );
    482473
    483     // User is already a member, just return true
     474    // User is already a member, just return true.
    484475    if ( groups_is_user_member( $user_id, $group_id ) )
    485476        return true;
     
    504495        $group = $bp->groups->current_group;
    505496
    506     // Record this in activity streams
     497    // Record this in activity streams.
    507498    groups_record_activity( array(
    508499        'type'    => 'joined_group',
     
    530521 *
    531522 * @param int $group_id ID of the group.
    532  *
    533523 * @return array Info about group admins (user_id + date_modified).
    534524 */
     
    541531 *
    542532 * @param int $group_id ID of the group.
    543  *
    544533 * @return array Info about group admins (user_id + date_modified).
    545534 */
     
    580569function groups_get_group_members( $args = array() ) {
    581570
    582     // Backward compatibility with old method of passing arguments
     571    // Backward compatibility with old method of passing arguments.
    583572    if ( ! is_array( $args ) || func_num_args() > 1 ) {
    584573        _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__ ) );
     
    612601    // For legacy users. Use of BP_Groups_Member::get_all_for_group()
    613602    // is deprecated. func_get_args() can't be passed to a function in PHP
    614     // 5.2.x, so we create a variable
     603    // 5.2.x, so we create a variable.
    615604    $func_args = func_get_args();
    616605    if ( apply_filters( 'bp_use_legacy_group_member_query', false, __FUNCTION__, $func_args ) ) {
     
    618607    } else {
    619608
    620         // exclude_admins_mods and exclude_banned are legacy arguments.
    621         // Convert to group_role
     609        // Both exclude_admins_mods and exclude_banned are legacy arguments.
     610        // Convert to group_role.
    622611        if ( empty( $r['group_role'] ) ) {
    623612            $r['group_role'] = array( 'member' );
     
    633622        }
    634623
    635         // Perform the group member query (extends BP_User_Query)
     624        // Perform the group member query (extends BP_User_Query).
    636625        $members = new BP_Group_Member_Query( array(
    637626            'group_id'       => $r['group_id'],
     
    644633        ) );
    645634
    646         // Structure the return value as expected by the template functions
     635        // Structure the return value as expected by the template functions.
    647636        $retval = array(
    648637            'members' => array_values( $members->results ),
     
    658647 *
    659648 * @param int $group_id Group ID.
    660  *
    661649 * @return int Count of confirmed members for the group.
    662650 */
     
    682670
    683671    $defaults = array(
    684         'type'              => false,    // active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts
    685         'order'             => 'DESC',   // 'ASC' or 'DESC'
    686         'orderby'           => 'date_created', // date_created, last_activity, total_member_count, name, random
    687         'user_id'           => false,    // Pass a user_id to limit to only groups that this user is a member of
    688         'include'           => false,    // Only include these specific groups (group_ids)
    689         'exclude'           => false,    // Do not include these specific groups (group_ids)
    690         'search_terms'      => false,    // Limit to groups that match these search terms
    691         'meta_query'        => false,    // Filter by groupmeta. See WP_Meta_Query for syntax
    692         'show_hidden'       => false,    // Show hidden groups to non-admins
    693         'per_page'          => 20,       // The number of results to return per page
    694         'page'              => 1,        // The page to return if limiting per page
    695         'populate_extras'   => true,     // Fetch meta such as is_banned and is_member
    696         'update_meta_cache' => true,   // Pre-fetch groupmeta for queried groups
     672        'type'              => false,          // Active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts.
     673        'order'             => 'DESC',         // 'ASC' or 'DESC'
     674        'orderby'           => 'date_created', // date_created, last_activity, total_member_count, name, random.
     675        'user_id'           => false,          // Pass a user_id to limit to only groups that this user is a member of.
     676        'include'           => false,          // Only include these specific groups (group_ids).
     677        'exclude'           => false,          // Do not include these specific groups (group_ids).
     678        'search_terms'      => false,          // Limit to groups that match these search terms.
     679        'meta_query'        => false,          // Filter by groupmeta. See WP_Meta_Query for syntax.
     680        'show_hidden'       => false,          // Show hidden groups to non-admins.
     681        'per_page'          => 20,             // The number of results to return per page.
     682        'page'              => 1,              // The page to return if limiting per page.
     683        'populate_extras'   => true,           // Fetch meta such as is_banned and is_member.
     684        'update_meta_cache' => true,           // Pre-fetch groupmeta for queried groups.
    697685    );
    698686
     
    769757 *
    770758 * @param int $user_id Optional. Default: ID of the displayed user.
    771  *
    772759 * @return int Group count.
    773760 */
     
    816803 * Generate the avatar upload directory path for a given group.
    817804 *
    818  * @param int $group_id Optional. ID of the group. Default: ID of the
    819  *                      current group.
     805 * @param int $group_id Optional. ID of the group. Default: ID of the current group.
    820806 * @return string
    821807 */
     
    857843 * @param int $user_id ID of the user.
    858844 * @param int $group_id ID of the group.
    859  *
    860845 * @return bool
    861846 */
     
    869854 * @param int $user_id ID of the user.
    870855 * @param int $group_id ID of the group.
    871  *
    872856 * @return bool
    873857 */
     
    881865 * @param int $user_id ID of the user.
    882866 * @param int $group_id ID of the group.
    883  *
    884867 * @return bool
    885868 */
     
    899882 * @param int $user_id ID of the user.
    900883 * @param int $group_id ID of the group.
    901  *
    902884 * @return bool
    903885 */
     
    947929        return false;
    948930
    949     // Record this in activity streams
     931    // Record this in activity streams.
    950932    $activity_action  = sprintf( __( '%1$s posted an update in the group %2$s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' );
    951933    $activity_content = $content;
     
    1000982 *
    1001983 * @param int               $user_id ID of the inviting user.
    1002  * @param int|bool          $limit Limit to restrict to.
    1003  * @param int|bool          $page
    1004  * @param string|array|bool $exclude
    1005  *
     984 * @param int|bool          $limit   Limit to restrict to.
     985 * @param int|bool          $page    Optional. Page offset of results to return.
     986 * @param string|array|bool $exclude Array of comma-separated list of group IDs
     987 *                                   to exclude from results.
    1006988 * @return array $value IDs of users who have been invited to the group by the
    1007989 *                      user but have not yet accepted.
     
    10211003 *
    10221004 * @param int $user_id The user ID.
    1023  *
    10241005 * @return int
    10251006 */
     
    10641045        return false;
    10651046
    1066     // if the user has already requested membership, accept the request
     1047    // If the user has already requested membership, accept the request.
    10671048    if ( $membership_id = groups_check_for_membership_request( $user_id, $group_id ) ) {
    10681049        groups_accept_membership_request( $membership_id, $user_id, $group_id );
    10691050
    1070     // Otherwise, create a new invitation
     1051    // Otherwise, create a new invitation.
    10711052    } elseif ( ! groups_is_user_member( $user_id, $group_id ) && ! groups_check_user_has_invite( $user_id, $group_id, 'all' ) ) {
    10721053        $invite                = new BP_Groups_Member;
     
    11001081 * @param int $user_id  ID of the user.
    11011082 * @param int $group_id ID of the group.
    1102  *
    11031083 * @return bool True on success, false on failure.
    11041084 */
     
    11281108 * @param int $user_id  ID of the user.
    11291109 * @param int $group_id ID of the group.
    1130  *
    11311110 * @return bool True when the user is a member of the group, otherwise false.
    11321111 */
     
    11341113
    11351114    // If the user is already a member (because BP at one point allowed two invitations to
    1136     // slip through), delete all existing invitations/requests and return true
     1115    // slip through), delete all existing invitations/requests and return true.
    11371116    if ( groups_is_user_member( $user_id, $group_id ) ) {
    11381117        if ( groups_check_user_has_invite( $user_id, $group_id ) ) {
     
    11541133    }
    11551134
    1156     // Remove request to join
     1135    // Remove request to join.
    11571136    if ( $member->check_for_membership_request( $user_id, $group_id ) ) {
    11581137        $member->delete_request( $user_id, $group_id );
    11591138    }
    11601139
    1161     // Modify group meta
     1140    // Modify group meta.
    11621141    groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
    11631142
     
    11801159 * @param int $user_id  ID of the user.
    11811160 * @param int $group_id ID of the group.
    1182  *
    11831161 * @return bool True on success, false on failure.
    11841162 */
     
    12051183 * @param int $user_id  ID of the invited user.
    12061184 * @param int $group_id ID of the group.
    1207  *
    12081185 * @return bool True on success, false on failure.
    12091186 */
     
    12431220        $member = new BP_Groups_Member( $invited_users[$i], $group_id );
    12441221
    1245         // Send the actual invite
     1222        // Send the actual invite.
    12461223        groups_notification_group_invites( $group, $member, $user_id );
    12471224
     
    12681245 * @param int $user_id  ID of the inviting user.
    12691246 * @param int $group_id ID of the group.
    1270  *
    12711247 * @return array $value IDs of users who have been invited to the group by the
    12721248 *                      user but have not yet accepted.
     
    12871263 * @param string $type     Optional. Use 'sent' to check for sent invites,
    12881264 *                         'all' to check for all. Default: 'sent'.
    1289  *
    12901265 * @return bool True if an invitation is found, otherwise false.
    12911266 */
     
    12981273 *
    12991274 * @param int $group_id ID of the group whose invitations are being deleted.
    1300  *
    13011275 * @return int|null Number of rows records deleted on success, null on failure.
    13021276 */
     
    13131287 * @param int    $group_id ID of the group.
    13141288 * @param string $status   The new status. 'mod' or 'admin'.
    1315  *
    13161289 * @return bool True on success, false on failure.
    13171290 */
     
    13451318 * @param int $user_id  ID of the user.
    13461319 * @param int $group_id ID of the group.
    1347  *
    13481320 * @return bool True on success, false on failure.
    13491321 */
     
    13731345 * @param int $user_id  ID of the user.
    13741346 * @param int $group_id ID of the group.
    1375  *
    13761347 * @return bool True on success, false on failure.
    13771348 */
     
    14011372 * @param int $user_id  ID of the user.
    14021373 * @param int $group_id ID of the group.
    1403  *
    14041374 * @return bool True on success, false on failure.
    14051375 */
     
    14311401 * @param int $user_id  ID of the user.
    14321402 * @param int $group_id ID of the group.
    1433  *
    14341403 * @return bool True on success, false on failure.
    14351404 */
     
    14621431 * @param int $requesting_user_id ID of the user requesting membership.
    14631432 * @param int $group_id           ID of the group.
    1464  *
    14651433 * @return bool True on success, false on failure.
    14661434 */
    14671435function groups_send_membership_request( $requesting_user_id, $group_id ) {
    14681436
    1469     // Prevent duplicate requests
     1437    // Prevent duplicate requests.
    14701438    if ( groups_check_for_membership_request( $requesting_user_id, $group_id ) )
    14711439        return false;
    14721440
    1473     // Check if the user is already a member or is banned
     1441    // Check if the user is already a member or is banned.
    14741442    if ( groups_is_user_member( $requesting_user_id, $group_id ) || groups_is_user_banned( $requesting_user_id, $group_id ) )
    14751443        return false;
    14761444
    1477     // Check if the user is already invited - if so, simply accept invite
     1445    // Check if the user is already invited - if so, simply accept invite.
    14781446    if ( groups_check_user_has_invite( $requesting_user_id, $group_id ) ) {
    14791447        groups_accept_invite( $requesting_user_id, $group_id );
     
    14941462        $admins = groups_get_group_admins( $group_id );
    14951463
    1496         // Saved okay, now send the email notification
     1464        // Saved okay, now send the email notification.
    14971465        for ( $i = 0, $count = count( $admins ); $i < $count; ++$i )
    14981466            groups_notification_new_membership_request( $requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id );
     
    15261494 *                           requested. Provide this value along with $user_id to
    15271495 *                           override $membership_id.
    1528  *
    15291496 * @return bool True on success, false on failure.
    15301497 */
     
    15721539 *                           requested. Provide this value along with $user_id to
    15731540 *                           override $membership_id.
    1574  *
    15751541 * @return bool True on success, false on failure.
    15761542 */
     
    16041570 *                           requested. Provide this value along with $user_id to
    16051571 *                           override $membership_id.
    1606  *
    16071572 * @return bool True on success, false on failure.
    16081573 */
     
    16241589 * @param int $user_id  ID of the user.
    16251590 * @param int $group_id ID of the group.
    1626  *
    16271591 * @return int|null ID of the membership if found, otherwise false.
    16281592 */
     
    16351599 *
    16361600 * @param int $group_id ID of the group.
    1637  *
    16381601 * @return bool True on success, false on failure.
    16391602 */
     
    16721635 *                                metadata entries for the specified group.
    16731636 *                                Default: false.
    1674  *
    16751637 * @return bool True on success, false on failure.
    16761638 */
     
    16781640    global $wpdb;
    16791641
    1680     // Legacy - if no meta_key is passed, delete all for the item
     1642    // Legacy - if no meta_key is passed, delete all for the item.
    16811643    if ( empty( $meta_key ) ) {
    16821644        $keys = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM {$wpdb->groupmeta} WHERE group_id = %d", $group_id ) );
    16831645
    1684         // With no meta_key, ignore $delete_all
     1646        // With no meta_key, ignore $delete_all.
    16851647        $delete_all = false;
    16861648    } else {
     
    17081670 *                         specified meta_key. This parameter has no effect if
    17091671 *                         meta_key is empty.
    1710  *
    17111672 * @return mixed Metadata value.
    17121673 */
     
    17281689 *                           metadata entries with the specified value.
    17291690 *                           Otherwise, update all entries.
    1730  *
    17311691 * @return bool|int $retval Returns false on failure. On successful update of existing
    17321692 *                          metadata, returns true. On successful creation of new metadata,
     
    17531713 *                           has a value for the key, no change will be made.
    17541714 *                           Default: false.
    1755  *
    17561715 * @return int|bool The meta ID on successful update, false on failure.
    17571716 */
  • trunk/src/bp-groups/bp-groups-loader.php

    r10262 r10373  
    1414defined( 'ABSPATH' ) || exit;
    1515
     16/**
     17 * Creates our Groups component.
     18 */
    1619class BP_Groups_Component extends BP_Component {
    1720
     
    3740     * @since 1.6.0
    3841     * @todo Is this used anywhere? Is this a duplicate of $default_extension?
     42     * @var string
    3943     */
    4044    var $default_component;
     
    136140        $bp = buddypress();
    137141
    138         // Define a slug, if necessary
     142        // Define a slug, if necessary.
    139143        if ( ! defined( 'BP_GROUPS_SLUG' ) ) {
    140144            define( 'BP_GROUPS_SLUG', $this->id );
    141145        }
    142146
    143         // Global tables for groups component
     147        // Global tables for groups component.
    144148        $global_tables = array(
    145149            'table_name'           => $bp->table_prefix . 'bp_groups',
     
    148152        );
    149153
    150         // Metadata tables for groups component
     154        // Metadata tables for groups component.
    151155        $meta_tables = array(
    152156            'group' => $bp->table_prefix . 'bp_groups_groupmeta',
     
    168172        parent::setup_globals( $args );
    169173
    170         /** Single Group Globals **********************************************/
     174        /* Single Group Globals **********************************************/
    171175
    172176        // Are we viewing a single group?
     
    215219            }
    216220
    217             // If the user is not an admin, check if they are a moderator
     221            // If the user is not an admin, check if they are a moderator.
    218222            if ( ! bp_is_item_admin() ) {
    219223                bp_update_is_item_mod  ( groups_is_user_mod  ( bp_loggedin_user_id(), $this->current_group->id ), 'groups' );
     
    245249            }
    246250
    247             // Check once if the current group has a custom front template
     251            // Check once if the current group has a custom front template.
    248252            $this->current_group->front_template = bp_groups_get_front_template( $this->current_group );
    249253
    250         // Set current_group to 0 to prevent debug errors
     254        // Set current_group to 0 to prevent debug errors.
    251255        } else {
    252256            $this->current_group = 0;
     
    277281        ) );
    278282
    279         // If the user was attempting to access a group, but no group by that name was found, 404
     283        // If the user was attempting to access a group, but no group by that name was found, 404.
    280284        if ( bp_is_groups_component() && empty( $this->current_group ) && bp_current_action() && !in_array( bp_current_action(), $this->forbidden_names ) ) {
    281285            bp_do_404();
     
    301305        ) );
    302306
    303         // If avatar uploads are not disabled, add avatar option
     307        // If avatar uploads are not disabled, add avatar option.
    304308        $disabled_avatar_uploads = (int) bp_disable_group_avatar_uploads();
    305309        if ( ! $disabled_avatar_uploads && $bp->avatar->show_avatars ) {
     
    317321        }
    318322
    319         // If friends component is active, add invitations
     323        // If friends component is active, add invitations.
    320324        if ( bp_is_active( 'friends' ) ) {
    321325            $this->group_creation_steps['group-invites'] = array(
     
    338342        ) );
    339343
    340         // Auto join group when non group member performs group activity
     344        // Auto join group when non group member performs group activity.
    341345        $this->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' ) && BP_DISABLE_AUTO_GROUP_JOIN ? false : true;
    342346    }
     
    368372        $bp = buddypress();
    369373
    370         // If the activity component is not active and the current group has no custom front, members are displayed in the home nav
     374        // If the activity component is not active and the current group has no custom front, members are displayed in the home nav.
    371375        if ( 'members' === $this->default_extension && ! bp_is_active( 'activity' ) && ! $this->current_group->front_template ) {
    372376            $this->default_extension = 'home';
     
    377381        }
    378382
    379         // Prepare for a redirect to the canonical URL
     383        // Prepare for a redirect to the canonical URL.
    380384        $bp->canonical_stack['base_url'] = bp_get_group_permalink( $this->current_group );
    381385
     
    401405        // When viewing the default extension, the canonical URL should not have
    402406        // that extension's slug, unless more has been tacked onto the URL via
    403         // action variables
     407        // action variables.
    404408        if ( bp_is_current_action( $this->default_extension ) && empty( $bp->action_variables ) )  {
    405409            unset( $bp->canonical_stack['action'] );
     
    419423    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    420424
    421         // Determine user to use
     425        // Determine user to use.
    422426        if ( bp_displayed_user_domain() ) {
    423427            $user_domain = bp_displayed_user_domain();
     
    428432        }
    429433
    430         // Only grab count if we're on a user page
     434        // Only grab count if we're on a user page.
    431435        if ( bp_is_user() ) {
    432436            $count    = bp_get_total_group_count_for_user();
     
    439443        $slug = bp_get_groups_slug();
    440444
    441         // Add 'Groups' to the main navigation
     445        // Add 'Groups' to the main navigation.
    442446        $main_nav = array(
    443447            'name'                => $nav_name,
     
    453457            $groups_link = trailingslashit( $user_domain . $slug );
    454458
    455             // Add the My Groups nav item
     459            // Add the My Groups nav item.
    456460            $sub_nav[] = array(
    457461                'name'            => __( 'Memberships', 'buddypress' ),
     
    464468            );
    465469
    466             // Add the Group Invites nav item
     470            // Add the Group Invites nav item.
    467471            $sub_nav[] = array(
    468472                'name'            => __( 'Invitations', 'buddypress' ),
     
    480484        if ( bp_is_groups_component() && bp_is_single_item() ) {
    481485
    482             // Reset sub nav
     486            // Reset sub nav.
    483487            $sub_nav = array();
    484488
    485             // Add 'Groups' to the main navigation
     489            // Add 'Groups' to the main navigation.
    486490            $main_nav = array(
    487491                'name'                => __( 'Memberships', 'buddypress' ),
    488492                'slug'                => $this->current_group->slug,
    489                 'position'            => -1, // Do not show in BuddyBar
     493                'position'            => -1, // Do not show in BuddyBar.
    490494                'screen_function'     => 'groups_screen_group_home',
    491495                'default_subnav_slug' => $this->default_extension,
     
    495499            $group_link = bp_get_group_permalink( $this->current_group );
    496500
    497             // Add the "Home" subnav item, as this will always be present
     501            // Add the "Home" subnav item, as this will always be present.
    498502            $sub_nav[] = array(
    499503                'name'            =>  _x( 'Home', 'Group screen navigation title', 'buddypress' ),
     
    526530            }
    527531
    528             // Forums are enabled and turned on
     532            // Forums are enabled and turned on.
    529533            if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) {
    530534                $sub_nav[] = array(
     
    559563
    560564                /**
    561                  * Only add the members subnav if it's not the home's nav
     565                 * Only add the members subnav if it's not the home's nav.
    562566                 */
    563567                $sub_nav[] = array(
     
    588592            }
    589593
    590             // If the user is a group admin, then show the group admin nav item
     594            // If the user is a group admin, then show the group admin nav item.
    591595            if ( bp_is_item_admin() ) {
    592596                $sub_nav[] = array(
     
    604608                $admin_link = trailingslashit( $group_link . 'admin' );
    605609
    606                 // Common params to all nav items
     610                // Common params to all nav items.
    607611                $default_params = array(
    608612                    'parent_url'        => $admin_link,
     
    692696    public function setup_admin_bar( $wp_admin_nav = array() ) {
    693697
    694         // Menus for logged in user
     698        // Menus for logged in user.
    695699        if ( is_user_logged_in() ) {
    696700
    697             // Setup the logged in user variables
     701            // Setup the logged in user variables.
    698702            $groups_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() );
    699703
    700             // Pending group invites
     704            // Pending group invites.
    701705            $count   = groups_get_invite_count_for_user();
    702706            $title   = _x( 'Groups', 'My Account Groups', 'buddypress' );
     
    708712            }
    709713
    710             // Add the "My Account" sub menus
     714            // Add the "My Account" sub menus.
    711715            $wp_admin_nav[] = array(
    712716                'parent' => buddypress()->my_account_menu_id,
     
    716720            );
    717721
    718             // My Groups
     722            // My Groups.
    719723            $wp_admin_nav[] = array(
    720724                'parent' => 'my-account-' . $this->id,
     
    724728            );
    725729
    726             // Invitations
     730            // Invitations.
    727731            $wp_admin_nav[] = array(
    728732                'parent' => 'my-account-' . $this->id,
     
    732736            );
    733737
    734             // Create a Group
     738            // Create a Group.
    735739            if ( bp_user_can_create_groups() ) {
    736740                $wp_admin_nav[] = array(
     
    793797    public function setup_cache_groups() {
    794798
    795         // Global groups
     799        // Global groups.
    796800        wp_cache_add_global_groups( array(
    797801            'bp_groups',
  • trunk/src/bp-groups/bp-groups-notifications.php

    r10148 r10373  
    6666    foreach ( (array) $user_ids as $user_id ) {
    6767
    68         // Continue if member opted out of receiving this email
     68        // Continue if member opted out of receiving this email.
    6969        if ( 'no' === bp_get_user_meta( $user_id, 'notification_groups_group_updated', true ) ) {
    7070            continue;
     
    7373        $ud = bp_core_get_core_userdata( $user_id );
    7474
    75         // Set up and send the message
     75        // Set up and send the message.
    7676        $to = $ud->user_email;
    7777
     
    150150 * @param int $group_id           ID of the group.
    151151 * @param int $membership_id      ID of the group membership object.
    152  *
    153152 * @return false|null False on failure.
    154153 */
    155154function groups_notification_new_membership_request( $requesting_user_id = 0, $admin_id = 0, $group_id = 0, $membership_id = 0 ) {
    156155
    157     // Trigger a BuddyPress Notification
     156    // Trigger a BuddyPress Notification.
    158157    if ( bp_is_active( 'notifications' ) ) {
    159158        bp_notifications_add_notification( array(
     
    166165    }
    167166
    168     // Bail if member opted out of receiving this email
     167    // Bail if member opted out of receiving this email.
    169168    if ( 'no' === bp_get_user_meta( $admin_id, 'notification_groups_membership_request', true ) ) {
    170169        return false;
    171170    }
    172171
    173     // Username of the user requesting a membership: %1$s in mail
     172    // Username of the user requesting a membership: %1$s in mail.
    174173    $requesting_user_name = bp_core_get_user_displayname( $requesting_user_id );
    175174    $group                = groups_get_group( array( 'group_id' => $group_id ) );
    176175
    177     // Group Administrator user's data
     176    // Group Administrator user's data.
    178177    $ud             = bp_core_get_core_userdata( $admin_id );
    179178    $group_requests = bp_get_group_permalink( $group ) . 'admin/membership-requests';
    180179
    181     // Link to the user's profile who's requesting a membership: %3$s in mail
     180    // Link to the user's profile who's requesting a membership: %3$s in mail.
    182181    $profile_link   = bp_core_get_user_domain( $requesting_user_id );
    183182
    184183    $settings_slug  = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
    185     // Link to the group administrator email settings: %s in "disable notifications" part of the email
     184    // Link to the group administrator email settings: %s in "disable notifications" part of the email.
    186185    $settings_link  = bp_core_get_user_domain( $admin_id ) . $settings_slug . '/notifications/';
    187186
     
    189188    $membership = new BP_Groups_Member( false, false, $membership_id );
    190189
    191     // Set up and send the message
     190    // Set up and send the message.
    192191    $to       = $ud->user_email;
    193192    $subject  = bp_get_email_subject( array( 'text' => sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name ) ) );
     
    225224    }
    226225
    227     // Only show the disable notifications line if the settings component is enabled
     226    // Only show the disable notifications line if the settings component is enabled.
    228227    if ( bp_is_active( 'settings' ) ) {
    229228        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
     
    289288 * @param bool $accepted           Optional. Whether the membership request was accepted.
    290289 *                                 Default: true.
    291  *
    292290 * @return false|null
    293291 */
    294292function groups_notification_membership_request_completed( $requesting_user_id = 0, $group_id = 0, $accepted = true ) {
    295293
    296     // Trigger a BuddyPress Notification
     294    // Trigger a BuddyPress Notification.
    297295    if ( bp_is_active( 'notifications' ) ) {
    298296
    299         // What type of acknowledgement
     297        // What type of acknowledgement.
    300298        $type = ! empty( $accepted )
    301299            ? 'membership_request_accepted'
     
    310308    }
    311309
    312     // Bail if member opted out of receiving this email
     310    // Bail if member opted out of receiving this email.
    313311    if ( 'no' === bp_get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) ) {
    314312        return false;
     
    322320    $to            = $ud->user_email;
    323321
    324     // Set up and send the message
     322    // Set up and send the message.
    325323    if ( ! empty( $accepted ) ) {
    326324        $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name ) ) );
     
    344342    }
    345343
    346     // Only show the disable notifications line if the settings component is enabled
     344    // Only show the disable notifications line if the settings component is enabled.
    347345    if ( bp_is_active( 'settings' ) ) {
    348346        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
     
    404402 * @param int $user_id  ID of the user.
    405403 * @param int $group_id ID of the group.
    406  *
    407404 * @return false|null False on failure.
    408405 */
     
    418415    }
    419416
    420     // Trigger a BuddyPress Notification
     417    // Trigger a BuddyPress Notification.
    421418    if ( bp_is_active( 'notifications' ) ) {
    422419        bp_notifications_add_notification( array(
     
    428425    }
    429426
    430     // Bail if admin opted out of receiving this email
     427    // Bail if admin opted out of receiving this email.
    431428    if ( 'no' === bp_get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) ) {
    432429        return false;
     
    439436    $settings_link = bp_core_get_user_domain( $user_id ) . $settings_slug . '/notifications/';
    440437
    441     // Set up and send the message
     438    // Set up and send the message.
    442439    $to       = $ud->user_email;
    443440    $subject  = bp_get_email_subject( array( 'text' => sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), $group->name ) ) );
     
    450447', 'buddypress' ), $promoted_to, $group->name, $group_link );
    451448
    452     // Only show the disable notifications line if the settings component is enabled
     449    // Only show the disable notifications line if the settings component is enabled.
    453450    if ( bp_is_active( 'settings' ) ) {
    454451        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
     
    511508 * @param BP_Groups_Member $member          Member object.
    512509 * @param int              $inviter_user_id ID of the user who sent the invite.
    513  *
    514510 * @return null|false False on failure.
    515511 */
    516512function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) {
    517513
    518     // Bail if member has already been invited
     514    // Bail if member has already been invited.
    519515    if ( ! empty( $member->invite_sent ) ) {
    520516        return;
     
    527523    $group_link   = bp_get_group_permalink( $group );
    528524
    529     // Setup the ID for the invited user
     525    // Setup the ID for the invited user.
    530526    $invited_user_id = $member->user_id;
    531527
    532     // Trigger a BuddyPress Notification
     528    // Trigger a BuddyPress Notification.
    533529    if ( bp_is_active( 'notifications' ) ) {
    534530        bp_notifications_add_notification( array(
     
    540536    }
    541537
    542     // Bail if member opted out of receiving this email
     538    // Bail if member opted out of receiving this email.
    543539    if ( 'no' === bp_get_user_meta( $invited_user_id, 'notification_groups_invite', true ) ) {
    544540        return false;
     
    551547    $invites_link  = trailingslashit( $invited_link . bp_get_groups_slug() . '/invites' );
    552548
    553     // Set up and send the message
     549    // Set up and send the message.
    554550    $to       = $invited_ud->user_email;
    555551    $subject  = bp_get_email_subject( array( 'text' => sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), $group->name ) ) );
     
    566562', 'buddypress' ), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link );
    567563
    568     // Only show the disable notifications line if the settings component is enabled
     564    // Only show the disable notifications line if the settings component is enabled.
    569565    if ( bp_is_active( 'settings' ) ) {
    570566        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
     
    634630 * @param string $format            'string' for BuddyBar-compatible notifications; 'array'
    635631 *                                  for WP Toolbar. Default: 'string'.
    636  *
    637632 * @return string
    638633 */
     
    649644
    650645            // Set up the string and the filter
    651             // Because different values are passed to the filters, we'll return the
    652             // values inline
     646            // because different values are passed to the filters,
     647            // we'll return values inline.
    653648            if ( (int) $total_items > 1 ) {
    654649                $text = sprintf( __( '%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int) $total_items, $group->name );
     
    12611256function bp_groups_screen_my_groups_mark_notifications() {
    12621257
    1263     // Delete group request notifications for the user
     1258    // Delete group request notifications for the user.
    12641259    if ( isset( $_GET['n'] ) && bp_is_active( 'notifications' ) ) {
    12651260
    1266         // Get the necessary ID's
     1261        // Get the necessary ID's.
    12671262        $group_id = buddypress()->groups->id;
    12681263        $user_id  = bp_loggedin_user_id();
    12691264
    1270         // Mark notifications read
     1265        // Mark notifications read.
    12711266        bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'membership_request_accepted' );
    12721267        bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'membership_request_rejected' );
  • trunk/src/bp-groups/bp-groups-screens.php

    r10276 r10373  
    6969
    7070    if ( bp_is_action_variable( 'accept' ) && is_numeric( $group_id ) ) {
    71         // Check the nonce
     71        // Check the nonce.
    7272        if ( !check_admin_referer( 'groups_accept_invite' ) )
    7373            return false;
     
    7878            bp_core_add_message( __('Group invite accepted', 'buddypress') );
    7979
    80             // Record this in activity streams
     80            // Record this in activity streams.
    8181            $group = groups_get_group( array( 'group_id' => $group_id ) );
    8282
     
    9696
    9797    } elseif ( bp_is_action_variable( 'reject' ) && is_numeric( $group_id ) ) {
    98         // Check the nonce
     98        // Check the nonce.
    9999        if ( !check_admin_referer( 'groups_reject_invite' ) )
    100100            return false;
     
    183183        return false;
    184184
    185     // Fetch the details we need
     185    // Fetch the details we need.
    186186    $topic_slug = (string)bp_action_variable( 1 );
    187187    $topic_id       = bp_forums_get_topic_id_from_slug( $topic_slug );
     
    194194    if ( !empty( $topic_slug ) && !empty( $topic_id ) ) {
    195195
    196         // Posting a reply
     196        // Posting a reply.
    197197        if ( !$user_is_banned && !bp_action_variable( 2 ) && isset( $_POST['submit_reply'] ) ) {
    198             // Check the nonce
     198            // Check the nonce.
    199199            check_admin_referer( 'bp_forums_new_reply' );
    200200
    201             // Auto join this user if they are not yet a member of this group
     201            // Auto join this user if they are not yet a member of this group.
    202202            if ( bp_groups_auto_join() && !bp_current_user_can( 'bp_moderate' ) && 'public' == $bp->groups->current_group->status && !groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
    203203                groups_join_group( $bp->groups->current_group->id, bp_loggedin_user_id() );
     
    206206            $topic_page = isset( $_GET['topic_page'] ) ? $_GET['topic_page'] : false;
    207207
    208             // Don't allow reply flooding
     208            // Don't allow reply flooding.
    209209            if ( bp_forums_reply_exists( $_POST['reply_text'], $topic_id, bp_loggedin_user_id() ) ) {
    210210                bp_core_add_message( __( 'It looks like you\'ve already said that!', 'buddypress' ), 'error' );
     
    228228        }
    229229
    230         // Sticky a topic
     230        // Sticky a topic.
    231231        elseif ( bp_is_action_variable( 'stick', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {
    232             // Check the nonce
     232            // Check the nonce.
    233233            check_admin_referer( 'bp_forums_stick_topic' );
    234234
     
    250250        }
    251251
    252         // Un-Sticky a topic
     252        // Un-Sticky a topic.
    253253        elseif ( bp_is_action_variable( 'unstick', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {
    254             // Check the nonce
     254            // Check the nonce.
    255255            check_admin_referer( 'bp_forums_unstick_topic' );
    256256
     
    272272        }
    273273
    274         // Close a topic
     274        // Close a topic.
    275275        elseif ( bp_is_action_variable( 'close', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {
    276             // Check the nonce
     276            // Check the nonce.
    277277            check_admin_referer( 'bp_forums_close_topic' );
    278278
     
    294294        }
    295295
    296         // Open a topic
     296        // Open a topic.
    297297        elseif ( bp_is_action_variable( 'open', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {
    298             // Check the nonce
     298            // Check the nonce.
    299299            check_admin_referer( 'bp_forums_open_topic' );
    300300
     
    316316        }
    317317
    318         // Delete a topic
     318        // Delete a topic.
    319319        elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'delete', 2 ) && !bp_action_variable( 3 ) ) {
    320             // Fetch the topic
     320            // Fetch the topic.
    321321            $topic = bp_forums_get_topic_details( $topic_id );
    322322
     
    326326            }
    327327
    328             // Check the nonce
     328            // Check the nonce.
    329329            check_admin_referer( 'bp_forums_delete_topic' );
    330330
     
    355355        }
    356356
    357         // Editing a topic
     357        // Editing a topic.
    358358        elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'edit', 2 ) && !bp_action_variable( 3 ) ) {
    359             // Fetch the topic
     359            // Fetch the topic.
    360360            $topic = bp_forums_get_topic_details( $topic_id );
    361361
    362             // Check the logged in user can edit this topic
     362            // Check the logged in user can edit this topic.
    363363            if ( ! bp_is_item_admin() && ! bp_is_item_mod() && ( (int) bp_loggedin_user_id() != (int) $topic->topic_poster ) ) {
    364364                bp_core_redirect( wp_get_referer() );
     
    366366
    367367            if ( isset( $_POST['save_changes'] ) ) {
    368                 // Check the nonce
     368                // Check the nonce.
    369369                check_admin_referer( 'bp_forums_edit_topic' );
    370370
     
    397397            bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/home' ) );
    398398
    399         // Delete a post
     399        // Delete a post.
    400400        } elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'delete', 2 ) && $post_id = bp_action_variable( 4 ) ) {
    401             // Fetch the post
     401            // Fetch the post.
    402402            $post = bp_forums_get_post( $post_id );
    403403
    404             // Check the logged in user can edit this topic
     404            // Check the logged in user can edit this topic.
    405405            if ( ! bp_is_item_admin() && ! bp_is_item_mod() && ( (int) bp_loggedin_user_id() != (int) $post->poster_id ) ) {
    406406                bp_core_redirect( wp_get_referer() );
    407407            }
    408408
    409             // Check the nonce
     409            // Check the nonce.
    410410            check_admin_referer( 'bp_forums_delete_post' );
    411411
     
    435435            bp_core_redirect( wp_get_referer() );
    436436
    437         // Editing a post
     437        // Editing a post.
    438438        } elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'edit', 2 ) && $post_id = bp_action_variable( 4 ) ) {
    439439
    440             // Fetch the post
     440            // Fetch the post.
    441441            $post = bp_forums_get_post( $post_id );
    442442
    443             // Check the logged in user can edit this topic
     443            // Check the logged in user can edit this topic.
    444444            if ( ! bp_is_item_admin() && ! bp_is_item_mod() && ( (int) bp_loggedin_user_id() != (int) $post->poster_id ) ) {
    445445                bp_core_redirect( wp_get_referer() );
     
    447447
    448448            if ( isset( $_POST['save_changes'] ) ) {
    449                 // Check the nonce
     449                // Check the nonce.
    450450                check_admin_referer( 'bp_forums_edit_post' );
    451451
     
    476476            bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/home' ) );
    477477
    478         // Standard topic display
     478        // Standard topic display.
    479479        } else {
    480480            if ( !empty( $user_is_banned ) ) {
     
    492492        }
    493493
    494     // Forum topic does not exist
     494    // Forum topic does not exist.
    495495    } elseif ( !empty( $topic_slug ) && empty( $topic_id ) ) {
    496496        bp_do_404();
     
    498498
    499499    } else {
    500         // Posting a topic
     500        // Posting a topic.
    501501        if ( isset( $_POST['submit_topic'] ) && bp_is_active( 'forums' ) ) {
    502502
    503             // Check the nonce
     503            // Check the nonce.
    504504            check_admin_referer( 'bp_forums_new_topic' );
    505505
     
    508508
    509509            } elseif ( bp_groups_auto_join() && !bp_current_user_can( 'bp_moderate' ) && 'public' == $bp->groups->current_group->status && !groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
    510                 // Auto join this user if they are not yet a member of this group
     510                // Auto join this user if they are not yet a member of this group.
    511511                groups_join_group( $bp->groups->current_group->id, bp_loggedin_user_id() );
    512512            }
     
    569569    $bp = buddypress();
    570570
    571     // Refresh the group member count meta
     571    // Refresh the group member count meta.
    572572    groups_update_groupmeta( $bp->groups->current_group->id, 'total_member_count', groups_get_total_member_count( $bp->groups->current_group->id ) );
    573573
     
    698698        return false;
    699699
    700     // If the user is already invited, accept invitation
     700    // If the user is already invited, accept invitation.
    701701    if ( groups_check_user_has_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
    702702        if ( groups_accept_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) )
     
    710710    if ( isset( $_POST['group-request-send']) ) {
    711711
    712         // Check the nonce
     712        // Check the nonce.
    713713        if ( !check_admin_referer( 'groups_request_membership' ) )
    714714            return false;
     
    809809        $bp = buddypress();
    810810
    811         // If the edit form has been submitted, save the edited details
     811        // If the edit form has been submitted, save the edited details.
    812812        if ( isset( $_POST['save'] ) ) {
    813             // Check the nonce
     813            // Check the nonce.
    814814            if ( !check_admin_referer( 'groups_edit_group_details' ) )
    815815                return false;
     
    869869    $bp = buddypress();
    870870
    871     // If the edit form has been submitted, save the edited details
     871    // If the edit form has been submitted, save the edited details.
    872872    if ( isset( $_POST['save'] ) ) {
    873873        $enable_forum   = ( isset($_POST['group-show-forum'] ) ) ? 1 : 0;
    874874
    875         // Checked against a whitelist for security
     875        // Checked against a whitelist for security.
    876876        /** This filter is documented in bp-groups/bp-groups-admin.php */
    877877        $allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) );
    878878        $status         = ( in_array( $_POST['group-status'], (array) $allowed_status ) ) ? $_POST['group-status'] : 'public';
    879879
    880         // Checked against a whitelist for security
     880        // Checked against a whitelist for security.
    881881        /** This filter is documented in bp-groups/bp-groups-admin.php */
    882882        $allowed_invite_status = apply_filters( 'groups_allowed_invite_status', array( 'members', 'mods', 'admins' ) );
    883883        $invite_status         = isset( $_POST['group-invite-status'] ) && in_array( $_POST['group-invite-status'], (array) $allowed_invite_status ) ? $_POST['group-invite-status'] : 'members';
    884884
    885         // Check the nonce
     885        // Check the nonce.
    886886        if ( !check_admin_referer( 'groups_edit_group_settings' ) )
    887887            return false;
     
    933933        return false;
    934934
    935     // If the logged-in user doesn't have permission or if avatar uploads are disabled, then stop here
     935    // If the logged-in user doesn't have permission or if avatar uploads are disabled, then stop here.
    936936    if ( ! bp_is_item_admin() || bp_disable_group_avatar_uploads() || ! buddypress()->avatar->show_avatars )
    937937        return false;
     
    939939    $bp = buddypress();
    940940
    941     // If the group admin has deleted the admin avatar
     941    // If the group admin has deleted the admin avatar.
    942942    if ( bp_is_action_variable( 'delete', 1 ) ) {
    943943
    944         // Check the nonce
     944        // Check the nonce.
    945945        check_admin_referer( 'bp_group_avatar_delete' );
    946946
     
    960960    if ( !empty( $_FILES ) ) {
    961961
    962         // Check the nonce
     962        // Check the nonce.
    963963        check_admin_referer( 'bp_avatar_upload' );
    964964
    965         // Pass the file to the avatar upload handler
     965        // Pass the file to the avatar upload handler.
    966966        if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
    967967            $bp->avatar_admin->step = 'crop-image';
    968968
    969             // Make sure we include the jQuery jCrop file for image cropping
     969            // Make sure we include the jQuery jCrop file for image cropping.
    970970            add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' );
    971971        }
     
    973973    }
    974974
    975     // If the image cropping is done, crop the image and save a full/thumb version
     975    // If the image cropping is done, crop the image and save a full/thumb version.
    976976    if ( isset( $_POST['avatar-crop-submit'] ) ) {
    977977
    978         // Check the nonce
     978        // Check the nonce.
    979979        check_admin_referer( 'bp_avatar_cropstore' );
    980980
     
    10271027    }
    10281028
    1029     // If the logged-in user doesn't have permission or if cover image uploads are disabled, then stop here
     1029    // If the logged-in user doesn't have permission or if cover image uploads are disabled, then stop here.
    10301030    if ( ! bp_is_item_admin() || ! bp_group_use_cover_image_header() ) {
    10311031        return false;
     
    11021102                return false;
    11031103
    1104             // Stop sole admins from abandoning their group
     1104            // Stop sole admins from abandoning their group.
    11051105            $group_admins = groups_get_group_admins( $bp->groups->current_group->id );
    11061106            if ( 1 == count( $group_admins ) && $group_admins[0]->user_id == $user_id )
     
    12491249                return false;
    12501250
    1251             // Accept the membership request
     1251            // Accept the membership request.
    12521252            if ( !groups_accept_membership_request( $membership_id ) )
    12531253                bp_core_add_message( __( 'There was an error accepting the membership request. Please try again.', 'buddypress' ), 'error' );
     
    12601260                return false;
    12611261
    1262             // Reject the membership request
     1262            // Reject the membership request.
    12631263            if ( !groups_reject_membership_request( $membership_id ) )
    12641264                bp_core_add_message( __( 'There was an error rejecting the membership request. Please try again.', 'buddypress' ), 'error' );
     
    14671467    public function is_group() {
    14681468
    1469         // Bail if not looking at a group
     1469        // Bail if not looking at a group.
    14701470        if ( ! bp_is_groups_component() )
    14711471            return;
    14721472
    1473         // Group Directory
     1473        // Group Directory.
    14741474        if ( ! bp_current_action() && ! bp_current_item() ) {
    14751475            bp_update_is_directory( true, 'groups' );
     
    14861486            add_filter( 'bp_replace_the_content',                    array( $this, 'directory_content'    ) );
    14871487
    1488         // Creating a group
     1488        // Creating a group.
    14891489        } elseif ( bp_is_groups_component() && bp_is_current_action( 'create' ) ) {
    14901490            add_filter( 'bp_get_buddypress_template',                array( $this, 'create_template_hierarchy' ) );
     
    14921492            add_filter( 'bp_replace_the_content',                    array( $this, 'create_content'    ) );
    14931493
    1494         // Group page
     1494        // Group page.
    14951495        } elseif ( bp_is_single_item() ) {
    14961496            add_filter( 'bp_get_buddypress_template',                array( $this, 'single_template_hierarchy' ) );
     
    15271527        ) );
    15281528
    1529         // Merge new templates with existing stack
    1530         // @see bp_get_theme_compat_templates()
     1529        // Merge new templates with existing stack.
     1530        // @see bp_get_theme_compat_templates().
    15311531        $templates = array_merge( (array) $new_templates, $templates );
    15321532
     
    15731573     *
    15741574     * @param string $templates The templates from bp_get_theme_compat_templates().
    1575      *
    15761575     * @return array $templates Array of custom templates to look for.
    15771576     */
     
    15891588        ) );
    15901589
    1591         // Merge new templates with existing stack
    1592         // @see bp_get_theme_compat_templates()
     1590        // Merge new templates with existing stack.
     1591        // @see bp_get_theme_compat_templates().
    15931592        $templates = array_merge( $new_templates, $templates );
    15941593
     
    16411640     */
    16421641    public function single_template_hierarchy( $templates ) {
    1643         // Setup some variables we're going to reference in our custom templates
     1642        // Setup some variables we're going to reference in our custom templates.
    16441643        $group = groups_get_current_group();
    16451644
     
    16591658        ) );
    16601659
    1661         // Merge new templates with existing stack
    1662         // @see bp_get_theme_compat_templates()
     1660        // Merge new templates with existing stack.
     1661        // @see bp_get_theme_compat_templates().
    16631662        $templates = array_merge( (array) $new_templates, $templates );
    16641663
  • trunk/src/bp-groups/bp-groups-template.php

    r10342 r10373  
    197197    function __construct( $args = array() ){
    198198
    199         // Backward compatibility with old method of passing arguments
     199        // Backward compatibility with old method of passing arguments.
    200200        if ( ! is_array( $args ) || func_num_args() > 1 ) {
    201201            _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__ ) );
     
    265265            }
    266266
    267             // backwards compatibility - the 'group_id' variable is not part of the
     267            // Backwards compatibility - the 'group_id' variable is not part of the
    268268            // BP_Groups_Group object, but we add it here for devs doing checks against it
    269269            //
     
    271271            //
    272272            // this is subject to removal in a future release; devs should check against
    273             // $group->id instead
     273            // $group->id instead.
    274274            $group->group_id = $group->id;
    275275
     
    326326        }
    327327
    328         // Build pagination links
     328        // Build pagination links.
    329329        if ( (int) $this->total_group_count && (int) $this->pag_num ) {
    330330            $pag_args = array(
     
    420420             */
    421421            do_action('group_loop_end');
    422             // Do some cleaning up after the loop
     422            // Do some cleaning up after the loop.
    423423            $this->rewind_groups();
    424424        }
     
    499499    global $groups_template;
    500500
    501     /***
     501    /*
    502502     * Defaults based on the current page & overridden by parsed $args
    503503     */
     
    506506    $search_terms = false;
    507507
    508     // When looking your own groups, check for two action variables
     508    // When looking your own groups, check for two action variables.
    509509    if ( bp_is_current_action( 'my-groups' ) ) {
    510510        if ( bp_is_action_variable( 'most-popular', 0 ) ) {
     
    514514        }
    515515
    516     // When looking at invites, set type to invites
     516    // When looking at invites, set type to invites.
    517517    } elseif ( bp_is_current_action( 'invites' ) ) {
    518518        $type = 'invites';
    519519
    520     // When looking at a single group, set the type and slug
     520    // When looking at a single group, set the type and slug.
    521521    } elseif ( bp_get_current_group_slug() ) {
    522522        $type = 'single-group';
     
    524524    }
    525525
    526     // Default search string (too soon to escape here)
     526    // Default search string (too soon to escape here).
    527527    $search_query_arg = bp_core_get_component_search_query_arg( 'groups' );
    528528    if ( ! empty( $_REQUEST[ $search_query_arg ] ) ) {
     
    534534    }
    535535
    536     // Parse defaults and requested arguments
     536    // Parse defaults and requested arguments.
    537537    $r = bp_parse_args( $args, array(
    538538        'type'              => $type,
     
    554554    ), 'has_groups' );
    555555
    556     // Setup the Groups template global
     556    // Setup the Groups template global.
    557557    $groups_template = new BP_Groups_Template( array(
    558558        'type'              => $r['type'],
     
    610610 *
    611611 * @param object|bool $group Optional. Group object. Default: current group in loop.
    612  *
    613612 * @return bool
    614613 */
     
    648647     * @param object|bool $group Optional. Group object.
    649648     *                           Default: current group in loop.
    650      *
    651649     * @return int
    652650     */
     
    684682     *
    685683     * @param array $classes Array of custom classes.
    686      *
    687684     * @return string Row class of the group.
    688685     */
     
    690687        global $groups_template;
    691688
    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.
    693690        if ( $groups_template->group_count > 1 ) {
    694691            $pos_in_loop = (int) $groups_template->current_group;
    695692            $classes[]   = ( $pos_in_loop % 2 ) ? 'even' : 'odd';
    696693
    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.
    698695        } else {
    699696            $classes[] = 'bp-single-group';
     
    703700        $classes[] = sanitize_key( $groups_template->group->status );
    704701
    705         // User's group role
     702        // User's group role.
    706703        if ( bp_is_user_active() ) {
    707704
    708             // Admin
     705            // Admin.
    709706            if ( bp_group_is_admin() ) {
    710707                $classes[] = 'is-admin';
    711708            }
    712709
    713             // Moderator
     710            // Moderator.
    714711            if ( bp_group_is_mod() ) {
    715712                $classes[] = 'is-mod';
    716713            }
    717714
    718             // Member
     715            // Member.
    719716            if ( bp_group_is_member() ) {
    720717                $classes[] = 'is-member';
     
    757754     * @param object|bool $group Optional. Group object.
    758755     *                           Default: current group in loop.
    759      *
    760756     * @return string
    761757     */
     
    792788 * @param object|bool $group Optional. Group object.
    793789 *                           Default: current group in loop.
    794  *
    795790 * @return string
    796791 */
     
    835830     * @param object|bool $group Optional. Group object.
    836831     *                           Default: current group in loop.
    837      *
    838832     * @return string
    839833     */
     
    874868     * @see bp_core_fetch_avatar() For a description of arguments and return values.
    875869
    876      * @param array $args {
     870     * @param array|string $args {
    877871     *     Arguments are listed here with an explanation of their defaults.
    878872     *     For more information about the arguments, see {@link bp_core_fetch_avatar()}.
     
    895889        }
    896890
    897         // Parse the arguments
     891        // Parse the arguments.
    898892        $r = bp_parse_args( $args, array(
    899893            'type'   => 'full',
     
    905899        ) );
    906900
    907         // Fetch the avatar from the folder
     901        // Fetch the avatar from the folder.
    908902        $avatar = bp_core_fetch_avatar( array(
    909903            'item_id'    => $groups_template->group->id,
     
    919913        ) );
    920914
    921         // If No avatar found, provide some backwards compatibility
     915        // If No avatar found, provide some backwards compatibility.
    922916        if ( empty( $avatar ) ) {
    923917            $avatar = '<img src="' . esc_url( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />';
     
    953947     * @param object|bool $group Optional. Group object.
    954948     *                           Default: current group in loop.
    955      *
    956949     * @return string
    957950     */
     
    981974     * @param object|bool $group Optional. Group object.
    982975     *                           Default: current group in loop.
    983      *
    984976     * @return string
    985977     */
     
    996988
    997989/**
    998  * Should we use the group's cover image header
     990 * Should we use the group's cover image header.
    999991 *
    1000992 * @since 2.4.0
     
    10211013     * @param object|bool $group Optional. Group object.
    10221014     *                           Default: current group in loop.
    1023      *
    10241015     * @return string
    10251016     */
     
    10661057     * @param object|bool $group Optional. Group object.
    10671058     *                           Default: current group in loop.
    1068      *
    10691059     * @return string
    10701060     */
     
    11001090     * @param object|bool $group Optional. Group object.
    11011091     *                           Default: current group in loop.
    1102      *
    11031092     * @return string
    11041093     */
     
    11341123     * @param object|bool $group Optional. Group object.
    11351124     *                           Default: current group in loop.
    1136      *
    11371125     * @return string
    11381126     */
     
    11681156     * @param object|bool $group Optional. Group object.
    11691157     *                           Default: current group in loop.
    1170      *
    11711158     * @return string
    11721159     */
     
    12061193     * @param object|bool $group Optional. Group object.
    12071194     *                           Default: current group in loop.
    1208      *
    12091195     * @return string
    12101196     */
     
    12461232     *                           Defaults to the group currently being
    12471233     *                           iterated on in the groups loop.
    1248      *
    12491234     * @return string Excerpt.
    12501235     */
     
    12851270     * @param object|bool $group Optional. Group object.
    12861271     *                           Default: current group in loop.
    1287      *
    12881272     * @return string
    12891273     */
     
    13201304     * @param object|bool $group Optional. Group object.
    13211305     *                           Default: current group in loop.
    1322      *
    1323      * @return unknown
     1306     * @return mixed
    13241307     */
    13251308    function bp_get_group_is_public( $group = false ) {
     
    13471330     * @param object|bool $group Optional. Group object.
    13481331     *                           Default: current group in loop.
    1349      *
    13501332     * @return string
    13511333     */
     
    13811363     * @param object|bool $group Optional. Group object.
    13821364     *                           Default: current group in loop.
    1383      *
    13841365     * @return string
    13851366     */
     
    14151396     * @param object|bool $group Optional. Group object.
    14161397     *                           Default: current group in loop.
    1417      *
    14181398     * @return int
    14191399     */
     
    14491429     * @param object|bool $group Optional. Group object.
    14501430     *                           Default: current group in loop.
    1451      *
    14521431     * @return string
    14531432     */
     
    14751454 *                             Default: current group in loop.
    14761455 * @param int         $user_id ID of the user.
    1477  *
    14781456 * @return bool
    14791457 */
     
    15891567    }
    15901568
    1591     // fetch group admins if 'populate_extras' flag is false
     1569    // Fetch group admins if 'populate_extras' flag is false.
    15921570    if ( empty( $group->args['populate_extras'] ) ) {
    15931571        $query = new BP_Group_Member_Query( array(
     
    16291607    }
    16301608
    1631     // fetch group mods if 'populate_extras' flag is false
     1609    // Fetch group mods if 'populate_extras' flag is false.
    16321610    if ( empty( $group->args['populate_extras'] ) ) {
    16331611        $query = new BP_Group_Member_Query( array(
     
    17591737     * @param object|bool $group Optional. Group object.
    17601738     *                           Default: current group in loop.
    1761      *
    17621739     * @return string
    17631740     */
     
    17841761 * No longer used in BuddyPress.
    17851762 *
    1786  * @todo Deprecate
     1763 * @todo Deprecate.
    17871764 */
    17881765function bp_group_search_form() {
     
    18071784 * No longer used in BuddyPress.
    18081785 *
    1809  * @todo Deprecate
     1786 * @todo Deprecate.
    18101787 *
    18111788 * @return bool True if the displayed user has no groups, otherwise false.
     
    19321909     * @param object|bool $group Optional. Group object.
    19331910     *                           Default: current group in loop.
    1934      *
    19351911     * @return int
    19361912     */
     
    19951971     * @param object|bool $group Optional. Group object.
    19961972     *                           Default: current group in loop.
    1997      *
    19981973     * @return string
    19991974     */
     
    22012176 *
    22022177 * @param string      $setting The setting you want to check against ('members',
    2203  *                             'mods', or 'admins').
     2178 *                             'mods', or 'admins').
    22042179 * @param object|bool $group   Optional. Group object. Default: current group in loop.
    22052180 */
     
    22302205 *                           check. Default: the displayed group, or the current group
    22312206 *                           in the loop.
    2232  *
    22332207 * @return bool|string Returns false when no group can be found. Otherwise
    22342208 *                     returns the group invite status, from among 'members',
     
    22422216
    22432217        if ( isset( $bp->groups->current_group->id ) ) {
    2244             // Default to the current group first
     2218            // Default to the current group first.
    22452219            $group_id = $bp->groups->current_group->id;
    22462220        } elseif ( isset( $groups_template->group->id ) ) {
    2247             // Then see if we're in the loop
     2221            // Then see if we're in the loop.
    22482222            $group_id = $groups_template->group->id;
    22492223        } else {
     
    22542228    $invite_status = groups_get_groupmeta( $group_id, 'invite_status' );
    22552229
    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.
    22572231    if ( !$invite_status ) {
    22582232        $invite_status = apply_filters( 'bp_group_invite_status_fallback', 'members' );
     
    22972271
    22982272    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.
    23002274        if ( user_can( $user_id, 'bp_moderate' ) ) {
    23012275            $can_send_invites = true;
     
    24972471 *
    24982472 * @param object|bool $group Optional. Group object. Default: current group in loop.
    2499  *
    25002473 * @return array Info about group admins (user_id + date_modified).
    25012474 */
     
    26162589     *                             member in a member loop.
    26172590     * @param object|bool $group   Optional. Group object. Default: current group.
    2618      *
    26192591     * @return string
    26202592     */
     
    26612633     *                             Default: current member in a member loop.
    26622634     * @param object|bool $group   Optional. Group object. Default: current group.
    2663      *
    26642635     * @return string
    26652636     */
     
    27022673     *                             Default: current member in a member loop.
    27032674     * @param object|bool $group   Optional. Group object. Default: current group.
    2704      *
    27052675     * @return string
    27062676     */
     
    27472717     *                             Default: current member in a member loop.
    27482718     * @param object|bool $group   Optional. Group object. Default: current group.
    2749      *
    27502719     * @return string
    27512720     */
     
    28002769 * @param  string $subnav_item   subnav item params.
    28012770 * @param  string $selected_item Surrent selected tab.
    2802  *
    28032771 * @return string HTML output
    28042772 */
     
    28622830     * @param object|bool $group Optional. Group object.
    28632831     *                           Default: current group in the loop.
    2864      *
    28652832     * @return string
    28662833     */
     
    28962863     * @param object|bool $group Optional. Group object.
    28972864     *                           Default: current group in the loop.
    2898      *
    28992865     * @return string
    29002866     */
     
    29252891 * @param object|bool $group Optional. Group object.
    29262892 *                           Default: current group in the loop.
    2927  *
    29282893 * @return bool
    29292894 */
     
    29492914 * @param object|bool $group Optional. Group to check is_member.
    29502915 *                           Default: current group in the loop.
    2951  *
    29522916 * @return bool If user is member of group or not.
    29532917 */
     
    29552919    global $groups_template;
    29562920
    2957     // Site admins always have access
     2921    // Site admins always have access.
    29582922    if ( bp_current_user_can( 'bp_moderate' ) ) {
    29592923        return true;
     
    29792943 * @param object|bool $group Optional. Group data object.
    29802944 *                           Default: the current group in the groups loop.
    2981  *
    29822945 * @return bool True if the user has an outstanding invite, otherwise false.
    29832946 */
     
    30182981 * @param BP_Groups_Group|bool $group   Group to check if user is banned.
    30192982 * @param int                  $user_id The user ID to check.
    3020  *
    30212983 * @return bool True if user is banned.  False if user isn't banned.
    30222984 */
     
    30242986    global $groups_template;
    30252987
    3026     // Site admins always have access
     2988    // Site admins always have access.
    30272989    if ( bp_current_user_can( 'bp_moderate' ) ) {
    30282990        return false;
    30292991    }
    30302992
    3031     // check groups loop first
    3032     // @see BP_Groups_Group::get_group_extras()
     2993    // Check groups loop first
     2994    // @see BP_Groups_Group::get_group_extras().
    30332995    if ( ! empty( $groups_template->in_the_loop ) && isset( $groups_template->group->is_banned ) ) {
    30342996        $retval = $groups_template->group->is_banned;
    30352997
    3036     // not in loop
     2998    // Not in loop.
    30372999    } else {
    3038         // Default to not banned
     3000        // Default to not banned.
    30393001        $retval = false;
    30403002
     
    30733035     * @param object|bool $group Optional. Group object.
    30743036     *                           Default: Current group in the loop.
    3075      *
    30763037     * @return string
    30773038     */
     
    31063067     * @param object|bool $group Optional. Group object.
    31073068     *                           Default: Current group in the loop.
    3108      *
    31093069     * @return string
    31103070     */
     
    31393099     * @param object|bool $group Optional. Group object.
    31403100     *                           Default: Current group in the loop.
    3141      *
    31423101     * @return string
    31433102     */
     
    31703129     * @param object|bool $group Optional. Group object.
    31713130     *                           Default: Current group in the loop.
    3172      *
    31733131     * @return string
    31743132     */
     
    32013159     * @param object|bool $group Optional. Group object.
    32023160     *                           Default: current group in the loop.
    3203      *
    32043161     * @return string
    32053162     */
     
    32263183 * @param object|bool $group Optional. Group object.
    32273184 *                           Default: current group in the loop.
    3228  *
    32293185 * @return bool
    32303186 */
     
    32663222     * @param BP_Groups_Group|bool $group The BP Groups_Group object if
    32673223     *                                    passed, boolean false if not passed.
    3268      *
    32693224     * @return string HTML code for the button.
    32703225     */
     
    33193274     *
    33203275     * @param object|bool $group Single group object.
    3321      *
    33223276     * @return mixed
    33233277     */
     
    33253279        global $groups_template;
    33263280
    3327         // Set group to current loop group if none passed
     3281        // Set group to current loop group if none passed.
    33283282        if ( empty( $group ) ) {
    33293283            $group =& $groups_template->group;
    33303284        }
    33313285
    3332         // Don't show button if not logged in or previously banned
     3286        // Don't show button if not logged in or previously banned.
    33333287        if ( ! is_user_logged_in() || bp_group_is_user_banned( $group ) ) {
    33343288            return false;
    33353289        }
    33363290
    3337         // Group creation was not completed or status is unknown
     3291        // Group creation was not completed or status is unknown.
    33383292        if ( empty( $group->status ) ) {
    33393293            return false;
    33403294        }
    33413295
    3342         // Already a member
     3296        // Already a member.
    33433297        if ( ! empty( $group->is_member ) ) {
    33443298
    3345             // Stop sole admins from abandoning their group
     3299            // Stop sole admins from abandoning their group.
    33463300            $group_admins = groups_get_group_admins( $group->id );
    33473301            if ( ( 1 == count( $group_admins ) ) && ( bp_loggedin_user_id() === (int) $group_admins[0]->user_id ) ) {
     
    33493303            }
    33503304
    3351             // Setup button attributes
     3305            // Setup button attributes.
    33523306            $button = array(
    33533307                'id'                => 'leave_group',
     
    33633317            );
    33643318
    3365         // Not a member
     3319        // Not a member.
    33663320        } else {
    33673321
    3368             // Show different buttons based on group status
     3322            // Show different buttons based on group status.
    33693323            switch ( $group->status ) {
    33703324                case 'hidden' :
     
    33893343
    33903344                    // Member has outstanding invitation -
    3391                     // show an "Accept Invitation" button
     3345                    // show an "Accept Invitation" button.
    33923346                    if ( $group->is_invited ) {
    33933347                        $button = array(
     
    34053359
    34063360                    // Member has requested membership but request is pending -
    3407                     // show a "Request Sent" button
     3361                    // show a "Request Sent" button.
    34083362                    } elseif ( $group->is_pending ) {
    34093363                        $button = array(
     
    34213375
    34223376                    // Member has not requested membership yet -
    3423                     // show a "Request Membership" button
     3377                    // show a "Request Membership" button.
    34243378                    } else {
    34253379                        $button = array(
     
    35153469     */
    35163470    function bp_get_group_create_nav_item() {
    3517         // Get the create a group button
     3471        // Get the create a group button.
    35183472        $create_group_button = bp_get_group_create_button();
    35193473
    3520         // Make sure the button is available
     3474        // Make sure the button is available.
    35213475        if ( empty( $create_group_button ) ) {
    35223476            return;
     
    35413495 * @since 2.2.0
    35423496 *
    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 *
    35443499 * @return string HTML Output
    35453500 */
    35463501function 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.
    35483503    if ( has_action( 'bp_groups_directory_group_filter', 'bp_legacy_theme_group_create_nav', 999 ) ) {
    35493504        return;
    35503505    }
    35513506
    3552     // Bail if the theme is not filtering the Groups directory title
     3507    // Bail if the theme is not filtering the Groups directory title.
    35533508    if ( ! has_filter( 'bp_groups_directory_header' ) ) {
    35543509        return;
     
    35663521 *
    35673522 * @global BP_Groups_Template $groups_template Groups template object.
     3523 *
    35683524 * @param object $group Group to get status message for. Optional; defaults to current group.
    35693525 */
     
    35713527    global $groups_template;
    35723528
    3573     // Group not passed so look for loop
     3529    // Group not passed so look for loop.
    35743530    if ( empty( $group ) ) {
    35753531        $group =& $groups_template->group;
    35763532    }
    35773533
    3578     // Group status is not set (maybe outside of group loop?)
     3534    // Group status is not set (maybe outside of group loop?).
    35793535    if ( empty( $group->status ) ) {
    35803536        $message = __( 'This group is not currently accessible.', 'buddypress' );
    35813537
    3582     // Group has a status
     3538    // Group has a status.
    35833539    } else {
    35843540        switch( $group->status ) {
    35853541
    3586             // Private group
     3542            // Private group.
    35873543            case 'private' :
    35883544                if ( ! bp_group_has_requested_membership( $group ) ) {
     
    36023558                break;
    36033559
    3604             // Hidden group
     3560            // Hidden group.
    36053561            case 'hidden' :
    36063562            default :
     
    36563612     *
    36573613     * @since 1.0.0
     3614     *
    36583615     * @return type
    36593616     */
     
    36883645     *
    36893646     * @param int $user_id User ID to get group membership count.
    3690      *
    36913647     * @return int
    36923648     */
     
    37053661    }
    37063662
    3707 /** Group Members *************************************************************/
     3663/* Group Members *************************************************************/
    37083664
    37093665class BP_Groups_Group_Members_Template {
     
    37263682     *     An array of optional arguments.
    37273683     *     @type int      $group_id           ID of the group whose members are being
    3728      *                                        queried. Default: current group ID.
     3684     *                                        queried. Default: current group ID.
    37293685     *     @type int      $page               Page of results to be queried. Default: 1.
    37303686     *     @type int      $per_page           Number of items to return per page of
     
    37423698    public function __construct( $args = array() ) {
    37433699
    3744         // Backward compatibility with old method of passing arguments
     3700        // Backward compatibility with old method of passing arguments.
    37453701        if ( ! is_array( $args ) || func_num_args() > 1 ) {
    37463702            _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__ ) );
     
    37873743        }
    37883744
    3789         // Assemble the base URL for pagination
     3745        // Assemble the base URL for pagination.
    37903746        $base_url = trailingslashit( bp_get_group_permalink( $current_group ) . bp_current_action() );
    37913747        if ( bp_action_variable() ) {
     
    37983754        $members_args['per_page'] = $this->pag_num;
    37993755
    3800         // Get group members for this loop
     3756        // Get group members for this loop.
    38013757        $this->members = groups_get_group_members( $members_args );
    38023758
     
    38073763        }
    38083764
    3809         // Reset members array for subsequent looping
     3765        // Reset members array for subsequent looping.
    38103766        $this->members = $this->members['members'];
    38113767
     
    38663822            do_action( 'loop_end', $this );
    38673823
    3868             // Do some cleaning up after the loop
     3824            // Do some cleaning up after the loop.
    38693825            $this->rewind_members();
    38703826        }
     
    38783834        $this->member      = $this->next_member();
    38793835
    3880         // loop has just started
     3836        // Loop has just started.
    38813837        if ( 0 == $this->current_member ) {
    38823838
     
    39773933 * @since 1.0.0
    39783934 *
    3979  * @param array|string $args {@see bp_core_fetch_avatar()}
     3935 * @param array|string $args {@see bp_core_fetch_avatar()}.
    39803936 */
    39813937function bp_group_member_avatar( $args = '' ) {
     
    39873943     * @since 1.0.0
    39883944     *
    3989      * @param array|string $args {@see bp_core_fetch_avatar()}
    3990      *
     3945     * @param array|string $args {@see bp_core_fetch_avatar()}.
    39913946     * @return string
    39923947     */
     
    40173972 * @since 1.0.0
    40183973 *
    4019  * @param array|string $args {@see bp_core_fetch_avatar()}
    4020  */
    4021 
     3974 * @param array|string $args {@see bp_core_fetch_avatar()}.
     3975 */
    40223976function bp_group_member_avatar_thumb( $args = '' ) {
    40233977    echo bp_get_group_member_avatar_thumb( $args );
     
    40283982     * @since 1.0.0
    40293983     *
    4030      * @param array|string $args {@see bp_core_fetch_avatar()}
    4031      *
     3984     * @param array|string $args {@see bp_core_fetch_avatar()}.
    40323985     * @return string
    40333986     */
     
    40714024     * @param int $width  Width of avatar to fetch.
    40724025     * @param int $height Height of avatar to fetch.
    4073      *
    40744026     * @return string
    40754027     */
     
    43994351 *
    44004352 * @since 2.0.0
    4401  *
    4402  * @return string html output
    44034353 */
    44044354function bp_groups_members_template_part() {
     
    44374387 *
    44384388 * @since 2.0.0
    4439  *
    4440  * @return string html output
    44414389 */
    44424390function bp_groups_members_filter() {
     
    44704418}
    44714419
    4472 /***************************************************************************
     4420/*
    44734421 * Group Creation Process Template Tags
    4474  **/
     4422 */
    44754423
    44764424/**
     
    44824430 * @uses bp_get_option() To retrieve value of 'bp_restrict_group_creation'. Defaults to 0.
    44834431 * @uses bp_current_user_can() To determine if current user if super admin.
    4484  *
    44854432 * @return bool True if user can create groups. False otherwise.
    44864433 */
    44874434function bp_user_can_create_groups() {
    44884435
    4489     // Super admin can always create groups
     4436    // Super admin can always create groups.
    44904437    if ( bp_current_user_can( 'bp_moderate' ) ) {
    44914438        return true;
    44924439    }
    44934440
    4494     // Get group creation option, default to 0 (allowed)
     4441    // Get group creation option, default to 0 (allowed).
    44954442    $restricted = (int) bp_get_option( 'bp_restrict_group_creation', 0 );
    44964443
    4497     // Allow by default
     4444    // Allow by default.
    44984445    $can_create = true;
    44994446
     
    45814528function bp_is_group_creation_step( $step_slug ) {
    45824529
    4583     // Make sure we are in the groups component
     4530    // Make sure we are in the groups component.
    45844531    if ( ! bp_is_groups_component() || ! bp_is_current_action( 'create' ) ) {
    45854532        return false;
     
    45884535    $bp = buddypress();
    45894536
    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.
    45914538    $keys = array_keys( $bp->groups->group_creation_steps );
    45924539    if ( !bp_action_variable( 1 ) && array_shift( $keys ) == $step_slug ) {
     
    45954542
    45964543    // Before allowing a user to see a group creation step we must make sure
    4597     // previous steps are completed
     4544    // previous steps are completed.
    45984545    if ( !bp_is_first_group_creation_step() ) {
    45994546        if ( !bp_are_previous_group_creation_steps_complete( $step_slug ) ) {
     
    46024549    }
    46034550
    4604     // Check the current step against the step parameter
     4551    // Check the current step against the step parameter.
    46054552    if ( bp_is_action_variable( $step_slug ) ) {
    46064553        return true;
     
    46374584    $bp = buddypress();
    46384585
    4639     // If this is the first group creation step, return true
     4586    // If this is the first group creation step, return true.
    46404587    $keys = array_keys( $bp->groups->group_creation_steps );
    46414588    if ( array_shift( $keys ) == $step_slug ) {
     
    46474594    $previous_steps = array();
    46484595
    4649     // Get previous steps
     4596    // Get previous steps.
    46504597    foreach ( (array) $bp->groups->group_creation_steps as $slug => $name ) {
    46514598        if ( $slug === $step_slug ) {
     
    47614708 * @see bp_core_fetch_avatar() For more information on accepted arguments
    47624709 *
    4763  * @param  array  $args See bp_core_fetch_avatar()
     4710 * @param array|string $args See bp_core_fetch_avatar().
    47644711 */
    47654712function bp_new_group_avatar( $args = '' ) {
     
    47734720     * @see bp_core_fetch_avatar() For a description of arguments and return values.
    47744721     *
    4775      * @param array $args {
     4722     * @param array|string $args {
    47764723     *     Arguments are listed here with an explanation of their defaults.
    47774724     *     For more information about the arguments, see {@link bp_core_fetch_avatar()}.
     
    47884735    function bp_get_new_group_avatar( $args = '' ) {
    47894736
    4790         // Parse arguments
     4737        // Parse arguments.
    47914738        $r = bp_parse_args( $args, array(
    47924739            'type'    => 'full',
     
    47994746        ), 'get_new_group_avatar' );
    48004747
    4801         // Merge parsed arguments with object specific data
     4748        // Merge parsed arguments with object specific data.
    48024749        $r = array_merge( $r, array(
    48034750            'item_id'    => bp_get_current_group_id(),
     
    48064753        ) );
    48074754
    4808         // Get the avatar
     4755        // Get the avatar.
    48094756        $avatar = bp_core_fetch_avatar( $r );
    48104757
     
    48404787        $steps = array_keys( $bp->groups->group_creation_steps );
    48414788
    4842         // Loop through steps
     4789        // Loop through steps.
    48434790        foreach ( $steps as $slug ) {
    48444791
    4845             // Break when the current step is found
     4792            // Break when the current step is found.
    48464793            if ( bp_is_action_variable( $slug ) ) {
    48474794                break;
    48484795            }
    48494796
    4850             // Add slug to previous steps
     4797            // Add slug to previous steps.
    48514798            $previous_steps[] = $slug;
    48524799        }
    48534800
    4854         // Generate the URL for the previous step
     4801        // Generate the URL for the previous step.
    48554802        $group_directory = bp_get_groups_directory_permalink();
    48564803        $create_step     = 'create/step/';
     
    49114858 * @since 1.1.0
    49124859 *
    4913  * @param  string $step Step to compare
    4914  * @return bool         True if yes, False if no
     4860 * @param string $step Step to compare.
     4861 * @return bool True if yes, False if no
    49154862 */
    49164863function bp_is_last_group_creation_step( $step = '' ) {
    49174864
    4918     // Use current step, if no step passed
     4865    // Use current step, if no step passed.
    49194866    if ( empty( $step ) ) {
    49204867        $step = bp_get_groups_current_create_step();
    49214868    }
    49224869
    4923     // Get the last step
     4870    // Get the last step.
    49244871    $bp     = buddypress();
    49254872    $steps  = array_keys( $bp->groups->group_creation_steps );
    49264873    $l_step = array_pop( $steps );
    49274874
    4928     // Compare last step to step
     4875    // Compare last step to step.
    49294876    $retval = ( $l_step === $step );
    49304877
     
    49464893 * @since 1.1.0
    49474894 *
    4948  * @param  string $step Step to compare
    4949  * @return bool         True if yes, False if no
     4895 * @param string $step Step to compare.
     4896 * @return bool True if yes, False if no
    49504897 */
    49514898function bp_is_first_group_creation_step( $step = '' ) {
    49524899
    4953     // Use current step, if no step passed
     4900    // Use current step, if no step passed.
    49544901    if ( empty( $step ) ) {
    49554902        $step = bp_get_groups_current_create_step();
    49564903    }
    49574904
    4958     // Get the first step
     4905    // Get the first step.
    49594906    $bp     = buddypress();
    49604907    $steps  = array_keys( $bp->groups->group_creation_steps );
    49614908    $f_step = array_shift( $steps );
    49624909
    4963     // Compare first step to step
     4910    // Compare first step to step.
    49644911    $retval = ( $f_step === $step );
    49654912
     
    49804927 *
    49814928 * @since 1.0.0
     4929 *
     4930 * @param array $args Array of arguments for friends list output.
    49824931 */
    49834932function bp_new_group_invite_friend_list( $args = array() ) {
     
    49894938     * @since 1.0.0
    49904939     *
    4991      * @param  array $args
     4940     * @param array $args Array of arguments for friends list output.
    49924941     * @return mixed HTML list of checkboxes, or false
    49934942     */
    49944943    function bp_get_new_group_invite_friend_list( $args = array() ) {
    49954944
    4996         // Bail if no friends component
     4945        // Bail if no friends component.
    49974946        if ( ! bp_is_active( 'friends' ) ) {
    49984947            return false;
    49994948        }
    50004949
    5001         // Parse arguments
     4950        // Parse arguments.
    50024951        $r = wp_parse_args( $args, array(
    50034952            'user_id'   => bp_loggedin_user_id(),
     
    50064955        ) );
    50074956
    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.
    50094958        if ( empty( $r['group_id'] ) ) {
    50104959            $bp            = buddypress();
     
    50144963        }
    50154964
    5016         // Setup empty items array
     4965        // Setup empty items array.
    50174966        $items = array();
    50184967
    5019         // Get user's friends who are not in this group already
     4968        // Get user's friends who are not in this group already.
    50204969        $friends = friends_get_friends_invite_list( $r['user_id'], $r['group_id'] );
    50214970
    50224971        if ( ! empty( $friends ) ) {
    50234972
    5024             // Get already invited users
     4973            // Get already invited users.
    50254974            $invites = groups_get_invites_for_group( $r['user_id'], $r['group_id'] );
    50264975
     
    51325081 * @since 1.1.0
    51335082 *
    5134  * @param string $slug
    5135  *
     5083 * @param string $slug Admin screen slug.
    51365084 * @return bool
    51375085 */
     
    51805128 *
    51815129 * @since 1.0.0
    5182  * @param string $type thumb or full ?
     5130 *
    51835131 * @uses bp_get_group_current_avatar() to get the avatar of the current group.
     5132 *
     5133 * @param string $type Thumb or full.
    51845134 */
    51855135function bp_group_current_avatar( $type = 'thumb' ) {
     
    51915141     * @since 2.0.0
    51925142     *
    5193      * @param string $type thumb or full ?
     5143     * @param string $type Thumb or full.
    51945144     * @return string $tab The current tab's slug.
    51955145     */
     
    52205170 * @since 1.1.0
    52215171 *
    5222  * @param  int|bool $group_id
    5223  *
     5172 * @param int|bool $group_id Group ID to check.
    52245173 * @return boolean
    52255174 */
     
    52765225}
    52775226
    5278 /** Group Membership Requests *************************************************/
     5227/* Group Membership Requests *************************************************/
    52795228
    52805229class BP_Groups_Membership_Requests_Template {
     
    53055254    public function __construct( $args = array() ) {
    53065255
    5307         // Backward compatibility with old method of passing arguments
     5256        // Backward compatibility with old method of passing arguments.
    53085257        if ( ! is_array( $args ) || func_num_args() > 1 ) {
    53095258            _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__ ) );
     
    53385287            'page'     => $this->pag_page,
    53395288
    5340             // These filters ensure we only get pending requests
     5289            // These filters ensure we only get pending requests.
    53415290            'is_confirmed' => false,
    53425291            'inviter_id'   => 0,
     
    53465295        $this->request_count = count( $this->requests );
    53475296
    5348         // Compatibility with legacy format of request data objects
     5297        // Compatibility with legacy format of request data objects.
    53495298        foreach ( $this->requests as $rk => $rv ) {
    53505299            // For legacy reasons, the 'id' property of each
    53515300            // 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).
    53535302            $this->requests[ $rk ]->user_id = $rv->ID;
    53545303            $this->requests[ $rk ]->id      = $rv->membership_id;
    53555304
    5356             // Miscellaneous values
     5305            // Miscellaneous values.
    53575306            $this->requests[ $rk ]->group_id   = $r['group_id'];
    53585307        }
     
    54175366             */
    54185367            do_action( 'group_request_loop_end' );
    5419             // Do some cleaning up after the loop
     5368            // Do some cleaning up after the loop.
    54205369            $this->rewind_requests();
    54215370        }
     
    54295378        $this->request     = $this->next_request();
    54305379
    5431         // loop has just started
     5380        // Loop has just started.
    54325381        if ( 0 == $this->current_request ) {
    54335382
     
    56645613    public function __construct( $args = array() ) {
    56655614
    5666         // Backward compatibility with old method of passing arguments
     5615        // Backward compatibility with old method of passing arguments.
    56675616        if ( ! is_array( $args ) || func_num_args() > 1 ) {
    56685617            _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__ ) );
     
    56955644            'page'     => $this->pag_page,
    56965645
    5697             // These filters ensure we get only pending invites
     5646            // These filters ensure we get only pending invites.
    56985647            'is_confirmed' => false,
    56995648            'inviter_id'   => $r['user_id'],
     
    57065655
    57075656        // If per_page is set to 0 (show all results), don't generate
    5708         // pag_links
     5657        // pag_links.
    57095658        if ( ! empty( $this->pag_num ) ) {
    57105659            $this->pag_links = paginate_links( array(
     
    58415790    }
    58425791
    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()).
    58445793    if ( empty( $group_id ) ) {
    58455794        $group_id = $r['group_id'];
     
    60265975function bp_groups_activity_feed() {
    60275976
    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.
    60295978    if ( ! bp_is_active( 'groups' ) || ! bp_is_active( 'activity' ) || ! bp_is_group() ) {
    60305979        return;
     
    60495998     *
    60505999     * @since 1.5.0
     6000     *
    60516001     * @return string
    60526002     */
     
    62146164 * @param string $query_args
    62156165 * @param bool $nonce
    6216  *
    62176166 * @return string
    62186167 */
     
    62286177     * @param string $query_args
    62296178     * @param bool $nonce
    6230      *
    62316179     * @return string
    62326180     */
     
    62366184        $url           = '';
    62376185
    6238         // Must be a group
     6186        // Must be a group.
    62396187        if ( ! empty( $current_group->id ) ) {
    62406188
     
    62466194            }
    62476195
    6248             // Add a slash at the end of our user url
     6196            // Add a slash at the end of our user url.
    62496197            $url = trailingslashit( $url );
    62506198
    6251             // Add possible query args
     6199            // Add possible query args.
    62526200            if ( !empty( $query_args ) && is_array( $query_args ) ) {
    62536201                $url = add_query_arg( $query_args, $url );
  • trunk/src/bp-groups/bp-groups-widgets.php

    r10148 r10373  
    1010defined( 'ABSPATH' ) || exit;
    1111
    12 /* Register widgets for groups component */
     12/**
     13 * Register widgets for groups component
     14 */
    1315function groups_register_widgets() {
    1416    add_action('widgets_init', create_function('', 'return register_widget("BP_Groups_Widget");') );
     
    1618add_action( 'bp_register_widgets', 'groups_register_widgets' );
    1719
    18 /*** GROUPS WIDGET *****************/
    19 
     20/**
     21 * GROUPS WIDGET
     22 */
    2023class BP_Groups_Widget extends WP_Widget {
     24
     25    /**
     26     * Working as a group, we get things done better.
     27     */
    2128    function __construct() {
    2229        $widget_ops = array(
     
    4148    }
    4249
     50    /**
     51     * Extends our frontend output method.
     52     *
     53     * @param array $args     Array of arguments for the widget.
     54     * @param array $instance Widget instance data.
     55     */
    4356    function widget( $args, $instance ) {
    4457
     
    146159    }
    147160
     161    /**
     162     * Extends our update method.
     163     *
     164     * @param array $new_instance New instance data.
     165     * @param array $old_instance Original instance data.
     166     * @return array
     167     */
    148168    function update( $new_instance, $old_instance ) {
    149169        $instance = $old_instance;
     
    157177    }
    158178
     179    /**
     180     * Extends our form method.
     181     *
     182     * @param array $instance Current instance.
     183     * @return mixed
     184     */
    159185    function form( $instance ) {
    160186        $defaults = array(
  • trunk/src/bp-groups/classes/class-bp-group-extension.php

    r10248 r10373  
    3636 *     of your main extension tab. Defaults to 'groups/single/plugins.php'.
    3737 *   - 'screens' A multi-dimensional array, described below.
    38  *   - 'access' Which users can visit the plugin's tab.
    39  *   - 'show_tab' Which users can see the plugin's navigation tab.
     38 *   - 'access' Which users can visit the plugin's tab.
     39 *   - 'show_tab' Which users can see the plugin's navigation tab.
    4040 *
    4141 * BP_Group_Extension uses the concept of "settings screens". There are three
     
    6363 *   'screens' => array(
    6464 *       'create' => array(
    65  *       'slug' => 'foo',
    66  *       'name' => 'Foo',
    67  *       'position' => 55,
    68  *       'screen_callback' => 'my_create_screen_callback',
    69  *       'screen_save_callback' => 'my_create_screen_save_callback',
    70  *  ),
    71  *  'edit' => array( // ...
     65 *       'slug' => 'foo',
     66 *       'name' => 'Foo',
     67 *       'position' => 55,
     68 *       'screen_callback' => 'my_create_screen_callback',
     69 *       'screen_save_callback' => 'my_create_screen_save_callback',
     70 *  ),
     71 *  'edit' => array( // ...
    7272 *   ),
    7373 * Only provide those arguments that you actually want to change from the
     
    272272     * The content of the group tab.
    273273     *
    274      * @param int|null $group_id
     274     * @param int|null $group_id ID of the group to display.
    275275     */
    276276    public function display( $group_id = null ) {}
     
    281281    public function widget_display() {}
    282282
    283     // *_screen() displays the settings form for the given context
    284     // *_screen_save() processes data submitted via the settings form
    285     // The settings_* methods are generic fallbacks, which can optionally
    286     // be overridden by the more specific edit_*, create_*, and admin_*
    287     // versions.
     283    /*
     284     * *_screen() displays the settings form for the given context
     285     * *_screen_save() processes data submitted via the settings form
     286     * The settings_* methods are generic fallbacks, which can optionally
     287     * be overridden by the more specific edit_*, create_*, and admin_*
     288     * versions.
     289     */
    288290    public function settings_screen( $group_id = null ) {}
    289291    public function settings_screen_save( $group_id = null ) {}
     
    354356     */
    355357    public function init( $args = array() ) {
    356         // Store the raw arguments
     358        // Store the raw arguments.
    357359        $this->params_raw = $args;
    358360
     
    361363        // compatibility with these plugins, we detect whether this is
    362364        // one of those legacy plugins, and parse any legacy arguments
    363         // with those passed to init()
     365        // with those passed to init().
    364366        $this->parse_legacy_properties();
    365367        $args = $this->parse_args_r( $args, $this->legacy_properties_converted );
    366368
    367         // Parse with defaults
     369        // Parse with defaults.
    368370        $this->params = $this->parse_args_r( $args, array(
    369371            'slug'              => $this->slug,
     
    399401    public function _register() {
    400402
    401         // Detect and parse properties set by legacy extensions
     403        // Detect and parse properties set by legacy extensions.
    402404        $this->parse_legacy_properties();
    403405
    404406        // Initialize, if necessary. This should only happen for
    405         // legacy extensions that don't call parent::init() themselves
     407        // legacy extensions that don't call parent::init() themselves.
    406408        if ( true !== $this->initialized ) {
    407409            $this->init();
    408410        }
    409411
    410         // Set some config values, based on the parsed params
     412        // Set some config values, based on the parsed params.
    411413        $this->group_id          = $this->get_group_id();
    412414        $this->slug              = $this->params['slug'];
     
    418420        $this->template_file     = $this->params['template_file'];
    419421
    420         // Configure 'screens': create, admin, and edit contexts
     422        // Configure 'screens': create, admin, and edit contexts.
    421423        $this->setup_screens();
    422424
    423         // Configure access-related settings
     425        // Configure access-related settings.
    424426        $this->setup_access_settings();
    425427
    426428        // Mirror configuration data so it's accessible to plugins
    427         // that look for it in its old locations
     429        // that look for it in its old locations.
    428430        $this->setup_legacy_properties();
    429431
    430         // Hook the extension into BuddyPress
     432        // Hook the extension into BuddyPress.
    431433        $this->setup_display_hooks();
    432434        $this->setup_create_hooks();
     
    468470    public static function get_group_id() {
    469471
    470         // Usually this will work
     472        // Usually this will work.
    471473        $group_id = bp_get_current_group_id();
    472474
    473         // On the admin, get the group id out of the $_GET params
     475        // On the admin, get the group id out of the $_GET params.
    474476        if ( empty( $group_id ) && is_admin() && ( isset( $_GET['page'] ) && ( 'bp-groups' === $_GET['page'] ) ) && ! empty( $_GET['gid'] ) ) {
    475477            $group_id = (int) $_GET['gid'];
     
    477479
    478480        // This fallback will only be hit when the create step is very
    479         // early
     481        // early.
    480482        if ( empty( $group_id ) && bp_get_new_group_id() ) {
    481483            $group_id = bp_get_new_group_id();
     
    484486        // On some setups, the group id has to be fetched out of the
    485487        // $_POST array
    486         // @todo Figure out why this is happening during group creation
     488        // @todo Figure out why this is happening during group creation.
    487489        if ( empty( $group_id ) && isset( $_POST['group_id'] ) ) {
    488490            $group_id = (int) $_POST['group_id'];
     
    552554     */
    553555    protected function setup_access_settings() {
    554         // Bail if no group ID is available
     556        // Bail if no group ID is available.
    555557        if ( empty( $this->group_id ) ) {
    556558            return;
    557559        }
    558560
    559         // Backward compatibility
     561        // Backward compatibility.
    560562        if ( isset( $this->params['enable_nav_item'] ) ) {
    561563            $this->enable_nav_item = (bool) $this->params['enable_nav_item'];
    562564        }
    563565
    564         // Tab Access
     566        // Tab Access.
    565567        $this->user_can_visit = false;
    566568
    567569        // Backward compatibility for components that do not provide
    568         // explicit 'access' parameter
     570        // explicit 'access' parameter.
    569571        if ( empty( $this->params['access'] ) ) {
    570572            if ( false === $this->enable_nav_item ) {
     
    576578
    577579                if ( ! empty( $group->status ) && 'public' === $group->status ) {
    578                     // Tabs in public groups are accessible to anyone by default
     580                    // Tabs in public groups are accessible to anyone by default.
    579581                    $this->params['access'] = 'anyone';
    580582                } else {
    581                     // All other groups have members-only as the default
     583                    // All other groups have members-only as the default.
    582584                    $this->params['access'] = 'member';
    583585                }
     
    585587        }
    586588
    587         // Parse multiple access conditions into an array
     589        // Parse multiple access conditions into an array.
    588590        $access_conditions = $this->params['access'];
    589591        if ( ! is_array( $access_conditions ) ) {
     
    592594
    593595        // If the current user meets at least one condition, the
    594         // get access
     596        // get access.
    595597        foreach ( $access_conditions as $access_condition ) {
    596598            if ( $this->user_meets_access_condition( $access_condition ) ) {
     
    600602        }
    601603
    602         // Tab Visibility
     604        // Tab Visibility.
    603605        $this->user_can_see_nav_item = false;
    604606
    605607        // Backward compatibility for components that do not provide
    606         // explicit 'show_tab' parameter
     608        // explicit 'show_tab' parameter.
    607609        if ( empty( $this->params['show_tab'] ) ) {
    608610            if ( false === $this->params['enable_nav_item'] ) {
    609                 // enable_nav_item is only false if it's been
     611                // The enable_nav_item index is only false if it's been
    610612                // defined explicitly as such in the
    611                 // constructor. So we always trust this value
     613                // constructor. So we always trust this value.
    612614                $this->params['show_tab'] = 'noone';
    613615
     
    616618                // we assume this  is a legacy extension.
    617619                // Legacy behavior is that enable_nav_item=true +
    618                 // visibility=private implies members-only
     620                // visibility=private implies members-only.
    619621                if ( 'public' !== $this->visibility ) {
    620622                    $this->params['show_tab'] = 'member';
     
    625627            } else {
    626628                // No show_tab or enable_nav_item value is
    627                 // available, so match the value of 'access'
     629                // available, so match the value of 'access'.
    628630                $this->params['show_tab'] = $this->params['access'];
    629631            }
    630632        }
    631633
    632         // Parse multiple access conditions into an array
     634        // Parse multiple access conditions into an array.
    633635        $access_conditions = $this->params['show_tab'];
    634636        if ( ! is_array( $access_conditions ) ) {
     
    637639
    638640        // If the current user meets at least one condition, the
    639         // get access
     641        // get access.
    640642        foreach ( $access_conditions as $access_condition ) {
    641643            if ( $this->user_meets_access_condition( $access_condition ) ) {
     
    697699    protected function setup_display_hooks() {
    698700
    699         // Bail if not a group
     701        // Bail if not a group.
    700702        if ( ! bp_is_group() ) {
    701703            return;
    702704        }
    703705
    704         // Backward compatibility only
     706        // Backward compatibility only.
    705707        if ( ( 'public' !== $this->visibility ) && ! buddypress()->groups->current_group->user_has_access ) {
    706708            return;
     
    740742            ) );
    741743
    742             // When we are viewing the extension display page, set the title and options title
     744            // When we are viewing the extension display page, set the title and options title.
    743745            if ( bp_is_current_action( $this->slug ) ) {
    744746                add_filter( 'bp_group_user_has_access',   array( $this, 'group_access_protection' ), 10, 2 );
     
    748750        }
    749751
    750         // Hook the group home widget
     752        // Hook the group home widget.
    751753        if ( ! bp_current_action() && bp_is_current_action( 'home' ) ) {
    752754            add_action( $this->display_hook, array( &$this, 'widget_display' ) );
     
    790792     * @since 2.1.0
    791793     *
    792      * @param bool $user_can_see_nav_item
    793      *
     794     * @param bool $user_can_see_nav_item Whether or not the user can see the nav item.
    794795     * @return bool
    795796     */
     
    807808     * @since 2.1.0
    808809     *
    809      * @param bool $user_can_visit
    810      *
     810     * @param bool $user_can_visit Whether or not the user can visit the tab.
    811811     * @return bool
    812812     */
     
    828828     * @since 2.1.0
    829829     *
    830      * @param bool  $user_can_visit
    831      * @param array $no_access_args
    832      *
     830     * @param bool  $user_can_visit Whether or not the user can visit the tab.
     831     * @param array $no_access_args Array of args to help determine access.
    833832     * @return bool
    834833     */
     
    864863        $screen = $this->screens['create'];
    865864
    866         // Insert the group creation step for the new group extension
     865        // Insert the group creation step for the new group extension.
    867866        buddypress()->groups->group_creation_steps[ $screen['slug'] ] = array(
    868867            'name'     => $screen['name'],
     
    875874        // correct group creation step). Hooked in separate
    876875        // methods because current creation step info not yet
    877         // available at this point
     876        // available at this point.
    878877        add_action( 'groups_custom_create_steps', array( $this, 'maybe_create_screen' ) );
    879878        add_action( 'groups_create_group_step_save_' . $screen['slug'], array( $this, 'maybe_create_screen_save' ) );
     
    894893
    895894        // The create screen requires an additional nonce field
    896         // due to a quirk in the way the templates are built
     895        // due to a quirk in the way the templates are built.
    897896        wp_nonce_field( 'groups_create_save_' . bp_get_groups_current_create_step(), '_wpnonce', false );
    898897    }
     
    920919     */
    921920    protected function setup_edit_hooks() {
    922         // Bail if not in a group
     921        // Bail if not in a group.
    923922        if ( ! bp_is_group() ) {
    924923            return;
    925924        }
    926925
    927         // Bail if not an edit screen
     926        // Bail if not an edit screen.
    928927        if ( ! $this->is_screen_enabled( 'edit' ) || ! bp_is_item_admin() ) {
    929928            return;
     
    948947        );
    949948
    950         // Should we add a menu to the Group's WP Admin Bar
     949        // Should we add a menu to the Group's WP Admin Bar.
    951950        if ( ! empty( $screen['show_in_admin_bar'] ) ) {
    952951            $subnav_args['show_in_admin_bar'] = true;
    953952        }
    954953
    955         // Add the tab to the manage navigation
     954        // Add the tab to the manage navigation.
    956955        bp_core_new_subnav_item( $subnav_args );
    957956
    958         // Catch the edit screen and forward it to the plugin template
     957        // Catch the edit screen and forward it to the plugin template.
    959958        if ( bp_is_groups_component() && bp_is_current_action( 'admin' ) && bp_is_action_variable( $screen['slug'], 0 ) ) {
    960959            $this->call_edit_screen_save( $this->group_id );
     
    963962
    964963            // Determine the proper template and save for later
    965             // loading
     964            // loading.
    966965            if ( '' !== bp_locate_template( array( 'groups/single/home.php' ), false ) ) {
    967966                $this->edit_screen_template = '/groups/single/home';
     
    973972
    974973            // We load the template at bp_screens, to give all
    975             // extensions a chance to load
     974            // extensions a chance to load.
    976975            add_action( 'bp_screens', array( $this, 'call_edit_screen_template_loader' ) );
    977976        }
     
    10151014
    10161015        // When DOING_AJAX, the POST global will be populated, but we
    1017         // should assume it's a save
     1016        // should assume it's a save.
    10181017        if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
    10191018            return;
     
    10231022
    10241023        // Detect whether the screen_save_callback is performing a
    1025         // redirect, so that we don't do one of our own
     1024        // redirect, so that we don't do one of our own.
    10261025        add_filter( 'wp_redirect', array( $this, 'detect_post_save_redirect' ) );
    10271026
    1028         // Call the extension's save routine
     1027        // Call the extension's save routine.
    10291028        call_user_func( $this->screens['edit']['screen_save_callback'], $this->group_id );
    10301029
    1031         // Clean up detection filters
     1030        // Clean up detection filters.
    10321031        remove_filter( 'wp_redirect', array( $this, 'detect_post_save_redirect' ) );
    10331032
    1034         // Perform a redirect only if one has not already taken place
     1033        // Perform a redirect only if one has not already taken place.
    10351034        if ( empty( $this->post_save_redirect ) ) {
    10361035
     
    10821081     * @param string $screen The screen markup, captured in the output
    10831082     *                       buffer.
    1084      *
    10851083     * @return string $screen The same markup, with a submit button added.
    10861084     */
     
    11041102     *
    11051103     * @param string $screen The markup to check.
    1106      *
    11071104     * @return bool True if a Submit button is found, otherwise false.
    11081105     */
     
    11181115     * @since 2.1.0
    11191116     *
    1120      * @param string $redirect
    1121      *
     1117     * @param string $redirect Redirect string.
    11221118     * @return string
    11231119     */
     
    11421138        }
    11431139
    1144         // Hook the admin screen markup function to the content hook
     1140        // Hook the admin screen markup function to the content hook.
    11451141        add_action( 'bp_groups_admin_meta_box_content_' . $this->slug, array( $this, 'call_admin_screen' ) );
    11461142
    1147         // Initialize the metabox
     1143        // Initialize the metabox.
    11481144        add_action( 'bp_groups_admin_meta_boxes', array( $this, '_meta_box_display_callback' ) );
    11491145
    1150         // Catch the metabox save
     1146        // Catch the metabox save.
    11511147        add_action( 'bp_group_admin_edit_after', array( $this, 'call_admin_screen_save' ), 10 );
    11521148    }
     
    12321228     *
    12331229     * @param string $context Screen context. 'create', 'edit', or 'admin'.
    1234      *
    12351230     * @return bool True if the screen is enabled, otherwise false.
    12361231     */
     
    12821277     * @param string $type    Screen type. 'screen' or 'screen_save'. Default:
    12831278     *                        'screen'.
    1284      *
    12851279     * @return callable A callable function handle.
    12861280     */
     
    12881282        $callback = '';
    12891283
    1290         // Try the context-specific callback first
     1284        // Try the context-specific callback first.
    12911285        $method  = $context . '_' . $type;
    12921286        $rmethod = $this->class_reflection->getMethod( $method );
     
    13321326     * @param array $a First set of arguments.
    13331327     * @param array $b Second set of arguments.
    1334      *
    13351328     * @return array Parsed arguments.
    13361329     */
     
    13761369     *
    13771370     * @param string $key Property name.
    1378      *
    13791371     * @return mixed The value if found, otherwise null.
    13801372     */
     
    14011393     *
    14021394     * @param string $key Property name.
    1403      *
    14041395     * @return bool True if the value is set, otherwise false.
    14051396     */
     
    14251416     *
    14261417     * @param string $key Property name.
    1427      * @param mixed $value Property value.
     1418     * @param mixed  $value Property value.
    14281419     */
    14291420    public function __set( $key, $value ) {
     
    14501441                break;
    14511442
    1452             // Note: 'admin' becomes 'edit' to distinguish from Dashboard 'admin'
     1443            // Note: 'admin' becomes 'edit' to distinguish from Dashboard 'admin'.
    14531444            case 'admin_name' :
    14541445                $this->screens['edit']['name'] = $value;
     
    15271518    protected function parse_legacy_properties() {
    15281519
    1529         // Only run this one time
     1520        // Only run this one time.
    15301521        if ( ! empty( $this->legacy_properties_converted ) ) {
    15311522            return;
     
    15341525        $properties = $this->get_legacy_property_list();
    15351526
    1536         // By-reference variable for convenience
     1527        // By-reference variable for convenience.
    15371528        $lpc =& $this->legacy_properties_converted;
    15381529
    15391530        foreach ( $properties as $property ) {
    15401531
    1541             // No legacy config exists for this key
     1532            // No legacy config exists for this key.
    15421533            if ( ! isset( $this->{$property} ) ) {
    15431534                continue;
    15441535            }
    15451536
    1546             // Grab the value and record it as appropriate
     1537            // Grab the value and record it as appropriate.
    15471538            $value = $this->{$property};
    15481539
     
    15641555                    break;
    15651556
    1566                 // Note: 'admin' becomes 'edit' to distinguish from Dashboard 'admin'
     1557                // Note: 'admin' becomes 'edit' to distinguish from Dashboard 'admin'.
    15671558                case 'admin_name' :
    15681559                    $lpc['screens']['edit']['name'] = $value;
     
    16101601    protected function setup_legacy_properties() {
    16111602
    1612         // Only run this one time
     1603        // Only run this one time.
    16131604        if ( ! empty( $this->legacy_properties ) ) {
    16141605            return;
     
    16371628                    break;
    16381629
    1639                 // Note: 'admin' becomes 'edit' to distinguish from Dashboard 'admin'
     1630                // Note: 'admin' becomes 'edit' to distinguish from Dashboard 'admin'.
    16401631                case 'admin_name' :
    16411632                    $lp['admin_name'] = $params['screens']['edit']['name'];
     
    16631654
    16641655                default :
    1665                     // All other items get moved over
     1656                    // All other items get moved over.
    16661657                    $lp[ $property ] = $params[ $property ];
    16671658
    1668                     // Also reapply to the object, for backpat
     1659                    // Also reapply to the object, for backpat.
    16691660                    $this->{$property} = $params[ $property ];
    16701661
     
    16781669 * Register a new Group Extension.
    16791670 *
    1680  * @param string Name of the Extension class.
     1671 * @param string $group_extension_class Name of the Extension class.
    16811672 * @return false|null Returns false on failure, otherwise null.
    16821673 */
  • trunk/src/bp-groups/classes/class-bp-group-member-query.php

    r10248 r10373  
    5858        // Take this early opportunity to set the default 'type' param
    5959        // to 'last_joined', which will ensure that BP_User_Query
    60         // trusts our order and does not try to apply its own
     60        // trusts our order and does not try to apply its own.
    6161        if ( empty( $this->query_vars_raw['type'] ) ) {
    6262            $this->query_vars_raw['type'] = 'last_joined';
    6363        }
    6464
    65         // Set the sort order
     65        // Set the sort order.
    6666        add_action( 'bp_pre_user_query', array( $this, 'set_orderby' ) );
    6767
    68         // Set up our populate_extras method
     68        // Set up our populate_extras method.
    6969        add_action( 'bp_user_query_populate_extras', array( $this, 'populate_group_member_extras' ), 10, 2 );
    7070    }
     
    100100
    101101        // If the group member query returned no users, bail with an
    102         // array that will guarantee no matches for BP_User_Query
     102        // array that will guarantee no matches for BP_User_Query.
    103103        if ( empty( $group_member_ids ) ) {
    104104            return array( 0 );
     
    134134        );
    135135
    136         /** WHERE clauses *****************************************************/
    137 
    138         // Group id
     136        /* WHERE clauses *****************************************************/
     137
     138        // Group id.
    139139        $sql['where'][] = $wpdb->prepare( "group_id = %d", $this->query_vars['group_id'] );
    140140
    141         // is_confirmed
     141        // If is_confirmed.
    142142        $is_confirmed = ! empty( $this->query_vars['is_confirmed'] ) ? 1 : 0;
    143143        $sql['where'][] = $wpdb->prepare( "is_confirmed = %d", $is_confirmed );
    144144
    145         // invite_sent
     145        // If invite_sent.
    146146        if ( ! is_null( $this->query_vars['invite_sent'] ) ) {
    147147            $invite_sent = ! empty( $this->query_vars['invite_sent'] ) ? 1 : 0;
     
    149149        }
    150150
    151         // inviter_id
     151        // If inviter_id.
    152152        if ( ! is_null( $this->query_vars['inviter_id'] ) ) {
    153153            $inviter_id = $this->query_vars['inviter_id'];
    154154
    155             // Empty: inviter_id = 0. (pass false, 0, or empty array)
     155            // Empty: inviter_id = 0. (pass false, 0, or empty array).
    156156            if ( empty( $inviter_id ) ) {
    157157                $sql['where'][] = "inviter_id = 0";
    158158
    159             // The string 'any' matches any non-zero value (inviter_id != 0)
     159            // The string 'any' matches any non-zero value (inviter_id != 0).
    160160            } elseif ( 'any' === $inviter_id ) {
    161161                $sql['where'][] = "inviter_id != 0";
    162162
    163             // Assume that a list of inviter IDs has been passed
     163            // Assume that a list of inviter IDs has been passed.
    164164            } else {
    165                 // Parse and sanitize
     165                // Parse and sanitize.
    166166                $inviter_ids = wp_parse_id_list( $inviter_id );
    167167                if ( ! empty( $inviter_ids ) ) {
     
    180180        }
    181181
    182         // Sanitize: Only 'admin', 'mod', 'member', and 'banned' are valid
     182        // Sanitize: Only 'admin', 'mod', 'member', and 'banned' are valid.
    183183        $allowed_roles = array( 'admin', 'mod', 'member', 'banned' );
    184184        foreach ( $roles as $role_key => $role_value ) {
     
    192192        // When querying for a set of roles containing 'member' (for
    193193        // which there is no dedicated is_ column), figure out a list
    194         // of columns *not* to match
     194        // of columns *not* to match.
    195195        $roles_sql = '';
    196196        if ( in_array( 'member', $roles ) ) {
     
    205205
    206206        // When querying for a set of roles *not* containing 'member',
    207         // simply construct a list of is_* = 1 clauses
     207        // simply construct a list of is_* = 1 clauses.
    208208        } else {
    209209            $role_columns = array();
     
    226226        // of 'type'. If the 'type' value is not 'last_joined' or
    227227        // 'first_joined', the order will be overridden in
    228         // BP_Group_Member_Query::set_orderby()
     228        // BP_Group_Member_Query::set_orderby().
    229229        $sql['orderby'] = "ORDER BY date_modified";
    230230        $sql['order']   = 'first_joined' === $this->query_vars['type'] ? 'ASC' : 'DESC';
     
    272272        if ( in_array( $query->query_vars['type'], array( 'last_joined', 'first_joined', 'group_activity' ) ) ) {
    273273
    274             // Group Activity DESC
     274            // Group Activity DESC.
    275275            if ( 'group_activity' == $query->query_vars['type'] ) {
    276276                $gm_ids = $this->get_gm_ids_ordered_by_activity( $query, $gm_ids );
    277277            }
    278278
    279             // The first param in the FIELD() clause is the sort column id
     279            // The first param in the FIELD() clause is the sort column id.
    280280            $gm_ids = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) );
    281281            $gm_ids_sql = implode( ',', $gm_ids );
     
    285285
    286286        // Prevent this filter from running on future BP_User_Query
    287         // instances on the same page
     287        // instances on the same page.
    288288        remove_action( 'bp_pre_user_query', array( $this, 'set_orderby' ) );
    289289    }
     
    293293     *
    294294     * Additional data fetched:
    295      *
    296295     *      - is_banned
    297296     *      - date_modified
     
    313312        foreach ( (array) $extras as $extra ) {
    314313            if ( isset( $this->results[ $extra->user_id ] ) ) {
    315                 // user_id is provided for backward compatibility
     314                // The user_id is provided for backward compatibility.
    316315                $this->results[ $extra->user_id ]->user_id       = (int) $extra->user_id;
    317316                $this->results[ $extra->user_id ]->is_admin      = (int) $extra->is_admin;
     
    328327        }
    329328
    330         // Don't filter other BP_User_Query objects on the same page
     329        // Don't filter other BP_User_Query objects on the same page.
    331330        remove_action( 'bp_user_query_populate_extras', array( $this, 'populate_group_member_extras' ), 10, 2 );
    332331    }
     
    339338     * @param BP_User_Query $query  BP_User_Query object.
    340339     * @param array         $gm_ids array of group member ids.
    341      *
    342340     * @return array
    343341     */
  • trunk/src/bp-groups/classes/class-bp-groups-group.php

    r10248 r10373  
    145145     * Constructor method.
    146146     *
    147      * @param int|null $id Optional. If the ID of an existing group is provided,
    148      *                     the object will be pre-popu