Skip to:
Content

BuddyPress.org

Changeset 9373


Ignore:
Timestamp:
01/19/2015 08:11:55 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Coding standards improvements to BP_Activity_Activity::save(). See #5138, #5891.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-classes.php

    r9372 r9373  
    193193     */
    194194    public function save() {
    195         global $wpdb, $bp;
     195        global $wpdb;
     196
     197        $bp = buddypress();
    196198
    197199        $this->id                = apply_filters_ref_array( 'bp_activity_id_before_save',                array( $this->id,                &$this ) );
     
    221223        do_action_ref_array( 'bp_activity_before_save', array( &$this ) );
    222224
    223         if ( !$this->component || !$this->type )
     225        if ( empty( $this->component ) || empty( $this->type ) ) {
    224226            return false;
    225 
    226         if ( !$this->primary_link )
     227        }
     228
     229        if ( empty( $this->primary_link ) ) {
    227230            $this->primary_link = bp_loggedin_user_domain();
     231        }
    228232
    229233        // If we have an existing ID, update the activity item, otherwise insert it.
    230         if ( $this->id )
     234        if ( ! empty( $this->id ) ) {
    231235            $q = $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component = %s, type = %s, action = %s, content = %s, primary_link = %s, date_recorded = %s, item_id = %d, secondary_item_id = %d, hide_sitewide = %d, is_spam = %d WHERE id = %d", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam, $this->id );
    232         else
     236        } else {
    233237            $q = $wpdb->prepare( "INSERT INTO {$bp->activity->table_name} ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( %d, %s, %s, %s, %s, %s, %s, %d, %d, %d, %d )", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam );
    234 
    235         if ( false === $wpdb->query( $q ) )
     238        }
     239
     240        if ( false === $wpdb->query( $q ) ) {
    236241            return false;
     242        }
    237243
    238244        // If this is a new activity item, set the $id property
    239         if ( empty( $this->id ) )
     245        if ( empty( $this->id ) ) {
    240246            $this->id = $wpdb->insert_id;
    241247
    242248        // If an existing activity item, prevent any changes to the content generating new @mention notifications.
    243         else
     249        } else {
    244250            add_filter( 'bp_activity_at_name_do_notifications', '__return_false' );
     251        }
    245252
    246253        /**
Note: See TracChangeset for help on using the changeset viewer.