Changeset 2471
- Timestamp:
- 01/28/2010 06:01:42 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r2416 r2471 611 611 'type' => false, 612 612 'item_id' => false, 613 'secondary_item_id' => false 613 'secondary_item_id' => false, 614 'action' => false, 615 'content' => false 614 616 ); 615 617 … … 617 619 extract( $r, EXTR_SKIP ); 618 620 619 return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( $user_id, $component, $type, $item_id, $secondary_item_id ) );621 return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content ) ); 620 622 } 621 623 622 624 /*** 623 625 * Deleting Activity 624 *625 * There are multiple ways to delete activity items, depending on626 * the information you have at the time.627 626 * 628 627 * If you're looking to hook into one action that provides the ID(s) of … … 635 634 */ 636 635 637 function bp_activity_delete_by_item_id( $args = '' ) { 638 global $bp; 639 636 function bp_activity_delete( $args = '' ) { 637 global $bp; 638 639 /* Pass one or more the of following variables to delete by those variables */ 640 640 $defaults = array( 641 'id' => false, 642 'action' => false, 643 'content' => false, 644 'component' => false, 645 'type' => false, 646 'primary_link' => false, 647 'user_id' => false, 641 648 'item_id' => false, 642 'component' => false, 643 'type' => false, // optional 644 'user_id' => false, // optional 645 'secondary_item_id' => false // optional 649 'secondary_item_id' => false, 650 'recorded_time' => false, 651 'hide_sitewide' => false 646 652 ); 647 653 648 $r = wp_parse_args( $args, $defaults ); 649 extract( $r, EXTR_SKIP ); 650 651 if ( !$activity_ids_deleted = BP_Activity_Activity::delete_by_item_id( $item_id, $component, $type, $user_id, $secondary_item_id ) ) 652 return false; 653 654 do_action( 'bp_activity_delete_by_item_id', $item_id, $component, $type, $user_id, $secondary_item_id ); 654 $args = wp_parse_args( $args, $defaults ); 655 656 if ( !$activity_ids_deleted = BP_Activity_Activity::delete( $args ) ) 657 return false; 658 659 do_action( 'bp_activity_delete', $args ); 655 660 do_action( 'bp_activity_deleted_activities', $activity_ids_deleted ); 656 661 657 662 return true; 658 663 } 659 660 function bp_activity_delete_by_activity_id( $activity_id ) { 661 if ( !BP_Activity_Activity::delete_by_activity_id( $activity_id ) ) 662 return false; 663 664 do_action( 'bp_activity_delete_by_activity_id', $activity_id ); 665 do_action( 'bp_activity_deleted_activities', $activity_id ); 666 667 return true; 668 } 669 670 function bp_activity_delete_by_content( $user_id, $content, $component, $type ) { 671 /* Insert the "time-since" placeholder to match the existing content in the DB */ 672 $content = bp_activity_add_timesince_placeholder( $content ); 673 674 if ( !$activity_ids_deleted = BP_Activity_Activity::delete_by_content( $user_id, $content, $component, $type ) ) 675 return false; 676 677 do_action( 'bp_activity_delete_by_content', $user_id, $content, $component, $type ); 678 do_action( 'bp_activity_deleted_activities', $activity_ids_deleted ); 679 680 return true; 681 } 682 683 function bp_activity_delete_for_user_by_component( $user_id, $component ) { 684 if ( !$activity_ids_deleted = BP_Activity_Activity::delete_for_user_by_component( $user_id, $component ) ) 685 return false; 686 687 do_action( 'bp_activity_delete_for_user_by_component', $user_id, $component ); 688 do_action( 'bp_activity_deleted_activities', $activity_ids_deleted ); 689 690 return true; 691 } 664 /* The following functions have been deprecated in place of bp_activity_delete() */ 665 function bp_activity_delete_by_item_id( $args = '' ) { 666 global $bp; 667 668 $defaults = array( 'item_id' => false, 'component' => false, 'type' => false, 'user_id' => false, 'secondary_item_id' => false ); 669 $r = wp_parse_args( $args, $defaults ); 670 extract( $r, EXTR_SKIP ); 671 672 return bp_activity_delete( array( 'item_id' => $item_id, 'component' => $component, 'type' => $type, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) ); 673 } 674 675 function bp_activity_delete_by_activity_id( $activity_id ) { 676 return bp_activity_delete( array( 'id' => $activity_id ) ); 677 } 678 679 function bp_activity_delete_by_content( $user_id, $content, $component, $type ) { 680 return bp_activity_delete( array( 'user_id' => $user_id, 'content' => $content, 'component' => $component, 'type' => $type ) ); 681 } 682 683 function bp_activity_delete_for_user_by_component( $user_id, $component ) { 684 return bp_activity_delete( array( 'user_id' => $user_id, 'component' => $component ) ); 685 } 686 /* End deprecation */ 692 687 693 688 function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { … … 997 992 function bp_activity_remove_data( $user_id ) { 998 993 // Clear the user's activity from the sitewide stream and clear their activity tables 999 BP_Activity_Activity::delete_for_user( $user_id);994 bp_activity_delete( array( 'user_id' => $user_id ) ); 1000 995 1001 996 // Remove any usermeta -
trunk/bp-activity/bp-activity-classes.php
r2416 r2471 71 71 /* Static Functions */ 72 72 73 function delete( $item_id, $component, $type, $user_id = false, $secondary_item_id = false ) {74 global $wpdb, $bp;75 76 if ( $secondary_item_id )77 $secondary_sql = $wpdb->prepare( "AND secondary_item_id = %s", $secondary_item_id );78 79 if ( $type )80 $type_sql = $wpdb->prepare( "AND type = %s", $type );81 82 if ( $user_id )83 $user_sql = $wpdb->prepare( "AND user_id = %d", $user_id );84 85 /* Fetch the activity IDs so we can delete any comments for this activity item */86 $activity_ids = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE item_id = %s {$secondary_sql} AND component = %s {$type_sql} {$user_sql}", $item_id, $component ) );87 88 error_log( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE item_id = %s {$secondary_sql} AND component = %s {$type_sql} {$user_sql}", $item_id, $component ) );89 90 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE item_id = %s {$secondary_sql} AND component = %s {$type_sql} {$user_sql}", $item_id, $component ) ) )91 return false;92 93 if ( $activity_ids ) {94 BP_Activity_Activity::delete_activity_item_comments( $activity_ids );95 BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );96 97 return $activity_ids;98 }99 100 return true;101 }102 103 function delete_by_item_id( $item_id, $component, $type, $user_id = false, $secondary_item_id = false ) {104 return BP_Activity_Activity::delete( $item_id, $component, $type, $user_id, $secondary_item_id );105 }106 107 function delete_by_activity_id( $activity_id ) {108 global $bp, $wpdb;109 110 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE id = %d", $activity_id ) ) )111 return false;112 113 /* Delete the comments for this activity ID */114 BP_Activity_Activity::delete_activity_item_comments( $activity_id );115 BP_Activity_Activity::delete_activity_meta_entries( $activity_id );116 117 return true;118 }119 120 function delete_by_content( $user_id, $content, $component, $type ) {121 global $bp, $wpdb;122 123 /* Fetch the activity ID so we can delete any comments for this activity item */124 $activity_ids = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component = %s AND type = %s", $user_id, $content, $component, $type ) );125 126 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component = %s AND type = %s", $user_id, $content, $component, $type ) ) )127 return false;128 129 if ( $activity_ids ) {130 BP_Activity_Activity::delete_activity_item_comments( $activity_ids );131 BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );132 133 return $activity_ids;134 }135 136 return true;137 }138 139 function delete_for_user_by_component( $user_id, $component ) {140 global $bp, $wpdb;141 142 /* Fetch the activity IDs so we can delete any comments for this activity item */143 $activity_ids = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND component = %s", $user_id, $component ) );144 145 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND component = %s", $user_id, $component ) ) )146 return false;147 148 if ( $activity_ids ) {149 BP_Activity_Activity::delete_activity_item_comments( $activity_ids );150 BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );151 152 return $activity_ids;153 }154 155 return true;156 }157 158 function delete_for_user( $user_id ) {159 global $wpdb, $bp;160 161 /* Fetch the activity IDs so we can delete any comments for this activity item */162 $activity_ids = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d", $user_id ) );163 164 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d", $user_id ) ) )165 return false;166 167 if ( $activity_ids ) {168 BP_Activity_Activity::delete_activity_item_comments( $activity_ids );169 BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );170 171 return $activity_ids;172 }173 }174 175 function delete_activity_item_comments( $activity_ids ) {176 global $bp, $wpdb;177 178 if ( is_array($activity_ids) )179 $activity_ids = implode( ',', $activity_ids );180 181 $activity_ids = $wpdb->escape( $activity_ids );182 183 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" ) );184 }185 186 function delete_activity_meta_entries( $activity_ids ) {187 global $bp, $wpdb;188 189 if ( is_array($activity_ids) )190 $activity_ids = implode( ',', $activity_ids );191 192 $activity_ids = $wpdb->escape( $activity_ids );193 194 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id IN ({$activity_ids})" ) );195 }196 197 73 function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false ) { 198 74 global $wpdb, $bp; … … 201 77 $select_sql = "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name"; 202 78 203 if ( function_exists( 'xprofile_install' ) ) 204 $select_sql .= ", pd.value as user_fullname"; 205 206 $from_sql = " FROM {$bp->activity->table_name} a, {$wpdb->users} u"; 207 208 if ( function_exists( 'xprofile_install' ) ) 209 $from_sql .= ", {$bp->profile->table_name_data} pd"; 79 $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID"; 210 80 211 81 /* Where conditions */ 212 82 $where_conditions = array(); 213 $where_conditions['user_join'] = "a.user_id = u.ID";214 215 if ( function_exists( 'xprofile_install' ) ) {216 $where_conditions['xprofile_join'] = "a.user_id = pd.user_id";217 $where_conditions['xprofile_filter'] = "pd.field_id = 1";218 }219 83 220 84 if ( $per_page && $page ) … … 253 117 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(a.id) {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}" ) ); 254 118 119 /* Get the fullnames of users so we don't have to query in the loop */ 120 if ( function_exists( 'xprofile_install' ) && $activities ) { 121 foreach ( (array)$activities as $activity ) { 122 if ( (int)$activity->user_id ) 123 $activity_user_ids[] = $activity->user_id; 124 } 125 126 $activity_user_ids = implode( ',', (array)$activity_user_ids ); 127 if ( !empty( $activity_user_ids ) ) { 128 if ( $names = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, value AS user_fullname FROM {$bp->profile->table_name_data} WHERE field_id = 1 AND user_id IN ({$activity_user_ids})" ) ) ) { 129 foreach ( (array)$names as $name ) 130 $tmp_names[$name->user_id] = $name->user_fullname; 131 132 foreach ( (array)$activities as $i => $activity ) { 133 if ( !empty( $tmp_names[$activity->user_id] ) ) 134 $activities[$i]->user_fullname = $tmp_names[$activity->user_id]; 135 } 136 137 unset( $names ); 138 unset( $tmp_names ); 139 } 140 } 141 } 142 255 143 if ( $activities && $display_comments ) 256 144 $activities = BP_Activity_Activity::append_comments( &$activities ); … … 295 183 } 296 184 297 function get_id( $user_id, $component, $type, $item_id, $secondary_item_id ) {185 function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content ) { 298 186 global $bp, $wpdb; 299 187 … … 314 202 if ( !empty( $secondary_item_id ) ) 315 203 $where_args[] = $wpdb->prepare( "secondary_item_id = %s", $secondary_item_id ); 204 205 if ( !empty( $action ) ) 206 $where_args[] = $wpdb->prepare( "action = %s", bp_activity_add_timesince_placeholder( $action ) ); 207 208 if ( !empty( $content ) ) 209 $where_args[] = $wpdb->prepare( "content = %s", $content ); 316 210 317 211 if ( !empty( $where_args ) ) … … 321 215 322 216 return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" ); 217 } 218 219 function delete( $args ) { 220 global $wpdb, $bp; 221 222 extract( $args ); 223 224 $defaults = array( 225 'id' => false, 226 'action' => false, 227 'content' => false, 228 'component' => false, 229 'type' => false, 230 'primary_link' => false, 231 'user_id' => false, 232 'item_id' => false, 233 'secondary_item_id' => false, 234 'recorded_time' => false, 235 'hide_sitewide' => false 236 ); 237 238 $where_args = false; 239 240 if ( !empty( $id ) ) 241 $where_args[] = $wpdb->prepare( "id = %d", $id ); 242 243 if ( !empty( $user_id ) ) 244 $where_args[] = $wpdb->prepare( "user_id = %d", $user_id ); 245 246 if ( !empty( $action ) ) 247 $where_args[] = $wpdb->prepare( "action = %s", bp_activity_add_timesince_placeholder( $action ) ); 248 249 if ( !empty( $content ) ) 250 $where_args[] = $wpdb->prepare( "content = %s", $content ); 251 252 if ( !empty( $component ) ) 253 $where_args[] = $wpdb->prepare( "component = %s", $component ); 254 255 if ( !empty( $type ) ) 256 $where_args[] = $wpdb->prepare( "type = %s", $type ); 257 258 if ( !empty( $primary_link ) ) 259 $where_args[] = $wpdb->prepare( "primary_link = %s", $primary_link ); 260 261 if ( !empty( $item_id ) ) 262 $where_args[] = $wpdb->prepare( "item_id = %s", $item_id ); 263 264 if ( !empty( $secondary_item_id ) ) 265 $where_args[] = $wpdb->prepare( "secondary_item_id = %s", $secondary_item_id ); 266 267 if ( !empty( $recorded_time ) ) 268 $where_args[] = $wpdb->prepare( "recorded_time = %s", $recorded_time ); 269 270 if ( !empty( $hide_sitewide ) ) 271 $where_args[] = $wpdb->prepare( "recorded_time = %d", $hide_sitewide ); 272 273 if ( !empty( $where_args ) ) 274 $where_sql = 'WHERE ' . join( ' AND ', $where_args ); 275 else 276 return false; 277 278 /* Fetch the activity IDs so we can delete any comments for this activity item */ 279 $activity_ids = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" ) ); 280 281 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} {$where_sql}" ) ) ) 282 return false; 283 284 if ( $activity_ids ) { 285 BP_Activity_Activity::delete_activity_item_comments( $activity_ids ); 286 BP_Activity_Activity::delete_activity_meta_entries( $activity_ids ); 287 288 return $activity_ids; 289 } 290 291 return $activity_ids; 292 } 293 294 function delete_activity_item_comments( $activity_ids ) { 295 global $bp, $wpdb; 296 297 if ( is_array($activity_ids) ) 298 $activity_ids = implode( ',', $activity_ids ); 299 300 $activity_ids = $wpdb->escape( $activity_ids ); 301 302 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" ) ); 303 } 304 305 function delete_activity_meta_entries( $activity_ids ) { 306 global $bp, $wpdb; 307 308 if ( is_array($activity_ids) ) 309 $activity_ids = implode( ',', $activity_ids ); 310 311 $activity_ids = $wpdb->escape( $activity_ids ); 312 313 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id IN ({$activity_ids})" ) ); 323 314 } 324 315 -
trunk/bp-activity/bp-activity-templatetags.php
r2463 r2471 298 298 function bp_get_activity_user_link() { 299 299 global $activities_template; 300 return apply_filters( 'bp_get_activity_user_link', bp_core_get_user_domain( $activities_template->activity->user_id, $activities_template->activity->user_nicename, $activities_template->activity->user_login ) ); 300 301 if ( empty( $activities_template->activity->user_id ) ) 302 $link = $activities_template->activity->primary_link; 303 else 304 $link = bp_core_get_user_domain( $activities_template->activity->user_id, $activities_template->activity->user_nicename, $activities_template->activity->user_login ); 305 306 return apply_filters( 'bp_get_activity_user_link', $link ); 301 307 } 302 308 … … 446 452 return false; 447 453 454 if ( empty( $parent_activity->content ) ) 455 $content = $parent_activity->action; 456 else 457 $content = $parent_activity->action . $parent_activity->content; 458 448 459 /* Remove the time since content */ 449 $ parent_activity->content = str_replace( '<span class="time-since">%s</span>', '', $parent_activity->content );460 $content = str_replace( '<span class="time-since">%s</span>', '', $content ); 450 461 451 462 /* Remove images */ 452 $ parent_activity->content = preg_replace( '/<img[^>]*>/Ui', '', $parent_activity->content );453 454 return apply_filters( 'bp_get_activity_parent_content', $ parent_activity->content );463 $content = preg_replace( '/<img[^>]*>/Ui', '', $content ); 464 465 return apply_filters( 'bp_get_activity_parent_content', $content ); 455 466 } 456 467 -
trunk/bp-groups.php
r2465 r2471 107 107 108 108 function groups_check_installed() { 109 global $wpdb, $bp;110 111 109 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 112 110 if ( get_site_option('bp-groups-db-version') < BP_GROUPS_DB_VERSION ) … … 116 114 117 115 function groups_setup_nav() { 118 global $bp , $current_blog, $group_obj;116 global $bp; 119 117 120 118 if ( $group_id = BP_Groups_Group::group_exists($bp->current_action) ) { … … 139 137 /* Should this group be visible to the logged in user? */ 140 138 $bp->groups->current_group->is_group_visible_to_member = ( 'public' == $bp->groups->current_group->status || $is_member ) ? true : false; 141 142 /* Pre 1.1 backwards compatibility - use $bp->groups->current_group instead */143 $group_obj = &$bp->groups->current_group;144 139 } 145 140 … … 667 662 global $bp; 668 663 669 if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != $bp->activity->slug ) 670 return false; 664 if ( $bp->current_component != $bp->groups->slug || $bp->current_action != $bp->activity->slug || empty( $bp->action_variables[0] ) ) 665 return false; 666 667 $bp->is_single_item = true; 671 668 672 669 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) ); … … 1244 1241 return false; 1245 1242 1246 foreach ( $bp->groups->group_creation_steps as $slug => $step ) 1243 foreach ( $bp->groups->group_creation_steps as $slug => $step ) { 1244 while ( !empty( $temp[$step['position']] ) ) 1245 $step['position']++; 1246 1247 1247 $temp[$step['position']] = array( 'name' => $step['name'], 'slug' => $slug ); 1248 } 1248 1249 1249 1250 /* Sort the steps by their position key */ -
trunk/bp-groups/bp-groups-templatetags.php
r2431 r2471 1500 1500 1501 1501 $counter = 1; 1502 1502 1503 foreach ( $bp->groups->group_creation_steps as $slug => $step ) { 1503 1504 $is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?> -
trunk/bp-themes/bp-default/_inc/ajax.php
r2462 r2471 156 156 } 157 157 158 if ( empty( $_POST['id'] ) || !is_numeric( $_POST['id'] ) || !bp_activity_delete _by_activity_id( $_POST['id']) ) {159 echo '-1<div class="error"><p>' . __( 'There was a problem when deleting. Please try again.', 'buddypress' ) . '</p></div>';158 if ( empty( $_POST['id'] ) || !is_numeric( $_POST['id'] ) || !bp_activity_delete( array( 'id' => $_POST['id'] ) ) ) { 159 echo '-1<div id="message" class="error"><p>' . __( 'There was a problem when deleting. Please try again.', 'buddypress' ) . '</p></div>'; 160 160 return false; 161 161 } -
trunk/bp-themes/bp-default/activity/post-form.php
r2441 r2471 16 16 17 17 <h5> 18 <?php if ( bp_is_group _home() ) : ?>18 <?php if ( bp_is_group() ) : ?> 19 19 <?php printf( __( "What's new in %s, %s?", 'buddypress' ), bp_get_group_name(), bp_dtheme_firstname() ) ?> 20 20 <?php else : ?> … … 34 34 </div> 35 35 36 <?php if ( !bp_is_my_profile() && !bp_is_group _home() ) : ?>36 <?php if ( !bp_is_my_profile() && !bp_is_group() ) : ?> 37 37 <div id="whats-new-post-in-box"> 38 38 <?php _e( 'Post in', 'buddypress' ) ?>:
Note: See TracChangeset
for help on using the changeset viewer.