Changeset 3549
- Timestamp:
- 10/30/2011 03:39:45 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-user-template.php
r3505 r3549 57 57 $bbp_user_id = get_query_var( 'bbp_user_id' ); 58 58 59 return apply_filters( 'bbp_get_user_id', (int) $bbp_user_id);59 return (int) apply_filters( 'bbp_get_user_id', (int) $bbp_user_id, $displayed_user_fallback, $current_user_fallback ); 60 60 } 61 61 … … 182 182 function bbp_get_current_user_avatar( $size = 40 ) { 183 183 184 if ( !$user = bbp_get_current_user_id() ) 184 $user = bbp_get_current_user_id(); 185 if ( empty( $user ) ) 185 186 $user = bbp_get_current_anonymous_user_data( 'email' ); 186 187 … … 213 214 */ 214 215 function bbp_get_user_profile_link( $user_id = 0 ) { 215 if ( !$user_id = bbp_get_user_id( $user_id ) ) 216 $user_id = bbp_get_user_id( $user_id ); 217 if ( empty( $user_id ) ) 216 218 return false; 217 219 … … 233 235 */ 234 236 function bbp_user_profile_url( $user_id = 0, $user_nicename = '' ) { 235 echo bbp_get_user_profile_url( $user_id );237 echo bbp_get_user_profile_url( $user_id, $user_nicename ); 236 238 } 237 239 /** … … 331 333 */ 332 334 function bbp_user_profile_edit_url( $user_id = 0, $user_nicename = '' ) { 333 echo bbp_get_user_profile_edit_url( $user_id );335 echo bbp_get_user_profile_edit_url( $user_id, $user_nicename ); 334 336 } 335 337 /** … … 352 354 global $wp_rewrite, $bbp; 353 355 354 if ( !$user_id = bbp_get_user_id( $user_id ) ) 356 $user_id = bbp_get_user_id( $user_id ); 357 if ( empty( $user_id ) ) 355 358 return; 356 359 … … 408 411 return; 409 412 410 if ( $args && is_string( $args ) && false === strpos( $args, '=') )413 if ( $args && is_string( $args ) && ( false === strpos( $args, '=' ) ) ) 411 414 $args = array( 'text' => $args ); 412 415 … … 459 462 460 463 // Get the author IP meta value 461 if ( $author_ip = get_post_meta( $post_id, '_bbp_author_ip', true ) ) 464 $author_ip = get_post_meta( $post_id, '_bbp_author_ip', true ); 465 if ( !empty( $author_ip ) ) 462 466 $author_ip = $before . $author_ip . $after; 463 467 … … 536 540 return false; 537 541 538 if ( !$user_id = bbp_get_user_id( $user_id, true, true ) ) 542 // Validate user and topic ID's 543 $user_id = bbp_get_user_id( $user_id, true, true ); 544 $topic_id = bbp_get_topic_id(); 545 if ( empty( $user_id ) || empty( $topic_id ) ) 539 546 return false; 540 547 541 548 if ( !current_user_can( 'edit_user', (int) $user_id ) ) 542 return false;543 544 if ( !$topic_id = bbp_get_topic_id() )545 549 return false; 546 550 … … 560 564 } 561 565 562 if ( $is_fav = bbp_is_user_favorite( $user_id, $topic_id ) ) { 566 $is_fav = bbp_is_user_favorite( $user_id, $topic_id ); 567 if ( !empty( $is_fav ) ) { 563 568 $url = esc_url( bbp_get_favorites_permalink( $user_id ) ); 564 569 $rem = preg_replace( '|%(.+)%|', "<a href='$url'>$1</a>", $rem ); … … 584 589 $permalink = get_permalink(); 585 590 586 $url 587 $is_fav 588 $html 591 $url = esc_url( wp_nonce_url( add_query_arg( $favs, $permalink ), 'toggle-favorite_' . $topic_id ) ); 592 $is_fav = $is_fav ? 'is-favorite' : ''; 593 $html = '<span id="favorite-toggle"><span id="favorite-' . $topic_id . '" class="' . $is_fav . '">' . $pre . '<a href="' . $url . '" class="dim:favorite-toggle:favorite-' . $topic_id . ':is-favorite">' . $mid . '</a>' . $post . '</span></span>'; 589 594 590 595 // Return the link … … 671 676 extract( $args ); 672 677 673 // Try to get a user_id 674 if ( !$user_id = bbp_get_user_id( $user_id, true, true ) ) 678 // Validate user and topic ID's 679 $user_id = bbp_get_user_id( $user_id, true, true ); 680 $topic_id = bbp_get_topic_id( $topic_id ); 681 if ( empty( $user_id ) || empty( $topic_id ) ) 675 682 return false; 676 683 … … 679 686 return false; 680 687 681 // No link if not viewing a topic682 if ( !$topic_id = bbp_get_topic_id( $topic_id ) )683 return false;684 685 688 // Decine which link to show 686 if ( $is_subscribed = bbp_is_user_subscribed( $user_id, $topic_id ) ) { 689 $is_subscribed = bbp_is_user_subscribed( $user_id, $topic_id ); 690 if ( !empty( $is_subscribed ) ) { 687 691 $text = $unsubscribe; 688 692 $query_args = array( 'action' => 'bbp_unsubscribe', 'topic_id' => $topic_id ); … … 1178 1182 1179 1183 // Allow access to be filtered 1180 return apply_filters( 'bbp_current_user_can_publish_topics', (bool) $retval ); 1184 return (bool) apply_filters( 'bbp_current_user_can_publish_forums', $retval ); 1185 } 1186 1187 /** 1188 * Check if the current user can publish forums 1189 * 1190 * @since bbPress (r3549) 1191 * 1192 * @uses is_super_admin() 1193 * @uses bbp_is_user_active() 1194 * @uses current_user_can() 1195 * @uses apply_filters() 1196 * 1197 * @return bool 1198 */ 1199 function bbp_current_user_can_publish_forums() { 1200 1201 // Users need to earn access 1202 $retval = false; 1203 1204 // Always allow super admins 1205 if ( is_super_admin() ) 1206 $retval = true; 1207 1208 // User is logged in 1209 elseif ( bbp_is_user_active() && current_user_can( 'publish_forums' ) ) 1210 $retval = true; 1211 1212 // Allow access to be filtered 1213 return (bool) apply_filters( 'bbp_current_user_can_publish_forums', $retval ); 1181 1214 } 1182 1215 … … 1213 1246 1214 1247 // Allow access to be filtered 1215 return apply_filters( 'bbp_current_user_can_publish_replies', (bool)$retval );1248 return (bool) apply_filters( 'bbp_current_user_can_publish_replies', $retval ); 1216 1249 } 1217 1250 … … 1267 1300 1268 1301 /** 1302 * Performs a series of checks to ensure the current user can create forums. 1303 * 1304 * @since bbPress (r3549) 1305 * 1306 * @uses bbp_is_forum_edit() 1307 * @uses current_user_can() 1308 * @uses bbp_get_forum_id() 1309 * 1310 * @return bool 1311 */ 1312 function bbp_current_user_can_access_create_forum_form() { 1313 1314 // Always allow super admins 1315 if ( is_super_admin() ) 1316 return true; 1317 1318 // Users need to earn access 1319 $retval = false; 1320 1321 // Looking at a single forum & forum is open 1322 if ( ( is_page() || is_single() ) && bbp_is_forum_open() ) 1323 $retval = bbp_current_user_can_publish_forums(); 1324 1325 // User can edit this topic 1326 elseif ( bbp_is_forum_edit() ) 1327 $retval = current_user_can( 'edit_forum', bbp_get_forum_id() ); 1328 1329 // Allow access to be filtered 1330 return (bool) apply_filters( 'bbp_current_user_can_access_create_forum_form', (bool) $retval ); 1331 } 1332 1333 /** 1269 1334 * Performs a series of checks to ensure the current user can create topics. 1270 1335 * … … 1297 1362 1298 1363 // Allow access to be filtered 1299 return apply_filters( 'bbp_current_user_can_access_create_topic_form', (bool) $retval );1364 return (bool) apply_filters( 'bbp_current_user_can_access_create_topic_form', (bool) $retval ); 1300 1365 } 1301 1366 … … 1331 1396 1332 1397 // Allow access to be filtered 1333 return apply_filters( 'bbp_current_user_can_access_create_topic_form', (bool) $retval );1398 return (bool) apply_filters( 'bbp_current_user_can_access_create_reply_form', (bool) $retval ); 1334 1399 } 1335 1400
Note: See TracChangeset
for help on using the changeset viewer.