Changeset 5259
- Timestamp:
- 10/24/2011 02:00:04 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-actions.php
r5253 r5259 171 171 } 172 172 add_action( 'bp_actions', 'bp_activity_action_delete_activity' ); 173 174 /** 175 * Mark specific activity item as spam and redirect to previous page 176 * 177 * @global object $bp BuddyPress global settings 178 * @param int $activity_id Activity id to be deleted. Defaults to 0. 179 * @return bool False on failure 180 * @since 1.6 181 */ 182 function bp_activity_action_spam_activity( $activity_id = 0 ) { 183 global $bp; 184 185 // Not viewing activity, or action is not spam, or Akismet isn't present 186 if ( !bp_is_activity_component() || !bp_is_current_action( 'spam' ) || empty( $bp->activity->akismet ) ) 187 return false; 188 189 if ( empty( $activity_id ) && bp_action_variable( 0 ) ) 190 $activity_id = (int) bp_action_variable( 0 ); 191 192 // Not viewing a specific activity item 193 if ( empty( $activity_id ) ) 194 return false; 195 196 // Is the current user allowed to spam items? 197 if ( !BP_Akismet::user_can_mark_spam() ) 198 return false; 199 200 // Load up the activity item 201 $activity = new BP_Activity_Activity( $activity_id ); 202 if ( empty( $activity->id ) ) 203 return false; 204 205 // Check nonce 206 check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id ); 207 208 // Call an action before the spamming so plugins can modify things if they want to 209 do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity ); 210 211 // Mark as spam 212 $bp->activity->akismet->mark_as_spam( $activity ); 213 $activity->save(); 214 215 // Tell the user the spamming has been succesful 216 bp_core_add_message( __( 'The activity item has been marked as spam and is no longer visible.', 'buddypress' ) ); 217 218 do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id ); 219 220 // Check for the redirect query arg, otherwise let WP handle things 221 if ( !empty( $_GET['redirect_to'] ) ) 222 bp_core_redirect( esc_url( $_GET['redirect_to'] ) ); 223 else 224 bp_core_redirect( wp_get_referer() ); 225 } 226 add_action( 'bp_actions', 'bp_activity_action_spam_activity' ); 173 227 174 228 /** … … 535 589 add_action( 'bp_actions', 'bp_activity_action_favorites_feed' ); 536 590 591 592 /** 593 * Loads Akismet 594 * 595 * @global object $bp BuddyPress global settings 596 * @since 1.6 597 */ 598 function bp_activity_setup_akismet() { 599 global $bp; 600 601 $akismet_key = bp_get_option( 'wordpress_api_key' ); 602 603 // Load Akismet support if Akismet is configured 604 if ( !defined( 'AKISMET_VERSION' ) || ( empty( $akismet_key ) && !defined( 'WPCOM_API_KEY' ) ) ) 605 return; 606 607 // Instantiate Akismet for BuddyPress 608 $bp->activity->akismet = new BP_Akismet(); 609 } 537 610 ?> -
trunk/bp-activity/bp-activity-classes.php
r5109 r5259 1 1 <?php 2 3 2 /** 4 3 * BuddyPress Activity Classes 5 4 * 6 5 * @package BuddyPress 7 * @subpackage Activity Classes6 * @subpackage Activity 8 7 */ 9 8 … … 25 24 var $mptt_left; 26 25 var $mptt_right; 27 28 function bp_activity_activity( $id = false ) { 29 $this->__construct( $id ); 30 } 26 var $is_spam; 31 27 32 28 function __construct( $id = false ) { 33 global $bp;34 35 29 if ( !empty( $id ) ) { 36 30 $this->id = $id; … … 56 50 $this->mptt_left = $row->mptt_left; 57 51 $this->mptt_right = $row->mptt_right; 52 $this->is_spam = $row->is_spam; 58 53 } 59 54 } … … 75 70 $this->mptt_left = apply_filters_ref_array( 'bp_activity_mptt_left_before_save', array( $this->mptt_left, &$this ) ); 76 71 $this->mptt_right = apply_filters_ref_array( 'bp_activity_mptt_right_before_save', array( $this->mptt_right, &$this ) ); 72 $this->is_spam = apply_filters_ref_array( 'bp_activity_is_spam_before_save', array( $this->is_spam, &$this ) ); 77 73 78 74 // Use this, not the filters above … … 87 83 // If we have an existing ID, update the activity item, otherwise insert it. 88 84 if ( $this->id ) 89 $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 = %s, secondary_item_id = %s, hide_sitewide = %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->id );90 else 91 $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 ) VALUES ( %d, %s, %s, %s, %s, %s, %s, %s, %s, %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);85 $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 = %s, secondary_item_id = %s, 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 ); 86 else 87 $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, %s, %s, %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 ); 92 88 93 89 if ( !$wpdb->query( $q ) ) … … 103 99 104 100 // Static Functions 105 106 function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false, $exclude = false, $in = false ) { 101 function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false, $exclude = false, $in = false, $hide_spam = true ) { 107 102 global $wpdb, $bp; 108 103 … … 114 109 // Where conditions 115 110 $where_conditions = array(); 111 112 // Spam 113 if ( $hide_spam ) 114 $where_conditions['spam_sql'] = 'a.is_spam = 0'; 116 115 117 116 // Searching … … 192 191 193 192 if ( $activities && $display_comments ) 194 $activities = BP_Activity_Activity::append_comments( $activities );193 $activities = BP_Activity_Activity::append_comments( $activities, $hide_spam ); 195 194 196 195 // If $max is set, only return up to the max results … … 357 356 } 358 357 359 function append_comments( $activities ) { 358 /** 359 * Append activity comments to their associated activity items 360 * 361 * @global object $bp Global BuddyPress settings object 362 * @global wpdb $wpdb WordPress database object 363 * @param array $activities 364 * @param bool $hide_spam Optional. Defaults to true (don't retrieve spammed items). 365 * @return array The updated activities with nested comments 366 * @since 1.2 367 */ 368 function append_comments( $activities, $hide_spam = true ) { 360 369 global $bp, $wpdb; 361 370 … … 365 374 foreach( (array)$activities as $activity ) { 366 375 if ( 'activity_comment' != $activity->type && $activity->mptt_left && $activity->mptt_right ) 367 $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right );376 $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $hide_spam ); 368 377 } 369 378 … … 376 385 } 377 386 378 function get_activity_comments( $activity_id, $left, $right ) { 387 /** 388 * Get activity comments that are associated with a specific activity ID 389 * 390 * @global object $bp Global BuddyPress settings object 391 * @global wpdb $wpdb WordPress database object 392 * @param int $activity_id Activity ID to fetch comments for 393 * @param int $left Left-most node boundary 394 * @param into $right Right-most node boundary 395 * @param bool $hide_spam Optional. Defaults to true (don't retrieve spammed items). 396 * @return array The updated activities with nested comments 397 * @since 1.2 398 */ 399 function get_activity_comments( $activity_id, $left, $right, $hide_spam = true ) { 379 400 global $wpdb, $bp; 380 401 … … 391 412 } 392 413 414 // Don't retrieve activity comments marked as spam 415 if ( $hide_spam ) 416 $spam_sql = 'AND a.is_spam = 0'; 417 else 418 $spam_sql = ''; 419 420 $sql = apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' ${spam_sql} AND a.item_id = %d AND a.mptt_left BETWEEN %d AND %d ORDER BY a.date_recorded ASC", $activity_id, $left, $right ), $activity_id, $left, $right, $hide_spam ); 421 393 422 // Retrieve all descendants of the $root node 394 $descendants = $wpdb->get_results( apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' AND a.item_id = %d AND a.mptt_left BETWEEN %d AND %d ORDER BY a.date_recorded ASC", $activity_id, $left, $right ), $activity_id, $left, $right ));423 $descendants = $wpdb->get_results( $sql ); 395 424 396 425 // Loop descendants and build an assoc array -
trunk/bp-activity/bp-activity-filters.php
r5109 r5259 145 145 */ 146 146 function bp_activity_at_name_filter( $content, $activity_id = 0 ) { 147 if ( $activity_id & bp_is_active( 'activity' ) ) { 148 $activity = new BP_Activity_Activity( $activity_id ); 149 150 // If this activity has been marked as spam, don't do anything. This prevents @notifications being sent. 151 if ( !empty( $activity ) && $activity->is_spam ) 152 return $content; 153 } 154 147 155 $usernames = bp_activity_find_mentions( $content ); 148 149 156 foreach( (array)$usernames as $username ) { 150 157 if ( bp_is_username_compatibility_mode() ) -
trunk/bp-activity/bp-activity-functions.php
r5109 r5259 702 702 'exclude' => false, // Comma-separated list of activity IDs to exclude 703 703 'in' => false, // Comma-separated list or array of activity IDs to which you want to limit the query 704 'hide_spam' => true, // Don't retrieve items marked as spam? 704 705 705 706 /** … … 721 722 if ( 1 == (int)$page && empty( $max ) && empty( $search_terms ) && empty( $filter ) && 'DESC' == $sort && empty( $exclude ) ) { 722 723 if ( !$activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ) ) { 723 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden );724 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden, false, false, $hide_spam ); 724 725 wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' ); 725 726 } 726 } else 727 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden, $exclude, $in ); 727 728 } else { 729 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden, $exclude, $in, $hide_spam ); 730 } 728 731 729 732 return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) ); … … 746 749 $defaults = array( 747 750 'activity_ids' => false, // A single activity_id or array of IDs. 751 'display_comments' => false, // true or false to display threaded comments for these specific activity items 752 'hide_spam' => false, // Retrieve items marked as spam 753 'max' => false, // Maximum number of results to return 748 754 'page' => 1, // page 1 without a per_page will result in no pagination. 749 755 'per_page' => false, // results per page 750 ' max' => false, // Maximum number of results to return756 'show_hidden' => true, // When fetching specific items, show all 751 757 'sort' => 'DESC', // sort ASC or DESC 752 'display_comments' => false, // true or false to display threaded comments for these specific activity items753 'show_hidden' => true // When fetching specific items, show all754 758 ); 755 759 $r = wp_parse_args( $args, $defaults ); 756 760 extract( $r, EXTR_SKIP ); 757 761 758 return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, $show_hidden, false, $activity_ids ) );762 return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, $show_hidden, false, $activity_ids, $hide_spam ) ); 759 763 } 760 764 … … 792 796 'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id 793 797 'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded 794 'hide_sitewide' => false // Should this be hidden on the sitewide activity stream? 798 'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream? 799 'is_spam' => false, // Is this activity item to be marked as spam? 795 800 ); 796 801 $params = wp_parse_args( $args, $defaults ); … … 816 821 $activity->date_recorded = $recorded_time; 817 822 $activity->hide_sitewide = $hide_sitewide; 823 $activity->is_spam = $is_spam; 818 824 819 825 if ( !$activity->save() ) -
trunk/bp-activity/bp-activity-loader.php
r5109 r5259 25 25 * @since 1.5.0 26 26 */ 27 function BP_Activity_Component() {28 $this->__construct();29 }30 31 27 function __construct() { 32 28 parent::start( … … 53 49 'notifications', 54 50 ); 51 52 // Load Akismet support if Akismet is configured 53 $akismet_key = bp_get_option( 'wordpress_api_key' ); 54 if ( defined( 'AKISMET_VERSION' ) && ( !empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) ) 55 $includes[] = 'akismet'; 55 56 56 57 parent::includes( $includes ); … … 308 309 parent::setup_title(); 309 310 } 311 312 /** 313 * Setup the actions 314 * 315 * @since 1.6 316 */ 317 function setup_actions() { 318 // Spam prevention 319 add_action( 'bp_include', 'bp_activity_setup_akismet' ); 320 321 parent::setup_actions(); 322 } 310 323 } 311 324 312 325 // Create the activity component 313 326 $bp->activity = new BP_Activity_Component(); 314 315 327 ?> -
trunk/bp-activity/bp-activity-screens.php
r5109 r5259 195 195 196 196 // Get the activity details 197 $activity = bp_activity_get_specific( array( 'activity_ids' => bp_current_action(), ' show_hidden' => true ) );197 $activity = bp_activity_get_specific( array( 'activity_ids' => bp_current_action(), 'hide_spam' => true, 'show_hidden' => true ) ); 198 198 199 199 // 404 if activity does not exist -
trunk/bp-activity/bp-activity-template.php
r5258 r5259 105 105 var $full_name; 106 106 107 function bp_activity_template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude = false, $in = false ) { 108 $this->__construct( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude, $in ); 109 } 110 111 function __construct( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude = false, $in = false ) { 107 function __construct( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude = false, $in = false, $hide_spam = true ) { 112 108 global $bp; 113 109 … … 123 119 // Fetch specific activity items based on ID's 124 120 if ( !empty( $include ) ) 125 $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments, 'show_hidden' => $show_hidden ) ); 121 $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments, 'show_hidden' => $show_hidden, 'hide_spam' => $hide_spam ) ); 122 126 123 // Fetch all activity items 127 124 else 128 $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden, 'exclude' => $exclude, 'in' => $in ) );125 $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden, 'exclude' => $exclude, 'in' => $in, 'hide_spam' => $hide_spam ) ); 129 126 130 127 if ( !$max || $max >= (int)$this->activities['total'] ) … … 302 299 'max' => false, // max number to return 303 300 'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide? 301 'hide_spam' => true, // Don't retrieve items marked as spam? 304 302 305 303 // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions) … … 385 383 $filter = false; 386 384 387 $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude, $in ); 385 // If specific activity items have been requested, override the $hide_spam argument. This prevents backpat errors with AJAX. 386 if ( !empty( $include ) && $hide_spam ) 387 $hide_spam = false; 388 389 $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude, $in, $hide_spam ); 388 390 389 391 return apply_filters( 'bp_has_activities', $activities_template->has_activities(), $activities_template ); -
trunk/bp-core/admin/bp-core-schema.php
r4820 r5259 49 49 50 50 $sql[] = "CREATE TABLE {$bp_prefix}bp_activity ( 51 51 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 52 52 user_id bigint(20) NOT NULL, 53 53 component varchar(75) NOT NULL, … … 62 62 mptt_left int(11) NOT NULL DEFAULT 0, 63 63 mptt_right int(11) NOT NULL DEFAULT 0, 64 is_spam tinyint(1) NOT NULL DEFAULT 0, 64 65 KEY date_recorded (date_recorded), 65 66 KEY user_id (user_id), … … 70 71 KEY mptt_left (mptt_left), 71 72 KEY mptt_right (mptt_right), 72 KEY hide_sitewide (hide_sitewide) 73 ) {$charset_collate};"; 73 KEY hide_sitewide (hide_sitewide), 74 KEY is_spam (is_spam) 75 ) {$charset_collate};"; 74 76 75 77 $sql[] = "CREATE TABLE {$bp_prefix}bp_activity_meta ( -
trunk/bp-loader.php
r5223 r5259 22 22 // Define the database version 23 23 if ( !defined( 'BP_DB_VERSION' ) ) 24 define( 'BP_DB_VERSION', 52 22);24 define( 'BP_DB_VERSION', 5249 ); 25 25 26 26 // Place your custom code (actions/filters) in a file called -
trunk/bp-themes/bp-default/_inc/ajax.php
r5095 r5259 223 223 224 224 // Load the new activity item into the $activities_template global 225 bp_has_activities( 'display_comments=stream& include=' . $comment_id );225 bp_has_activities( 'display_comments=stream&hide_spam=false&include=' . $comment_id ); 226 226 227 227 // Swap the current comment with the activity item we just loaded … … 317 317 } 318 318 add_action( 'wp_ajax_delete_activity_comment', 'bp_dtheme_delete_activity_comment' ); 319 320 /** 321 * AJAX spam an activity item or an activity comment 322 * 323 * @global object $bp BuddyPress global settings 324 * @since 1.6 325 */ 326 function bp_dtheme_spam_activity() { 327 global $bp; 328 329 // Check that user is logged in, Activity Streams are enabled, and Akismet is present. 330 if ( !is_user_logged_in() || !bp_is_active( 'activity' ) || empty( $bp->activity->akismet ) ) { 331 echo '-1'; 332 return false; 333 } 334 335 // Check an item ID was passed 336 if ( empty( $_POST['id'] ) || !is_numeric( $_POST['id'] ) ) { 337 echo '-1'; 338 return false; 339 } 340 341 // Is the current user allowed to spam items? 342 if ( !BP_Akismet::user_can_mark_spam() ) 343 return false; 344 345 // Load up the activity item 346 $activity = new BP_Activity_Activity( (int) $_POST['id'] ); 347 if ( empty( $activity->id ) ) { 348 echo '-1'; 349 return false; 350 } 351 352 // Check nonce 353 check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id ); 354 355 // Call an action before the spamming so plugins can modify things if they want to 356 do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity ); 357 358 // Mark as spam 359 $bp->activity->akismet->mark_as_spam( $activity ); 360 $activity->save(); 361 362 do_action( 'bp_activity_action_spam_activity', $activity->id, $activity->user_id ); 363 return true; 364 } 365 add_action( 'wp_ajax_spam_activity', 'bp_dtheme_spam_activity' ); 366 add_action( 'wp_ajax_spam_activity_comment', 'bp_dtheme_spam_activity' ); 319 367 320 368 /* AJAX mark an activity as a favorite */ -
trunk/bp-themes/bp-default/_inc/global.js
r4961 r5259 69 69 'content': content, 70 70 'object': object, 71 'item_id': item_id 71 'item_id': item_id, 72 '_bp_as_nonce': jq('#_bp_as_nonce').val() || '' 72 73 }, 73 74 function(response) { … … 248 249 } 249 250 251 // Spam activity stream items 252 if ( target.hasClass( 'spam-activity' ) ) { 253 var li = target.parents( 'div.activity ul li' ); 254 target.addClass( 'loading' ); 255 256 jq.post( ajaxurl, { 257 action: 'spam_activity', 258 'cookie': encodeURIComponent( document.cookie ), 259 'id': li.attr( 'id' ).substr( 9, li.attr( 'id' ).length ), 260 '_wpnonce': target.attr( 'href' ).split( '_wpnonce=' )[1] 261 }, 262 263 function(response) { 264 if ( response[0] + response[1] === '-1' ) { 265 li.prepend( response.substr( 2, response.length ) ); 266 li.children( 'div#message' ).hide().fadeIn(300); 267 } else { 268 li.slideUp( 300 ); 269 } 270 }); 271 272 return false; 273 } 274 250 275 /* Load more updates at the end of the page */ 251 276 if ( target.parent().hasClass('load-more') ) { … … 365 390 target.addClass('loading').prop('disabled', true); 366 391 367 jq.post( ajaxurl,{392 var ajaxdata = { 368 393 action: 'new_activity_comment', 369 394 'cookie': encodeURIComponent(document.cookie), … … 372 397 'form_id': form_id[2], 373 398 'content': jq('form#' + form.attr('id') + ' textarea').val() 374 }, 399 }; 400 401 // Akismet 402 var ak_nonce = jq('#_bp_as_nonce_' + comment_id).val(); 403 if ( ak_nonce ) { 404 ajaxdata['_bp_as_nonce_' + comment_id] = ak_nonce; 405 } 406 407 jq.post( ajaxurl, ajaxdata, 375 408 function(response) 376 409 { … … 457 490 } 458 491 492 // Spam an activity stream comment 493 if ( target.hasClass( 'spam-activity-comment' ) ) { 494 var link_href = target.attr( 'href' ); 495 var comment_li = target.parent().parent(); 496 497 target.addClass('loading'); 498 499 // Remove any error messages 500 jq( 'div.activity-comments ul div.error' ).remove(); 501 502 // Reset the form position 503 comment_li.parents( 'div.activity-comments' ).append( comment_li.parents( 'div.activity-comments' ).children( 'form' ) ); 504 505 jq.post( ajaxurl, { 506 action: 'spam_activity_comment', 507 'cookie': encodeURIComponent( document.cookie ), 508 '_wpnonce': link_href.split( '_wpnonce=' )[1], 509 'id': link_href.split( 'cid=' )[1].split( '&' )[0] 510 }, 511 512 function ( response ) { 513 // Check for errors and append if found. 514 if ( response[0] + response[1] == '-1' ) { 515 comment_li.prepend( response.substr( 2, response.length ) ).hide().fadeIn( 200 ); 516 517 } else { 518 var children = jq( 'li#' + comment_li.attr( 'id' ) + ' ul' ).children( 'li' ); 519 var child_count = 0; 520 jq(children).each( function() { 521 if ( !jq( this ).is( ':hidden' ) ) { 522 child_count++; 523 } 524 }); 525 comment_li.fadeOut( 200 ); 526 527 // Decrease the "Reply (X)" button count 528 var parent_li = comment_li.parents( 'ul#activity-stream > li' ); 529 jq( 'li#' + parent_li.attr( 'id' ) + ' a.acomment-reply span' ).html( jq( 'li#' + parent_li.attr( 'id' ) + ' a.acomment-reply span' ).html() - ( 1 + child_count ) ); 530 } 531 }); 532 533 return false; 534 } 535 459 536 /* Showing hidden comments - pause for half a second */ 460 537 if ( target.parent().hasClass('show-all') ) { -
trunk/bp-themes/bp-default/functions.php
r5251 r5259 140 140 function bp_dtheme_enqueue_scripts() { 141 141 // Bump this when changes are made to bust cache 142 $version = '2011 0921';142 $version = '20111023'; 143 143 144 144 // Enqueue the global JS - Ajax will not work without it
Note: See TracChangeset
for help on using the changeset viewer.