Changeset 3373
- Timestamp:
- 11/07/2010 11:33:21 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
bp-activity.php (modified) (3 diffs)
-
bp-activity/bp-activity-classes.php (modified) (6 diffs)
-
bp-activity/bp-activity-templatetags.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r3369 r3373 504 504 'search_terms' => false, // Pass search terms as a string 505 505 'show_hidden' => false, // Show activity items that are hidden site-wide? 506 'exclude' => false, // Comma-separated list of activity IDs to exclude 506 507 507 508 /** … … 522 523 523 524 /* Attempt to return a cached copy of the first page of sitewide activity. */ 524 if ( 1 == (int)$page && empty( $max ) && empty( $search_terms ) && empty( $filter ) && 'DESC' == $sort ) {525 if ( 1 == (int)$page && empty( $max ) && empty( $search_terms ) && empty( $filter ) && 'DESC' == $sort && empty( $exclude ) ) { 525 526 if ( !$activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ) ) { 526 527 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden ); … … 528 529 } 529 530 } else 530 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden );531 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden, $exclude ); 531 532 532 533 return apply_filters( 'bp_activity_get', $activity, &$r ); -
trunk/bp-activity/bp-activity-classes.php
r3369 r3373 71 71 $this->primary_link = $bp->loggedin_user->domain; 72 72 73 / * If we have an existing ID, update the activity item, otherwise insert it. */73 // If we have an existing ID, update the activity item, otherwise insert it. 74 74 if ( $this->id ) 75 75 $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 ); … … 87 87 } 88 88 89 / * Static Functions */90 91 function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false ) {92 global $wpdb, $bp; 93 94 / * Select conditions */89 // Static Functions 90 91 function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false, $exclude = false ) { 92 global $wpdb, $bp; 93 94 // Select conditions 95 95 $select_sql = "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name"; 96 96 97 97 $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID"; 98 98 99 / * Where conditions */99 // Where conditions 100 100 $where_conditions = array(); 101 101 102 / * Searching */102 // Searching 103 103 if ( $search_terms ) { 104 104 $search_terms = $wpdb->escape( $search_terms ); … … 106 106 } 107 107 108 / * Filtering */108 // Filtering 109 109 if ( $filter && $filter_sql = BP_Activity_Activity::get_filter_sql( $filter ) ) 110 110 $where_conditions['filter_sql'] = $filter_sql; 111 111 112 / * Sorting */112 // Sorting 113 113 if ( $sort != 'ASC' && $sort != 'DESC' ) 114 114 $sort = 'DESC'; 115 115 116 / * Hide Hidden Items? */116 // Hide Hidden Items? 117 117 if ( !$show_hidden ) 118 118 $where_conditions['hidden_sql'] = "a.hide_sitewide = 0"; 119 119 120 /* Alter the query based on whether we want to show activity item comments in the stream like normal comments or threaded below the activity */ 120 // Exclude specified items 121 if ( $exclude ) 122 $where_conditions['exclude'] = "a.id NOT IN ({$exclude})"; 123 124 // Alter the query based on whether we want to show activity item comments in the stream like normal comments or threaded below the activity 121 125 if ( !$display_comments || 'threaded' == $display_comments ) { 122 126 $where_conditions[] = "a.type != 'activity_comment'"; … … 134 138 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a {$where_sql} ORDER BY a.date_recorded {$sort}" ) ); 135 139 136 / * Get the fullnames of users so we don't have to query in the loop */140 // Get the fullnames of users so we don't have to query in the loop 137 141 if ( bp_is_active( 'xprofile' ) && $activities ) { 138 142 foreach ( (array)$activities as $activity ) { … … 161 165 $activities = BP_Activity_Activity::append_comments( &$activities ); 162 166 163 / * If $max is set, only return up to the max results */167 // If $max is set, only return up to the max results 164 168 if ( !empty( $max ) ) { 165 169 if ( (int)$total_activities > (int)$max ) … … 194 198 $activities = BP_Activity_Activity::append_comments( $activities ); 195 199 196 / * If $max is set, only return up to the max results */200 // If $max is set, only return up to the max results 197 201 if ( !empty( $max ) ) { 198 202 if ( (int)$total_activities > (int)$max ) -
trunk/bp-activity/bp-activity-templatetags.php
r3369 r3373 16 16 var $full_name; 17 17 18 function bp_activity_template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden ) {18 function bp_activity_template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude ) { 19 19 global $bp; 20 20 … … 33 33 // Fetch all activity items 34 34 else 35 $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 ) );35 $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 ) ); 36 36 37 37 if ( !$max || $max >= (int)$this->activities['total'] ) … … 143 143 $user_id = false; 144 144 $include = false; 145 $exclude = false; 145 146 $show_hidden = false; 146 147 $object = false; … … 167 168 $defaults = array( 168 169 'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items 169 'include' => $include, // pass an activity_id or string of ID's comma separated 170 'include' => $include, // pass an activity_id or string of IDs comma-separated 171 'exclude' => $exclude, // pass an activity_id or string of IDs comma-separated 170 172 'sort' => 'DESC', // sort DESC or ASC 171 173 'page' => 1, // which page to load … … 255 257 $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id ); 256 258 257 $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden );259 $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude ); 258 260 259 261 return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template );
Note: See TracChangeset
for help on using the changeset viewer.