Ticket #6432: 6432.patch
File 6432.patch, 21.0 KB (added by , 9 years ago) |
---|
-
src/bp-activity/bp-activity-loader.php
diff --git src/bp-activity/bp-activity-loader.php src/bp-activity/bp-activity-loader.php index 2a34aca..9366910 100644
class BP_Activity_Component extends BP_Component { 114 114 'search_string' => __( 'Search Activity...', 'buddypress' ), 115 115 'global_tables' => $global_tables, 116 116 'meta_tables' => $meta_tables, 117 'feedback_messages' => array( 118 array( 'code' => 2, 'message' => sprintf( __( 'Please use less than %d links in your update', 'buddypress' ), get_option( 'comment_max_links' ) ), 'data' => '' ), 119 ), 117 120 ); 118 121 119 122 parent::setup_globals( $args ); -
src/bp-core/bp-core-classes.php
diff --git src/bp-core/bp-core-classes.php src/bp-core/bp-core-classes.php index 41be065..ccd8804 100644
9 9 // Exit if accessed directly 10 10 defined( 'ABSPATH' ) || exit; 11 11 12 require dirname( __FILE__ ) . '/classes/class-bp-feedback.php'; 12 13 require dirname( __FILE__ ) . '/classes/class-bp-user-query.php'; 13 14 require dirname( __FILE__ ) . '/classes/class-bp-core-user.php'; 14 15 require dirname( __FILE__ ) . '/classes/class-bp-date-query.php'; -
src/bp-core/bp-core-component.php
diff --git src/bp-core/bp-core-component.php src/bp-core/bp-core-component.php index a24de99..2b7a592 100644
class BP_Component { 125 125 */ 126 126 public $global_tables = array(); 127 127 128 /** 129 * Feedback for the component (if applicable) 130 * 131 * @since BuddyPress (2.4.0) 132 * 133 * @var object 134 */ 135 public $feedback = null; 136 128 137 /** Methods ***************************************************************/ 129 138 130 139 /** … … class BP_Component { 221 230 'search_string' => '', 222 231 'global_tables' => '', 223 232 'meta_tables' => '', 233 'feedback_messages' => array(), 224 234 ) ); 225 235 226 236 /** … … class BP_Component { 287 297 $this->register_meta_tables( $r['meta_tables'] ); 288 298 } 289 299 300 // Set the feedback messages 301 if ( ! empty( $r['feedback_messages'] ) ) { 302 $this->feedback = new BP_Feedback; 303 304 foreach ( (array) $r['feedback_messages'] as $feedback_message ) { 305 $this->feedback->add( $feedback_message['code'], $feedback_message['message'], $feedback_message['data'] ); 306 } 307 } 308 290 309 /** BuddyPress ********************************************************/ 291 310 292 311 // Register this component in the loaded components array -
src/bp-core/bp-core-functions.php
diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php index 55449bf..2707f6a 100644
function bp_core_get_root_domain() { 917 917 * headers. Default: 302. 918 918 */ 919 919 function bp_core_redirect( $location = '', $status = 302 ) { 920 $bp = buddypress(); 920 921 921 922 // On some setups, passing the value of wp_get_referer() may result in an 922 923 // empty value for $location, which results in an error. Ensure that we … … function bp_core_redirect( $location = '', $status = 302 ) { 925 926 $location = bp_get_root_domain(); 926 927 } 927 928 929 if ( ! empty( $bp->template_message_code ) ) { 930 $args = array( 'success' => $bp->template_message_code ); 931 932 if ( ! empty( $bp->template_message_type ) ) { 933 $args = array( $bp->template_message_type => $bp->template_message_code ); 934 } 935 936 $location = esc_url_raw( add_query_arg( $args, $location ) ); 937 } 938 928 939 // Make sure we don't call status_header() in bp_core_do_catch_uri() as this 929 940 // conflicts with wp_redirect() and wp_safe_redirect(). 930 buddypress()->no_status_set = true;941 $bp->no_status_set = true; 931 942 932 943 wp_safe_redirect( $location, $status ); 933 944 die; … … function bp_core_add_message( $message, $type = '' ) { 1260 1271 */ 1261 1272 $bp->template_message = $message; 1262 1273 $bp->template_message_type = $type; 1274 1275 // Template message code defaults to 1 1276 $bp->template_message_code = 1; 1277 } 1278 1279 /** 1280 * Set the feedback message code 1281 * 1282 * @param mixed $codes single message code, array or comma separated list of message codes 1283 * @param string $type Message type. 'updated', 'success', 'error', 'warning'. 1284 * Default: 'success'. 1285 */ 1286 function bp_core_add_message_code( $codes = '', $type = '' ) { 1287 1288 // Success is the default 1289 if ( empty( $type ) ) { 1290 $type = 'success'; 1291 } 1292 1293 // Get BuddyPress 1294 $bp = buddypress(); 1295 1296 $message_codes = wp_parse_id_list( $codes ); 1297 1298 /*** 1299 * Send the values to the $bp global so we can still output messages 1300 * without a page reload 1301 */ 1302 $bp->template_message_code = join( ',', $message_codes ); 1303 $bp->template_message_type = $type; 1263 1304 } 1264 1305 1265 1306 /** … … function bp_core_setup_message() { 1300 1341 add_action( 'bp_actions', 'bp_core_setup_message', 5 ); 1301 1342 1302 1343 /** 1344 * Get feedback messages for given codes and component 1345 * 1346 * @since BuddyPress (2.4.0) 1347 * 1348 * @param array $codes the code of the feedback messages to get 1349 * @param string $component the id of the component messages are related to 1350 * @return array list of matching feedback messages 1351 */ 1352 function bp_core_get_feedback_messages( $codes = array(), $component = '' ) { 1353 $bp = buddypress(); 1354 1355 if ( empty( $component ) ) { 1356 $component = 'core'; 1357 1358 if ( bp_current_component() ) { 1359 $component = bp_current_component(); 1360 } 1361 } 1362 1363 if ( ! bp_is_active( $component ) || empty( $codes ) ) { 1364 return false; 1365 } 1366 1367 /** 1368 * Filter to edit the feedback messages 1369 * 1370 * @since BuddyPress (2.4.0) 1371 * 1372 * @param array list of feedback messages 1373 * @param array $codes list of feedback codes 1374 * @param string $component the component id the messages are related to 1375 */ 1376 return (array) apply_filters( 'bp_core_get_feedback_messages', $bp->{$component}->feedback->get_feedback_messages( $codes ), $codes, $component ); 1377 } 1378 1379 /** 1303 1380 * Render the 'template_notices' feedback message. 1304 1381 * 1305 1382 * The hook action 'template_notices' is used to call this function, it is not 1306 1383 * called directly. 1307 1384 */ 1308 function bp_core_render_message( ) {1385 function bp_core_render_message( $class = '', $echo = true ) { 1309 1386 1310 1387 // Get BuddyPress 1311 1388 $bp = buddypress(); 1312 1389 1313 if ( !empty( $bp->template_message ) ) : 1314 $type = ( 'success' === $bp->template_message_type ) ? 'updated' : 'error'; 1390 if ( ! empty( $_REQUEST ) ) { 1391 $is_feedback = array_intersect_key( $_REQUEST, array( 'error' => true, 'success' => true ) ); 1392 1393 if ( ! empty( $is_feedback ) ) { 1394 $bp->template_message_type = key( $is_feedback ); 1395 $bp->template_message_code = $is_feedback[ $bp->template_message_type ]; 1396 } 1397 } 1398 1399 if ( isset( $bp->template_message_code ) && 1 !== (int) $bp->template_message_code ) { 1400 $codes = wp_parse_id_list( $bp->template_message_code ); 1401 $messages = bp_core_get_feedback_messages( $codes ); 1402 1403 } elseif ( ! empty( $bp->template_message ) ) { 1404 $messages = array( $bp->template_message ); 1405 } 1406 1407 if ( empty( $messages ) ) { 1408 return; 1409 } 1410 1411 // Set the type 1412 $type = ( 'success' === $bp->template_message_type ) ? 'updated' : 'error'; 1413 1414 if ( empty( $class ) ) { 1415 $class = 'bp-template-notice'; 1416 } 1417 1418 /** 1419 * Filters the classes of the 'template_notices' 1420 * 1421 * @since BuddyPress (2.4.0) 1422 * 1423 * @param array the classes for the template notices 1424 */ 1425 $classes = apply_filters( 'bp_core_render_message_classes', array( $class, $type ) ); 1426 1427 // Build the output 1428 $output = '<div id="message" class="' . join( ' ', array_map( 'sanitize_html_class', $classes ) ) . '">'; 1315 1429 1430 foreach ( $messages as $message ) { 1316 1431 /** 1317 1432 * Filters the 'template_notices' feedback message content. 1318 1433 * … … function bp_core_render_message() { 1322 1437 * @param string $type The type of message being displayed. 1323 1438 * Either 'updated' or 'error'. 1324 1439 */ 1325 $content = apply_filters( 'bp_core_render_message_content', $bp->template_message, $type ); ?> 1326 1327 <div id="message" class="bp-template-notice <?php echo esc_attr( $type ); ?>"> 1440 $output .= apply_filters( 'bp_core_render_message_content', $message, $type ); 1441 } 1328 1442 1329 <?php echo $content; ?>1443 $output .= '</div>'; 1330 1444 1331 </div>1332 1333 <?php1445 // Return the message 1446 if ( false === (bool) $echo ) { 1447 return $output; 1334 1448 1449 // Display the message 1450 } else { 1451 echo $output; 1335 1452 /** 1336 1453 * Fires after the display of any template_notices feedback messages. 1337 1454 * 1338 1455 * @since BuddyPress (1.1.0) 1339 1456 */ 1340 1457 do_action( 'bp_core_render_message' ); 1341 1342 endif; 1458 } 1343 1459 } 1344 1460 1345 1461 /** Last active ***************************************************************/ -
src/bp-core/bp-core-moderation.php
diff --git src/bp-core/bp-core-moderation.php src/bp-core/bp-core-moderation.php index c2cf377..40fb21e 100644
function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '' 134 134 135 135 // Das ist zu viele links! 136 136 if ( $num_links >= $max_links ) { 137 bp_core_add_message_code( 2, 'error' ); 137 138 return false; 138 139 } 139 140 } -
src/bp-core/classes/class-bp-feedback.php
diff --git src/bp-core/classes/class-bp-feedback.php src/bp-core/classes/class-bp-feedback.php index e69de29..14ebd40 100644
1 <?php 2 /** 3 * Core component classes. 4 * 5 * @package BuddyPress 6 * @subpackage Core 7 */ 8 9 // Exit if accessed directly 10 defined( 'ABSPATH' ) || exit; 11 12 /** 13 * User feedback class 14 * 15 * @since BuddyPress (2.4.0) 16 */ 17 class BP_Feedback extends WP_Error { 18 19 /** 20 * Get the list of feedback messages for the requested codes 21 * 22 * @since BuddyPress (2.4.0) 23 * 24 * @param array $codes the list of requested codes 25 * @return array $selected_messages the list of feedback messages 26 */ 27 public function get_feedback_messages( $codes = array() ) { 28 $selected_messages = array(); 29 30 if ( count( $codes ) > 1 ) { 31 $selected_messages = array_flip( $codes ); 32 33 foreach ( (array) $this->errors as $code => $messages ) { 34 if ( isset( $selected_messages[ $code ] ) ) { 35 $selected_messages[ $code ] = $messages[0]; 36 } 37 } 38 } else { 39 $selected_messages = array( $this->get_feedback_message( $codes[0] ) ); 40 } 41 42 return $selected_messages; 43 } 44 45 /** 46 * Get all feedback messages 47 * 48 * @since BuddyPress (2.4.0) 49 * 50 * @return array all feedback messages 51 */ 52 public function get_all_feedback_messages() { 53 return parent::get_error_messages(); 54 } 55 56 /** 57 * Get a specific feedback message 58 * 59 * @since BuddyPress (2.4.0) 60 * 61 * @param int $code the requested code 62 * @return string the feedback message 63 */ 64 public function get_feedback_message( $code = 0 ) { 65 return parent::get_error_message( $code ); 66 } 67 } -
src/bp-members/bp-members-loader.php
diff --git src/bp-members/bp-members-loader.php src/bp-members/bp-members-loader.php index e02daaa..8cf64b2 100644
class BP_Members_Component extends BP_Component { 104 104 'global_tables' => array( 105 105 'table_name_last_activity' => bp_core_get_table_prefix() . 'bp_activity', 106 106 'table_name_signups' => bp_core_get_table_prefix() . 'signups', 107 ) 107 ), 108 'feedback_messages' => array( 109 array( 'code' => 15, 'message' => __( 'The account was successfully deleted.', 'buddypress' ), 'data' => '' ), 110 ), 108 111 ); 109 112 110 113 parent::setup_globals( $args ); -
src/bp-settings/bp-settings-actions.php
diff --git src/bp-settings/bp-settings-actions.php src/bp-settings/bp-settings-actions.php index 6eb9bc4..aa57ae1 100644
Regards, 215 215 // Email feedback 216 216 switch ( $email_error ) { 217 217 case 'invalid' : 218 $feedback['email_invalid'] = __( 'That email address is invalid. Check the formatting and try again.', 'buddypress' );218 $feedback['email_invalid'] = 2; 219 219 break; 220 220 case 'blocked' : 221 $feedback['email_blocked'] = __( 'That email address is currently unavailable for use.', 'buddypress' );221 $feedback['email_blocked'] = 3; 222 222 break; 223 223 case 'taken' : 224 $feedback['email_taken'] = __( 'That email address is already taken.', 'buddypress' );224 $feedback['email_taken'] = 4; 225 225 break; 226 226 case 'empty' : 227 $feedback['email_empty'] = __( 'Email address cannot be empty.', 'buddypress' );227 $feedback['email_empty'] = 5; 228 228 break; 229 229 case false : 230 230 // No change … … Regards, 234 234 // Password feedback 235 235 switch ( $pass_error ) { 236 236 case 'invalid' : 237 $feedback['pass_error'] = __( 'Your current password is invalid.', 'buddypress' );237 $feedback['pass_error'] = 6; 238 238 break; 239 239 case 'mismatch' : 240 $feedback['pass_mismatch'] = __( 'The new password fields did not match.', 'buddypress' );240 $feedback['pass_mismatch'] = 7; 241 241 break; 242 242 case 'empty' : 243 $feedback['pass_empty'] = __( 'One of the password fields was empty.', 'buddypress' );243 $feedback['pass_empty'] = 8; 244 244 break; 245 245 case 'same' : 246 $feedback['pass_same'] = __( 'The new password must be different from the current password.', 'buddypress' );246 $feedback['pass_same'] = 9; 247 247 break; 248 248 case false : 249 249 // No change … … Regards, 252 252 253 253 // No errors so show a simple success message 254 254 if ( ( ( false === $email_error ) || ( false == $pass_error ) ) && ( ( true === $pass_changed ) || ( true === $email_changed ) ) ) { 255 $feedback[] = __( 'Your settings have been saved.', 'buddypress' );255 $feedback[] = 10; 256 256 $feedback_type = 'success'; 257 257 258 258 // Some kind of errors occurred 259 259 } elseif ( ( ( false === $email_error ) || ( false === $pass_error ) ) && ( ( false === $pass_changed ) || ( false === $email_changed ) ) ) { 260 260 if ( bp_is_my_profile() ) { 261 $feedback['nochange'] = __( 'No changes were made to your account.', 'buddypress' );261 $feedback['nochange'] = 11; 262 262 } else { 263 $feedback['nochange'] = __( 'No changes were made to this account.', 'buddypress' );263 $feedback['nochange'] = 12; 264 264 } 265 265 } 266 266 267 267 // Set the feedback 268 bp_core_add_message ( implode( "\n", $feedback ), $feedback_type );268 bp_core_add_message_code( $feedback, $feedback_type ); 269 269 270 270 /** 271 271 * Fires after the general settings have been saved, and before redirect. … … function bp_settings_action_notifications() { 312 312 313 313 // Switch feedback for super admins 314 314 if ( bp_is_my_profile() ) { 315 bp_core_add_message ( __( 'Your notification settings have been saved.', 'buddypress' ), 'success' );315 bp_core_add_message_code( 13, 'success' ); 316 316 } else { 317 bp_core_add_message ( __( "This user's notification settings have been saved.", 'buddypress' ), 'success' );317 bp_core_add_message_code( 14, 'success' ); 318 318 } 319 319 320 320 /** … … function bp_settings_action_delete_account() { 431 431 // Nonce check 432 432 check_admin_referer( 'delete-account' ); 433 433 434 // Get username now because it might be gone soon!435 $username = bp_get_displayed_user_fullname();436 437 434 // delete the users account 438 435 if ( bp_core_delete_account( bp_displayed_user_id() ) ) { 439 436 440 437 // Add feedback after deleting a user 441 bp_core_add_message( sprintf( __( '%s was successfully deleted.', 'buddypress' ), $username ), 'success' ); 438 bp_core_add_message_code( 15, 'success' ); 439 440 $redirect = bp_get_root_domain(); 441 442 // Should always be the case! 443 if ( bp_is_active( 'members' ) ) { 444 $redirect = bp_get_members_directory_permalink(); 445 } 442 446 443 447 // Redirect to the root domain 444 bp_core_redirect( bp_get_root_domain());448 bp_core_redirect( $redirect ); 445 449 } 446 450 } 447 451 add_action( 'bp_actions', 'bp_settings_action_delete_account' ); … … function bp_settings_verify_email_change(){ 484 488 bp_delete_user_meta( bp_displayed_user_id(), 'pending_email_change' ); 485 489 486 490 // Post a success message and redirect 487 bp_core_add_message ( __( 'You have successfully verified your new email address.', 'buddypress' ));491 bp_core_add_message_code( 15 ); 488 492 } else { 489 493 // Unknown error 490 bp_core_add_message ( __( 'There was a problem verifying your new email address. Please try again.', 'buddypress' ), 'error' );494 bp_core_add_message_code( 16, 'error' ); 491 495 } 492 496 493 497 bp_core_redirect( $redirect_to ); … … function bp_settings_verify_email_change(){ 495 499 496 500 // Email change is being dismissed 497 501 } elseif ( ! empty( $_GET['dismiss_email_change'] ) ) { 498 499 bp_core_add_message ( __( 'You have successfully dismissed your pending email change.', 'buddypress' ));502 bp_delete_user_meta( bp_displayed_user_id(), 'pending_email_change' ); 503 bp_core_add_message_code( 17 ); 500 504 501 505 bp_core_redirect( $redirect_to ); 502 506 die(); -
src/bp-settings/bp-settings-loader.php
diff --git src/bp-settings/bp-settings-loader.php src/bp-settings/bp-settings-loader.php index c310125..e6a07fd 100644
class BP_Settings_Component extends BP_Component { 58 58 59 59 // All globals for settings component. 60 60 parent::setup_globals( array( 61 'slug' => BP_SETTINGS_SLUG, 62 'has_directory' => false, 61 'slug' => BP_SETTINGS_SLUG, 62 'has_directory' => false, 63 'feedback_messages' => array( 64 array( 'code' => 2, 'message' => __( 'That email address is invalid. Check the formatting and try again.', 'buddypress' ), 'data' => '' ), 65 array( 'code' => 3, 'message' => __( 'That email address is currently unavailable for use.', 'buddypress' ), 'data' => '' ), 66 array( 'code' => 4, 'message' => __( 'That email address is already taken.', 'buddypress' ), 'data' => '' ), 67 array( 'code' => 5, 'message' => __( 'Email address cannot be empty.', 'buddypress' ), 'data' => '' ), 68 array( 'code' => 6, 'message' => __( 'Your current password is invalid.', 'buddypress' ), 'data' => '' ), 69 array( 'code' => 7, 'message' => __( 'The new password fields did not match.', 'buddypress' ), 'data' => '' ), 70 array( 'code' => 8, 'message' => __( 'One of the password fields was empty.', 'buddypress' ), 'data' => '' ), 71 array( 'code' => 9, 'message' => __( 'The new password must be different from the current password.', 'buddypress' ), 'data' => '' ), 72 array( 'code' => 10, 'message' => __( 'Your settings have been saved.', 'buddypress' ), 'data' => '' ), 73 array( 'code' => 11, 'message' => __( 'No changes were made to your account.', 'buddypress' ), 'data' => '' ), 74 array( 'code' => 12, 'message' => __( 'No changes were made to this account.', 'buddypress' ), 'data' => '' ), 75 array( 'code' => 13, 'message' => __( 'Your notification settings have been saved.', 'buddypress' ), 'data' => '' ), 76 array( 'code' => 14, 'message' => __( "This user's notification settings have been saved.", 'buddypress' ), 'data' => '' ), 77 array( 'code' => 15, 'message' => __( 'You have successfully verified your new email address.', 'buddypress' ), 'data' => '' ), 78 array( 'code' => 16, 'message' => __( 'There was a problem verifying your new email address. Please try again.', 'buddypress' ), 'data' => '' ), 79 array( 'code' => 17, 'message' => __( 'You have successfully dismissed your pending email change.', 'buddypress' ), 'data' => '' ), 80 ), 63 81 ) ); 64 82 } 65 83 -
src/bp-templates/bp-legacy/buddypress-functions.php
diff --git src/bp-templates/bp-legacy/buddypress-functions.php src/bp-templates/bp-legacy/buddypress-functions.php index 7ebf90e..0f4128d 100644
function bp_legacy_theme_post_update() { 920 920 $activity_id = apply_filters( 'bp_activity_custom_update', false, $_POST['object'], $_POST['item_id'], $_POST['content'] ); 921 921 } 922 922 923 if ( empty( $activity_id ) ) 924 exit( '-1<div id="message" class="error bp-ajax-message"><p>' . __( 'There was a problem posting your update. Please try again.', 'buddypress' ) . '</p></div>' ); 923 if ( empty( $activity_id ) ) { 924 $feedback_message = '-1<div id="message" class="error bp-ajax-message"><p>' . __( 'There was a problem posting your update. Please try again.', 'buddypress' ) . '</p></div>'; 925 926 // Do we have a specific feedback message for the error ? 927 if ( ! empty( $bp->template_message_code ) ) { 928 $feedback_message = '-1' . bp_core_render_message( 'bp-ajax-message', false ); 929 } 930 931 exit( $feedback_message ); 932 } 925 933 926 934 $last_recorded = ! empty( $_POST['since'] ) ? date( 'Y-m-d H:i:s', intval( $_POST['since'] ) ) : 0; 927 935 if ( $last_recorded ) { -
src/bp-templates/bp-legacy/buddypress/members/index.php
diff --git src/bp-templates/bp-legacy/buddypress/members/index.php src/bp-templates/bp-legacy/buddypress/members/index.php index 1cefe5e..48becd5 100644
do_action( 'bp_before_directory_members_page' ); ?> 41 41 do_action( 'bp_before_directory_members_tabs' ); ?> 42 42 43 43 <form action="" method="post" id="members-directory-form" class="dir-form"> 44 <?php 45 46 /** This action is documented in bp-templates/bp-legacy/buddypress/activity/index.php */ 47 do_action( 'template_notices' ); ?> 44 48 45 49 <div class="item-list-tabs" role="navigation"> 46 50 <ul>