Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/09/2014 10:59:31 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Bracketize users component.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/users/functions.php

    r5369 r5436  
    2828
    2929        // Raw redirect_to was passed, so use it
    30         if ( !empty( $raw_url ) )
     30        if ( !empty( $raw_url ) ) {
    3131                $url = $raw_url;
    3232
    3333        // $url was manually set in wp-login.php to redirect to admin
    34         elseif ( admin_url() === $url )
     34        } elseif ( admin_url() === $url ) {
    3535                $url = home_url();
    3636
    3737        // $url is empty
    38         elseif ( empty( $url ) )
     38        } elseif ( empty( $url ) ) {
    3939                $url = home_url();
     40        }
    4041
    4142        return apply_filters( 'bbp_redirect_login', $url, $raw_url, $user );
     
    5455 */
    5556function bbp_is_anonymous() {
    56         if ( !is_user_logged_in() && bbp_allow_anonymous() )
     57        if ( !is_user_logged_in() && bbp_allow_anonymous() ) {
    5758                $is_anonymous = true;
    58         else
     59        } else {
    5960                $is_anonymous = false;
     61        }
    6062
    6163        return apply_filters( 'bbp_is_anonymous', $is_anonymous );
     
    102104                $bbp_current_poster = wp_get_current_commenter();
    103105
    104                 if ( !empty( $key ) && in_array( $key, array_keys( $cookie_names ) ) )
     106                if ( !empty( $key ) && in_array( $key, array_keys( $cookie_names ) ) ) {
    105107                        return $bbp_current_poster[$cookie_names[$key]];
     108                }
    106109
    107110                return $bbp_current_poster;
     
    122125 */
    123126function bbp_set_current_anonymous_user_data( $anonymous_data = array() ) {
    124         if ( empty( $anonymous_data ) || !is_array( $anonymous_data ) )
    125                 return;
     127        if ( empty( $anonymous_data ) || !is_array( $anonymous_data ) ) {
     128                return;
     129        }
    126130
    127131        $comment_cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
     
    173177function bbp_get_topic_favoriters( $topic_id = 0 ) {
    174178        $topic_id = bbp_get_topic_id( $topic_id );
    175         if ( empty( $topic_id ) )
    176                 return;
     179        if ( empty( $topic_id ) ) {
     180                return;
     181        }
    177182
    178183        global $wpdb;
     
    202207function bbp_get_user_favorites( $user_id = 0 ) {
    203208        $user_id = bbp_get_user_id( $user_id );
    204         if ( empty( $user_id ) )
    205                 return false;
     209        if ( empty( $user_id ) ) {
     210                return false;
     211        }
    206212
    207213        // If user has favorites, load them
     
    230236function bbp_get_user_favorites_topic_ids( $user_id = 0 ) {
    231237        $user_id = bbp_get_user_id( $user_id );
    232         if ( empty( $user_id ) )
    233                 return false;
     238        if ( empty( $user_id ) ) {
     239                return false;
     240        }
    234241
    235242        $favorites = get_user_option( '_bbp_favorites', $user_id );
     
    257264
    258265        $user_id = bbp_get_user_id( $user_id, true, true );
    259         if ( empty( $user_id ) )
    260                 return false;
     266        if ( empty( $user_id ) ) {
     267                return false;
     268        }
    261269
    262270        $retval    = false;
     
    301309 */
    302310function bbp_add_user_favorite( $user_id = 0, $topic_id = 0 ) {
    303         if ( empty( $user_id ) || empty( $topic_id ) )
    304                 return false;
     311        if ( empty( $user_id ) || empty( $topic_id ) ) {
     312                return false;
     313        }
    305314
    306315        $topic = bbp_get_topic( $topic_id );
    307         if ( empty( $topic ) )
    308                 return false;
     316        if ( empty( $topic ) ) {
     317                return false;
     318        }
    309319
    310320        $favorites = bbp_get_user_favorites_topic_ids( $user_id );
     
    335345 */
    336346function bbp_remove_user_favorite( $user_id, $topic_id ) {
    337         if ( empty( $user_id ) || empty( $topic_id ) )
    338                 return false;
     347        if ( empty( $user_id ) || empty( $topic_id ) ) {
     348                return false;
     349        }
    339350
    340351        $favorites = (array) bbp_get_user_favorites_topic_ids( $user_id );
    341         if ( empty( $favorites ) )
    342                 return false;
     352        if ( empty( $favorites ) ) {
     353                return false;
     354        }
    343355
    344356        $pos = array_search( $topic_id, $favorites );
     
    380392function bbp_favorites_handler( $action = '' ) {
    381393
    382         if ( !bbp_is_favorites_active() )
    383                 return false;
     394        if ( !bbp_is_favorites_active() ) {
     395                return false;
     396        }
    384397
    385398        // Bail if no topic ID is passed
    386         if ( empty( $_GET['topic_id'] ) )
    387                 return;
     399        if ( empty( $_GET['topic_id'] ) ) {
     400                return;
     401        }
    388402
    389403        // Setup possible get actions
     
    394408
    395409        // Bail if actions aren't meant for this function
    396         if ( !in_array( $action, $possible_actions ) )
    397                 return;
     410        if ( !in_array( $action, $possible_actions ) ) {
     411                return;
     412        }
    398413
    399414        // What action is taking place?
     
    415430
    416431        // Bail if errors
    417         if ( bbp_has_errors() )
    418                 return;
     432        if ( bbp_has_errors() ) {
     433                return;
     434        }
    419435
    420436        /** No errors *************************************************************/
     
    423439        $success     = false;
    424440
    425         if ( true === $is_favorite && 'bbp_favorite_remove' === $action )
     441        if ( true === $is_favorite && 'bbp_favorite_remove' === $action ) {
    426442                $success = bbp_remove_user_favorite( $user_id, $topic_id );
    427         elseif ( false === $is_favorite && 'bbp_favorite_add' === $action )
     443        } elseif ( false === $is_favorite && 'bbp_favorite_add' === $action ) {
    428444                $success = bbp_add_user_favorite( $user_id, $topic_id );
     445        }
    429446
    430447        // Do additional favorites actions
     
    474491function bbp_get_forum_subscribers( $forum_id = 0 ) {
    475492        $forum_id = bbp_get_forum_id( $forum_id );
    476         if ( empty( $forum_id ) )
    477                 return;
     493        if ( empty( $forum_id ) ) {
     494                return;
     495        }
    478496
    479497        global $wpdb;
     
    501519function bbp_get_topic_subscribers( $topic_id = 0 ) {
    502520        $topic_id = bbp_get_topic_id( $topic_id );
    503         if ( empty( $topic_id ) )
    504                 return;
     521        if ( empty( $topic_id ) ) {
     522                return;
     523        }
    505524
    506525        global $wpdb;
     
    609628function bbp_get_user_subscribed_forum_ids( $user_id = 0 ) {
    610629        $user_id = bbp_get_user_id( $user_id );
    611         if ( empty( $user_id ) )
    612                 return false;
     630        if ( empty( $user_id ) ) {
     631                return false;
     632        }
    613633
    614634        $subscriptions = get_user_option( '_bbp_forum_subscriptions', $user_id );
     
    632652function bbp_get_user_subscribed_topic_ids( $user_id = 0 ) {
    633653        $user_id = bbp_get_user_id( $user_id );
    634         if ( empty( $user_id ) )
    635                 return false;
     654        if ( empty( $user_id ) ) {
     655                return false;
     656        }
    636657
    637658        $subscriptions = get_user_option( '_bbp_subscriptions', $user_id );
     
    13171338
    13181339        // Bail if action is not 'bbp-update-user'
    1319         if ( 'bbp-update-user' !== $action )
    1320                 return;
     1340        if ( 'bbp-update-user' !== $action ) {
     1341                return;
     1342        }
    13211343
    13221344        // Get the displayed user ID
     
    14321454        // Validate user
    14331455        $user_id = bbp_get_user_id( $user_id );
    1434         if ( empty( $user_id ) )
    1435                 return false;
     1456        if ( empty( $user_id ) ) {
     1457                return false;
     1458        }
    14361459
    14371460        // Try to get the topics
     
    14571480        // Validate user
    14581481        $user_id = bbp_get_user_id( $user_id );
    1459         if ( empty( $user_id ) )
    1460                 return false;
     1482        if ( empty( $user_id ) ) {
     1483                return false;
     1484        }
    14611485
    14621486        // Try to get the topics
     
    16791703
    16801704        // Bail if not editing a topic
    1681         if ( ! bbp_is_single_user_edit() )
    1682                 return;
     1705        if ( ! bbp_is_single_user_edit() ) {
     1706                return;
     1707        }
    16831708
    16841709        // Default to false
     
    18101835        // Bail if no username
    18111836        $username = !empty( $_POST['log'] ) ? $_POST['log'] : '';
    1812         if ( empty( $username ) )
    1813                 return;
     1837        if ( empty( $username ) ) {
     1838                return;
     1839        }
    18141840
    18151841        global $wpdb;
     
    18171843        // Bail if no user password to convert
    18181844        $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} INNER JOIN {$wpdb->usermeta} ON user_id = ID WHERE meta_key = '_bbp_class' AND user_login = '%s' LIMIT 1", $username ) );
    1819         if ( empty( $row ) || is_wp_error( $row ) )
    1820                 return;
     1845        if ( empty( $row ) || is_wp_error( $row ) ) {
     1846                return;
     1847        }
    18211848
    18221849        // Setup admin (to include converter)
Note: See TracChangeset for help on using the changeset viewer.