Changeset 11926
- Timestamp:
- 04/02/2018 02:58:28 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 9 added
- 1 deleted
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-settings/actions/general.php
r11925 r11926 1 1 <?php 2 2 /** 3 * BuddyPress Settings Actions 4 * 5 * @todo split actions into separate screen functions 3 * Settings: Email address and password action handler 4 * 6 5 * @package BuddyPress 7 6 * @subpackage SettingsActions 8 * @since 1.5.07 * @since 3.0.0 9 8 */ 10 11 // Exit if accessed directly.12 defined( 'ABSPATH' ) || exit;13 9 14 10 /** … … 256 252 257 253 /** 258 * Handles the changing and saving of user notification settings.259 *260 * @since 1.6.0261 */262 function bp_settings_action_notifications() {263 if ( ! bp_is_post_request() ) {264 return;265 }266 267 // Bail if no submit action.268 if ( ! isset( $_POST['submit'] ) ) {269 return;270 }271 272 // Bail if not in settings.273 if ( ! bp_is_settings_component() || ! bp_is_current_action( 'notifications' ) ) {274 return false;275 }276 277 // 404 if there are any additional action variables attached278 if ( bp_action_variables() ) {279 bp_do_404();280 return;281 }282 283 check_admin_referer( 'bp_settings_notifications' );284 285 bp_settings_update_notification_settings( bp_displayed_user_id(), (array) $_POST['notifications'] );286 287 // Switch feedback for super admins.288 if ( bp_is_my_profile() ) {289 bp_core_add_message( __( 'Your notification settings have been saved.', 'buddypress' ), 'success' );290 } else {291 bp_core_add_message( __( "This user's notification settings have been saved.", 'buddypress' ), 'success' );292 }293 294 /**295 * Fires after the notification settings have been saved, and before redirect.296 *297 * @since 1.5.0298 */299 do_action( 'bp_core_notification_settings_after_save' );300 301 bp_core_redirect( bp_displayed_user_domain() . bp_get_settings_slug() . '/notifications/' );302 }303 add_action( 'bp_actions', 'bp_settings_action_notifications' );304 305 /**306 * Handles the setting of user capabilities, spamming, hamming, role, etc...307 *308 * @since 1.6.0309 */310 function bp_settings_action_capabilities() {311 if ( ! bp_is_post_request() ) {312 return;313 }314 315 // Bail if no submit action.316 if ( ! isset( $_POST['capabilities-submit'] ) ) {317 return;318 }319 320 // Bail if not in settings.321 if ( ! bp_is_settings_component() || ! bp_is_current_action( 'capabilities' ) ) {322 return false;323 }324 325 // 404 if there are any additional action variables attached326 if ( bp_action_variables() ) {327 bp_do_404();328 return;329 }330 331 // Only super admins can currently spam users (but they can't spam332 // themselves).333 if ( ! is_super_admin() || bp_is_my_profile() ) {334 return;335 }336 337 // Nonce check.338 check_admin_referer( 'capabilities' );339 340 /**341 * Fires before the capabilities settings have been saved.342 *343 * @since 1.6.0344 */345 do_action( 'bp_settings_capabilities_before_save' );346 347 /* Spam **************************************************************/348 349 $is_spammer = !empty( $_POST['user-spammer'] ) ? true : false;350 351 if ( bp_is_user_spammer( bp_displayed_user_id() ) != $is_spammer ) {352 $status = ( true == $is_spammer ) ? 'spam' : 'ham';353 bp_core_process_spammer_status( bp_displayed_user_id(), $status );354 355 /**356 * Fires after processing a user as a spammer.357 *358 * @since 1.1.0359 *360 * @param int $value ID of the currently displayed user.361 * @param string $status Determined status of "spam" or "ham" for the displayed user.362 */363 do_action( 'bp_core_action_set_spammer_status', bp_displayed_user_id(), $status );364 }365 366 /* Other *************************************************************/367 368 /**369 * Fires after the capabilities settings have been saved and before redirect.370 *371 * @since 1.6.0372 */373 do_action( 'bp_settings_capabilities_after_save' );374 375 // Redirect to the root domain.376 bp_core_redirect( bp_displayed_user_domain() . bp_get_settings_slug() . '/capabilities/' );377 }378 add_action( 'bp_actions', 'bp_settings_action_capabilities' );379 380 /**381 * Handles the deleting of a user.382 *383 * @since 1.6.0384 */385 function bp_settings_action_delete_account() {386 if ( ! bp_is_post_request() ) {387 return;388 }389 390 // Bail if no submit action.391 if ( ! isset( $_POST['delete-account-understand'] ) ) {392 return;393 }394 395 // Bail if not in settings.396 if ( ! bp_is_settings_component() || ! bp_is_current_action( 'delete-account' ) ) {397 return false;398 }399 400 // 404 if there are any additional action variables attached401 if ( bp_action_variables() ) {402 bp_do_404();403 return;404 }405 406 // Bail if account deletion is disabled.407 if ( bp_disable_account_deletion() && ! bp_current_user_can( 'delete_users' ) ) {408 return false;409 }410 411 // Nonce check.412 check_admin_referer( 'delete-account' );413 414 // Get username now because it might be gone soon!415 $username = bp_get_displayed_user_fullname();416 417 // Delete the users account.418 if ( bp_core_delete_account( bp_displayed_user_id() ) ) {419 420 // Add feedback after deleting a user.421 bp_core_add_message( sprintf( __( '%s was successfully deleted.', 'buddypress' ), $username ), 'success' );422 423 // Redirect to the root domain.424 bp_core_redirect( bp_get_root_domain() );425 }426 }427 add_action( 'bp_actions', 'bp_settings_action_delete_account' );428 429 /**430 254 * Process email change verification or cancel requests. 431 255 * … … 486 310 } 487 311 add_action( 'bp_actions', 'bp_settings_verify_email_change' ); 488 489 /**490 * Removes 'Email' sub nav, if no component has registered options there.491 *492 * @since 2.2.0493 */494 function bp_settings_remove_email_subnav() {495 if ( ! has_action( 'bp_notification_settings' ) ) {496 bp_core_remove_subnav_item( BP_SETTINGS_SLUG, 'notifications' );497 }498 }499 add_action( 'bp_actions', 'bp_settings_remove_email_subnav' ); -
trunk/src/bp-settings/classes/class-bp-settings-component.php
r10555 r11926 43 43 public function includes( $includes = array() ) { 44 44 parent::includes( array( 45 'actions',46 'screens',47 45 'template', 48 46 'functions', 49 47 ) ); 48 } 49 50 /** 51 * Late includes method. 52 * 53 * Only load up certain code when on specific pages. 54 * 55 * @since 3.0.0 56 */ 57 public function late_includes() { 58 // Bail if PHPUnit is running. 59 if ( defined( 'BP_TESTS_DIR' ) ) { 60 return; 61 } 62 63 // Bail if not on Settings component. 64 if ( ! bp_is_settings_component() ) { 65 return; 66 } 67 68 $actions = array( 'notifications', 'capabilities', 'delete-account' ); 69 70 // Authenticated actions. 71 if ( is_user_logged_in() ) { 72 if ( bp_is_current_action( 'general' ) ) { 73 require $this->path . 'bp-settings/screens/general.php'; 74 75 // Specific to post requests. 76 } elseif ( bp_is_post_request() && in_array( bp_current_action(), $actions, true ) ) { 77 require $this->path . 'bp-settings/actions/' . bp_current_action() . '.php'; 78 } 79 } 80 81 // Screens - User profile integration. 82 if ( bp_is_user() ) { 83 require $this->path . 'bp-settings/screens/general.php'; 84 85 // Sub-nav items. 86 if ( in_array( bp_current_action(), $actions, true ) ) { 87 require $this->path . 'bp-settings/screens/' . bp_current_action() . '.php'; 88 } 89 } 50 90 } 51 91 -
trunk/tests/phpunit/includes/loader.php
r11925 r11926 24 24 * loaded at the same time to prevent weird load order issues. 25 25 */ 26 $components = array( 'activity', 'groups', 'messages' );26 $components = array( 'activity', 'groups', 'messages', 'settings' ); 27 27 foreach ( $components as $component ) { 28 28 add_action( "bp_{$component}_includes", function() use ( $component ) {
Note: See TracChangeset
for help on using the changeset viewer.