Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/10/2012 01:17:51 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Remove unneeded globals and clean up some code in Groups component. See #3989.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-classes.php

    r5687 r5689  
    5959            $admin_mods = $wpdb->get_results( apply_filters( 'bp_group_admin_mods_user_join_filter', $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_email, u.user_nicename, m.is_admin, m.is_mod FROM {$wpdb->users} u, {$bp->groups->table_name_members} m WHERE u.ID = m.user_id AND m.group_id = %d AND ( m.is_admin = 1 OR m.is_mod = 1 )", $this->id ) ) );
    6060            foreach( (array)$admin_mods as $user ) {
    61                 if ( (int)$user->is_admin )
     61                if ( (int) $user->is_admin )
    6262                    $this->admins[] = $user;
    6363                else
     
    191191        global $wpdb, $bp;
    192192
    193         if ( !$user_id )
     193        if ( empty( $user_id ) )
    194194            $user_id = bp_displayed_user_id();
    195195
     
    796796
    797797    function ban() {
    798         global $bp;
    799798
    800799        if ( $this->is_admin )
     
    808807        $group_count = bp_get_user_meta( $this->user_id, 'total_group_count', true );
    809808        if ( !empty( $group_count ) )
    810             bp_update_user_meta( $this->user_id, 'total_group_count', (int)$group_count - 1 );
     809            bp_update_user_meta( $this->user_id, 'total_group_count', (int) $group_count - 1 );
    811810
    812811        return $this->save();
     
    814813
    815814    function unban() {
    816         global $bp;
    817815
    818816        if ( $this->is_admin )
     
    822820
    823821        groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) + 1 ) );
    824         bp_update_user_meta( $this->user_id, 'total_group_count', (int)bp_get_user_meta( $this->user_id, 'total_group_count', true ) + 1 );
     822        bp_update_user_meta( $this->user_id, 'total_group_count', (int) bp_get_user_meta( $this->user_id, 'total_group_count', true ) + 1 );
    825823
    826824        return $this->save();
     
    828826
    829827    function accept_invite() {
    830         global $bp;
    831828
    832829        $this->inviter_id    = 0;
     
    834831        $this->date_modified = bp_core_current_time();
    835832
    836         bp_update_user_meta( $this->user_id, 'total_group_count', (int)bp_get_user_meta( $this->user_id, 'total_group_count', true ) + 1 );
     833        bp_update_user_meta( $this->user_id, 'total_group_count', (int) bp_get_user_meta( $this->user_id, 'total_group_count', true ) + 1 );
    837834    }
    838835
    839836    function accept_request() {
    840         global $bp;
    841837
    842838        $this->is_confirmed = 1;
    843839        $this->date_modified = bp_core_current_time();
    844840
    845         bp_update_user_meta( $this->user_id, 'total_group_count', (int)bp_get_user_meta( $this->user_id, 'total_group_count', true ) + 1 );
     841        bp_update_user_meta( $this->user_id, 'total_group_count', (int) bp_get_user_meta( $this->user_id, 'total_group_count', true ) + 1 );
    846842    }
    847843
     
    858854        $group_count = bp_get_user_meta( $this->user_id, 'total_group_count', true );
    859855        if ( !empty( $group_count ) )
    860             bp_update_user_meta( $this->user_id, 'total_group_count', (int)$group_count - 1 );
     856            bp_update_user_meta( $this->user_id, 'total_group_count', (int) $group_count - 1 );
    861857
    862858        return $result;
     
    961957        global $bp, $wpdb;
    962958
    963         if ( !$user_id )
     959        if ( empty( $user_id ) )
    964960            $user_id = bp_displayed_user_id();
    965961
     
    987983        global $wpdb, $bp;
    988984
    989         if ( !$user_id )
     985        if ( empty( $user_id ) )
    990986            return false;
    991987
     
    1001997        global $wpdb, $bp;
    1002998
    1003         if ( !$user_id )
     999        if ( empty( $user_id ) )
    10041000            return false;
    10051001
     
    10101006        global $wpdb, $bp;
    10111007
    1012         if ( !$user_id )
     1008        if ( empty( $user_id ) )
    10131009            return false;
    10141010
     
    10191015        global $wpdb, $bp;
    10201016
    1021         if ( !$user_id )
     1017        if ( empty( $user_id ) )
    10221018            return false;
    10231019
     
    10281024        global $wpdb, $bp;
    10291025
    1030         if ( !$user_id )
     1026        if ( empty( $user_id ) )
    10311027            return false;
    10321028
     
    10371033        global $wpdb, $bp;
    10381034
    1039         if ( !$user_id )
     1035        if ( empty( $user_id ) )
    10401036            return false;
    10411037
     
    10461042        global $wpdb, $bp;
    10471043
    1048         if ( !$user_id )
     1044        if ( empty( $user_id ) )
    10491045            return false;
    10501046
     
    10641060        global $bp, $wpdb;
    10651061
    1066         if ( !$user_id )
     1062        if ( empty( $user_id ) )
    10671063            return false;
    10681064
     
    10731069        global $wpdb, $bp;
    10741070
    1075         if ( !$user_id )
     1071        if ( empty( $user_id ) )
    10761072            return false;
    10771073
     
    13361332        return false;
    13371333
    1338     /* Register the group extension on the bp_init action so we have access to all plugins */
     1334    // Register the group extension on the bp_init action so we have access
     1335    // to all plugins.
    13391336    add_action( 'bp_init', create_function( '', '$extension = new ' . $group_extension_class . '; add_action( "bp_actions", array( &$extension, "_register" ), 8 );' ), 11 );
    13401337}
Note: See TracChangeset for help on using the changeset viewer.