Changeset 2088
- Timestamp:
- 11/13/2009 01:01:37 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r2077 r2088 1 1 <?php 2 2 3 define ( 'BP_ACTIVITY_DB_VERSION', '1 800' );3 define ( 'BP_ACTIVITY_DB_VERSION', '1900' ); 4 4 5 5 /* Define the slug for the component */ … … 33 33 date_recorded datetime NOT NULL, 34 34 hide_sitewide bool DEFAULT 0, 35 mptt_left int(11) NOT NULL, 36 mptt_right int(11) NOT NULL, 35 37 KEY date_recorded (date_recorded), 36 38 KEY user_id (user_id), … … 224 226 */ 225 227 228 function bp_activity_get_sitewide( $args = '' ) { 229 $defaults = array( 230 'max' => false, // Maximum number of results to return 231 'page' => 1, // page 1 without a per_page will result in no pagination. 232 'per_page' => false, // results per page 233 'sort' => 'DESC', // sort ASC or DESC 234 'display_comments' => false, // false for no comments. 'stream' for within stream display, 'threaded' for below each activity item 235 236 'search_terms' => false, // Pass search terms as a string 237 238 /** 239 * Pass filters as an array: 240 * array( 241 * 'user_id' => false, // user_id to filter on 242 * 'object' => false, // object to filter on e.g. groups, profile, status, friends 243 * 'action' => false, // action to filter on e.g. new_wire_post, new_forum_post, profile_updated 244 * 'primary_id' => false, // object ID to filter on e.g. a group_id or forum_id or blog_id etc. 245 * 'secondary_id' => false, // secondary object ID to filter on e.g. a post_id 246 * ); 247 */ 248 'filter' => array() 249 ); 250 251 $r = wp_parse_args( $args, $defaults ); 252 extract( $r, EXTR_SKIP ); 253 254 return apply_filters( 'bp_activity_get_sitewide', BP_Activity_Activity::get_sitewide_activity( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments ), &$r ); 255 } 256 257 function bp_activity_get_for_user( $args = '' ) { 258 global $bp; 259 260 $defaults = array( 261 'user_id' => $bp->displayed_user->id, 262 'max' => false, // Maximum number of results to return 263 'page' => 1, // page 1 without a per_page will result in no pagination. 264 'per_page' => false, // results per page 265 'sort' => 'DESC', // sort ASC or DESC 266 'display_comments' => 'stream', // false for no comments. 'stream' for within stream display, 'threaded' for below each activity item 267 268 'search_terms' => false, // Pass search terms as a string 269 'filter' => array() 270 ); 271 272 $r = wp_parse_args( $args, $defaults ); 273 extract( $r, EXTR_SKIP ); 274 275 return apply_filters( 'bp_activity_get_for_user', BP_Activity_Activity::get_activity_for_user( $user_id, $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments ), &$r ); 276 } 277 278 function bp_activity_get_friends_activity( $user_id, $max = 30, $max_items_per_friend = false, $pag_num = false, $pag_page = false, $filter = false ) { 279 return apply_filters( 'bp_activity_get_friends_activity', BP_Activity_Activity::get_activity_for_friends( $user_id, $max_items, $max_items_per_friend, $pag_num, $pag_page, $filter ), $user_id, $max_items, $max_items_per_friend, $pag_num, $pag_page, $filter ); 280 } 281 282 function bp_activity_get_specific( $args = '' ) { 283 $defaults = array( 284 'activity_ids' => false, // A single activity_id or array of IDs. 285 'max' => false, // Maximum number of results to return 286 'page' => 1, // page 1 without a per_page will result in no pagination. 287 'per_page' => false, // results per page 288 'sort' => 'DESC', // sort ASC or DESC 289 'display_comments' => false // true or false to display threaded comments for these specific activity items 290 ); 291 292 $r = wp_parse_args( $args, $defaults ); 293 extract( $r, EXTR_SKIP ); 294 295 return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get_specific( $activity_ids, $max, $page, $per_page, $sort, $display_comments ) ); 296 } 297 226 298 function bp_activity_add( $args = '' ) { 227 299 global $bp, $wpdb; … … 247 319 $content = bp_activity_add_timesince_placeholder( $content ); 248 320 249 $activity = new BP_Activity_Activity; 321 /* Pass certain values so we can update an activity item if it already exists */ 322 $activity = new BP_Activity_Activity(); 323 250 324 $activity->user_id = $user_id; 251 325 $activity->content = $content; … … 261 335 return false; 262 336 263 do_action( 'bp_activity_add', $args ); 264 265 return true; 337 /* If this is an activity comment, rebuild the tree */ 338 if ( 'activity_comment' == $activity->component_action ) 339 BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id ); 340 341 do_action( 'bp_activity_add', $r ); 342 343 return $activity->id; 266 344 } 267 345 … … 374 452 } 375 453 376 function bp_activity_get_sitewide_activity( $max_items = 30, $pag_num = false, $pag_page = false, $filter = false ) {377 return apply_filters( 'bp_activity_get_sitewide_activity', BP_Activity_Activity::get_sitewide_activity( $max_items, $pag_num, $pag_page, $filter ), $max_items, $pag_num, $pag_page, $filter );378 }379 380 function bp_activity_get_user_activity( $user_id, $max_items = 30, $pag_num = false, $pag_page = false, $filter = false ) {381 return apply_filters( 'bp_activity_get_user_activity', BP_Activity_Activity::get_activity_for_user( $user_id, $max_items, $pag_num, $pag_page, $filter ), $user_id, $max_items, $pag_num, $pag_page, $filter );382 }383 384 function bp_activity_get_friends_activity( $user_id, $max_items = 30, $max_items_per_friend = false, $pag_num = false, $pag_page = false, $filter = false ) {385 return apply_filters( 'bp_activity_get_friends_activity', BP_Activity_Activity::get_activity_for_friends( $user_id, $max_items, $max_items_per_friend, $pag_num, $pag_page, $filter ), $user_id, $max_items, $max_items_per_friend, $pag_num, $pag_page, $filter );386 }387 388 454 function bp_activity_remove_data( $user_id ) { 389 455 // Clear the user's activity from the sitewide stream and clear their activity tables -
trunk/bp-activity/bp-activity-classes.php
r2077 r2088 26 26 $activity = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) ); 27 27 28 $this->id = $activity->id; 29 $this->item_id = $activity->item_id; 30 $this->secondary_item_id = $activity->secondary_item_id; 31 $this->user_id = $activity->user_id; 32 $this->content = $activity->content; 33 $this->primary_link = $activity->primary_link; 34 $this->component_name = $activity->component_name; 35 $this->component_action = $activity->component_action; 36 $this->date_recorded = $activity->date_recorded; 37 $this->hide_sitewide = $activity->hide_sitewide; 28 if ( $activity ) { 29 $this->id = $activity->id; 30 $this->item_id = $activity->item_id; 31 $this->secondary_item_id = $activity->secondary_item_id; 32 $this->user_id = $activity->user_id; 33 $this->content = $activity->content; 34 $this->primary_link = $activity->primary_link; 35 $this->component_name = $activity->component_name; 36 $this->component_action = $activity->component_action; 37 $this->date_recorded = $activity->date_recorded; 38 $this->hide_sitewide = $activity->hide_sitewide; 39 } 38 40 } 39 41 … … 63 65 $this->primary_link = $bp->loggedin_user->domain; 64 66 65 if ( $existing_activity_id = $this->exists() )66 BP_Activity_Activity::delete_by_activity_id( $existing_activity_id );67 68 67 /* If we have an existing ID, update the activity item, otherwise insert it. */ 69 if ( $this->id ) { 70 if ( $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component_name = %s, component_action = %s, content = %s, primary_link = %s, date_recorded = FROM_UNIXTIME(%d), item_id = %s, secondary_item_id = %s, hide_sitewide = %d WHERE id = %d", $this->user_id, $this->component_name, $this->component_action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->id ) ) ) { 71 do_action( 'bp_activity_after_save', $this ); 72 return true; 73 } 74 } else { 75 if ( $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->activity->table_name} ( user_id, component_name, component_action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide ) VALUES ( %d, %s, %s, %s, %s, FROM_UNIXTIME(%d), %s, %s, %d )", $this->user_id, $this->component_name, $this->component_action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide ) ) ) { 76 do_action( 'bp_activity_after_save', $this ); 77 return true; 78 } 79 } 80 81 return false; 82 } 83 84 function exists() { 85 global $wpdb, $bp; 86 87 /* This doesn't seem to be working correctly at the moment, so it is disabled [TODO] */ 88 return false; 89 90 /* If we have an item id, try and match on that, if not do a content match */ 91 if ( $this->item_id ) { 92 if ( $this->secondary_item_id ) 93 $secondary_sql = $wpdb->prepare( " AND secondary_item_id = %s", $secondary_item_id ); 94 95 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND item_id = %s{$secondary_sql} AND component_name = %s AND component_action = %s", $this->user_id, $this->item_id, $this->component_name, $this->component_action ) ); 96 } else { 97 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $this->user_id, $this->content, $this->component_name, $this->component_action ) ); 98 } 68 if ( $this->id ) 69 $q = $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component_name = %s, component_action = %s, content = %s, primary_link = %s, date_recorded = FROM_UNIXTIME(%d), item_id = %s, secondary_item_id = %s, hide_sitewide = %d WHERE id = %d", $this->user_id, $this->component_name, $this->component_action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->id ); 70 else 71 $q = $wpdb->prepare( "INSERT INTO {$bp->activity->table_name} ( user_id, component_name, component_action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide ) VALUES ( %d, %s, %s, %s, %s, FROM_UNIXTIME(%d), %s, %s, %d )", $this->user_id, $this->component_name, $this->component_action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide ); 72 73 if ( !$wpdb->query( $q ) ) 74 return false; 75 76 $this->id = $wpdb->insert_id; 77 78 do_action( 'bp_activity_after_save', $this ); 79 return true; 99 80 } 100 81 … … 144 125 } 145 126 146 function get_activity_for_user( $user_id, $max_items, $limit, $page, $filter ) { 147 global $wpdb, $bp; 127 function get_activity_for_user( $user_id, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false ) { 128 global $wpdb, $bp; 129 130 if ( $limit && $page ) 131 $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 132 133 if ( $max ) 134 $max_sql = $wpdb->prepare( "LIMIT %d", $max ); 135 136 /* Searching */ 137 if ( $search_terms ) { 138 $search_terms = $wpdb->escape( $search_terms ); 139 $search_sql = "AND content LIKE '%%" . like_escape( $search_terms ) . "%%'"; 140 } 141 142 /* Filtering */ 143 if ( $filter ) 144 $filter_sql = BP_Activity_Activity::get_filter_sql( $filter ); 145 146 /* Sorting */ 147 if ( $sort != 'ASC' && $sort != 'DESC' ) 148 $sort = 'DESC'; 149 150 /* Alter the query based on whether we want to show activity item comments in the stream like normal comments or threaded below the activity */ 151 if ( !$display_comments || 'threaded' == $display_comments ) { 152 if ( $per_page && $page && $max ) 153 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d {$search_sql} {$filter_sql} AND component_action != 'activity_comment' ORDER BY date_recorded {$sort} {$pag_sql}", $user_id ) ); 154 else 155 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d {$search_sql} {$filter_sql} AND component_action != 'activity_comment' ORDER BY date_recorded {$sort} {$pag_sql} {$max_sql}", $user_id ) ); 156 157 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE user_id = %d {$search_sql} {$filter_sql} AND component_action != 'activity_comment' ORDER BY date_recorded {$sort} {$max_sql}", $user_id ) ); 158 159 if ( $activities && $display_comments ) 160 $activities = BP_Activity_Activity::append_comments( &$activities ); 161 } else { 162 if ( $per_page && $page && $max ) 163 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d {$search_sql} {$filter_sql} ORDER BY date_recorded {$sort} {$pag_sql}", $user_id ) ); 164 else 165 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d {$search_sql} {$filter_sql} ORDER BY date_recorded {$sort} {$pag_sql} {$max_sql}", $user_id ) ); 166 167 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE user_id = %d {$search_sql} {$filter_sql} ORDER BY date_recorded {$sort} {$max_sql}", $user_id ) ); 168 169 if ( $activities ) 170 $activities = BP_Activity_Activity::append_comments( &$activities ); 171 } 172 173 return array( 'activities' => $activities, 'total' => (int)$total_activities ); 174 } 175 176 function get_activity_for_friends( $user_id, $max_items, $max_items_per_friend, $limit, $page, $filter ) { 177 global $wpdb, $bp; 178 179 // TODO: Max items per friend not yet implemented. 180 181 if ( !function_exists('friends_get_friend_user_ids') ) 182 return false; 148 183 149 184 if ( $limit && $page ) … … 157 192 $filter_sql = BP_Activity_Activity::get_filter_sql( $filter ); 158 193 159 if ( $limit && $page && $max_items )160 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $pag_sql", $user_id ) );161 else162 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql", $user_id ) );163 164 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $max_sql", $user_id ) );165 166 return array( 'activities' => $activities, 'total' => (int)$total_activities );167 }168 169 function get_activity_for_friends( $user_id, $max_items, $max_items_per_friend, $limit, $page, $filter ) {170 global $wpdb, $bp;171 172 // TODO: Max items per friend not yet implemented.173 174 if ( !function_exists('friends_get_friend_user_ids') )175 return false;176 177 if ( $limit && $page )178 $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );179 180 if ( $max_items )181 $max_sql = $wpdb->prepare( "LIMIT %d", $max_items );182 183 /* Sort out filtering */184 if ( $filter )185 $filter_sql = BP_Activity_Activity::get_filter_sql( $filter );186 187 194 $friend_ids = friends_get_friend_user_ids( $user_id ); 188 195 … … 190 197 return false; 191 198 192 $friend_ids = implode( ',', $friend_ids);199 $friend_ids = $wpdb->escape( implode( ',', $friend_ids ) ); 193 200 194 201 if ( $limit && $page && $max_items ) … … 202 209 } 203 210 204 function get_sitewide_activity( $max , $limit, $page, $filter) {205 global $wpdb, $bp; 206 207 if ( $ limit&& $page )208 $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $ limit), intval( $limit) );211 function get_sitewide_activity( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false ) { 212 global $wpdb, $bp; 213 214 if ( $per_page && $page ) 215 $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) ); 209 216 210 217 if ( $max ) 211 218 $max_sql = $wpdb->prepare( "LIMIT %d", $max ); 212 219 213 /* Sort out filtering */ 220 /* Searching */ 221 if ( $search_terms ) { 222 $search_terms = $wpdb->escape( $search_terms ); 223 $search_sql = "AND content LIKE '%%" . like_escape( $search_terms ) . "%%'"; 224 } 225 226 /* Filtering */ 214 227 if ( $filter ) 215 228 $filter_sql = BP_Activity_Activity::get_filter_sql( $filter ); 216 229 217 if ( $limit && $page && $max ) 218 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 $filter_sql ORDER BY date_recorded DESC $pag_sql" ) ); 230 /* Sorting */ 231 if ( $sort != 'ASC' && $sort != 'DESC' ) 232 $sort = 'DESC'; 233 234 /* Alter the query based on whether we want to show activity item comments in the stream like normal comments or threaded below the activity */ 235 if ( !$display_comments || 'threaded' == $display_comments ) { 236 if ( $per_page && $page && $max ) 237 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 {$search_sql} {$filter_sql} AND component_action != 'activity_comment' ORDER BY date_recorded {$sort} {$pag_sql}" ) ); 238 else 239 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 {$search_sql} {$filter_sql} AND component_action != 'activity_comment' ORDER BY date_recorded {$sort} {$pag_sql} {$max_sql}" ) ); 240 241 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 {$search_sql} {$filter_sql} AND component_action != 'activity_comment' ORDER BY date_recorded {$sort} {$max_sql}" ) ); 242 243 if ( $activities && $display_comments ) 244 $activities = BP_Activity_Activity::append_comments( &$activities ); 245 } else { 246 if ( $per_page && $page && $max ) 247 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 {$search_sql} {$filter_sql} ORDER BY date_recorded {$sort} {$pag_sql}" ) ); 248 else 249 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 {$search_sql} {$filter_sql} ORDER BY date_recorded {$sort} {$pag_sql} {$max_sql}" ) ); 250 251 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 {$search_sql} {$filter_sql} ORDER BY date_recorded {$sort} {$max_sql}" ) ); 252 253 if ( $activities ) 254 $activities = BP_Activity_Activity::append_comments( &$activities ); 255 } 256 257 return array( 'activities' => $activities, 'total' => (int)$total_activities ); 258 } 259 260 function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) { 261 global $wpdb, $bp; 262 263 if ( is_array( $activity_ids ) ) 264 $activity_ids = implode( ',', $activity_ids ); 265 266 $activity_ids = $wpdb->escape( $activity_ids ); 267 268 if ( $per_page && $page ) 269 $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) ); 270 271 if ( $max ) 272 $max_sql = $wpdb->prepare( "LIMIT %d", $max ); 273 274 if ( $sort != 'ASC' && $sort != 'DESC' ) 275 $sort = 'DESC'; 276 277 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$activity_ids}) ORDER BY date_recorded {$sort} $pag_sql $max_sql" ) ); 278 $total_activities = $wpdb->get_results( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE id IN ({$activity_ids}) ORDER BY date_recorded {$sort}" ) ); 279 280 if ( $display_comments ) 281 $activities = BP_Activity_Activity::append_comments( $activities ); 282 283 return array( 'activities' => $activities, 'total' => (int)$total_activities ); 284 } 285 286 function append_comments( $activities ) { 287 global $bp, $wpdb; 288 289 /* Now fetch the activity comments and parse them into the correct position in the activities array. */ 290 foreach( $activities as $activity ) { 291 if ( 'activity_comment' != $activity->component_action ) 292 $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right ); 293 } 294 295 /* Merge the comments with the activity items */ 296 foreach( $activities as $key => $activity ) 297 $activities[$key]->children = $activity_comments[$activity->id]; 298 299 return $activities; 300 } 301 302 function get_activity_comments( $activity_id, $left, $right ) { 303 global $wpdb, $bp; 304 305 /* Start with an empty $stack */ 306 $stack = array(); 307 308 /* Retrieve all descendants of the $root node */ 309 $descendants = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE component_action = 'activity_comment' AND item_id = %d AND mptt_left BETWEEN %d AND %d", $activity_id, $left, $right ) ); 310 311 /* Loop descendants and build an assoc array */ 312 foreach ( $descendants as $d ) { 313 $d->children = array(); 314 315 /* We have a reference on its parent */ 316 if ( isset( $ref[ $d->secondary_item_id ] ) ) { 317 $ref[ $d->secondary_item_id ]->children[ $d->id ] = $d; 318 $ref[ $d->id ] =& $ref[ $d->secondary_item_id ]->children[ $d->id ]; 319 320 /* We don't have a reference on its parent, put it a root level */ 321 } else { 322 $menu[ $d->id ] = $d; 323 $ref[ $d->id ] =& $menu[ $d->id ]; 324 } 325 } 326 327 return $menu; 328 } 329 330 function rebuild_activity_comment_tree( $parent_id, $left = 1 ) { 331 global $wpdb, $bp; 332 333 /* The right value of this node is the left value + 1 */ 334 $right = $left + 1; 335 336 /* Get all descendants of this node */ 337 $descendants = $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE component_action = 'activity_comment' AND secondary_item_id = %d", $parent_id ) ); 338 339 /* Loop the descendants and recalculate the left and right values */ 340 foreach ( $descendants as $descendant ) 341 $right = BP_Activity_Activity::rebuild_activity_comment_tree( $descendant->id, $right ); 342 343 /* We've got the left value, and now that we've processed the children of this node we also know the right value */ 344 if ( 1 == $left ) 345 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE id = %d", $left, $right, $parent_id ) ); 219 346 else 220 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql" ) ); 221 222 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 $filter_sql ORDER BY date_recorded DESC $max_sql" ) ); 223 224 return array( 'activities' => $activities, 'total' => (int)$total_activities ); 347 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE component_action = 'activity_comment' AND id = %d", $left, $right, $parent_id ) ); 348 349 /* Return the right value of this node + 1 */ 350 return $right + 1; 225 351 } 226 352 … … 234 360 global $wpdb, $bp; 235 361 236 $activities = bp_activity_get_sitewide_activity( $limit ); 362 $activities = bp_activity_get_sitewide( array( 'max' => $limit ) ); 363 237 364 for ( $i = 0; $i < count($activities); $i++ ) { 238 365 $title = explode( '<span', $activities[$i]['content'] ); -
trunk/bp-activity/bp-activity-filters.php
r2077 r2088 19 19 $activity_allowedtags['span'] = array(); 20 20 $activity_allowedtags['span']['class'] = array(); 21 $activity_allowedtags['div'] = array(); 22 $activity_allowedtags['div']['class'] = array(); 23 $activity_allowedtags['div']['id'] = array(); 21 24 $activity_allowedtags['a']['class'] = array(); 22 25 $activity_allowedtags['img'] = array(); -
trunk/bp-activity/bp-activity-templatetags.php
r2077 r2088 17 17 var $full_name; 18 18 19 function bp_activity_template( $type, $user_id, $per_page, $max, $ filter) {19 function bp_activity_template( $type, $user_id, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments ) { 20 20 global $bp; 21 21 … … 24 24 $this->activity_type = $type; 25 25 26 if ( $type == 'sitewide' ) 27 $this->activities = bp_activity_get_sitewide_activity( $max, $this->pag_num, $this->pag_page, $filter ); 28 29 if ( $type == 'personal' ) 30 $this->activities = bp_activity_get_user_activity( $user_id, $max, $this->pag_num, $this->pag_page, $filter ); 31 32 if ( $type == 'friends' && ( bp_is_home() || is_site_admin() || $bp->loggedin_user->id == $user_id ) ) 33 $this->activities = bp_activity_get_friends_activity( $user_id, $max, false, $this->pag_num, $this->pag_page, $filter ); 26 if ( !empty( $include ) ) { 27 /* Fetch specific activity items based on ID's */ 28 $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $page, 'per_page' => $per_page, 'sort' => $sort, 'display_comments' => $display_comments ) ); 29 } else { 30 if ( $type == 'sitewide' ) 31 $this->activities = bp_activity_get_sitewide( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter ) ); 32 33 if ( $type == 'personal' ) 34 $this->activities = bp_activity_get_for_user( array( 'user_id' => $user_id, 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter ) ); 35 36 if ( $type == 'friends' && ( bp_is_home() || is_site_admin() || $bp->loggedin_user->id == $user_id ) ) 37 $this->activities = bp_activity_get_friends_activity( $user_id, $max, false, $this->pag_num, $this->pag_page, $filter ); 38 } 34 39 35 40 if ( !$max || $max >= (int)$this->activities['total'] ) … … 119 124 $defaults = array( 120 125 'type' => 'sitewide', 121 'per_page' => 25, 122 'max' => false, 126 'display_comments' => false, // false for none, stream/threaded - show comments in the stream or threaded under items 127 'include' => false, // pass an activity_id or string of ID's comma separated 128 'sort' => 'DESC', // sort DESC or ASC 129 'per_page' => 25, // number of items per page 130 'max' => false, // max number to return 131 132 /* Filtering */ 123 133 'user_id' => false, // user_id to filter on 124 134 'object' => false, // object to filter on e.g. groups, profile, status, friends … … 126 136 'primary_id' => false, // object ID to filter on e.g. a group_id or forum_id or blog_id etc. 127 137 'secondary_id' => false, // secondary object ID to filter on e.g. a post_id 138 139 /* Searching */ 140 'search_terms' => false // specify terms to search on 128 141 ); 129 142 … … 144 157 $filter = array( 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id ); 145 158 146 $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $filter ); 159 $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments ); 160 147 161 return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template ); 148 162 } … … 197 211 198 212 return apply_filters( 'bp_get_activities_no_activity', $bp_activity_no_activity ); 213 } 214 215 function bp_activity_id() { 216 echo bp_get_activity_id(); 217 } 218 function bp_get_activity_id() { 219 global $activities_template; 220 return apply_filters( 'bp_get_activity_id', $activities_template->activity->id ); 221 } 222 223 function bp_activity_item_id() { 224 echo bp_get_activity_item_id(); 225 } 226 function bp_get_activity_item_id() { 227 global $activities_template; 228 return apply_filters( 'bp_get_activity_item_id', $activities_template->activity->item_id ); 229 } 230 231 function bp_activity_secondary_item_id() { 232 echo bp_get_activity_secondary_item_id(); 233 } 234 function bp_get_activity_secondary_item_id() { 235 global $activities_template; 236 return apply_filters( 'bp_get_activity_secondary_item_id', $activities_template->activity->secondary_item_id ); 237 } 238 239 function bp_activity_date_recorded() { 240 echo bp_get_activity_date_recorded(); 241 } 242 function bp_get_activity_date_recorded() { 243 global $activities_template; 244 return apply_filters( 'bp_get_activity_date_recorded', $activities_template->activity->date_recorded ); 245 } 246 247 function bp_activity_object_name() { 248 echo bp_get_activity_object_name(); 249 } 250 function bp_get_activity_object_name() { 251 global $activities_template; 252 return apply_filters( 'bp_get_activity_object_name', $activities_template->activity->component_name ); 253 } 254 255 function bp_activity_action_name() { 256 echo bp_get_activity_action_name(); 257 } 258 function bp_get_activity_action_name() { 259 global $activities_template; 260 return apply_filters( 'bp_get_activity_action_name', $activities_template->activity->component_action ); 199 261 } 200 262 … … 255 317 $content = apply_filters( 'the_content', $content ); 256 318 257 return apply_filters( 'bp_get_activity_content', $content );319 return apply_filters( 'bp_get_activity_content', $content, $activities_template->activity->component_name, $activities_template->activity->component_action ); 258 320 } 259 321 … … 299 361 return apply_filters( 'bp_activity_content_filter', $content_new ); 300 362 } 363 364 function bp_activity_comments( $args = '' ) { 365 echo bp_activity_get_comments( $args ); 366 } 367 function bp_activity_get_comments( $args = '' ) { 368 global $activities_template, $bp; 369 370 if ( !$activities_template->activity->children ) 371 return false; 372 373 $comments_html = bp_activity_recurse_comments( $activities_template->activity ); 374 375 return apply_filters( 'bp_activity_get_comments', $comments_html ); 376 } 377 /* The HTML in this function is temporary, it will be move to template tags once comments are working. */ 378 function bp_activity_recurse_comments( $comment ) { 379 global $activities_template, $bp; 380 381 if ( !$comment->children ) 382 return false; 383 384 $content .= '<ul>'; 385 foreach ( $comment->children as $comment ) { 386 $content .= '<li id="acomment-' . $comment->id . '">'; 387 388 $content .= '<div class="acomment-avatar">' . bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'width' => 25, 'height' => 25 ) ) . '</div>'; 389 390 $content .= '<div class="acomment-meta">' . bp_core_get_userlink( $comment->user_id ) . ' · ' . sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( strtotime( $comment->date_recorded ) ) ); 391 392 /* Reply link */ 393 if ( is_user_logged_in() ) 394 $content .= ' · <a href="#acomment-' . $comment->id . '" class="acomment-reply" id="acomment-reply-' . $activities_template->activity->id . '">' . __( 'Reply', 'buddypress' ) . '</a>'; 395 396 /* Delete link */ 397 if ( is_site_admin() || $bp->loggedin_user->id == $comment->user_id ) 398 $content .= ' · <a href="' . wp_nonce_url( $bp->activity->id . '/delete/?cid=' . $comment->id, 'delete_activity_comment' ) . '" class="delete acomment-delete">' . __( 'Delete', 'buddypress' ) . '</a>'; 399 400 $content .= '</div>'; 401 $content .= '<div class="acomment-content">' . apply_filters( 'bp_get_activity_content', $comment->content ) . '</div>'; 402 403 $content .= bp_activity_recurse_comments( $comment ); 404 $content .= '</li>'; 405 } 406 $content .= '</ul>'; 407 408 return $content; 409 } 301 410 302 411 function bp_activity_insert_time_since( $content, $date ) { … … 391 500 $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . attribute_escape( $link ) . '"">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>'; 392 501 393 return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) );502 return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) ); 394 503 } 395 504 -
trunk/bp-activity/deprecated/bp-activity-deprecated.php
r2077 r2088 93 93 add_action( 'bp_styles', 'bp_activity_add_structure_css' ); 94 94 95 /* DEPRECATED - use bp_activity_get_sitewide( $args ) */ 96 function bp_activity_get_sitewide_activity( $max_items = 30, $pag_num = false, $pag_page = false, $filter = false ) { 97 return apply_filters( 'bp_activity_get_sitewide_activity', bp_activity_get_sitewide( array( 'max' => $max_items, 'limit' => $pag_num, 'page' => $pag_page, 'filter' => $filter ) ), $max_items, $pag_num, $pag_page, $filter ); 98 } 99 100 /* DEPRECATED - use bp_activity_get_for_user( $args ) */ 101 function bp_activity_get_user_activity( $user_id, $max = 30, $pag_num = false, $pag_page = false, $filter = false ) { 102 return apply_filters( 'bp_activity_get_user_activity', BP_Activity_Activity::get_activity_for_user( $user_id, $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments ), $user_id, $max_items, $pag_num, $pag_page, $filter ); 103 } 104 105 95 106 ?> -
trunk/bp-blogs/bp-blogs-templatetags.php
r1949 r2088 5 5 function bp_blog_signup_enabled() { 6 6 $active_signup = get_site_option( 'registration' ); 7 7 8 8 if ( !$active_signup ) 9 9 $active_signup = 'all'; 10 10 11 11 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user" 12 12 13 13 if ( 'none' == $active_signup || 'user' == $active_signup ) 14 14 return false; 15 15 16 16 return true; 17 17 } … … 20 20 global $current_user, $current_site; 21 21 global $bp; 22 22 23 23 require_once( ABSPATH . WPINC . '/registration.php' ); 24 24 … … 48 48 <input type="hidden" name="stage" value="gimmeanotherblog" /> 49 49 <?php do_action( "signup_hidden_fields" ); ?> 50 50 51 51 <?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?> 52 52 <p> 53 53 <input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Create Blog »', 'buddypress') ?>" /> 54 54 </p> 55 55 56 56 <?php wp_nonce_field( 'bp_blog_signup_form' ) ?> 57 57 </form> … … 62 62 function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) { 63 63 global $current_site; 64 64 65 65 // Blog name 66 66 if( 'no' == constant( "VHOST" ) ) … … 90 90 // Blog Title 91 91 ?> 92 <label for="blog_title"><?php _e('Blog Title:', 'buddypress') ?></label> 92 <label for="blog_title"><?php _e('Blog Title:', 'buddypress') ?></label> 93 93 <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?> 94 94 <p class="error"><?php echo $errmsg ?></p> … … 99 99 <p> 100 100 <label for="blog_public_on"><?php _e('Privacy:', 'buddypress') ?></label> 101 <?php _e('I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress'); ?> 101 <?php _e('I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress'); ?> 102 102 103 103 … … 119 119 global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path; 120 120 121 if ( !check_admin_referer( 'bp_blog_signup_form' ) ) 121 if ( !check_admin_referer( 'bp_blog_signup_form' ) ) 122 122 return false; 123 123 124 124 $current_user = wp_get_current_user(); 125 125 126 126 if( !is_user_logged_in() ) 127 127 die(); … … 137 137 138 138 $public = (int) $_POST['blog_public']; 139 139 140 140 $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated 141 141 $meta = apply_filters( 'add_signup_meta', $meta ); 142 142 143 143 /* If this is a VHOST install, remove the username from the domain as we are setting this blog 144 144 up inside a user domain, not the root domain. */ 145 145 146 146 wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid ); 147 147 bp_blogs_confirm_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta); … … 169 169 function bp_create_blog_link() { 170 170 global $bp; 171 171 172 172 if ( bp_is_home() ) { 173 173 echo apply_filters( 'bp_create_blog_link', '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog', 'buddypress') . '</a>' ); … … 177 177 function bp_blogs_blog_tabs() { 178 178 global $bp, $groups_template; 179 179 180 180 // Don't show these tabs on a user's own profile 181 181 if ( bp_is_home() ) 182 182 return false; 183 183 184 184 $current_tab = $bp->current_action 185 185 ?> … … 187 187 <li<?php if ( 'my-blogs' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/my-blogs"><?php printf( __( "%s's Blogs", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li> 188 188 <li<?php if ( 'recent-posts' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-posts"><?php printf( __( "%s's Recent Posts", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li> 189 <li<?php if ( 'recent-comments' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-comments"><?php printf( __( "%s's Recent Comments", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li> 189 <li<?php if ( 'recent-comments' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-comments"><?php printf( __( "%s's Recent Comments", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li> 190 190 </ul> 191 191 <?php … … 202 202 var $blogs; 203 203 var $blog; 204 204 205 205 var $in_the_loop; 206 206 207 207 var $pag_page; 208 208 var $pag_num; 209 209 var $pag_links; 210 210 var $total_blog_count; 211 211 212 212 function bp_blogs_user_blogs_template( $user_id, $per_page, $max ) { 213 213 global $bp; 214 214 215 215 if ( !$user_id ) 216 216 $user_id = $bp->displayed_user->id; … … 223 223 wp_cache_set( 'bp_blogs_for_user_' . $user_id, $this->blogs, 'bp' ); 224 224 } 225 225 226 226 if ( !$max || $max >= (int)$this->blogs['count'] ) 227 227 $this->total_blog_count = (int)$this->blogs['count']; 228 228 else 229 229 $this->total_blog_count = (int)$max; 230 230 231 231 $this->blogs = array_slice( (array)$this->blogs['blogs'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) ); 232 232 233 233 if ( $max ) { 234 234 if ( $max >= count($this->blogs) ) … … 239 239 $this->blog_count = count($this->blogs); 240 240 } 241 241 242 242 $this->pag_links = paginate_links( array( 243 243 'base' => add_query_arg( 'fpage', '%#%' ), … … 250 250 )); 251 251 } 252 252 253 253 function has_blogs() { 254 254 if ( $this->blog_count ) 255 255 return true; 256 256 257 257 return false; 258 258 } 259 259 260 260 function next_blog() { 261 261 $this->current_blog++; 262 262 $this->blog = $this->blogs[$this->current_blog]; 263 263 264 264 return $this->blog; 265 265 } 266 266 267 267 function rewind_blogs() { 268 268 $this->current_blog = -1; … … 271 271 } 272 272 } 273 274 function user_blogs() { 273 274 function user_blogs() { 275 275 if ( $this->current_blog + 1 < $this->blog_count ) { 276 276 return true; … … 284 284 return false; 285 285 } 286 286 287 287 function the_blog() { 288 288 global $blog; … … 290 290 $this->in_the_loop = true; 291 291 $blog = $this->next_blog(); 292 292 293 293 if ( 0 == $this->current_blog ) // loop has just started 294 294 do_action('loop_start'); … … 324 324 function bp_blogs_pagination_count() { 325 325 global $bp, $blogs_template; 326 326 327 327 $from_num = intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1; 328 328 $to_num = ( $from_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $from_num + ( $blogs_template->pag_num - 1 ) ; … … 346 346 function bp_get_blog_title() { 347 347 global $blogs_template; 348 349 return apply_filters( 'bp_get_blog_title', $blogs_template->blog ['title']);348 349 return apply_filters( 'bp_get_blog_title', $blogs_template->blog->name ); 350 350 } 351 351 … … 355 355 function bp_get_blog_description() { 356 356 global $blogs_template; 357 358 return apply_filters( 'bp_get_blog_description', $blogs_template->blog ['description']);357 358 return apply_filters( 'bp_get_blog_description', $blogs_template->blog->description ); 359 359 } 360 360 … … 363 363 } 364 364 function bp_get_blog_permalink() { 365 global $blogs_template; 366 367 return apply_filters( 'bp_get_blog_permalink', $blogs_template->blog ['siteurl']);365 global $blogs_template; 366 367 return apply_filters( 'bp_get_blog_permalink', $blogs_template->blog->siteurl ); 368 368 } 369 369 … … 378 378 var $posts; 379 379 var $post; 380 380 381 381 var $in_the_loop; 382 382 383 383 var $pag_page; 384 384 var $pag_num; 385 385 var $pag_links; 386 386 var $total_post_count; 387 387 388 388 function bp_blogs_blog_post_template( $user_id, $per_page, $max ) { 389 389 global $bp; 390 390 391 391 if ( !$user_id ) 392 392 $user_id = $bp->displayed_user->id; … … 394 394 $this->pag_page = isset( $_GET['fpage'] ) ? intval( $_GET['fpage'] ) : 1; 395 395 $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page; 396 396 397 397 if ( !$this->posts = wp_cache_get( 'bp_user_posts_' . $user_id, 'bp' ) ) { 398 398 $this->posts = bp_blogs_get_posts_for_user( $user_id ); 399 399 wp_cache_set( 'bp_user_posts_' . $user_id, $this->posts, 'bp' ); 400 400 } 401 401 402 402 if ( !$max || $max >= (int)$this->posts['count'] ) 403 403 $this->total_post_count = (int)$this->posts['count']; 404 404 else 405 405 $this->total_post_count = (int)$max; 406 406 407 407 $this->posts = array_slice( (array)$this->posts['posts'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) ); 408 408 … … 415 415 $this->post_count = count($this->posts); 416 416 } 417 417 418 418 $this->pag_links = paginate_links( array( 419 419 'base' => add_query_arg( 'fpage', '%#%' ), … … 424 424 'next_text' => '»', 425 425 'mid_size' => 1 426 )); 427 } 428 426 )); 427 } 428 429 429 function has_posts() { 430 430 if ( $this->post_count ) 431 431 return true; 432 432 433 433 return false; 434 434 } 435 435 436 436 function next_post() { 437 437 $this->current_post++; 438 438 $this->post = $this->posts[$this->current_post]; 439 439 440 440 return $this->post; 441 441 } 442 442 443 443 function rewind_posts() { 444 444 $this->current_post = -1; … … 447 447 } 448 448 } 449 450 function user_posts() { 449 450 function user_posts() { 451 451 if ( $this->current_post + 1 < $this->post_count ) { 452 452 return true; … … 460 460 return false; 461 461 } 462 462 463 463 function the_post() { 464 464 global $post; … … 466 466 $this->in_the_loop = true; 467 467 $post = $this->next_post(); 468 468 469 469 if ( 0 == $this->current_post ) // loop has just started 470 470 do_action('loop_start'); … … 484 484 extract( $r, EXTR_SKIP ); 485 485 486 $posts_template = new BP_Blogs_Blog_Post_Template( $user_id, $per_page, $max ); 486 $posts_template = new BP_Blogs_Blog_Post_Template( $user_id, $per_page, $max ); 487 487 return apply_filters( 'bp_has_posts', $posts_template->has_posts(), &$posts_template ); 488 488 } … … 500 500 function bp_post_pagination_count() { 501 501 global $bp, $posts_template; 502 502 503 503 $from_num = intval( ( $posts_template->pag_page - 1 ) * $posts_template->pag_num ) + 1; 504 504 $to_num = ( $from_num + ( $posts_template->pag_num - 1 ) > $posts_template->total_post_count ) ? $posts_template->total_post_count : $from_num + ( $posts_template->pag_num - 1 ) ; … … 522 522 function bp_get_post_id() { 523 523 global $posts_template; 524 return apply_filters( 'bp_get_post_id', $posts_template->post->ID ); 525 } 526 524 return apply_filters( 'bp_get_post_id', $posts_template->post->ID ); 525 } 526 527 527 function bp_post_title( $deprecated = true ) { 528 528 if ( !$deprecated ) … … 533 533 function bp_get_post_title() { 534 534 global $posts_template; 535 535 536 536 return apply_filters( 'bp_get_post_title', $posts_template->post->post_title ); 537 537 } … … 539 539 function bp_post_permalink() { 540 540 global $posts_template; 541 542 echo bp_post_get_permalink(); 541 542 echo bp_post_get_permalink(); 543 543 } 544 544 545 545 function bp_post_excerpt() { 546 echo bp_get_post_excerpt(); 546 echo bp_get_post_excerpt(); 547 547 } 548 548 function bp_get_post_excerpt() { 549 549 global $posts_template; 550 echo apply_filters( 'bp_get_post_excerpt', $posts_template->post->post_excerpt ); 550 echo apply_filters( 'bp_get_post_excerpt', $posts_template->post->post_excerpt ); 551 551 } 552 552 … … 567 567 function bp_get_post_status() { 568 568 global $posts_template; 569 return apply_filters( 'bp_get_post_status', $posts_template->post->post_status ); 570 } 571 569 return apply_filters( 'bp_get_post_status', $posts_template->post->post_status ); 570 } 571 572 572 function bp_post_date( $date_format = null, $deprecated = true ) { 573 573 if ( !$date_format ) 574 574 $date_format = get_option('date_format'); 575 575 576 576 if ( !$deprecated ) 577 577 return bp_get_post_date( $date_format ); … … 593 593 function bp_get_post_comment_count() { 594 594 global $posts_template; 595 return apply_filters( 'bp_get_post_comment_count', $posts_template->post->comment_count ); 595 return apply_filters( 'bp_get_post_comment_count', $posts_template->post->comment_count ); 596 596 } 597 597 598 598 function bp_post_comments( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $css_class = '', $none = 'Comments Off' ) { 599 599 global $posts_template, $wpdb; 600 600 601 601 $number = (int)$posts_template->post->comment_count; 602 602 603 603 if ( 0 == $number && 'closed' == $posts_template->postcomment_status && 'closed' == $posts_template->postping_status ) { 604 604 echo '<span' . ((!empty($css_class)) ? ' class="' . $css_class . '"' : '') . '>' . $none . '</span>'; … … 614 614 615 615 echo '<a href="'; 616 616 617 617 if ( 0 == $number ) 618 618 echo bp_post_get_permalink() . '#respond'; … … 620 620 echo bp_post_get_permalink() . '#comments'; 621 621 echo '"'; 622 622 623 623 if ( !empty( $css_class ) ) { 624 624 echo ' class="'.$css_class.'" '; … … 629 629 630 630 echo ' title="' . sprintf( __('Comment on %s', 'buddypress'), $title ) . '">'; 631 631 632 632 if ( 1 == $number ) 633 633 printf( __( '%d Comment', 'buddypress' ), $number ); 634 634 else 635 635 printf( __( '%d Comments', 'buddypress' ), $number ); 636 636 637 637 echo '</a>'; 638 638 } … … 646 646 function bp_get_post_author() { 647 647 global $posts_template; 648 648 649 649 return apply_filters( 'bp_get_post_author', bp_core_get_userlink( $posts_template->post->post_author ) ); 650 650 } … … 664 664 $post_id = $posts_template->post->ID; 665 665 666 return apply_filters( 'bp_get_post_category', get_the_category_list( $separator, $parents, $post_id ) ); 666 return apply_filters( 'bp_get_post_category', get_the_category_list( $separator, $parents, $post_id ) ); 667 667 } 668 668 669 669 function bp_post_tags( $before = '', $sep = ', ', $after = '' ) { 670 670 global $posts_template, $wpdb; 671 671 672 672 /* Disabling this for now as it's too expensive and there is no global tags directory */ 673 673 return false; 674 674 675 675 switch_to_blog( $posts_template->post->blog_id ); 676 676 $terms = bp_post_get_term_list( $before, $sep, $after ); … … 692 692 function bp_get_post_blog_name() { 693 693 global $posts_template; 694 return apply_filters( 'bp_get_post_blog_name', get_blog_option( $posts_template->post->blog_id, 'blogname' ) ); 694 return apply_filters( 'bp_get_post_blog_name', get_blog_option( $posts_template->post->blog_id, 'blogname' ) ); 695 695 } 696 696 697 697 function bp_post_blog_permalink() { 698 echo bp_get_post_blog_permalink(); 698 echo bp_get_post_blog_permalink(); 699 699 } 700 700 function bp_get_post_blog_permalink() { 701 701 global $posts_template; 702 return apply_filters( 'bp_get_post_blog_permalink', get_blog_option( $posts_template->post->blog_id, 'siteurl' ) ); 703 } 704 702 return apply_filters( 'bp_get_post_blog_permalink', get_blog_option( $posts_template->post->blog_id, 'siteurl' ) ); 703 } 704 705 705 function bp_post_get_permalink( $post = null, $blog_id = null ) { 706 706 global $current_blog, $posts_template; 707 707 708 708 if ( !$post ) 709 $post = $posts_template->post; 710 709 $post = $posts_template->post; 710 711 711 if ( !$blog_id ) 712 712 $blog_id = $posts_template->post->blog_id; 713 713 714 714 if ( !$post || !$blog_id ) 715 715 return false; 716 716 717 717 $rewritecode = array( 718 718 '%year%', … … 735 735 736 736 $permalink = get_blog_option( $blog_id, 'permalink_structure' ); 737 $site_url = get_blog_option( $blog_id, 'siteurl' ); 737 $site_url = get_blog_option( $blog_id, 'siteurl' ); 738 738 739 739 if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending')) ) { … … 753 753 if ( empty($category) ) { 754 754 $default_category = get_category( get_option( 'default_category' ) ); 755 $category = is_wp_error( $default_category ) ? '' : $default_category->slug; 755 $category = is_wp_error( $default_category ) ? '' : $default_category->slug; 756 756 } 757 757 } … … 789 789 function bp_post_get_term_list( $before = '', $sep = '', $after = '' ) { 790 790 global $posts_template; 791 791 792 792 $terms = get_the_terms( $posts_template->post->ID, 'post_tag' ); 793 793 … … 801 801 $link = get_blog_option( BP_ROOT_BLOG, 'siteurl') . '/tag/' . $term->slug; 802 802 $link = apply_filters('term_link', $link); 803 803 804 804 $term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>'; 805 805 } … … 820 820 var $comments; 821 821 var $comment; 822 822 823 823 var $in_the_loop; 824 824 825 825 var $pag_page; 826 826 var $pag_num; 827 827 var $pag_links; 828 828 var $total_comment_count; 829 829 830 830 function bp_blogs_post_comment_template( $user_id, $per_page, $max ) { 831 831 global $bp; 832 832 833 833 if ( !$user_id ) 834 834 $user_id = $bp->displayed_user->id; … … 836 836 $this->pag_page = isset( $_GET['compage'] ) ? intval( $_GET['compage'] ) : 1; 837 837 $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page; 838 838 839 839 if ( !$this->comments = wp_cache_get( 'bp_user_comments_' . $user_id, 'bp' ) ) { 840 840 $this->comments = bp_blogs_get_comments_for_user( $user_id ); 841 841 wp_cache_set( 'bp_user_comments_' . $user_id, $this->comments, 'bp' ); 842 842 } 843 843 844 844 if ( !$max || $max >= (int)$this->comments['count'] ) 845 845 $this->total_comment_count = (int)$this->comments['count']; 846 846 else 847 847 $this->total_comment_count = (int)$max; 848 848 849 849 $this->comments = array_slice( (array)$this->comments['comments'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) ); 850 850 … … 857 857 $this->comment_count = count($this->comments); 858 858 } 859 859 860 860 $this->pag_links = paginate_links( array( 861 861 'base' => add_query_arg( 'compage', '%#%' ), … … 867 867 'mid_size' => 1 868 868 )); 869 870 } 871 869 870 } 871 872 872 function has_comments() { 873 873 if ( $this->comment_count ) 874 874 return true; 875 875 876 876 return false; 877 877 } 878 878 879 879 function next_comment() { 880 880 $this->current_comment++; 881 881 $this->comment = $this->comments[$this->current_comment]; 882 882 883 883 return $this->comment; 884 884 } 885 885 886 886 function rewind_comments() { 887 887 $this->current_comment = -1; … … 890 890 } 891 891 } 892 893 function user_comments() { 892 893 function user_comments() { 894 894 if ( $this->current_comment + 1 < $this->comment_count ) { 895 895 return true; … … 903 903 return false; 904 904 } 905 905 906 906 function the_comment() { 907 907 global $comment; … … 909 909 $this->in_the_loop = true; 910 910 $comment = $this->next_comment(); 911 911 912 912 if ( 0 == $this->current_comment ) // loop has just started 913 913 do_action('loop_start'); … … 926 926 $r = wp_parse_args( $args, $defaults ); 927 927 extract( $r, EXTR_SKIP ); 928 928 929 929 $comments_template = new BP_Blogs_Post_Comment_Template( $user_id, $per_page, $max ); 930 930 return apply_filters( 'bp_has_comments', $comments_template->has_comments(), &$comments_template ); … … 946 946 function bp_get_comments_pagination() { 947 947 global $comments_template; 948 948 949 949 return apply_filters( 'bp_get_comments_pagination', $comments_template->pag_links ); 950 950 } … … 966 966 function bp_get_comment_post_permalink() { 967 967 global $comments_template; 968 968 969 969 return apply_filters( 'bp_get_comment_post_permalink', bp_post_get_permalink( $comments_template->comment->post, $comments_template->comment->blog_id ) . '#comment-' . $comments_template->comment->comment_ID ); 970 970 } … … 978 978 function bp_get_comment_post_title( $deprecated = true ) { 979 979 global $comments_template; 980 980 981 981 return apply_filters( 'bp_get_comment_post_title', $comments_template->comment->post->post_title ); 982 982 } … … 984 984 function bp_comment_author( $deprecated = true ) { 985 985 global $comments_template; 986 986 987 987 if ( !$deprecated ) 988 988 return bp_get_comment_author(); … … 1010 1010 if ( !$date_format ) 1011 1011 $date_format = get_option('date_format'); 1012 1012 1013 1013 if ( !$deprecated ) 1014 1014 return bp_get_comment_date( $date_format ); 1015 else 1015 else 1016 1016 echo bp_get_comment_date( $date_format ); 1017 1017 } … … 1027 1027 function bp_comment_blog_permalink( $deprecated = true ) { 1028 1028 if ( !$deprecated ) 1029 return bp_get_comment_blog_permalink(); 1029 return bp_get_comment_blog_permalink(); 1030 1030 else 1031 1031 echo bp_get_comment_blog_permalink(); … … 1039 1039 function bp_comment_blog_name( $deprecated = true ) { 1040 1040 global $comments_template; 1041 1041 1042 1042 if ( !$deprecated ) 1043 return bp_get_comment_blog_permalink(); 1043 return bp_get_comment_blog_permalink(); 1044 1044 else 1045 echo bp_get_comment_blog_permalink(); 1045 echo bp_get_comment_blog_permalink(); 1046 1046 } 1047 1047 function bp_get_comment_blog_name( $deprecated = true ) { … … 1060 1060 var $blogs; 1061 1061 var $blog; 1062 1062 1063 1063 var $in_the_loop; 1064 1064 1065 1065 var $pag_page; 1066 1066 var $pag_num; 1067 1067 var $pag_links; 1068 1068 var $total_blog_count; 1069 1069 1070 1070 function bp_blogs_site_blogs_template( $type, $per_page, $max ) { 1071 1071 global $bp; … … 1073 1073 $this->pag_page = isset( $_REQUEST['bpage'] ) ? intval( $_REQUEST['bpage'] ) : 1; 1074 1074 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 1075 1075 1076 1076 if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) { 1077 1077 $this->blogs = BP_Blogs_Blog::search_blogs( $_REQUEST['s'], $this->pag_num, $this->pag_page ); … … 1083 1083 $this->blogs = BP_Blogs_Blog::get_random( $this->pag_num, $this->pag_page ); 1084 1084 break; 1085 1085 1086 1086 case 'newest': 1087 1087 $this->blogs = BP_Blogs_Blog::get_newest( $this->pag_num, $this->pag_page ); 1088 break; 1089 1088 break; 1089 1090 1090 case 'active': default: 1091 1091 $this->blogs = BP_Blogs_Blog::get_active( $this->pag_num, $this->pag_page ); 1092 break; 1092 break; 1093 1093 } 1094 1094 } 1095 1095 1096 1096 if ( !$max || $max >= (int)$this->blogs['total'] ) 1097 1097 $this->total_blog_count = (int)$this->blogs['total']; … … 1109 1109 $this->blog_count = count($this->blogs); 1110 1110 } 1111 1111 1112 1112 $this->pag_links = paginate_links( array( 1113 1113 'base' => add_query_arg( 'bpage', '%#%' ), … … 1118 1118 'next_text' => '»', 1119 1119 'mid_size' => 1 1120 )); 1121 } 1122 1120 )); 1121 } 1122 1123 1123 function has_blogs() { 1124 1124 if ( $this->blog_count ) 1125 1125 return true; 1126 1126 1127 1127 return false; 1128 1128 } 1129 1129 1130 1130 function next_blog() { 1131 1131 $this->current_blog++; 1132 1132 $this->blog = $this->blogs[$this->current_blog]; 1133 1133 1134 1134 return $this->blog; 1135 1135 } 1136 1136 1137 1137 function rewind_blogs() { 1138 1138 $this->current_blog = -1; … … 1141 1141 } 1142 1142 } 1143 1144 function blogs() { 1143 1144 function blogs() { 1145 1145 if ( $this->current_blog + 1 < $this->blog_count ) { 1146 1146 return true; … … 1154 1154 return false; 1155 1155 } 1156 1156 1157 1157 function the_blog() { 1158 1158 global $blog; … … 1160 1160 $this->in_the_loop = true; 1161 1161 $this->blog = $this->next_blog(); 1162 1162 1163 1163 if ( 0 == $this->current_blog ) // loop has just started 1164 1164 do_action('loop_start'); … … 1168 1168 function bp_rewind_site_blogs() { 1169 1169 global $site_blogs_template; 1170 1171 $site_blogs_template->rewind_blogs(); 1170 1171 $site_blogs_template->rewind_blogs(); 1172 1172 } 1173 1173 … … 1183 1183 $r = wp_parse_args( $args, $defaults ); 1184 1184 extract( $r, EXTR_SKIP ); 1185 1185 1186 1186 // type: active ( default ) | random | newest | popular 1187 1187 1188 1188 if ( $max ) { 1189 1189 if ( $per_page > $max ) 1190 1190 $per_page = $max; 1191 1191 } 1192 1192 1193 1193 $site_blogs_template = new BP_Blogs_Site_Blogs_Template( $type, $per_page, $max ); 1194 1194 … … 1198 1198 function bp_site_blogs() { 1199 1199 global $site_blogs_template; 1200 1200 1201 1201 return $site_blogs_template->blogs(); 1202 1202 } … … 1204 1204 function bp_the_site_blog() { 1205 1205 global $site_blogs_template; 1206 1206 1207 1207 return $site_blogs_template->the_blog(); 1208 1208 } … … 1210 1210 function bp_site_blogs_pagination_count() { 1211 1211 global $bp, $site_blogs_template; 1212 1212 1213 1213 $from_num = intval( ( $site_blogs_template->pag_page - 1 ) * $site_blogs_template->pag_num ) + 1; 1214 1214 $to_num = ( $from_num + ( $site_blogs_template->pag_num - 1 ) > $site_blogs_template->total_blog_count ) ? $site_blogs_template->total_blog_count : $from_num + ( $site_blogs_template->pag_num - 1 ) ; … … 1226 1226 return apply_filters( 'bp_get_site_blogs_pagination_links', $site_blogs_template->pag_links ); 1227 1227 } 1228 1228 1229 1229 function bp_the_site_blog_avatar() { 1230 1230 echo bp_get_the_site_blog_avatar(); … … 1232 1232 function bp_get_the_site_blog_avatar() { 1233 1233 global $site_blogs_template, $bp; 1234 1234 1235 1235 /*** 1236 1236 * In future BuddyPress versions you will be able to set the avatar for a blog. … … 1309 1309 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ). '" name="search_terms" />'; 1310 1310 } 1311 1311 1312 1312 if ( isset( $_REQUEST['letter'] ) ) { 1313 1313 echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />'; 1314 1314 } 1315 1315 1316 1316 if ( isset( $_REQUEST['blogs_search'] ) ) { 1317 1317 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['blogs_search'] ) . '" name="search_terms" />'; -
trunk/bp-core.php
r2077 r2088 533 533 * @uses get_usermeta() WordPress function to get the usermeta for a user. 534 534 */ 535 function bp_core_get_user_domain( $user_id ) {535 function bp_core_get_user_domain( $user_id, $user_nicename = false, $user_login = false ) { 536 536 global $bp; 537 537 538 538 if ( !$user_id ) return; 539 539 540 $ud = get_userdata($user_id); 540 if ( $domain = wp_cache_get( 'bp_user_domain_' . $user_id, 'bp' ) ) 541 return apply_filters( 'bp_core_get_user_domain', $domain ); 542 543 if ( !$user_nicename && !$user_login ) { 544 $ud = get_userdata($user_id); 545 $user_nicename = $ud->user_nicename; 546 $user_login = $ud->user_login; 547 } 541 548 542 549 if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) ) 543 $username = $u d->user_login;550 $username = $user_login; 544 551 else 545 $username = $u d->user_nicename;552 $username = $user_nicename; 546 553 547 554 /* If we are using a members slug, include it. */ 548 555 if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) 549 return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $username . '/' );556 $domain = $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $username . '/'; 550 557 else 551 return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . $username . '/' ); 558 $domain = $bp->root_domain . '/' . $username . '/'; 559 560 /* Cache the link */ 561 wp_cache_set( 'bp_user_domain_' . $user_id, $domain, 'bp' ); 562 563 return apply_filters( 'bp_core_get_user_domain', $domain ); 552 564 } 553 565 … … 721 733 } 722 734 add_action( 'wp_head', 'bp_core_sort_nav_items' ); 723 724 /**725 * bp_core_remove_nav_item()726 *727 * Removes a navigation item from the main navigation array.728 *729 * @package BuddyPress Core730 * @param $slug The slug of the sub navigation item.731 */732 function bp_core_remove_nav_item( $slug ) {733 global $bp;734 735 unset( $bp->bp_nav[$slug] );736 }737 735 738 736 /** … … 820 818 821 819 /** 822 * bp_core_remove_ subnav_item()820 * bp_core_remove_nav_item() 823 821 * 824 822 * Removes a navigation item from the sub navigation array used in BuddyPress themes. … … 828 826 * @param $slug The slug of the sub navigation item. 829 827 */ 828 function bp_core_remove_nav_item( $parent_id ) { 829 global $bp; 830 831 /* Unset subnav items for this nav item */ 832 foreach( $bp->bp_options_nav[$parent_id] as $subnav_item ) { 833 bp_core_remove_subnav_item( $parent_id, $subnav_item['slug'] ); 834 } 835 836 unset( $bp->bp_nav[$parent_id] ); 837 } 838 839 /** 840 * bp_core_remove_subnav_item() 841 * 842 * Removes a navigation item from the sub navigation array used in BuddyPress themes. 843 * 844 * @package BuddyPress Core 845 * @param $parent_id The id of the parent navigation item. 846 * @param $slug The slug of the sub navigation item. 847 */ 830 848 function bp_core_remove_subnav_item( $parent_id, $slug ) { 831 849 global $bp; 832 850 851 $function = $bp->bp_options_nav[$parent_id][$slug]['screen_function']; 852 853 if ( $function ) { 854 if ( !is_object( $screen_function[0] ) ) 855 remove_action( 'wp', $screen_function, 3 ); 856 else 857 remove_action( 'wp', array( &$screen_function[0], $screen_function[1] ), 3 ); 858 } 859 833 860 unset( $bp->bp_options_nav[$parent_id][$slug] ); 861 862 if ( !count( $bp->bp_options_nav[$parent_id] ) ) 863 unset($bp->bp_options_nav[$parent_id]); 834 864 } 835 865 … … 979 1009 global $bp; 980 1010 981 if ( !is_numeric($uid) ) 982 return false; 983 984 return apply_filters( 'bp_core_get_userurl', bp_core_get_user_domain( $uid ) ); 1011 if ( !$url = wp_cache_get( 'bp_user_url_' . $uid, 'bp' ) ) { 1012 $url = bp_core_get_user_domain( $uid ); 1013 } 1014 1015 return apply_filters( 'bp_core_get_userurl', $url ); 985 1016 } 986 1017 … … 997 1028 */ 998 1029 function bp_core_get_user_email( $uid ) { 999 $ud = get_userdata($uid); 1000 return apply_filters( 'bp_core_get_user_email', $ud->user_email ); 1030 if ( !$email = wp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) { 1031 $ud = get_userdata($uid); 1032 $email = $ud->user_email; 1033 } 1034 return apply_filters( 'bp_core_get_user_email', $email ); 1001 1035 } 1002 1036 … … 1031 1065 return false; 1032 1066 1033 if ( function_exists( 'bp_fetch_user_fullname') ) {1067 if ( function_exists( 'bp_core_get_user_displayname' ) ) { 1034 1068 $display_name = bp_core_get_user_displayname( $user_id ); 1035 1069 … … 1050 1084 return $url; 1051 1085 1052 return '<a href="' . $url . '">' . $display_name . '</a>';1086 return apply_filters( 'bp_core_get_userlink', '<a href="' . $url . '">' . $display_name . '</a>', $user_id ); 1053 1087 } 1054 1088 … … 1666 1700 global $wpdb; 1667 1701 ?> 1668 <!-- Generated in <?php timer_stop(1); ?> seconds. -->1702 <!-- Generated in <?php timer_stop(1); ?> seconds. <?php echo get_num_queries(); ?> --> 1669 1703 <?php 1670 1704 } -
trunk/bp-core/bp-core-avatars.php
r2077 r2088 130 130 131 131 if ( 'user' == $object ) { 132 $ud = get_userdata( $item_id ); 133 $grav_email = $ud->user_email; 132 $grav_email = bp_core_get_user_email( $item_id ); 134 133 } else if ( 'group' == $object || 'blog' == $object ) { 135 134 $grav_email = "{$item_id}-{$object}@{$bp->root_domain}"; … … 140 139 141 140 return apply_filters( 'bp_core_fetch_avatar', "<img src='{$gravatar}' alt='{$alt}' id='{$css_id}' class='{$class}'{$html_width}{$html_height} />", $params ); 141 142 142 } else if ( !file_exists( $avatar_url ) && $no_grav ) 143 143 return false; -
trunk/bp-core/bp-core-catchuri.php
r2077 r2088 254 254 bp_core_redirect( $bp->root_domain ); 255 255 256 // If the template file doesn't exist, redirect to the root domain. 257 if ( !bp_is_blog_page() && !file_exists( locate_template( array( $bp_path . '.php' ), false ) ) ) 258 bp_core_redirect( $bp->root_domain ); 259 256 260 if ( !$bp_path && !bp_is_blog_page() ) { 257 261 if ( is_user_logged_in() ) { -
trunk/bp-core/bp-core-classes.php
r2077 r2088 57 57 */ 58 58 function populate() { 59 $this->user_url = bp_core_get_userurl( $this->id ); 60 $this->user_link = bp_core_get_userlink( $this->id ); 61 62 $this->fullname = attribute_escape( bp_core_get_user_displayname( $this->id ) ); 63 $this->email = attribute_escape( bp_core_get_user_email( $this->id ) ); 64 $this->last_active = attribute_escape( bp_core_get_last_activity( get_usermeta( $this->id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ) ); 59 if ( function_exists( 'xprofile_install' ) ) 60 $this->profile_data = $this->get_profile_data(); 61 62 if ( $this->profile_data ) { 63 $this->user_url = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] ); 64 $this->fullname = attribute_escape( $this->profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] ); 65 $this->user_link = "<a href='{$this->user_url}'>{$this->fullname}</a>"; 66 $this->email = attribute_escape( $this->profile_data['user_email'] ); 67 } else { 68 $this->user_url = bp_core_get_userurl( $this->id ); 69 $this->user_link = bp_core_get_userlink( $this->id ); 70 $this->fullname = attribute_escape( bp_core_get_user_displayname( $this->id ) ); 71 $this->email = attribute_escape( bp_core_get_user_email( $this->id ) ); 72 } 73 74 /* Cache a few things that are fetched often */ 75 wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' ); 76 wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' ); 77 wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' ); 65 78 66 79 $this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full' ) ); … … 72 85 global $bp; 73 86 74 if ( function_exists('friends_install') ) {87 if ( function_exists('friends_install') ) 75 88 $this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id ); 76 89 77 if ( $this->total_friends ) { 78 if ( 1 == $this->total_friends ) 79 $this->total_friends .= ' ' . __( 'friend', 'buddypress' ); 80 else 81 $this->total_friends .= ' ' . __( 'friends', 'buddypress' ); 82 83 $this->total_friends = '<a href="' . $this->user_url . $bp->friends->slug . '" title="' . sprintf( __( "%s's friend list", 'buddypress' ), $this->fullname ) . '">' . $this->total_friends . '</a>'; 84 } 85 } 86 87 if ( function_exists('bp_blogs_install') ) { 88 if ( $this->total_blogs ) { 89 if ( 1 == $this->total_blogs ) 90 $this->total_blogs .= ' ' . __( 'blog', 'buddypress' ); 91 else 92 $this->total_blogs .= ' ' . __( 'blogs', 'buddypress' ); 93 94 $this->total_blogs = '<a href="' . $this->user_url . $bp->blogs->slug . '" title="' . sprintf( __( "%s's blog list", 'buddypress' ), $this->fullname ) . '">' . $this->total_blogs . '</a>'; 95 } 96 } 97 98 if ( function_exists('groups_install') ) { 90 if ( function_exists('groups_install') ) 99 91 $this->total_groups = BP_Groups_Member::total_group_count( $this->id ); 100 101 if ( $this->total_groups ) { 102 if ( 1 == $this->total_groups ) 103 $this->total_groups .= ' ' . __( 'group', 'buddypress' ); 104 else 105 $this->total_groups .= ' ' . __( 'groups', 'buddypress' ); 106 107 $this->total_groups = '<a href="' . $this->user_url . $bp->groups->slug . '" title="' . sprintf( __( "%s's group list", 'buddypress' ), $this->fullname ) . '">' . $this->total_groups . '</a>'; 108 } 109 } 92 } 93 94 function get_profile_data() { 95 return BP_XProfile_ProfileData::get_all_for_user( $this->id ); 110 96 } 111 97 -
trunk/bp-core/bp-core-templatetags.php
r2077 r2088 1054 1054 } 1055 1055 1056 function bp_the_site_member_avatar() { 1057 echo apply_filters( 'bp_the_site_member_avatar', bp_get_the_site_member_avatar() ); 1058 } 1059 function bp_get_the_site_member_avatar() { 1060 global $site_members_template; 1061 1062 return apply_filters( 'bp_get_the_site_member_avatar', $site_members_template->member->avatar_thumb ); 1056 function bp_the_site_member_avatar( $args = '' ) { 1057 echo apply_filters( 'bp_the_site_member_avatar', bp_get_the_site_member_avatar( $args ) ); 1058 } 1059 function bp_get_the_site_member_avatar( $args = '' ) { 1060 global $bp, $site_members_template; 1061 1062 $defaults = array( 1063 'type' => 'thumb', 1064 'width' => false, 1065 'height' => false, 1066 'class' => 'avatar', 1067 'id' => false, 1068 'alt' => __( 'Member avatar', 'buddypress' ) 1069 ); 1070 1071 $r = wp_parse_args( $args, $defaults ); 1072 extract( $r, EXTR_SKIP ); 1073 1074 /* Fetch the avatar from the folder, if not provide backwards compat. */ 1075 if ( !$avatar = bp_core_fetch_avatar( array( 'item_id' => $site_members_template->member->id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height ) ) ) 1076 $avatar = '<img src="' . attribute_escape( $site_members_template->member->avatar_thumb ) . '" class="avatar" alt="' . __( 'Member avatar', 'buddypress' ) . '" />'; 1077 1078 return apply_filters( 'bp_get_the_site_member_avatar', $avatar ); 1063 1079 } 1064 1080 … … 1089 1105 global $site_members_template; 1090 1106 1091 return apply_filters( 'bp_the_site_member_last_active', $site_members_template->member->last_active ); 1107 $last_activity = attribute_escape( bp_core_get_last_activity( get_usermeta( $site_members_template->member->id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ) ); 1108 1109 return apply_filters( 'bp_the_site_member_last_active', $last_activity ); 1110 } 1111 1112 function bp_the_site_member_profile_data( $field_name = false ) { 1113 echo bp_get_the_site_member_profile_data( $field_name ); 1114 } 1115 function bp_get_the_site_member_profile_data( $field_name = false ) { 1116 global $site_members_template; 1117 1118 if ( !$field_name || !function_exists( 'xprofile_install' ) ) 1119 return false; 1120 1121 return apply_filters( 'bp_get_the_site_member_profile_data', $site_members_template->member->profile_data[$field_name]['field_data'], $site_members_template->member->profile_data[$field_name]['field_type'] ); 1092 1122 } 1093 1123 … … 1208 1238 } 1209 1239 function bp_displayed_user_fullname() { 1210 return bp_user_fullname(); 1240 global $bp; 1241 1242 return apply_filters( 'bp_displayed_user_fullname', $bp->displayed_user->fullname ); 1211 1243 } 1212 1244 -
trunk/bp-core/deprecated/bp-core-deprecated.php
r2077 r2088 332 332 $blog_title = $filtered_results['blog_title']; 333 333 $errors = $filtered_results['errors']; 334 334 335 335 if ( empty($blogname) ) 336 336 $blogname = $user_name; -
trunk/bp-groups.php
r2077 r2088 110 110 item_id bigint(20) NOT NULL, 111 111 user_id bigint(20) NOT NULL, 112 parent_id bigint(20) NOT NULL, 112 113 content longtext NOT NULL, 113 114 date_posted datetime NOT NULL, 114 115 KEY item_id (item_id), 115 KEY user_id (user_id) 116 KEY user_id (user_id), 117 KEY parent_id (parent_id) 116 118 ) {$charset_collate};"; 117 119 -
trunk/bp-groups/bp-groups-classes.php
r2077 r2088 706 706 $hidden_sql = " AND g.status != 'hidden'"; 707 707 708 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1ORDER BY m.date_modified DESC {$pag_sql}", $user_id ) );708 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY m.date_modified DESC {$pag_sql}", $user_id ) ); 709 709 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC", $user_id ) ); 710 710 … … 726 726 $hidden_sql = " AND g.status != 'hidden'"; 727 727 728 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC {$pag_sql}", $user_id ) );728 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY CONVERT( total_member_count, SIGNED ) DESC {$pag_sql}", $user_id ) ); 729 729 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC", $user_id ) ); 730 730 … … 746 746 $hidden_sql = " AND g.status != 'hidden'"; 747 747 748 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_valueDESC {$pag_sql}", $user_id ) );748 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY last_activity DESC {$pag_sql}", $user_id ) ); 749 749 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC", $user_id ) ); 750 750 … … 766 766 $hidden_sql = " AND g.status != 'hidden'"; 767 767 768 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}", $user_id ) );768 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}", $user_id ) ); 769 769 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC", $user_id ) ); 770 770 … … 786 786 $hidden_sql = " AND g.status != 'hidden'"; 787 787 788 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BYdate_modified ASC {$pag_sql}", $user_id ) );788 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY m.date_modified ASC {$pag_sql}", $user_id ) ); 789 789 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC", $user_id ) ); 790 790 … … 806 806 $hidden_sql = " AND g.status != 'hidden'"; 807 807 808 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BYdate_modified ASC {$pag_sql}", $user_id ) );808 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY m.date_modified ASC {$pag_sql}", $user_id ) ); 809 809 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC", $user_id ) ); 810 810 -
trunk/bp-groups/bp-groups-templatetags.php
r2077 r2088 247 247 $this->group = $this->next_group(); 248 248 249 // If this is a single group then instantiate group meta when creating the object. 250 if ( $this->single_group ) { 251 if ( !$group = wp_cache_get( 'groups_group_' . $this->group->group_id, 'bp' ) ) { 252 $group = new BP_Groups_Group( $this->group->group_id, true ); 253 wp_cache_set( 'groups_group_' . $this->group->group_id, $group, 'bp' ); 254 } 255 } else { 256 if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) { 257 $group = new BP_Groups_Group( $this->group->group_id, false, false ); 258 wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' ); 259 } 260 } 261 262 $this->group = $group; 249 if ( $this->single_group ) 250 $this->group = new BP_Groups_Group( $this->group->group_id, true, true ); 263 251 264 252 if ( 0 == $this->current_group ) // loop has just started … … 282 270 extract( $r, EXTR_SKIP ); 283 271 284 /* The following code will auto set parameters based on the page being viewed. 285 * for example on example.com/members/andy/groups/my-groups/most-popular/ 286 * $type = 'most-popular' 287 */ 288 if ( 'my-groups' == $bp->current_action ) { 289 $order = $bp->action_variables[0]; 290 if ( 'recently-joined' == $order ) 291 $type = 'recently-joined'; 292 else if ( 'most-popular' == $order ) 293 $type = 'popular'; 294 else if ( 'admin-of' == $order ) 295 $type = 'admin-of'; 296 else if ( 'mod-of' == $order ) 297 $type = 'mod-of'; 298 else if ( 'alphabetically' == $order ) 299 $type = 'alphabetical'; 300 } else if ( 'invites' == $bp->current_action ) { 301 $type = 'invites'; 302 } else if ( $bp->groups->current_group->slug ) { 303 $type = 'single-group'; 304 $slug = $bp->groups->current_group->slug; 272 if ( '' == $args ) { 273 /* The following code will auto set parameters based on the page being viewed. 274 * for example on example.com/members/andy/groups/my-groups/most-popular/ 275 * $type = 'most-popular' 276 */ 277 if ( 'my-groups' == $bp->current_action ) { 278 $order = $bp->action_variables[0]; 279 if ( 'recently-joined' == $order ) 280 $type = 'recently-joined'; 281 else if ( 'most-popular' == $order ) 282 $type = 'popular'; 283 else if ( 'admin-of' == $order ) 284 $type = 'admin-of'; 285 else if ( 'mod-of' == $order ) 286 $type = 'mod-of'; 287 else if ( 'alphabetically' == $order ) 288 $type = 'alphabetical'; 289 } else if ( 'invites' == $bp->current_action ) { 290 $type = 'invites'; 291 } else if ( $bp->groups->current_group->slug ) { 292 $type = 'single-group'; 293 $slug = $bp->groups->current_group->slug; 294 } 305 295 } 306 296 … … 470 460 $group =& $groups_template->group; 471 461 472 $last_active = groups_get_groupmeta( $group->id, 'last_activity' ); 462 $last_active = $group->last_activity; 463 464 if ( !$last_active ) 465 $last_active = groups_get_groupmeta( $group->id, 'last_activity' ); 473 466 474 467 if ( empty( $last_active ) ) { … … 1997 1990 } 1998 1991 1999 function bp_the_site_group_avatar( ) {2000 echo bp_get_the_site_group_avatar( );2001 } 2002 function bp_get_the_site_group_avatar( ) {1992 function bp_the_site_group_avatar( $args = '' ) { 1993 echo bp_get_the_site_group_avatar( $args ); 1994 } 1995 function bp_get_the_site_group_avatar( $args = '' ) { 2003 1996 global $site_groups_template; 2004 1997 2005 return apply_filters( 'bp_the_site_group_avatar', bp_core_fetch_avatar( array( 'item_id' => $site_groups_template->group->id, 'object' => 'group', 'type' => 'full', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) ); 1998 $defaults = array( 1999 'type' => 'full', 2000 'width' => false, 2001 'height' => false, 2002 'class' => 'avatar', 2003 'id' => false, 2004 'alt' => __( 'Group avatar', 'buddypress' ) 2005 ); 2006 2007 $r = wp_parse_args( $args, $defaults ); 2008 extract( $r, EXTR_SKIP ); 2009 2010 return apply_filters( 'bp_the_site_group_avatar', bp_core_fetch_avatar( array( 'item_id' => $site_groups_template->group->id, 'object' => 'group', 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height ) ) ); 2006 2011 } 2007 2012 -
trunk/bp-xprofile.php
r2077 r2088 1 1 <?php 2 define ( 'BP_XPROFILE_DB_VERSION', '18 00' );2 define ( 'BP_XPROFILE_DB_VERSION', '1850' ); 3 3 4 4 /* Define the slug for the component */ … … 110 110 item_id bigint(20) NOT NULL, 111 111 user_id bigint(20) NOT NULL, 112 parent_id bigint(20) NOT NULL, 112 113 content longtext NOT NULL, 113 114 date_posted datetime NOT NULL, 114 115 KEY item_id (item_id), 115 KEY user_id (user_id) 116 KEY user_id (user_id), 117 KEY parent_id (parent_id) 116 118 ) {$charset_collate};"; 117 119 … … 530 532 return false; 531 533 532 if ( !$wire_post = bp_wire_new_post( $bp->displayed_user->id, $_POST['wire-post-textarea'], $bp->profile-> slug, false, $bp->profile->table_name_wire) ) {534 if ( !$wire_post = bp_wire_new_post( $bp->displayed_user->id, $_POST['wire-post-textarea'], $bp->profile->id ) ) { 533 535 bp_core_add_message( __( 'Wire message could not be posted. Please try again.', 'buddypress' ), 'error' ); 534 536 } else { -
trunk/bp-xprofile/bp-xprofile-classes.php
r2077 r2088 719 719 /** Static Functions **/ 720 720 721 /** 722 * BP_XProfile_ProfileData::get_all_for_user() 723 * 724 * Get all of the profile information for a specific user. 725 */ 726 function get_all_for_user( $user_id ) { 727 global $wpdb, $bp; 728 729 $results = $wpdb->get_results( $wpdb->prepare( "SELECT g.name as field_group_name, f.name as field_name, f.type as field_type, d.value as field_data, u.user_login, u.user_nicename, u.user_email FROM {$bp->profile->table_name_groups} g LEFT JOIN {$bp->profile->table_name_fields} f ON g.id = f.group_id INNER JOIN {$bp->profile->table_name_data} d ON f.id = d.field_id LEFT JOIN {$wpdb->users} u ON d.user_id = u.ID WHERE d.user_id = %d AND d.value != ''", $user_id ) ); 730 731 if ( $results ) { 732 $profile_data['user_login'] = $results[0]->user_login; 733 $profile_data['user_nicename'] = $results[0]->user_nicename; 734 $profile_data['user_email'] = $results[0]->user_email; 735 736 foreach( (array) $results as $field ) { 737 $profile_data[$field->field_name] = array( 'field_group' => $field->field_group_name, 'field_type' => $field->field_type, 'field_data' => $field->field_data ); 738 } 739 } 740 741 return $profile_data; 742 } 743 721 744 function get_value_byid( $field_id, $user_id = null ) { 722 745 global $wpdb, $bp; -
trunk/bp-xprofile/bp-xprofile-filters.php
r2077 r2088 3 3 /* Apply WordPress defined filters */ 4 4 add_filter( 'bp_get_the_profile_field_value', 'wp_filter_kses', 1 ); 5 add_filter( 'bp_get_the_site_member_profile_data', 'wp_filter_kses', 1 ); 5 6 add_filter( 'xprofile_get_field_data', 'wp_filter_kses', 1 ); 6 7 add_filter( 'xprofile_field_name_before_save', 'wp_filter_kses', 1 ); … … 20 21 add_filter( 'bp_get_the_profile_field_value', 'force_balance_tags' ); 21 22 23 add_filter( 'bp_get_the_site_member_profile_data', 'wptexturize' ); 24 add_filter( 'bp_get_the_site_member_profile_data', 'convert_smilies', 2 ); 25 add_filter( 'bp_get_the_site_member_profile_data', 'convert_chars' ); 26 add_filter( 'bp_get_the_site_member_profile_data', 'make_clickable' ); 27 add_filter( 'bp_get_the_site_member_profile_data', 'force_balance_tags' ); 28 22 29 add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_format_field_value', 1, 2 ); 30 add_filter( 'bp_get_the_site_member_profile_data', 'xprofile_filter_format_field_value', 1, 2 ); 23 31 add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 2, 2 ); 24 32 … … 27 35 add_filter( 'xprofile_get_field_data', 'stripslashes' ); 28 36 add_filter( 'bp_get_the_profile_field_description', 'stripslashes' ); 37 add_filter( 'bp_get_the_site_member_profile_data', 'stripslashes' ); 29 38 30 39 /* Custom BuddyPress filters */
Note: See TracChangeset
for help on using the changeset viewer.