Changeset 5436 for trunk/src/includes/users/capabilities.php
- Timestamp:
- 07/09/2014 10:59:31 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/users/capabilities.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/users/capabilities.php
r5167 r5436 190 190 191 191 // Bail if no user ID was passed 192 if ( empty( $user_id ) ) 193 return; 192 if ( empty( $user_id ) ) { 193 return; 194 } 194 195 195 196 // Bail if no role 196 if ( ! isset( $_POST['bbp-forums-role'] ) ) 197 return; 197 if ( ! isset( $_POST['bbp-forums-role'] ) ) { 198 return; 199 } 198 200 199 201 // Fromus role we want the user to have … … 202 204 203 205 // Bail if no role change 204 if ( $new_role === $forums_role ) 205 return; 206 if ( $new_role === $forums_role ) { 207 return; 208 } 206 209 207 210 // Bail if trying to set their own role 208 if ( bbp_is_user_home_edit() ) 209 return; 211 if ( bbp_is_user_home_edit() ) { 212 return; 213 } 210 214 211 215 // Bail if current user cannot promote the passing user 212 if ( ! current_user_can( 'promote_user', $user_id ) ) 213 return; 216 if ( ! current_user_can( 'promote_user', $user_id ) ) { 217 return; 218 } 214 219 215 220 // Set the new forums role … … 240 245 241 246 // Bail if deactivating bbPress 242 if ( bbp_is_deactivation() ) 243 return; 247 if ( bbp_is_deactivation() ) { 248 return; 249 } 244 250 245 251 // Catch all, to prevent premature user initialization 246 if ( ! did_action( 'set_current_user' ) ) 247 return; 252 if ( ! did_action( 'set_current_user' ) ) { 253 return; 254 } 248 255 249 256 // Bail if not logged in or already a member of this site 250 if ( ! is_user_logged_in() ) 251 return; 257 if ( ! is_user_logged_in() ) { 258 return; 259 } 252 260 253 261 // Get the current user ID … … 255 263 256 264 // Bail if user already has a forums role 257 if ( bbp_get_user_role( $user_id ) ) 258 return; 265 if ( bbp_get_user_role( $user_id ) ) { 266 return; 267 } 259 268 260 269 // Bail if user is marked as spam or is deleted 261 if ( bbp_is_user_inactive( $user_id ) ) 262 return; 270 if ( bbp_is_user_inactive( $user_id ) ) { 271 return; 272 } 263 273 264 274 /** Ready *****************************************************************/ … … 341 351 342 352 // Default to current user 343 if ( empty( $user_id ) && is_user_logged_in() ) 353 if ( empty( $user_id ) && is_user_logged_in() ) { 344 354 $user_id = bbp_get_current_user_id(); 355 } 345 356 346 357 // No user to check 347 if ( empty( $user_id ) ) 348 return false; 358 if ( empty( $user_id ) ) { 359 return false; 360 } 349 361 350 362 // Assume user is not spam … … 393 405 394 406 // Use displayed user if it's not yourself 395 if ( empty( $user_id ) && bbp_is_single_user() && !bbp_is_user_home() ) 407 if ( empty( $user_id ) && bbp_is_single_user() && !bbp_is_user_home() ) { 396 408 $user_id = bbp_get_displayed_user_id(); 409 } 397 410 398 411 // Bail if no user ID 399 if ( empty( $user_id ) ) 400 return false; 412 if ( empty( $user_id ) ) { 413 return false; 414 } 401 415 402 416 // Bail if user ID is keymaster 403 if ( bbp_is_user_keymaster( $user_id ) ) 404 return false; 417 if ( bbp_is_user_keymaster( $user_id ) ) { 418 return false; 419 } 405 420 406 421 // Arm the torpedos … … 411 426 412 427 // If user has no blogs, they are a guest on this site 413 if ( empty( $blogs ) ) 414 $blogs[$wpdb->blogid] = array(); 428 if ( empty( $blogs ) ) { 429 $blogs[ $wpdb->blogid ] = array(); 430 } 415 431 416 432 // Make array of post types to mark as spam … … 480 496 481 497 // Use displayed user if it's not yourself 482 if ( empty( $user_id ) && bbp_is_single_user() && !bbp_is_user_home() ) 498 if ( empty( $user_id ) && bbp_is_single_user() && !bbp_is_user_home() ) { 483 499 $user_id = bbp_get_displayed_user_id(); 500 } 484 501 485 502 // Bail if no user ID 486 if ( empty( $user_id ) ) 487 return false; 503 if ( empty( $user_id ) ) { 504 return false; 505 } 488 506 489 507 // Bail if user ID is keymaster 490 if ( bbp_is_user_keymaster( $user_id ) ) 491 return false; 508 if ( bbp_is_user_keymaster( $user_id ) ) { 509 return false; 510 } 492 511 493 512 // Arm the torpedos … … 498 517 499 518 // If user has no blogs, they are a guest on this site 500 if ( empty( $blogs ) ) 501 $blogs[$wpdb->blogid] = array(); 519 if ( empty( $blogs ) ) { 520 $blogs[ $wpdb->blogid ] = array(); 521 } 502 522 503 523 // Make array of post types to mark as spam … … 552 572 553 573 // Default to current user 554 if ( empty( $user_id ) && is_user_logged_in() ) 574 if ( empty( $user_id ) && is_user_logged_in() ) { 555 575 $user_id = bbp_get_current_user_id(); 576 } 556 577 557 578 // No user to check 558 if ( empty( $user_id ) ) 559 return false; 579 if ( empty( $user_id ) ) { 580 return false; 581 } 560 582 561 583 // Assume user is not deleted … … 593 615 594 616 // Default to current user 595 if ( empty( $user_id ) && is_user_logged_in() ) 617 if ( empty( $user_id ) && is_user_logged_in() ) { 596 618 $user_id = bbp_get_current_user_id(); 619 } 597 620 598 621 // No user to check 599 if ( empty( $user_id ) ) 600 return false; 622 if ( empty( $user_id ) ) { 623 return false; 624 } 601 625 602 626 // Check spam 603 if ( bbp_is_user_spammer( $user_id ) ) 604 return false; 627 if ( bbp_is_user_spammer( $user_id ) ) { 628 return false; 629 } 605 630 606 631 // Check deleted 607 if ( bbp_is_user_deleted( $user_id ) ) 608 return false; 632 if ( bbp_is_user_deleted( $user_id ) ) { 633 return false; 634 } 609 635 610 636 // Assume true if not spam or deleted … … 627 653 628 654 // Default to current user 629 if ( empty( $user_id ) && is_user_logged_in() ) 655 if ( empty( $user_id ) && is_user_logged_in() ) { 630 656 $user_id = bbp_get_current_user_id(); 657 } 631 658 632 659 // No user to check 633 if ( empty( $user_id ) ) 634 return false; 660 if ( empty( $user_id ) ) { 661 return false; 662 } 635 663 636 664 // Return the inverse of active
Note: See TracChangeset
for help on using the changeset viewer.