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