Skip to:
Content

BuddyPress.org

Changeset 1351


Ignore:
Timestamp:
04/19/2009 12:21:53 PM (17 years ago)
Author:
apeatling
Message:

Added value filters and before and after actions to all save() methods.

Location:
trunk
Files:
11 edited

Legend:

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

    r1338 r1351  
    4545    function save() {
    4646        global $wpdb, $bp, $current_user;
     47       
     48        do_action( 'bp_activity_before_save', $this );
    4749
    4850        if ( !$this->item_id || !$this->user_id || $this->is_private || !$this->component_name )
     
    7072                $sitewide_cached = $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->activity->table_name_sitewide} ( user_id, item_id, secondary_item_id, content, primary_link, component_name, component_action, date_cached, date_recorded ) VALUES ( %d, %d, %d, %s, %s, %s, %s, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d) )", $this->user_id, $this->item_id, $this->secondary_item_id, $activity_content['content'], $activity_content['primary_link'], $this->component_name, $this->component_action, time(), $this->date_recorded ) );
    7173           
    72             if ( $activity && $activity_cached )
     74            if ( $activity && $activity_cached ) {
     75                do_action( 'bp_activity_after_save', $this );
    7376                return true;
     77            }
    7478           
    7579            return false;
  • trunk/bp-blogs/bp-blogs-classes.php

    r1250 r1351  
    2929    function save() {
    3030        global $wpdb, $bp;
     31       
     32        $this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
     33        $this->blog_ud = apply_filters( 'bp_blogs_blog_id_before_save', $this->blog_id, $this->id );
     34       
     35        do_action( 'bp_blogs_blog_before_save', $this );
    3136       
    3237        // Don't try and save if there is no user ID or blog ID set.
     
    4853        if ( !$wpdb->query($sql) )
    4954            return false;
     55           
     56        do_action( 'bp_blogs_blog_after_save', $this );
    5057       
    5158        if ( $this->id )
     
    301308        global $wpdb, $bp;
    302309       
     310        $this->post_id = apply_filters( 'bp_blogs_post_id_before_save', $this->post_id, $this->id );
     311        $this->blog_id = apply_filters( 'bp_blogs_post_blog_id_before_save', $this->blog_id, $this->id );
     312        $this->user_id = apply_filters( 'bp_blogs_post_user_id_before_save', $this->user_id, $this->id );
     313        $this->date_created = apply_filters( 'bp_blogs_post_date_created_before_save', $this->date_created, $this->id );
     314
     315        do_action( 'bp_blogs_post_before_save', $this );
     316
    303317        if ( $this->id ) {
    304318            // Update
     
    311325        if ( !$wpdb->query($sql) )
    312326            return false;
     327
     328        do_action( 'bp_blogs_post_after_save', $this );
    313329       
    314330        if ( $this->id )
     
    496512    function save() {
    497513        global $wpdb, $bp;
     514
     515        $this->comment_id = apply_filters( 'bp_blogs_comment_id_before_save', $this->comment_id, $this->id );
     516        $this->comment_post_id = apply_filters( 'bp_blogs_comment_post_id_before_save', $this->comment_post_id, $this->id );
     517        $this->blog_id = apply_filters( 'bp_blogs_comment_blog_id_before_save', $this->blog_id, $this->id );
     518        $this->user_id = apply_filters( 'bp_blogs_comment_user_id_before_save', $this->user_id, $this->id );
     519        $this->date_created = apply_filters( 'bp_blogs_comment_date_created_before_save', $this->date_created, $this->id );
     520
     521        do_action( 'bp_blogs_comment_before_save', $this );
    498522       
    499523        if ( $this->id ) {
     
    507531        if ( !$wpdb->query($sql) )
    508532            return false;
     533           
     534        do_action( 'bp_blogs_comment_after_save', $this );
    509535       
    510536        if ( $this->id )
  • trunk/bp-core/bp-core-adminbar.php

    r1318 r1351  
    3535
    3636    if ( !is_user_logged_in() ) {   
    37         echo '<li class="bp-login no-arrow"><a href="' . get_bloginfo('siteurl') . '/wp-login.php?redirect_to=' . urlencode( $bp->root_domain ) . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
     37        echo '<li class="bp-login no-arrow"><a href="' . $bp->root_domain . '/wp-login.php?redirect_to=' . urlencode( $bp->root_domain ) . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
    3838       
    3939        // Show "Sign Up" link if registrations are allowed
  • trunk/bp-friends/bp-friends-classes.php

    r1052 r1351  
    5050    function save() {
    5151        global $wpdb, $bp;
     52
     53        $this->initiator_user_id = apply_filters( 'friends_friendship_initiator_user_id_before_save', $this->initiator_user_id, $this->id );
     54        $this->friend_user_id = apply_filters( 'friends_friendship_friend_user_id_before_save', $this->friend_user_id, $this->id );
     55        $this->is_confirmed = apply_filters( 'friends_friendship_is_confirmed_before_save', $this->is_confirmed, $this->id );
     56        $this->is_limited = apply_filters( 'friends_friendship_is_limited_before_save', $this->is_limited, $this->id );
     57        $this->date_created = apply_filters( 'friends_friendship_date_created_before_save', $this->date_created, $this->id );
     58
     59        do_action( 'friends_friendship_before_save', $this );       
    5260       
    5361        if ( $this->id ) {
     
    5967            $this->id = $wpdb->insert_id;
    6068        }
     69
     70        do_action( 'friends_friendship_after_save', $this );       
    6171       
    6272        return $result;
  • trunk/bp-groups/bp-groups-classes.php

    r1348 r1351  
    9191        global $wpdb, $bp;
    9292       
    93         $this->creator_id = apply_filters( 'groups_details_creator_id_pre_save', $this->creator_id, $this->id );
    94         $this->name = apply_filters( 'groups_details_name_pre_save', $this->name, $this->id );
    95         $this->slug = apply_filters( 'groups_details_slug_pre_save', $this->slug, $this->id );
    96         $this->description = apply_filters( 'groups_details_description_pre_save', $this->description, $this->id );
    97         $this->news = apply_filters( 'groups_details_news_pre_save', $this->news, $this->id );
    98         $this->status = apply_filters( 'groups_details_status_pre_save', $this->status, $this->id );
    99         $this->is_invitation_only = apply_filters( 'groups_details_is_invitation_only_pre_save', $this->is_invitation_only, $this->id );
    100         $this->enable_wire = apply_filters( 'groups_details_enable_wire_pre_save', $this->enable_wire, $this->id );
    101         $this->enable_forum = apply_filters( 'groups_details_enable_forum_pre_save', $this->enable_forum, $this->id );
    102         $this->enable_photos = apply_filters( 'groups_details_enable_photos_pre_save', $this->enable_photos, $this->id );
    103         $this->photos_admin_only = apply_filters( 'groups_details_photos_admin_only_pre_save', $this->photos_admin_only, $this->id );
    104         $this->date_created = apply_filters( 'groups_details_date_created_pre_save', $this->date_created, $this->id );
    105         $this->avatar_thumb = apply_filters( 'groups_details_avatar_thumb_pre_save', $this->avatar_thumb, $this->id );
    106         $this->avatar_full = apply_filters( 'groups_details_avatar_full_pre_save', $this->avatar_full, $this->id );
    107 
    108         do_action( 'groups_group_pre_save', $this );
     93        $this->creator_id = apply_filters( 'groups_group_creator_id_before_save', $this->creator_id, $this->id );
     94        $this->name = apply_filters( 'groups_group_name_before_save', $this->name, $this->id );
     95        $this->slug = apply_filters( 'groups_group_slug_before_save', $this->slug, $this->id );
     96        $this->description = apply_filters( 'groups_group_description_before_save', $this->description, $this->id );
     97        $this->news = apply_filters( 'groups_group_news_before_save', $this->news, $this->id );
     98        $this->status = apply_filters( 'groups_group_status_before_save', $this->status, $this->id );
     99        $this->is_invitation_only = apply_filters( 'groups_group_is_invitation_only_before_save', $this->is_invitation_only, $this->id );
     100        $this->enable_wire = apply_filters( 'groups_group_enable_wire_before_save', $this->enable_wire, $this->id );
     101        $this->enable_forum = apply_filters( 'groups_group_enable_forum_before_save', $this->enable_forum, $this->id );
     102        $this->enable_photos = apply_filters( 'groups_group_enable_photos_before_save', $this->enable_photos, $this->id );
     103        $this->photos_admin_only = apply_filters( 'groups_group_photos_admin_only_before_save', $this->photos_admin_only, $this->id );
     104        $this->date_created = apply_filters( 'groups_group_date_created_before_save', $this->date_created, $this->id );
     105        $this->avatar_thumb = apply_filters( 'groups_group_avatar_thumb_before_save', $this->avatar_thumb, $this->id );
     106        $this->avatar_full = apply_filters( 'groups_group_avatar_full_before_save', $this->avatar_full, $this->id );
     107
     108        do_action( 'groups_group_before_save', $this );
    109109       
    110110        if ( $this->id ) {
     
    188188        }
    189189
    190         do_action( 'groups_group_post_save', $this );
     190        do_action( 'groups_group_after_save', $this );
    191191       
    192192        return true;
  • trunk/bp-messages/bp-messages-classes.php

    r1280 r1351  
    334334    function send() {   
    335335        global $wpdb, $bp;
    336 
    337         $this->subject = wp_filter_kses( $this->subject );
    338         $this->message = wp_filter_kses( $this->message );
    339 
     336       
     337        $this->sender_id = apply_filters( 'messages_message_sender_id_before_save', $this->sender_id, $this->id );
     338        $this->subject = apply_filters( 'messages_message_subject_before_save', $this->subject, $this->id );
     339        $this->message = apply_filters( 'messages_message_content_before_save', $this->message, $this->id );
     340        $this->date_sent = apply_filters( 'messages_message_date_sent_before_save', $this->date_sent, $this->id );
     341        $this->message_order = apply_filters( 'messages_message_order_before_save', $this->message_order, $this->id );
     342        $this->sender_is_group = apply_filters( 'messages_message_sender_is_group_before_save', $this->sender_is_group, $this->id );
     343
     344        do_action( 'messages_message_before_save', $this );
     345       
    340346        // First insert the message into the messages table
    341347        if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( sender_id, subject, message, date_sent, message_order, sender_is_group ) VALUES ( %d, %s, %s, FROM_UNIXTIME(%d), %d, %d )", $this->sender_id, $this->subject, $this->message, $this->date_sent, $this->message_order, $this->sender_is_group ) ) )
     
    399405        $this->id = $message_id;
    400406        messages_remove_callback_values();
     407
     408        do_action( 'messages_message_after_save', $this );
    401409       
    402410        return true;
  • trunk/bp-messages/bp-messages-filters.php

    r1154 r1351  
    4141add_filter( 'bp_messages_content_value', 'wp_filter_kses', 1 );
    4242add_filter( 'bp_message_content', 'wp_filter_kses', 1 );
     43add_filter( 'messages_message_content_before_save', 'wp_filter_kses', 1 );
     44add_filter( 'messages_message_subject_before_save', 'wp_filter_kses', 1 );
    4345
    4446?>
  • trunk/bp-wire/bp-wire-classes.php

    r1280 r1351  
    3939        global $wpdb, $bp;
    4040       
    41         $this->content = wp_filter_kses( $this->content );
     41        $this->item_id = apply_filters( 'bp_wire_post_item_id_before_save', $this->item_id, $this->id );
     42        $this->user_id = apply_filters( 'bp_wire_post_user_id_before_save', $this->user_id, $this->id );
     43        $this->content = apply_filters( 'bp_wire_post_content_before_save', $this->content, $this->id );
     44        $this->date_posted = apply_filters( 'bp_wire_post_date_posted_before_save', $this->date_posted, $this->id );
     45
     46        do_action( 'bp_wire_post_before_save', $this );     
    4247       
    4348        if ( $this->id ) {
     
    7984        if ( !$this->id )
    8085            $this->id = $wpdb->insert_id;
     86
     87        do_action( 'bp_wire_post_after_save', $this );     
    8188       
    8289        return $result;
  • trunk/bp-wire/bp-wire-filters.php

    r1154 r1351  
    1515
    1616add_filter( 'bp_wire_post_content', 'wp_filter_kses', 1 );
     17add_filter( 'bp_wire_post_content_before_save', 'wp_filter_kses', 1 );
    1718
    1819?>
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r1311 r1351  
    4646        global $wpdb, $bp;
    4747       
    48         $this->name = wp_filter_kses( $this->name );
    49         $this->description = wp_filter_kses( $this->description );
    50 
    51         if ( $this->id != null ) {
    52             $sql = $wpdb->prepare("UPDATE {$bp->profile->table_name_groups} SET name = %s, description = %s WHERE id = %d", $this->name, $this->description, $this->id);
    53         } else {
    54             $sql = $wpdb->prepare("INSERT INTO {$bp->profile->table_name_groups} (name, description, can_delete) VALUES (%s, %s, 1)", $this->name, $this->description);     
     48        $this->name = apply_filters( 'xprofile_group_name_before_save', $this->name, $this->id );
     49        $this->description = apply_filters( 'xprofile_group_description_before_save', $this->description, $this->id );
     50
     51        do_action( 'xprofile_group_before_save', $this );
     52
     53        if ( $this->id ) {
     54            $sql = $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s, description = %s WHERE id = %d", $this->name, $this->description, $this->id );
     55        } else {
     56            $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_groups} (name, description, can_delete) VALUES (%s, %s, 1)", $this->name, $this->description );       
    5557        }
    5658       
    5759        if ( !$wpdb->query($sql) )
    5860            return false;
     61
     62        do_action( 'xprofile_group_after_save', $this );
    5963       
    6064        return true;
     
    246250        global $wpdb, $bp;
    247251       
    248         $this->name = wp_filter_kses( $this->name );
    249         $this->desc = wp_filter_kses( $this->desc );       
     252        $error = false;
     253       
     254        $this->group_id = apply_filters( 'xprofile_field_group_id_before_save', $this->group_id, $this->id );
     255        $this->parent_id = apply_filters( 'xprofile_field_parent_id_before_save', $this->parent_id, $this->id );
     256        $this->type = apply_filters( 'xprofile_field_type_before_save', $this->type, $this->id );
     257        $this->name = apply_filters( 'xprofile_field_name_before_save', $this->name, $this->id );
     258        $this->desc = apply_filters( 'xprofile_field_description_before_save', $this->desc, $this->id );
     259        $this->is_required = apply_filters( 'xprofile_field_is_required_before_save', $this->is_required, $this->id );
     260        $this->is_public = apply_filters( 'xprofile_field_is_public_before_save', $this->is_public, $this->id );
     261        $this->order_by = apply_filters( 'xprofile_field_order_by_before_save', $this->order_by, $this->id );
     262
     263        do_action( 'xprofile_field_before_save', $this );
    250264       
    251265        if ( $this->id != null ) {
     
    354368                    }
    355369                }
    356 
    357                 return true;
    358            
    359             } else {
    360                 return true;
    361370            }
    362         }
    363         else
    364         {
     371        } else {
     372            $error = true;
     373        }
     374       
     375        if ( !$error ) {
     376            do_action( 'xprofile_field_after_save', $this );
     377            return true;
     378        } else {
    365379            return false;
    366380        }
     
    10391053    function save() {
    10401054        global $wpdb, $bp;
    1041        
    1042         $this->last_updated = date( 'Y-m-d H:i:s' );
    1043         $this->value = wp_filter_kses( $this->value );
    1044 
     1055
     1056        $this->user_id = apply_filters( 'xprofile_data_user_id_before_save', $this->user_id, $this->id );
     1057        $this->field_id = apply_filters( 'xprofile_data_field_id_before_save', $this->field_id, $this->id );
     1058        $this->value = apply_filters( 'xprofile_data_value_before_save', $this->value, $this->id );
     1059        $this->last_updated = apply_filters( 'xprofile_data_last_updated_before_save', date( 'Y-m-d H:i:s' ), $this->id );
     1060       
     1061        do_action( 'xprofile_data_before_save', $this );
     1062       
    10451063        if ( $this->is_valid_field() ) {
    10461064            if ( $this->exists() && $this->value != '' ) {
     
    10561074                return false;
    10571075
     1076            do_action( 'xprofile_data_after_save', $this );
     1077           
    10581078            return true;
    10591079        }
  • trunk/bp-xprofile/bp-xprofile-filters.php

    r1273 r1351  
    44add_filter( 'bp_the_profile_field_value', 'wp_filter_kses', 1 );
    55add_filter( 'xprofile_get_field_data', 'wp_filter_kses', 1 );
     6add_filter( 'xprofile_field_name_before_save', 'wp_filter_kses', 1 );
     7add_filter( 'xprofile_field_description_before_save', 'wp_filter_kses', 1 );
    68
    79add_filter( 'bp_the_profile_field_value', 'wptexturize' );
     
    1618add_filter( 'bp_the_profile_field_type', 'convert_smilies' );
    1719add_filter( 'bp_the_profile_field_type', 'convert_chars' );
    18 
    1920
    2021/* Custom BuddyPress filters */
Note: See TracChangeset for help on using the changeset viewer.