Ticket #5022: 5022.bp-activity-classes.diff
File 5022.bp-activity-classes.diff, 5.4 KB (added by , 11 years ago) |
---|
-
bp-activity/bp-activity-classes.php
9 9 // Exit if accessed directly 10 10 if ( !defined( 'ABSPATH' ) ) exit; 11 11 12 /** 13 * Database interaction class for the BuddyPress activity component. 14 * 15 * Instance methods are available for creating/editing an activity, 16 * static methods for querying activities. 17 * 18 * @since BuddyPress (1.0) 19 */ 12 20 class BP_Activity_Activity { 21 22 /** Properties ************************************************************/ 23 24 /** 25 * @var int Activity ID 26 */ 13 27 var $id; 28 29 /** 30 * @var int The primary item ID 31 */ 14 32 var $item_id; 33 34 /** 35 * @var int The secondary item ID 36 */ 15 37 var $secondary_item_id; 38 39 /** 40 * @var int The user ID 41 */ 16 42 var $user_id; 43 44 /** 45 * @var string The primary URL for the activity in RSS feeds 46 */ 17 47 var $primary_link; 48 49 /** 50 * @var string The BuddyPress component activity relates to 51 */ 18 52 var $component; 53 54 /** 55 * @var string Activity type (e.g. activity_update) 56 */ 19 57 var $type; 58 59 /** 60 * @var string Description of the activity, (e.g. Alex posted an update) 61 */ 20 62 var $action; 63 64 /** 65 * @var string Activity content 66 */ 21 67 var $content; 68 69 /** 70 * @var string ISO timestamp of the activity's date/time 71 */ 22 72 var $date_recorded; 73 74 /** 75 * @var int Hide activity from sitewide feeds 76 */ 23 77 var $hide_sitewide = false; 78 79 /** 80 * @var int node boundary start for activity or activity comment 81 */ 24 82 var $mptt_left; 83 84 /** 85 * @var int node boundary end for activity or activity comment 86 */ 25 87 var $mptt_right; 88 89 /** 90 * @var int Activity spam/ham status 91 */ 26 92 var $is_spam; 27 93 94 /** Instance Methods ******************************************************/ 95 96 /** 97 * Constructor 98 * 99 * @param int $id optional Activity ID 100 */ 28 101 function __construct( $id = false ) { 29 102 if ( !empty( $id ) ) { 30 103 $this->id = $id; … … 104 177 return true; 105 178 } 106 179 107 / / Static Functions180 /** Static Methods ********************************************************/ 108 181 109 182 /** 110 183 * Get activity items, as specified by parameters … … 256 329 $activity_user_ids = wp_list_pluck( $activities, 'user_id' ); 257 330 $activity_user_ids = implode( ',', wp_parse_id_list( $activity_user_ids ) ); 258 331 259 if ( !empty( $activity_user_ids ) ) { 332 if ( !empty( $activity_user_ids ) ) { 260 333 if ( $names = $wpdb->get_results( "SELECT user_id, value AS user_fullname FROM {$bp->profile->table_name_data} WHERE field_id = 1 AND user_id IN ({$activity_user_ids})" ) ) { 261 334 foreach ( (array) $names as $name ) 262 335 $tmp_names[$name->user_id] = $name->user_fullname; … … 584 657 return $comments; 585 658 } 586 659 660 /** 661 * Rebuild nested comment tree under an activity or activity comment. 662 * 663 * @global BuddyPress $bp The one true BuddyPress instance 664 * @global wpdb $wpdb WordPress database object 665 * @param int $parent_id ID of an activty or activity comment 666 * @param int $left node boundary start for activity or activity comment 667 * @return int Right node boundary of activity or activity comment 668 * @since BuddyPress (1.2) 669 */ 587 670 function rebuild_activity_comment_tree( $parent_id, $left = 1 ) { 588 671 global $wpdb, $bp; 589 672 … … 608 691 return $right + 1; 609 692 } 610 693 694 /** 695 * Get child comments of an activity or activity comment 696 * 697 * @global BuddyPress $bp The one true BuddyPress instance 698 * @global wpdb $wpdb WordPress database object 699 * @param int $parent_id ID of an activty or activity comment 700 * @return object Numerically indexed array of child comments 701 * @since BuddyPress (1.2) 702 */ 611 703 function get_child_comments( $parent_id ) { 612 704 global $bp, $wpdb; 613 705 614 706 return $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND secondary_item_id = %d", $parent_id ) ); 615 707 } 616 708 709 /** 710 * Get a unique list of components that have related activity recorded to them 711 * 712 * @global BuddyPress $bp The one true BuddyPress instance 713 * @global wpdb $wpdb WordPress database object 714 * @return array The components 715 * @since BuddyPress (1.2) 716 */ 617 717 function get_recorded_components() { 618 718 global $wpdb, $bp; 619 719 … … 637 737 return $activity_feed; 638 738 } 639 739 740 /** 741 * Create SQL IN clause 742 * 743 * @param string $field The database field 744 * @param array $items The values for the IN clause 745 * @since BuddyPress (1.3) 746 */ 640 747 function get_in_operator_sql( $field, $items ) { 641 748 global $wpdb; 642 749 … … 661 768 return false; 662 769 } 663 770 771 /** 772 * Create filter SQL clauses 773 * 774 * @param array $filter_array Multidimensional array of fields to filter and values 775 * @since BuddyPress (1.3) 776 */ 664 777 function get_filter_sql( $filter_array ) { 665 778 666 779 $filter_sql = array(); … … 701 814 return join( ' AND ', $filter_sql ); 702 815 } 703 816 817 818 /** 819 * Get the date/time of last recorded activity 820 * 821 * @return string ISO timestamp 822 * @since BuddyPress (1.2) 823 */ 704 824 function get_last_updated() { 705 825 global $bp, $wpdb; 706 826 … … 720 840 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) ); 721 841 } 722 842 843 /** 844 * Hide all sitewide activity for a specific user 845 * 846 * @param int $user_id 847 * @since BuddyPress (1.2) 848 */ 723 849 function hide_all_for_user( $user_id ) { 724 850 global $wpdb, $bp; 725 851