Skip to:
Content

BuddyPress.org


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

More docs cleanup for BP-Groups component.

See #6401.

File:
1 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',
Note: See TracChangeset for help on using the changeset viewer.