Changeset 5442
- Timestamp:
- 07/11/2014 09:54:15 PM (12 years ago)
- Location:
- trunk/src/includes/users
- Files:
-
- 4 edited
-
capabilities.php (modified) (12 diffs)
-
functions.php (modified) (27 diffs)
-
options.php (modified) (1 diff)
-
template.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/users/capabilities.php
r5436 r5442 63 63 64 64 // User exists 65 if ( ! empty( $user ) ) {65 if ( ! empty( $user ) ) { 66 66 67 67 // Get users forum role … … 81 81 82 82 // Add the new role 83 if ( ! empty( $new_role ) ) {83 if ( ! empty( $new_role ) ) { 84 84 85 85 // Make sure bbPress roles are added … … 128 128 // smart, but since roles aren't exactly hierarchical, and bbPress 129 129 // does not yet have a UI for multiple user roles, it's fine for now. 130 if ( ! empty( $roles ) ) {130 if ( ! empty( $roles ) ) { 131 131 $role = array_shift( $roles ); 132 132 } … … 161 161 162 162 // Look for a non bbPress role 163 $roles = array_intersect(163 $roles = array_intersect( 164 164 array_values( $user->roles ), 165 165 array_keys( bbp_get_blog_roles() ) … … 169 169 // smart, but since roles aren't exactly hierarchical, and WordPress 170 170 // does not yet have a UI for multiple user roles, it's fine for now. 171 if ( ! empty( $roles ) ) {171 if ( ! empty( $roles ) ) { 172 172 $role = array_shift( $roles ); 173 173 } … … 371 371 372 372 // Check if spam 373 } elseif ( ! empty( $user->spam ) ) {373 } elseif ( ! empty( $user->spam ) ) { 374 374 $is_spammer = true; 375 375 } … … 405 405 406 406 // Use displayed user if it's not yourself 407 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() ) { 408 408 $user_id = bbp_get_displayed_user_id(); 409 409 } … … 444 444 445 445 // Loop through posts and spam them 446 if ( ! empty( $posts ) ) {446 if ( ! empty( $posts ) ) { 447 447 foreach ( $posts as $post_id ) { 448 448 … … 496 496 497 497 // Use displayed user if it's not yourself 498 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() ) { 499 499 $user_id = bbp_get_displayed_user_id(); 500 500 } … … 535 535 536 536 // Loop through posts and spam them 537 if ( ! empty( $posts ) ) {537 if ( ! empty( $posts ) ) { 538 538 foreach ( $posts as $post_id ) { 539 539 … … 592 592 593 593 // Check if deleted 594 } elseif ( ! empty( $user->deleted ) ) {594 } elseif ( ! empty( $user->deleted ) ) { 595 595 $is_deleted = true; 596 596 } … … 663 663 664 664 // Return the inverse of active 665 return ! bbp_is_user_active( $user_id );665 return ! bbp_is_user_active( $user_id ); 666 666 } 667 667 -
trunk/src/includes/users/functions.php
r5436 r5442 28 28 29 29 // Raw redirect_to was passed, so use it 30 if ( ! empty( $raw_url ) ) {30 if ( ! empty( $raw_url ) ) { 31 31 $url = $raw_url; 32 32 … … 104 104 $bbp_current_poster = wp_get_current_commenter(); 105 105 106 if ( ! empty( $key ) && in_array( $key, array_keys( $cookie_names ) ) ) {106 if ( ! empty( $key ) && in_array( $key, array_keys( $cookie_names ) ) ) { 107 107 return $bbp_current_poster[$cookie_names[$key]]; 108 108 } … … 125 125 */ 126 126 function bbp_set_current_anonymous_user_data( $anonymous_data = array() ) { 127 if ( empty( $anonymous_data ) || ! is_array( $anonymous_data ) ) {127 if ( empty( $anonymous_data ) || ! is_array( $anonymous_data ) ) { 128 128 return; 129 129 } … … 157 157 */ 158 158 function bbp_current_author_ua() { 159 $retval = ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 ) : '';159 $retval = ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 ) : ''; 160 160 161 161 return apply_filters( 'bbp_current_author_ua', $retval ); … … 213 213 // If user has favorites, load them 214 214 $favorites = bbp_get_user_favorites_topic_ids( $user_id ); 215 if ( ! empty( $favorites ) ) {215 if ( ! empty( $favorites ) ) { 216 216 $query = bbp_has_topics( array( 'post__in' => $favorites ) ); 217 217 } else { … … 271 271 $favorites = bbp_get_user_favorites_topic_ids( $user_id ); 272 272 273 if ( ! empty( $favorites ) ) {273 if ( ! empty( $favorites ) ) { 274 274 275 275 // Checking a specific topic id 276 if ( ! empty( $topic_id ) ) {276 if ( ! empty( $topic_id ) ) { 277 277 $topic = bbp_get_topic( $topic_id ); 278 $topic_id = ! empty( $topic ) ? $topic->ID : 0;278 $topic_id = ! empty( $topic ) ? $topic->ID : 0; 279 279 280 280 // Using the global topic id … … 283 283 284 284 // Use the current post id 285 } elseif ( ! bbp_get_topic_id() ) {285 } elseif ( ! bbp_get_topic_id() ) { 286 286 $topic_id = get_the_ID(); 287 287 } 288 288 289 289 // Is topic_id in the user's favorites 290 if ( ! empty( $topic_id ) ) {290 if ( ! empty( $topic_id ) ) { 291 291 $retval = in_array( $topic_id, $favorites ); 292 292 } … … 319 319 320 320 $favorites = bbp_get_user_favorites_topic_ids( $user_id ); 321 if ( ! in_array( $topic_id, $favorites ) ) {321 if ( ! in_array( $topic_id, $favorites ) ) { 322 322 $favorites[] = $topic_id; 323 323 $favorites = implode( ',', wp_parse_id_list( array_filter( $favorites ) ) ); … … 359 359 $favorites = array_filter( $favorites ); 360 360 361 if ( ! empty( $favorites ) ) {361 if ( ! empty( $favorites ) ) { 362 362 $favorites = implode( ',', wp_parse_id_list( $favorites ) ); 363 363 update_user_option( $user_id, '_bbp_favorites', $favorites ); … … 392 392 function bbp_favorites_handler( $action = '' ) { 393 393 394 if ( ! bbp_is_favorites_active() ) {394 if ( ! bbp_is_favorites_active() ) { 395 395 return false; 396 396 } … … 408 408 409 409 // Bail if actions aren't meant for this function 410 if ( ! in_array( $action, $possible_actions ) ) {410 if ( ! in_array( $action, $possible_actions ) ) { 411 411 return; 412 412 } … … 425 425 426 426 // Check current user's ability to edit the user 427 } elseif ( ! current_user_can( 'edit_user', $user_id ) ) {427 } elseif ( ! current_user_can( 'edit_user', $user_id ) ) { 428 428 bbp_add_error( 'bbp_favorite_permissions', __( '<strong>ERROR</strong>: You don\'t have the permission to edit favorites of that user!', 'bbpress' ) ); 429 429 } … … 574 574 // If user has subscriptions, load them 575 575 $subscriptions = bbp_get_user_subscribed_topic_ids( $user_id ); 576 if ( ! empty( $subscriptions ) ) {576 if ( ! empty( $subscriptions ) ) { 577 577 $query = bbp_has_topics( array( 'post__in' => $subscriptions ) ); 578 578 } else { … … 605 605 // If user has subscriptions, load them 606 606 $subscriptions = bbp_get_user_subscribed_forum_ids( $user_id ); 607 if ( ! empty( $subscriptions ) ) {607 if ( ! empty( $subscriptions ) ) { 608 608 $query = bbp_has_forums( array( 'post__in' => $subscriptions ) ); 609 609 } else { … … 796 796 // Validate user 797 797 $user_id = bbp_get_user_id( $user_id, true, true ); 798 if ( ! empty( $user_id ) ) {798 if ( ! empty( $user_id ) ) { 799 799 800 800 // Get subscription ID's if none passed … … 816 816 817 817 // Use the current post id 818 } elseif ( ! bbp_get_topic_id() ) {818 } elseif ( ! bbp_get_topic_id() ) { 819 819 $topic_id = get_the_ID(); 820 820 } … … 900 900 901 901 $subscriptions = (array) bbp_get_user_subscribed_forum_ids( $user_id ); 902 if ( ! in_array( $forum_id, $subscriptions ) ) {902 if ( ! in_array( $forum_id, $subscriptions ) ) { 903 903 $subscriptions[] = $forum_id; 904 904 $subscriptions = implode( ',', wp_parse_id_list( array_filter( $subscriptions ) ) ); … … 937 937 938 938 $subscriptions = (array) bbp_get_user_subscribed_topic_ids( $user_id ); 939 if ( ! in_array( $topic_id, $subscriptions ) ) {939 if ( ! in_array( $topic_id, $subscriptions ) ) { 940 940 $subscriptions[] = $topic_id; 941 941 $subscriptions = implode( ',', wp_parse_id_list( array_filter( $subscriptions ) ) ); … … 1029 1029 $subscriptions = array_filter( $subscriptions ); 1030 1030 1031 if ( ! empty( $subscriptions ) ) {1031 if ( ! empty( $subscriptions ) ) { 1032 1032 $subscriptions = implode( ',', wp_parse_id_list( $subscriptions ) ); 1033 1033 update_user_option( $user_id, '_bbp_forum_subscriptions', $subscriptions ); … … 1076 1076 $subscriptions = array_filter( $subscriptions ); 1077 1077 1078 if ( ! empty( $subscriptions ) ) {1078 if ( ! empty( $subscriptions ) ) { 1079 1079 $subscriptions = implode( ',', wp_parse_id_list( $subscriptions ) ); 1080 1080 update_user_option( $user_id, '_bbp_subscriptions', $subscriptions ); … … 1146 1146 1147 1147 // Check current user's ability to edit the user 1148 } elseif ( ! current_user_can( 'edit_user', $user_id ) ) {1148 } elseif ( ! current_user_can( 'edit_user', $user_id ) ) { 1149 1149 bbp_add_error( 'bbp_subscription_permissions', __( '<strong>ERROR</strong>: You don\'t have the permission to edit favorites of that user!', 'bbpress' ) ); 1150 1150 } … … 1219 1219 function bbp_subscriptions_handler( $action = '' ) { 1220 1220 1221 if ( ! bbp_is_subscriptions_active() ) {1221 if ( ! bbp_is_subscriptions_active() ) { 1222 1222 return false; 1223 1223 } … … 1235 1235 1236 1236 // Bail if actions aren't meant for this function 1237 if ( ! in_array( $action, $possible_actions ) ) {1237 if ( ! in_array( $action, $possible_actions ) ) { 1238 1238 return; 1239 1239 } … … 1252 1252 1253 1253 // Check current user's ability to edit the user 1254 } elseif ( ! current_user_can( 'edit_user', $user_id ) ) {1254 } elseif ( ! current_user_can( 'edit_user', $user_id ) ) { 1255 1255 bbp_add_error( 'bbp_subscription_permissions', __( '<strong>ERROR</strong>: You don\'t have the permission to edit favorites of that user!', 'bbpress' ) ); 1256 1256 } … … 1369 1369 1370 1370 // Delete new email address from user options 1371 } elseif ( is_multisite() && bbp_is_user_home_edit() && ! empty( $_GET['dismiss'] ) && ( $user_id . '_new_email' === $_GET['dismiss'] ) ) {1371 } elseif ( is_multisite() && bbp_is_user_home_edit() && ! empty( $_GET['dismiss'] ) && ( $user_id . '_new_email' === $_GET['dismiss'] ) ) { 1372 1372 delete_option( $user_id . '_new_email' ); 1373 1373 wp_safe_redirect( add_query_arg( array( 'updated' => 'true' ), bbp_get_user_profile_edit_url( $user_id ) ) ); … … 1392 1392 1393 1393 // Prevent edit_user() from wiping out the user's Toolbar on front setting 1394 if ( ! isset( $_POST['admin_bar_front'] ) && _get_admin_bar_pref( 'front', $user_id ) ) {1394 if ( ! isset( $_POST['admin_bar_front'] ) && _get_admin_bar_pref( 'front', $user_id ) ) { 1395 1395 $_POST['admin_bar_front'] = 1; 1396 1396 } … … 1834 1834 1835 1835 // Bail if no username 1836 $username = ! empty( $_POST['log'] ) ? $_POST['log'] : '';1836 $username = ! empty( $_POST['log'] ) ? $_POST['log'] : ''; 1837 1837 if ( empty( $username ) ) { 1838 1838 return; -
trunk/src/includes/users/options.php
r5309 r5442 116 116 117 117 // Check the options global for preset value 118 if ( isset( $user->ID ) && isset( $bbp->user_options[$user->ID] ) && ! empty( $bbp->user_options[$user->ID][$option] ) ) {118 if ( isset( $user->ID ) && isset( $bbp->user_options[$user->ID] ) && ! empty( $bbp->user_options[$user->ID][$option] ) ) { 119 119 $value = $bbp->user_options[$user->ID][$option]; 120 120 } -
trunk/src/includes/users/template.php
r5436 r5442 42 42 43 43 // Easy empty checking 44 if ( ! empty( $user_id ) && is_numeric( $user_id ) ) {44 if ( ! empty( $user_id ) && is_numeric( $user_id ) ) { 45 45 $bbp_user_id = $user_id; 46 46 47 47 // Currently viewing or editing a user 48 } elseif ( ( true === $displayed_user_fallback ) && ! empty( $bbp->displayed_user->ID ) ) {48 } elseif ( ( true === $displayed_user_fallback ) && ! empty( $bbp->displayed_user->ID ) ) { 49 49 $bbp_user_id = $bbp->displayed_user->ID; 50 50 51 51 // Maybe fallback on the current_user ID 52 } elseif ( ( true === $current_user_fallback ) && ! empty( $bbp->current_user->ID ) ) {52 } elseif ( ( true === $current_user_fallback ) && ! empty( $bbp->current_user->ID ) ) { 53 53 $bbp_user_id = $bbp->current_user->ID; 54 54 … … 310 310 311 311 // Maybe wrap the nicename 312 $retval = ! empty( $nicename ) ? ( $r['before'] . $nicename . $r['after'] ) : '';312 $retval = ! empty( $nicename ) ? ( $r['before'] . $nicename . $r['after'] ) : ''; 313 313 314 314 // Filter and return … … 460 460 if ( empty( $user_nicename ) ) { 461 461 $user = get_userdata( $user_id ); 462 if ( ! empty( $user->user_nicename ) ) {462 if ( ! empty( $user->user_nicename ) ) { 463 463 $user_nicename = $user->user_nicename; 464 464 } … … 554 554 */ 555 555 function bbp_get_admin_link( $args = '' ) { 556 if ( ! current_user_can( 'moderate' ) ) {556 if ( ! current_user_can( 'moderate' ) ) { 557 557 return; 558 558 } 559 559 560 if ( ! empty( $args ) && is_string( $args ) && ( false === strpos( $args, '=' ) ) ) {560 if ( ! empty( $args ) && is_string( $args ) && ( false === strpos( $args, '=' ) ) ) { 561 561 $args = array( 'text' => $args ); 562 562 } … … 610 610 // Get the author IP meta value 611 611 $author_ip = get_post_meta( $r['post_id'], '_bbp_author_ip', true ); 612 if ( ! empty( $author_ip ) ) {612 if ( ! empty( $author_ip ) ) { 613 613 $author_ip = $r['before'] . $author_ip . $r['after']; 614 614 … … 1119 1119 1120 1120 // Initial output is wrapped in a span, ajax output is hooked to this 1121 if ( ! empty( $wrap ) ) {1121 if ( ! empty( $wrap ) ) { 1122 1122 $html = '<span id="subscription-toggle">' . $html . '</span>'; 1123 1123 } … … 1150 1150 1151 1151 // Initial output is wrapped in a span, ajax output is hooked to this 1152 if ( ! empty( $wrap ) ) {1152 if ( ! empty( $wrap ) ) { 1153 1153 $html = '<span id="subscription-toggle">' . $html . '</span>'; 1154 1154 } … … 1215 1215 $public_display['display_username'] = $bbp->displayed_user->user_login; 1216 1216 1217 if ( ! empty( $bbp->displayed_user->nickname ) ) {1217 if ( ! empty( $bbp->displayed_user->nickname ) ) { 1218 1218 $public_display['display_nickname'] = $bbp->displayed_user->nickname; 1219 1219 } 1220 1220 1221 if ( ! empty( $bbp->displayed_user->first_name ) ) {1221 if ( ! empty( $bbp->displayed_user->first_name ) ) { 1222 1222 $public_display['display_firstname'] = $bbp->displayed_user->first_name; 1223 1223 } 1224 1224 1225 if ( ! empty( $bbp->displayed_user->last_name ) ) {1225 if ( ! empty( $bbp->displayed_user->last_name ) ) { 1226 1226 $public_display['display_lastname'] = $bbp->displayed_user->last_name; 1227 1227 } 1228 1228 1229 if ( ! empty( $bbp->displayed_user->first_name ) && !empty( $bbp->displayed_user->last_name ) ) {1229 if ( ! empty( $bbp->displayed_user->first_name ) && ! empty( $bbp->displayed_user->last_name ) ) { 1230 1230 $public_display['display_firstlast'] = $bbp->displayed_user->first_name . ' ' . $bbp->displayed_user->last_name; 1231 1231 $public_display['display_lastfirst'] = $bbp->displayed_user->last_name . ' ' . $bbp->displayed_user->first_name; … … 1233 1233 1234 1234 // Only add this if it isn't duplicated elsewhere 1235 if ( ! in_array( $bbp->displayed_user->display_name, $public_display ) ) {1235 if ( ! in_array( $bbp->displayed_user->display_name, $public_display ) ) { 1236 1236 $public_display = array( 'display_displayname' => $bbp->displayed_user->display_name ) + $public_display; 1237 1237 } … … 1475 1475 1476 1476 // loggedout was passed 1477 if ( ! empty( $_GET['loggedout'] ) && ( true === $_GET['loggedout'] ) ) {1477 if ( ! empty( $_GET['loggedout'] ) && ( true === $_GET['loggedout'] ) ) { 1478 1478 bbp_add_error( 'loggedout', __( 'You are now logged out.', 'bbpress' ), 'message' ); 1479 1479 1480 1480 // registration is disabled 1481 } elseif ( ! empty( $_GET['registration'] ) && ( 'disabled' === $_GET['registration'] ) ) {1481 } elseif ( ! empty( $_GET['registration'] ) && ( 'disabled' === $_GET['registration'] ) ) { 1482 1482 bbp_add_error( 'registerdisabled', __( 'New user registration is currently not allowed.', 'bbpress' ) ); 1483 1483 1484 1484 // Prompt user to check their email 1485 } elseif ( ! empty( $_GET['checkemail'] ) && in_array( $_GET['checkemail'], array( 'confirm', 'newpass', 'registered' ) ) ) {1485 } elseif ( ! empty( $_GET['checkemail'] ) && in_array( $_GET['checkemail'], array( 'confirm', 'newpass', 'registered' ) ) ) { 1486 1486 1487 1487 switch ( $_GET['checkemail'] ) { … … 1522 1522 1523 1523 // Bail if user is not logged in 1524 if ( ! is_user_logged_in() ) {1524 if ( ! is_user_logged_in() ) { 1525 1525 return; 1526 1526 } 1527 1527 1528 1528 // Setup the profile page to redirect to 1529 $redirect_to = ! empty( $url ) ? $url : bbp_get_user_profile_url( bbp_get_current_user_id() );1529 $redirect_to = ! empty( $url ) ? $url : bbp_get_user_profile_url( bbp_get_current_user_id() ); 1530 1530 1531 1531 // Do a safe redirect and exit … … 1671 1671 1672 1672 // Neither a reply nor a topic, so could be a revision 1673 if ( ! empty( $r['post_id'] ) ) {1673 if ( ! empty( $r['post_id'] ) ) { 1674 1674 1675 1675 // Generate title with the display name of the author 1676 1676 if ( empty( $r['link_title'] ) ) { 1677 $r['link_title'] = sprintf( ! bbp_is_reply_anonymous( $r['post_id'] ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s website', 'bbpress' ), get_the_author_meta( 'display_name', $user_id ) );1677 $r['link_title'] = sprintf( ! bbp_is_reply_anonymous( $r['post_id'] ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s website', 'bbpress' ), get_the_author_meta( 'display_name', $user_id ) ); 1678 1678 } 1679 1679 1680 1680 // Assemble some link bits 1681 $link_title = ! empty( $r['link_title'] ) ? ' title="' . $r['link_title'] . '"' : '';1681 $link_title = ! empty( $r['link_title'] ) ? ' title="' . $r['link_title'] . '"' : ''; 1682 1682 $anonymous = bbp_is_reply_anonymous( $r['post_id'] ); 1683 1683 … … 1750 1750 1751 1751 // User is a keymaster 1752 if ( ! empty( $user_id ) && bbp_is_user_keymaster( $user_id ) ) {1752 if ( ! empty( $user_id ) && bbp_is_user_keymaster( $user_id ) ) { 1753 1753 $retval = true; 1754 1754 … … 1793 1793 1794 1794 // Do not allow anonymous if not enabled 1795 } elseif ( ! is_user_logged_in() && bbp_allow_anonymous() ) {1795 } elseif ( ! is_user_logged_in() && bbp_allow_anonymous() ) { 1796 1796 $retval = true; 1797 1797 … … 1859 1859 1860 1860 // Do not allow anonymous if not enabled 1861 } elseif ( ! is_user_logged_in() && bbp_allow_anonymous() ) {1861 } elseif ( ! is_user_logged_in() && bbp_allow_anonymous() ) { 1862 1862 $retval = true; 1863 1863 … … 1896 1896 1897 1897 // Private forums 1898 if ( ! current_user_can( 'read_private_forums' ) ) {1898 if ( ! current_user_can( 'read_private_forums' ) ) { 1899 1899 $private = bbp_get_private_forum_ids(); 1900 1900 } 1901 1901 1902 1902 // Hidden forums 1903 if ( ! current_user_can( 'read_hidden_forums' ) ) {1903 if ( ! current_user_can( 'read_hidden_forums' ) ) { 1904 1904 $hidden = bbp_get_hidden_forum_ids(); 1905 1905 } … … 1909 1909 1910 1910 // There are forums that need to be ex 1911 if ( ! empty( $forum_ids ) ) {1911 if ( ! empty( $forum_ids ) ) { 1912 1912 $post__not_in = implode( ',', $forum_ids ); 1913 1913 }
Note: See TracChangeset
for help on using the changeset viewer.