Changeset 511
- Timestamp:
- 11/07/2008 06:01:12 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
-
bp-activity/bp-activity-templatetags.php (modified) (1 diff)
-
bp-blogs.php (modified) (1 diff)
-
bp-blogs/bp-blogs-classes.php (modified) (1 diff)
-
bp-core.php (modified) (7 diffs)
-
bp-friends.php (modified) (1 diff)
-
bp-groups.php (modified) (21 diffs)
-
bp-groups/bp-groups-classes.php (modified) (4 diffs)
-
bp-groups/bp-groups-templatetags.php (modified) (2 diffs)
-
bp-messages.php (modified) (12 diffs)
-
bp-messages/bp-messages-templatetags.php (modified) (2 diffs)
-
bp-wire.php (modified) (2 diffs)
-
bp-wire/bp-wire-classes.php (modified) (1 diff)
-
bp-xprofile.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-templatetags.php
r438 r511 174 174 175 175 function bp_activity_insert_time_since( $content, $date ) { 176 if ( !$content || !$date ) 177 return false; 178 176 179 return sprintf( $content, ' ' . bp_core_time_since( strtotime( $date ) ) . ' ' . __('ago', 'buddypress') ); 177 180 } -
trunk/bp-blogs.php
r508 r511 485 485 } 486 486 487 function bp_blogs_get_random_blog() { 488 return BP_Blogs_Blog::get_random(); 489 } 490 487 491 function bp_blogs_get_all_posts() { 488 492 return BP_Blogs_Post::get_all(); 489 493 } 490 494 491 function bp_blogs_ get_random_blog() {495 function bp_blogs_redirect_to_random_blog() { 492 496 global $bp, $wpdb; 493 497 494 498 if ( $bp['current_component'] == $bp['blogs']['slug'] && isset( $_GET['random-blog'] ) ) { 495 $blog s = bp_blogs_get_all_blogs();496 497 wp_redirect( get_blog_option( $blog s[rand( 0, count($blogs) - 1)], 'siteurl') );498 } 499 } 500 add_action( 'wp', 'bp_blogs_ get_random_blog', 6 );499 $blog_id = bp_blogs_get_random_blog(); 500 501 wp_redirect( get_blog_option( $blog_id, 'siteurl') ); 502 } 503 } 504 add_action( 'wp', 'bp_blogs_redirect_to_random_blog', 6 ); 501 505 502 506 -
trunk/bp-blogs/bp-blogs-classes.php
r508 r511 111 111 return $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM " . $bp['blogs']['table_name'] ) ); 112 112 } 113 114 function get_random() { 115 global $bp, $wpdb; 116 117 return $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM " . $bp['blogs']['table_name'] . " ORDER BY rand() LIMIT 1" ) ); 118 } 119 113 120 } 114 121 -
trunk/bp-core.php
r508 r511 7 7 define( 'MEMBERS_SLUG', 'members' ); 8 8 9 /* These components are accessed via the root, and not under a blog name or home base.9 /* These components are accessed via the root, and not under a blog name or member home. 10 10 e.g Groups is accessed via: http://domain.com/groups/group-name NOT http://domain.com/andy/groups/group-name */ 11 11 define( 'BP_CORE_ROOT_COMPONENTS', 'groups' . ',' . MEMBERS_SLUG ); … … 119 119 /* Sets up container used for the avatar of the current component being viewed. Rendered by bp_get_options_avatar() */ 120 120 $bp['bp_options_avatar'] = ''; 121 122 /* Sets up container for callback messages rendered by bp_core_render_notice() */123 $bp['message'] = '';124 125 /* Sets up container for callback message type rendered by bp_core_render_notice() */126 $bp['message_type'] = ''; // error/success127 121 128 122 /* Fetch the full name for the logged in and current user */ … … 146 140 add_action( 'wp', 'bp_core_setup_globals', 1 ); 147 141 add_action( '_admin_menu', 'bp_core_setup_globals', 1 ); // must be _admin_menu hook. 142 143 144 function bp_core_setup_session() { 145 // Start a session for error/success feedback on redirect and for signup functions. 146 session_start(); 147 148 // Render any error/success feedback on the template 149 if ( $_SESSION['message'] != '' ) 150 add_action( 'template_notices', 'bp_core_render_notice' ); 151 } 152 add_action( 'wp', 'bp_core_setup_session', 3 ); 148 153 149 154 … … 423 428 424 429 if ( $bp['current_component'] == MEMBERS_SLUG && isset( $_GET['random'] ) ) { 425 $user s = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM " . $wpdb->base_prefix . "users WHERE user_status = 0 AND spam = 0 AND deleted = 0" ) );426 427 $ud = get_userdata( $user s[rand( 0, count($users) - 1)]);430 $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->base_prefix . "users WHERE user_status = 0 AND spam = 0 AND deleted = 0 ORDER BY rand() LIMIT 1" ) ); 431 432 $ud = get_userdata( $user_id ); 428 433 wp_redirect( $bp['root_domain'] . '/' . MEMBERS_SLUG . '/' . $ud->user_login ); 429 434 } … … 763 768 } 764 769 770 function bp_core_add_message( $message, $type = false ) { 771 if ( !$type ) 772 $type = 'success'; 773 774 $_SESSION['message'] = $message; 775 $_SESSION['message_type'] = $type; 776 } 777 765 778 /** 766 779 * bp_core_render_notice() … … 768 781 * Renders a feedback notice (either error or success message) to the theme template. 769 782 * The hook action 'template_notices' is used to call this function, it is not called directly. 770 * The message and message type are stored in the $bp global, and are set up right before771 * the add_action( 'template_notices', 'bp_core_render_notice' ); is called where needed.772 783 * 773 784 * @package BuddyPress Core … … 775 786 */ 776 787 function bp_core_render_notice() { 777 global $bp; 778 779 if ( $bp['message'] != '' ) { 780 $type = ( $bp['message_type'] == 'success' ) ? 'updated' : 'error'; 788 if ( $_SESSION['message'] ) { 789 $type = ( $_SESSION['message_type'] == 'success' ) ? 'updated' : 'error'; 781 790 ?> 782 791 <div id="message" class="<?php echo $type; ?>"> 783 <p><?php echo $ bp['message']; ?></p>792 <p><?php echo $_SESSION['message']; ?></p> 784 793 </div> 785 794 <?php 795 unset( $_SESSION['message'] ); 796 unset( $_SESSION['message_type'] ); 786 797 } 787 798 } -
trunk/bp-friends.php
r502 r511 122 122 123 123 if ( friends_accept_friendship( $bp['action_variables'][1] ) ) { 124 $bp['message'] = __('Friendship accepted', 'buddypress'); 125 $bp['message_type'] = 'success'; 124 bp_core_add_message( __('Friendship accepted', 'buddypress') ); 126 125 } else { 127 $bp['message'] = __('Friendship could not be accepted', 'buddypress'); 128 $bp['message_type'] = 'error'; 126 bp_core_add_message( __('Friendship could not be accepted', 'buddypress'), 'error' ); 129 127 } 130 add_action( 'template_notices', 'bp_core_render_notice');128 wp_redirect( $_SERVER['HTTP_REFERER'] ); 131 129 132 130 } else if ( isset($bp['action_variables']) && in_array( 'reject', $bp['action_variables'] ) && is_numeric($bp['action_variables'][1]) ) { 133 131 134 132 if ( friends_reject_friendship( $bp['action_variables'][1] ) ) { 135 $bp['message'] = __('Friendship rejected', 'buddypress'); 136 $bp['message_type'] = 'success'; 133 bp_core_add_message( __('Friendship rejected', 'buddypress') ); 137 134 } else { 138 $bp['message'] = __('Friendship could not be rejected', 'buddypress'); 139 $bp['message_type'] = 'error'; 140 } 141 add_action( 'template_notices', 'bp_core_render_notice' ); 142 143 } 135 bp_core_add_message( __('Friendship could not be rejected', 'buddypress'), 'error' ); 136 } 137 wp_redirect( $_SERVER['HTTP_REFERER'] ); 138 } 139 144 140 bp_catch_uri( 'friends/requests' ); 145 141 } -
trunk/bp-groups.php
r508 r511 260 260 261 261 if ( $member->save() ) { 262 $bp['message'] = __('Group invite accepted', 'buddypress'); 263 $bp['message_type'] = 'success'; 262 bp_core_add_message( __('Group invite accepted', 'buddypress') ); 264 263 } else { 265 $bp['message'] = __('Group invite could not be accepted', 'buddypress'); 266 $bp['message_type'] = 'error'; 264 bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' ); 267 265 } 268 add_action( 'template_notices', 'bp_core_render_notice' ); 266 wp_redirect( $_SERVER['HTTP_REFERER'] ); 267 269 268 } else if ( isset($bp['action_variables']) && in_array( 'reject', $bp['action_variables'] ) && is_numeric($bp['action_variables'][1]) ) { 270 269 if ( BP_Groups_Member::delete( $bp['loggedin_userid'], $bp['action_variables'][1] ) ) { 271 $bp['message'] = __('Group invite rejected', 'buddypress'); 272 $bp['message_type'] = 'success'; 270 bp_core_add_message( __('Group invite rejected', 'buddypress') ); 273 271 } else { 274 $bp['message'] = __('Group invite could not be rejected', 'buddypress'); 275 $bp['message_type'] = 'error'; 272 bp_core_add_message( __('Group invite could not be rejected', 'buddypress'), 'error' ); 276 273 } 277 add_action( 'template_notices', 'bp_core_render_notice' ); 278 } 274 wp_redirect( $_SERVER['HTTP_REFERER'] ); 275 } 276 279 277 bp_catch_uri( 'groups/list-invites' ); 280 278 } … … 308 306 //var_dump($create_group_step, $_COOKIE['group_obj_id']); 309 307 if ( !$group_obj_id = &groups_manage_group( $create_group_step, $_COOKIE['group_obj_id'] ) ) { 310 $bp['message'] = __('There was an error saving group details. Please try again.', 'buddypress'); 311 $bp['message_type'] = 'error'; 312 313 add_action( 'template_notices', 'bp_core_render_notice' ); 308 bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' ); 309 wp_redirect( $_SERVER['HTTP_REFERER'] ); 314 310 } else { 315 311 $create_group_step++; … … 364 360 bp_catch_uri( 'groups/group-home' ); 365 361 } else { 366 $bp['message'] = __('Wire message successfully posted.', 'buddypress'); 367 $bp['message_type'] = 'success'; 368 369 add_action( 'template_notices', 'bp_core_render_notice' ); 370 if ( !strpos( $_SERVER['HTTP_REFERER'], 'wire' ) ) { 371 bp_catch_uri( 'groups/group-home' ); 362 bp_core_add_message( __('Wire message successfully posted.', 'buddypress') ); 363 364 if ( !strpos( $_SERVER['HTTP_REFERER'], $bp['wire']['slug'] ) ) { 365 wp_redirect( bp_group_permalink( $group_obj, false ) ); 372 366 } else { 373 bp_catch_uri( 'groups/wire');367 wp_redirect( bp_group_permalink( $group_obj, false ) . '/' . $bp['wire']['slug'] ); 374 368 } 375 369 } … … 381 375 bp_catch_uri( 'groups/group-home' ); 382 376 } else { 383 $bp['message'] = __('Wire message successfully deleted.', 'buddypress'); 384 $bp['message_type'] = 'success'; 385 386 add_action( 'template_notices', 'bp_core_render_notice' ); 387 388 if ( !strpos( $_SERVER['HTTP_REFERER'], 'wire' ) ) { 389 bp_catch_uri( 'groups/group-home' ); 377 bp_core_add_message( __('Wire message successfully deleted.', 'buddypress') ); 378 379 if ( !strpos( $_SERVER['HTTP_REFERER'], $bp['wire']['slug'] ) ) { 380 wp_redirect( bp_group_permalink( $group_obj, false ) ); 390 381 } else { 391 bp_catch_uri( 'groups/wire');392 } 382 wp_redirect( bp_group_permalink( $group_obj, false ) . '/' . $bp['wire']['slug'] ); 383 } 393 384 } 394 385 … … 429 420 groups_send_invites($group_obj); 430 421 431 $bp['message'] = __('Group invites sent.', 'buddypress'); 432 $bp['message_type'] = 'success'; 433 434 add_action( 'template_notices', 'bp_core_render_notice' ); 435 bp_catch_uri( 'groups/group-home' ); 422 bp_core_add_message( __('Group invites sent.', 'buddypress') ); 423 wp_redirect( bp_group_permalink( $group_obj, false ) ); 436 424 } else { 437 425 // Show send invite page … … 449 437 // remove the user from the group. 450 438 if ( !groups_leave_group( $group_obj->id ) ) { 451 $bp['message'] = __('There was an error leaving the group. Please try again.', 'buddypress');452 $bp['message_type'] = 'error';439 bp_core_add_message( __('There was an error leaving the group. Please try again.', 'buddypress'), 'error' ); 440 wp_redirect( bp_group_permalink( $group_obj, false) ); 453 441 } else { 454 $bp['message'] = __('You left the group successfully.', 'buddypress');455 $bp['message_type'] = 'success';442 bp_core_add_message( __('You left the group successfully.', 'buddypress') ); 443 wp_redirect( $bp['loggedin_domain'] . $bp['groups']['slug'] ); 456 444 } 457 add_action( 'template_notices', 'bp_core_render_notice' );458 459 $bp['current_action'] = 'group-home';460 bp_catch_uri( 'groups/group-home' );461 462 445 } else if ( isset($bp['action_variables']) && $bp['action_variables'][0] == 'no' ) { 463 bp_catch_uri( 'groups/group-home');446 wp_redirect( bp_group_permalink( $group_obj, false) ); 464 447 } else { 465 448 // Show leave group page … … 476 459 477 460 if ( $group_obj->status == 'private' ) { 478 479 461 // If the user has submitted a request, send it. 480 462 if ( isset( $_POST['group-request-send']) ) { 481 463 if ( !groups_send_membership_request( $bp['loggedin_userid'], $group_obj->id ) ) { 482 $bp['message'] = __( 'There was an error sending your group membership request, please try again.', 'buddypress' ); 483 $bp['message_type'] = 'error'; 464 bp_core_add_message( __( 'There was an error sending your group membership request, please try again.', 'buddypress' ), 'error' ); 484 465 } else { 485 $bp['message'] = __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ); 486 $bp['message_type'] = 'success'; 466 bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) ); 487 467 } 488 add_action( 'template_notices', 'bp_core_render_notice' );489 490 468 } 491 469 bp_catch_uri( 'groups/request-membership' ); … … 501 479 502 480 function groups_screen_group_admin_edit_details() { 503 global $bp ;481 global $bp, $group_obj; 504 482 505 483 if ( $bp['current_component'] == $bp['groups']['slug'] && $bp['action_variables'][0] == 'edit-details' ) { … … 507 485 if ( !$bp['is_item_admin'] ) 508 486 return false; 509 487 510 488 // If the edit form has been submitted, save the edited details 511 489 if ( isset( $_POST['save'] ) ) { 512 490 if ( !groups_edit_base_group_details( $_POST['group-id'], $_POST['group-name'], $_POST['group-desc'], $_POST['group-news'], (int)$_POST['group-notify-members'] ) ) { 513 $bp['message'] = __( 'There was an error updating group details, please try again.', 'buddypress' ); 514 $bp['message_type'] = 'error'; 491 bp_core_add_message( __( 'There was an error updating group details, please try again.', 'buddypress' ), 'error' ); 515 492 } else { 516 $bp['message'] = __( 'Group details were successfully updated.', 'buddypress' ); 517 $bp['message_type'] = 'success'; 493 bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) ); 518 494 } 519 add_action( 'template_notices', 'bp_core_render_notice');495 wp_redirect( $_SERVER['HTTP_REFERER'] ); 520 496 } 521 497 … … 523 499 } 524 500 } 525 add_action( 'wp', 'groups_screen_group_admin_edit_details', 3);501 add_action( 'wp', 'groups_screen_group_admin_edit_details', 4 ); 526 502 527 503 … … 543 519 544 520 if ( !groups_edit_group_settings( $_POST['group-id'], $enable_wire, $enable_forum, $enable_photos, $photos_admin_only, $status ) ) { 545 $bp['message'] = __( 'There was an error updating group settings, please try again.', 'buddypress' ); 546 $bp['message_type'] = 'error'; 521 bp_core_add_message( __( 'There was an error updating group settings, please try again.', 'buddypress' ), 'error' ); 547 522 } else { 548 $bp['message'] = __( 'Group settings were successfully updated.', 'buddypress' ); 549 $bp['message_type'] = 'success'; 523 bp_core_add_message( __( 'Group settings were successfully updated.', 'buddypress' ) ); 550 524 } 551 add_action( 'template_notices', 'bp_core_render_notice' ); 525 526 wp_redirect( $_SERVER['HTTP_REFERER'] ); 552 527 } 553 528 … … 555 530 } 556 531 } 557 add_action( 'wp', 'groups_screen_group_admin_settings', 3);532 add_action( 'wp', 'groups_screen_group_admin_settings', 4 ); 558 533 559 534 … … 576 551 // Accept the membership request 577 552 if ( !groups_accept_membership_request( $membership_id ) ) { 578 $bp['message'] = __( 'There was an error accepting the membership request, please try again.', 'buddypress' ); 579 $bp['message_type'] = 'error'; 553 bp_core_add_message( __( 'There was an error accepting the membership request, please try again.', 'buddypress' ), 'error' ); 580 554 } else { 581 $bp['message'] = __( 'Group membership request accepted', 'buddypress' ); 582 $bp['message_type'] = 'success'; 555 bp_core_add_message( __( 'Group membership request accepted', 'buddypress' ) ); 583 556 } 584 557 } else if ( $request_action == 'reject' && is_numeric($membership_id) ) { 585 558 // Reject the membership request 586 559 if ( !groups_reject_membership_request( $membership_id ) ) { 587 $bp['message'] = __( 'There was an error rejecting the membership request, please try again.', 'buddypress' ); 588 $bp['message_type'] = 'error'; 560 bp_core_add_message( __( 'There was an error rejecting the membership request, please try again.', 'buddypress' ), 'error' ); 589 561 } else { 590 $bp['message'] = __( 'Group membership request rejected', 'buddypress' ); 591 $bp['message_type'] = 'success'; 562 bp_core_add_message( __( 'Group membership request rejected', 'buddypress' ) ); 592 563 } 593 564 } 594 add_action( 'template_notices', 'bp_core_render_notice');565 wp_redirect( $_SERVER['HTTP_REFERER'] ); 595 566 } 596 567 … … 598 569 } 599 570 } 600 add_action( 'wp', 'groups_screen_group_admin_requests', 3 ); 601 571 add_action( 'wp', 'groups_screen_group_admin_requests', 4 ); 572 573 function groups_screen_group_admin_delete_group() { 574 global $bp, $group_obj; 575 576 if ( $bp['current_component'] == $bp['groups']['slug'] && $bp['action_variables'][0] == 'delete-group' ) { 577 578 if ( !$bp['is_item_admin'] ) 579 return false; 580 581 if ( isset( $_POST['delete-group-button'] ) && isset( $_POST['delete-group-understand'] ) ) { 582 // Group admin has deleted the group, now do it. 583 if ( !groups_delete_group( $_POST['group-id']) ) { 584 bp_core_add_message( __( 'There was an error deleting the group, please try again.', 'buddypress' ), 'error' ); 585 } else { 586 bp_core_add_message( __( 'The group was deleted successfully', 'buddypress' ) ); 587 wp_redirect( site_url() . '/' . $bp['groups']['slug'] . '/' ); 588 } 589 wp_redirect( $_SERVER['HTTP_REFERER'] ); 590 } else { 591 bp_catch_uri( 'groups/admin/delete-group' ); 592 } 593 } 594 } 595 add_action( 'wp', 'groups_screen_group_admin_delete_group', 4 ); 602 596 603 597 function groups_screen_notification_settings() { … … 660 654 if ( !groups_is_user_member( $bp['loggedin_userid'], $group_obj->id ) ) { 661 655 if ( !groups_join_group($group_obj->id) ) { 662 $bp['message'] = __('There was an error joining the group. Please try again.', 'buddypress'); 663 $bp['message_type'] = 'error'; 656 bp_core_add_message( __('There was an error joining the group. Please try again.', 'buddypress'), 'error' ); 664 657 } else { 665 $bp['message'] = __('You joined the group!', 'buddypress'); 666 $bp['message_type'] = 'success'; 658 bp_core_add_message( __('You joined the group!', 'buddypress') ); 667 659 } 668 669 add_action( 'template_notices', 'bp_core_render_notice' ); 660 wp_redirect( $_SERVER['HTTP_REFERER'] ); 670 661 } 671 662 … … 1192 1183 } 1193 1184 1185 function groups_is_group_admin( $user_id, $group_id ) { 1186 return BP_Groups_Member::check_is_admin( $user_id, $group_id ); 1187 } 1188 1194 1189 function groups_new_wire_post( $group_id, $content ) { 1195 1190 if ( $wire_post_id = bp_wire_new_post( $group_id, $content ) ) { … … 1229 1224 if ( !$group->save() ) 1230 1225 return false; 1231 1226 1232 1227 if ( $notify_members ) 1233 1228 groups_notification_group_updated( $group->id ); … … 1312 1307 } 1313 1308 1314 function groups_ get_random_group() {1309 function groups_redirect_to_random_group() { 1315 1310 global $bp, $wpdb; 1316 1311 1317 1312 if ( $bp['current_component'] == $bp['groups']['slug'] && isset( $_GET['random'] ) ) { 1318 $groups = groups_get_all(); 1319 1320 wp_redirect( $bp['root_domain'] . '/' . $bp['groups']['slug'] . '/' . $groups[rand( 0, count($groups) - 1)]->slug ); 1321 } 1322 } 1323 add_action( 'wp', 'groups_get_random_group', 6 ); 1313 $group = groups_get_random_group(); 1314 1315 wp_redirect( $bp['root_domain'] . '/' . $bp['groups']['slug'] . '/' . $group->slug ); 1316 } 1317 } 1318 add_action( 'wp', 'groups_redirect_to_random_group', 6 ); 1319 1320 function groups_delete_group( $group_id ) { 1321 global $bp; 1322 1323 // Check the user is the group admin. 1324 if ( !groups_is_group_admin( $bp['loggedin_userid'], $group_id ) ) 1325 return false; 1326 1327 // Get the group object 1328 $group = new BP_Groups_Group( $group_id ); 1329 1330 if ( !$group->delete() ) 1331 return false; 1332 1333 return true; 1334 } 1324 1335 1325 1336 function groups_check_for_membership_request( $user_id, $group_id ) { … … 1341 1352 function groups_get_all() { 1342 1353 return BP_Groups_Group::get_all(); 1354 } 1355 1356 function groups_get_random_group() { 1357 return BP_Groups_Group::get_random(); 1343 1358 } 1344 1359 … … 1349 1364 // 1350 1365 1351 function groups_delete_groupmeta( $group_id, $meta_key , $meta_value = '') {1366 function groups_delete_groupmeta( $group_id, $meta_key = false, $meta_value = false ) { 1352 1367 global $wpdb, $bp; 1353 1368 … … 1362 1377 $meta_value = trim( $meta_value ); 1363 1378 1364 if ( !empty($meta_value) ) 1365 $wpdb->query( $wpdb->prepare("DELETE FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE groups_id = %d AND meta_key = %s AND meta_value = %s", $group_id, $meta_key, $meta_value) ); 1366 else 1367 $wpdb->query( $wpdb->prepare("DELETE FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key) ); 1368 1379 if ( !$meta_key ) { 1380 $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE group_id = %d", $group_id ) ); 1381 } else if ( !$meta_value ) { 1382 $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE group_id = %d AND meta_key = %s AND meta_value = %s", $group_id, $meta_key, $meta_value ) ); 1383 } else { 1384 $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) ); 1385 } 1386 1369 1387 // TODO need to look into using this. 1370 1388 // wp_cache_delete($group_id, 'groups'); -
trunk/bp-groups/bp-groups-classes.php
r508 r511 164 164 ); 165 165 } 166 167 if ( !$result = $wpdb->query($sql))166 167 if ( $wpdb->query($sql) === false ) 168 168 return false; 169 169 … … 228 228 return false; 229 229 } 230 231 function delete() { 232 global $wpdb, $bp; 233 234 // Delete groupmeta for the group 235 groups_delete_groupmeta( $this->id ); 236 237 // Modify group count usermeta for members 238 for ( $i = 0; $i < count($this->user_dataset); $i++ ) { 239 $user = $this->user_dataset[$i]; 240 241 if ( $total_count = get_usermeta( $user->user_id, 'total_group_count' ) != '' ) { 242 update_usermeta( $user->user_id, 'total_group_count', (int)$total_count - 1 ); 243 } 244 245 // Now delete the group member record 246 BP_Groups_Member::delete( $user->user_id, $this->id, false ); 247 } 248 249 // Delete the wire posts for this group if the wire is installed 250 if ( function_exists('bp_wire_install') ) { 251 BP_Wire_Post::delete_all_for_item( $this->id, $bp['groups']['table_name_wire'] ); 252 } 253 254 do_action( 'bp_groups_delete_group_content', $this->id ); 255 256 // Finally remove the group entry from the DB 257 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['groups']['table_name'] . " WHERE id = %d", $this->id ) ) ) 258 return false; 259 260 return true; 261 } 262 230 263 231 264 /* Static Functions */ 232 233 function delete( $group_id ) { 234 global $wpdb, $bp; 235 236 if ( $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['groups']['table_name'] . " WHERE id = %d", $group_id ) ) ) 237 return false; 238 239 /* Remove groupmeta */ 240 groups_delete_groupmeta( $group_id ); 241 242 return true; 243 } 244 265 245 266 function group_exists( $slug, $table_name = false ) { 246 267 global $wpdb, $bp; … … 379 400 380 401 return $wpdb->get_results( $wpdb->prepare( "SELECT id, slug FROM " . $bp['groups']['table_name'] . " WHERE status = 'public'" ) ); 402 } 403 404 function get_random() { 405 global $wpdb, $bp; 406 407 return $wpdb->get_row( $wpdb->prepare( "SELECT id, slug FROM " . $bp['groups']['table_name'] . " WHERE status = 'public' ORDER BY rand() LIMIT 1" ) ); 381 408 } 382 409 } … … 476 503 /* Static Functions */ 477 504 478 function delete( $user_id, $group_id ) {505 function delete( $user_id, $group_id, $check_empty = true ) { 479 506 global $wpdb, $bp; 480 507 481 508 $delete_result = $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['groups']['table_name_members'] . " WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) ); 482 483 // Check to see if there are any members left for the group, if not, delete it. 484 if ( !BP_Groups_Group::has_members( $group_id ) ) { 485 BP_Groups_Group::delete( $group_id ); 486 } 487 509 488 510 return $delete_result; 489 511 } -
trunk/bp-groups/bp-groups-templatetags.php
r505 r511 414 414 <li<?php if ( $current_tab == 'edit-details' || $current_tab == '' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li> 415 415 <li<?php if ( $current_tab == 'group-settings' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/group-settings"><?php _e('Group Settings', 'buddypress') ?></a></li> 416 < !--<li<?php if ( $current_tab == 'manage-members' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li>-->417 <!--<li<?php if ( $current_tab == 'delete-group' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li>-->416 <li<?php if ( $current_tab == 'manage-members' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li> 417 418 418 <?php if ( $groups_template->group->status == 'private' ) : ?> 419 419 <li<?php if ( $current_tab == 'membership-requests' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li> 420 420 <?php endif; ?> 421 422 <li<?php if ( $current_tab == 'delete-group' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li> 423 421 424 <?php 422 425 do_action( 'bp_groups_admin_tabs' ); … … 575 578 bp_group_send_invite_form( $group_obj ); 576 579 } else { 577 $group_link = bp_group_permalink( $group , false );580 $group_link = bp_group_permalink( $group_obj, false ); 578 581 ?> 579 582 <div id="message" class="info"> -
trunk/bp-messages.php
r462 r511 117 117 118 118 function messages_check_installed() { 119 global $wpdb, $bp , $userdata;119 global $wpdb, $bp; 120 120 121 121 if ( is_site_admin() ) { … … 174 174 175 175 function messages_screen_compose() { 176 177 if ( isset($_POST['send_to']) || ( isset($_POST['send-notice']) && is_site_admin() ) ) { 178 messages_send_message( $_POST['send_to'], $_POST['subject'], $_POST['content'], $_POST['thread_id'], false, true ); 179 } 180 176 181 bp_catch_uri( 'messages/compose' ); 177 182 } … … 193 198 if ( $bp['action_variables'][0] == 'deactivate' ) { 194 199 if ( !$notice->deactivate() ) { 195 $bp['message'] = __('There was a problem deactivating that notice.', 'buddypress');200 bp_core_add_message( __('There was a problem deactivating that notice.', 'buddypress'), 'error' ); 196 201 } else { 197 $bp['message'] = __('Notice deactivated.', 'buddypress'); 198 $bp['message_type'] = 'success'; 202 bp_core_add_message( __('Notice deactivated.', 'buddypress') ); 199 203 } 200 204 } else if ( $bp['action_variables'][0] == 'activate' ) { 201 205 if ( !$notice->activate() ) { 202 $bp['message'] = __('There was a problem activating that notice.', 'buddypress');206 bp_core_add_message( __('There was a problem activating that notice.', 'buddypress'), 'error' ); 203 207 } else { 204 $bp['message'] = __('Notice activated.', 'buddypress'); 205 $bp['message_type'] = 'success'; 208 bp_core_add_message( __('Notice activated.', 'buddypress') ); 206 209 } 207 210 } else if ( $bp['action_variables'][0] == 'delete' ) { 208 211 if ( !$notice->delete() ) { 209 $bp['message'] = __('There was a problem deleting that notice.', 'buddypress');212 bp_core_add_message( __('There was a problem deleting that notice.', 'buddypress'), 'buddypress' ); 210 213 } else { 211 $bp['message'] = __('Notice deleted.', 'buddypress'); 212 $bp['message_type'] = 'success'; 214 bp_core_add_message( __('Notice deleted.', 'buddypress') ); 213 215 } 214 216 } 215 217 } 216 217 add_action( 'template_notices', 'bp_core_render_notice' );218 218 bp_catch_uri( 'messages/notices' ); 219 219 } … … 279 279 280 280 if ( !$thread_id || !is_numeric($thread_id) || !BP_Messages_Thread::check_access($thread_id) ) { 281 $bp['current_action'] = 'inbox'; 282 bp_catch_uri( 'messages/index' ); 281 wp_redirect( $_SERVER['HTTP_REFERER'] ); 283 282 } else { 284 283 // delete message 285 284 if ( !BP_Messages_Thread::delete($thread_id) ) { 286 $bp['message'] = __('There was an error deleting that message.', 'buddypress'); 287 add_action( 'template_notices', 'bp_core_render_notice' ); 288 289 $bp['current_action'] = 'inbox'; 290 bp_catch_uri( 'messages/index' ); 291 } else { 292 $bp['message'] = __('Message deleted.', 'buddypress'); 293 $bp['message_type'] = 'success'; 294 add_action( 'template_notices', 'bp_core_render_notice' ); 295 296 $bp['current_action'] = 'inbox'; 297 bp_catch_uri( 'messages/index' ); 285 bp_core_add_message( __('There was an error deleting that message.', 'buddypress'), 'error' ); 286 wp_redirect( $_SERVER['HTTP_REFERER'] ); 287 } else { 288 bp_core_add_message( __('Message deleted.', 'buddypress') ); 289 wp_redirect( $_SERVER['HTTP_REFERER'] ); 298 290 } 299 291 } … … 315 307 } else { 316 308 if ( !BP_Messages_Thread::delete( explode(',', $thread_ids ) ) ) { 317 $message = __('There was an error deleting messages.', 'buddypress'); 318 add_action( 'template_notices', 'bp_core_render_notice' ); 319 320 $bp['current_action'] = 'inbox'; 321 bp_catch_uri( 'messages/index' ); 322 } else { 323 $bp['message'] = __('Messages deleted.', 'buddypress'); 324 $bp['message_type'] = 'success'; 325 add_action( 'template_notices', 'bp_core_render_notice' ); 326 327 $bp['current_action'] = 'inbox'; 328 bp_catch_uri( 'messages/index' ); 309 bp_core_add_message( __('There was an error deleting messages.', 'buddypress'), 'error' ); 310 wp_redirect( $_SERVER['HTTP_REFERER'] ); 311 } else { 312 bp_core_add_message( __('Messages deleted.', 'buddypress') ); 313 wp_redirect( $_SERVER['HTTP_REFERER'] ); 329 314 } 330 315 } … … 360 345 361 346 /************************************************************************** 362 messages_write_new()363 364 Handle and display the write new messages screen.365 **************************************************************************/366 367 function messages_write_new( $username = '', $subject = '', $content = '', $type = '', $message = '' ) { ?>368 <?php369 global $messages_write_new_action;370 ?>371 372 <div class="wrap">373 <h2><?php _e('Compose Message', 'buddypress') ?></h2>374 375 <?php376 if ( $message != '' ) {377 $type = ( $type == 'error' ) ? 'error' : 'updated';378 ?>379 <div id="message" class="<?php echo $type; ?> fade">380 <p><?php echo $message; ?></p>381 </div>382 <?php } ?>383 384 <form action="<?php echo $messages_write_new_action ?>" method="post" id="send_message_form">385 <div id="poststuff">386 <p>387 <div id="titlediv">388 <h3><?php _e("Send To", 'buddypress') ?> <small>(Use username - autocomplete coming soon)</small></h3>389 <div id="titlewrap">390 <input type="text" name="send_to" id="send_to" value="<?php echo $username; ?>" />391 <?php if ( is_site_admin() ) : ?><br /><input type="checkbox" id="send-notice" name="send-notice" value="1" /> This is a notice to all users.<?php endif; ?>392 </div>393 </div>394 </p>395 396 <p>397 <div id="titlediv">398 <h3><?php _e("Subject", 'buddypress') ?></h3>399 <div id="titlewrap">400 <input type="text" name="subject" id="subject" value="<?php echo $subject; ?>" />401 </div>402 </div>403 </p>404 405 <p>406 <div id="postdivrich" class="postarea">407 <h3><?php _e("Message", 'buddypress') ?></h3>408 <div id="editorcontainer">409 <textarea name="content" id="message_content" rows="15" cols="40"><?php echo $content; ?></textarea>410 </div>411 </div>412 </p>413 414 <p class="submit">415 <input type="submit" value="<?php _e("Send", 'buddypress') ?> »" name="send" id="send" style="font-weight: bold" />416 </p>417 </div>418 </form>419 <script type="text/javascript">420 document.getElementById("send_to").focus();421 </script>422 423 </div>424 <?php425 }426 427 /**************************************************************************428 347 messages_send_message() 429 348 … … 432 351 433 352 function messages_send_message( $recipients, $subject, $content, $thread_id, $from_ajax = false, $from_template = false, $is_reply = false ) { 434 global $userdata;435 global $messages_write_new_action;436 353 global $pmessage; 437 354 global $message, $type; … … 440 357 if ( isset( $_POST['send-notice'] ) ) { 441 358 messages_send_notice( $subject, $content, $from_template ); 442 } else { 443 if ( $recipients == '' ) { 444 if ( !$from_ajax ) { 445 messages_write_new( '', $subject, $content, 'error', __('Please enter at least one valid user to send this message to.', 'buddypress'), $messages_write_new_action ); 359 return true; 360 } 361 362 messages_add_callback_values( $recipients, $subject, $content ); 363 364 if ( $recipients == '' ) { 365 if ( !$from_ajax ) { 366 bp_core_add_message( __('Please enter at least one valid user to send this message to.', 'buddypress'), 'error' ); 367 wp_redirect( $_SERVER['HTTP_REFERER'] ); 368 } else { 369 return array('status' => 0, 'message' => __('There was an error sending the reply, please try again.', 'buddypress')); 370 } 371 } else if ( $subject == '' || $content == '' ) { 372 if ( !$from_ajax ) { 373 bp_core_add_message( __('Please make sure you fill in all the fields.', 'buddypress'), 'error' ); 374 wp_redirect( $_SERVER['HTTP_REFERER'] ); 375 } else { 376 return array('status' => 0, 'message' => __('Please make sure you have typed a message before sending a reply.', 'buddypress')); 377 } 378 } else { 379 $pmessage = new BP_Messages_Message; 380 381 $pmessage->sender_id = $bp['loggedin_userid']; 382 $pmessage->subject = $subject; 383 $pmessage->message = $content; 384 $pmessage->thread_id = $thread_id; 385 $pmessage->date_sent = time(); 386 $pmessage->message_order = 0; // TODO 387 $pmessage->sender_is_group = 0; 388 389 if ( $is_reply ) { 390 $thread = new BP_Messages_Thread($thread_id); 391 $pmessage->recipients = $thread->get_recipients(); 392 } else { 393 $pmessage->recipients = BP_Messages_Message::get_recipient_ids( explode( ',', $recipients ) ); 394 } 395 396 if ( !is_null( $pmessage->recipients ) ) { 397 if ( !$pmessage->send() ) { 398 $message = __('Message could not be sent, please try again.', 'buddypress'); 399 $type = 'error'; 400 401 if ( $from_ajax ) { 402 return array('status' => 0, 'message' => $message); 403 } else { 404 bp_core_add_message( $message, $type ); 405 wp_redirect( $_SERVER['HTTP_REFERER'] ); 406 } 446 407 } else { 447 return array('status' => 0, 'message' => __('There was an error sending the reply, please try again.', 'buddypress')); 448 } 449 } else if ( $subject == '' || $content == '' ) { 450 if ( !$from_ajax ) { 451 messages_write_new( $to_user, $subject, $content, 'error', __('Please make sure you fill in all the fields.', 'buddypress'), $messages_write_new_action ); 452 } else { 453 return array('status' => 0, 'message' => __('Please make sure you have typed a message before sending a reply.', 'buddypress')); 454 } 455 } else { 456 $pmessage = new BP_Messages_Message; 457 458 $pmessage->sender_id = $userdata->ID; 459 $pmessage->subject = $subject; 460 $pmessage->message = $content; 461 $pmessage->thread_id = $thread_id; 462 $pmessage->date_sent = time(); 463 $pmessage->message_order = 0; // TODO 464 $pmessage->sender_is_group = 0; 465 466 if ( $is_reply ) { 467 $thread = new BP_Messages_Thread($thread_id); 468 $pmessage->recipients = $thread->get_recipients(); 469 } else { 470 $pmessage->recipients = BP_Messages_Message::get_recipient_ids( explode( ',', $recipients ) ); 471 } 472 473 unset($_GET['mode']); 474 475 if ( !is_null( $pmessage->recipients ) ) { 476 if ( !$pmessage->send() ) { 477 $message = __('Message could not be sent, please try again.', 'buddypress'); 478 $type = 'error'; 479 480 if ( $from_ajax ) { 481 return array('status' => 0, 'message' => $message); 482 } else if ( $from_template ) { 483 unset($_POST['send_to']); 484 $bp['message'] = $message; 485 $bp['message_type'] = $type; 486 487 bp_core_render_notice(); 488 messages_write_new(); 489 } else { 490 messages_box( 'inbox', __('Inbox', 'buddypress'), $message, $type ); 491 } 492 } else { 493 $message = __('Message sent successfully!', 'buddypress') . ' <a href="' . $bp['loggedin_domain'] . $bp['messages']['slug'] . '/view/' . $pmessage->thread_id . '">' . __('View Message', 'buddypress') . '</a> »'; 494 $type = 'success'; 495 496 // Send notices to the recipients 497 for ( $i = 0; $i < count($pmessage->recipients); $i++ ) { 498 if ( $pmessage->recipients[$i] != $bp['loggedin_userid'] ) { 499 bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' ); 500 } 501 } 502 503 do_action( 'bp_messages_message_sent', array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'thread_id' => $pmessage->thread_id, 'component_name' => 'messages', 'component_action' => 'message_sent', 'is_private' => 1 ) ); 504 505 if ( $from_ajax ) { 506 return array('status' => 1, 'message' => $message, 'reply' => $pmessage); 507 } else if ( $from_template ) { 508 unset($_POST['send_to']); 509 $bp['message'] = $message; 510 $bp['message_type'] = $type; 511 512 bp_core_render_notice(); 513 messages_write_new(); 514 } else { 515 messages_box( 'inbox', __('Inbox', 'buddypress'), $message, $type ); 408 $message = __('Message sent successfully!', 'buddypress') . ' <a href="' . $bp['loggedin_domain'] . $bp['messages']['slug'] . '/view/' . $pmessage->thread_id . '">' . __('View Message', 'buddypress') . '</a> »'; 409 $type = 'success'; 410 411 // Send notices to the recipients 412 for ( $i = 0; $i < count($pmessage->recipients); $i++ ) { 413 if ( $pmessage->recipients[$i] != $bp['loggedin_userid'] ) { 414 bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' ); 516 415 } 517 416 } 518 } else { 519 unset($_POST['send_to']); 520 unset($_POST['send-notice']); 521 522 $message = __('Message could not be sent, please try again.', 'buddypress'); 523 $type = 'error'; 524 417 418 do_action( 'bp_messages_message_sent', array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'thread_id' => $pmessage->thread_id, 'component_name' => 'messages', 'component_action' => 'message_sent', 'is_private' => 1 ) ); 419 525 420 if ( $from_ajax ) { 526 return array('status' => 0, 'message' => $message); 527 } else if ( $from_template ) { 528 $bp['message'] = $message; 529 $bp['message_type'] = $type; 530 531 bp_core_render_notice(); 532 messages_write_new(); 421 return array('status' => 1, 'message' => $message, 'reply' => $pmessage); 533 422 } else { 534 messages_box( 'inbox', __('Inbox', 'buddypress'), $message, $type ); 423 bp_core_add_message( $message ); 424 wp_redirect( $bp['loggedin_domain'] . $bp['messages']['slug'] . '/inbox' ); 535 425 } 536 426 } 537 } 538 } 427 } else { 428 $message = __('Message could not be sent, please try again.', 'buddypress'); 429 $type = 'error'; 430 431 if ( $from_ajax ) { 432 return array('status' => 0, 'message' => $message); 433 } else { 434 bp_core_add_message( $message, $type ); 435 wp_redirect( $bp['loggedin_domain'] . $bp['messages']['slug'] . '/compose' ); 436 } 437 } 438 } 439 440 } 441 442 function messages_add_callback_values( $recipients, $subject, $content ) { 443 $_SESSION['send_to'] = $recipients; 444 $_SESSION['subject'] = $subject; 445 $_SESSION['content'] = $content; 539 446 } 540 447 … … 570 477 do_action( 'bp_messages_notice_sent', $subject, $message ); 571 478 } 572 573 479 } 574 480 … … 615 521 616 522 function messages_view_thread( $thread_id ) { 617 global $ userdata, $bp;523 global $bp; 618 524 619 525 $thread = new BP_Messages_Thread( $thread_id, true ); … … 634 540 <img src="<?php echo $bp['messages']['image_base'] ?>/email_open.gif" alt="Message" style="vertical-align: top;" /> 635 541 <?php _e('Sent between ', 'buddypress') ?> <?php echo BP_Messages_Thread::get_recipient_links($thread->recipients) ?> 636 <?php _e('and', 'buddypress') ?> <?php echo bp_core_get_userlink($ userdata->ID) ?>.542 <?php _e('and', 'buddypress') ?> <?php echo bp_core_get_userlink($bp['loggedin_userid']) ?>. 637 543 </td> 638 544 </tr> … … 665 571 <div class="avatar-box"> 666 572 <?php if ( function_exists('bp_core_get_avatar') ) 667 echo bp_core_get_avatar($ userdata->ID, 1);573 echo bp_core_get_avatar($bp['loggedin_userid'], 1); 668 574 ?> 669 575 -
trunk/bp-messages/bp-messages-templatetags.php
r439 r511 190 190 } 191 191 192 function bp_compose_message_form() {193 global $bp;194 global $messages_write_new_action;195 196 $messages_write_new_action = $bp['loggedin_domain'] . $bp['messages']['slug'] . '/compose/';197 198 if ( isset($_POST['send_to']) || ( isset($_POST['send-notice']) && is_site_admin() ) ) {199 messages_send_message( $_POST['send_to'], $_POST['subject'], $_POST['content'], $_POST['thread_id'], false, true );200 } else {201 messages_write_new();202 }203 }204 205 192 function bp_messages_pagination() { 206 193 global $messages_template; … … 212 199 213 200 echo $bp['loggedin_domain'] . $bp['messages']['slug'] . '/' . $bp['current_action']; 201 } 202 203 function bp_messages_username_value() { 204 echo $_SESSION['send_to']; 205 } 206 207 function bp_messages_subject_value() { 208 echo $_SESSION['subject']; 209 } 210 211 function bp_messages_content_value() { 212 echo $_SESSION['content']; 214 213 } 215 214 -
trunk/bp-wire.php
r476 r511 85 85 global $bp; 86 86 87 if ( $bp['current_ action'] != 'post' )87 if ( $bp['current_component'] != $bp['xprofile']['slug'] && $bp['current_action'] != 'post' ) 88 88 return false; 89 89 90 if ( $wire_post_id = bp_wire_new_post( $bp['current_userid'], $_POST['wire-post-textarea'], $bp['profile']['table_name_wire'] ) ) { 91 $bp['message'] = __('Wire message successfully posted.', 'buddypress'); 92 $bp['message_type'] = 'success'; 93 94 do_action( 'bp_xprofile_new_wire_post', array( 'item_id' => $wire_post_id, 'component_name' => 'profile', 'component_action' => 'new_wire_post', 'is_private' => 0 ) ); 95 add_action( 'template_notices', 'bp_core_render_notice' ); 90 if ( !$wire_post_id = bp_wire_new_post( $bp['current_userid'], $_POST['wire-post-textarea'], $bp['profile']['table_name_wire'] ) ) { 91 bp_core_add_message( __('Wire message could not be posted. Please try again.', 'buddypress'), 'error' ); 92 } else { 93 bp_core_add_message( __('Wire message successfully posted.', 'buddypress') ); 94 do_action( 'bp_xprofile_new_wire_post', array( 'item_id' => $wire_post_id, 'component_name' => 'profile', 'component_action' => 'new_wire_post', 'is_private' => 0 ) ); 96 95 } 97 96 98 97 if ( !strpos( $_SERVER['HTTP_REFERER'], $bp['wire']['slug'] ) ) { 99 $bp['current_component'] = $bp['profile']['slug']; 100 $bp['current_action'] = 'public'; 101 bp_catch_uri( 'profile/index' ); 98 wp_redirect( $bp['current_domain'] ); 102 99 } else { 103 bp_catch_uri( 'wire/latest');104 } 100 wp_redirect( $bp['current_domain']. $bp['wire']['slug'] ); 101 } 105 102 } 106 103 add_action( 'wp', 'bp_wire_action_post', 3 ); … … 109 106 global $bp; 110 107 111 if ( $bp['current_ action'] != 'delete' )108 if ( $bp['current_component'] != $bp['xprofile']['slug'] && $bp['current_action'] != 'delete' ) 112 109 return false; 113 110 114 111 if ( bp_wire_delete_post( $bp['action_variables'][0], $bp['profile']['table_name_wire'] ) ) { 115 $bp['message'] = __('Wire message successfully deleted.', 'buddypress'); 116 $bp['message_type'] = 'success'; 117 118 do_action( 'bp_xprofile_delete_wire_post' ); 119 add_action( 'template_notices', 'bp_core_render_notice' ); 112 bp_core_add_message( __('Wire message successfully deleted.', 'buddypress'), false, true ); 113 do_action( 'bp_xprofile_delete_wire_post' ); 120 114 } 121 115 122 116 if ( !strpos( $_SERVER['HTTP_REFERER'], $bp['wire']['slug'] ) ) { 123 $bp['current_component'] = $bp['profile']['slug']; 124 $bp['current_action'] = 'public'; 125 bp_catch_uri( 'profile/index' ); 117 wp_redirect( $bp['current_domain'] ); 126 118 } else { 127 bp_catch_uri( 'wire/latest');119 wp_redirect( $bp['current_domain']. $bp['wire']['slug'] ); 128 120 } 129 121 } -
trunk/bp-wire/bp-wire-classes.php
r476 r511 100 100 return array( 'wire_posts' => $wire_posts, 'count' => $count ); 101 101 } 102 103 function delete_all_for_item( $item_id, $table_name ) { 104 global $wpdb, $bp; 105 106 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE item_id = %d", $item_id ) ); 107 } 102 108 } 103 109 -
trunk/bp-xprofile.php
r502 r511 126 126 function xprofile_setup_globals() { 127 127 global $bp, $wpdb; 128 129 /* Need to start a session for signup metadata purposes */130 session_start();131 128 132 129 $bp['profile'] = array(
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)