Ticket #7329: 7329.02.patch
File 7329.02.patch, 4.2 KB (added by , 8 years ago) |
---|
-
src/bp-activity/bp-activity-template.php
2230 2230 * Output the depth of the current activity comment. 2231 2231 * 2232 2232 * @since 2.0.0 2233 * 2234 * @param object|null $comment Object of the activity comment. Usually unnecessary when used in activity 2235 * comment loop. 2233 2236 */ 2234 function bp_activity_comment_depth( ) {2235 echo bp_activity_get_comment_depth( );2237 function bp_activity_comment_depth( $comment = null ) { 2238 echo bp_activity_get_comment_depth( $comment ); 2236 2239 } 2240 2237 2241 /** 2238 2242 * Return the current activity comment depth. 2239 2243 * 2240 2244 * @since 2.0.0 2241 2245 * 2242 * @return int $depth Depth for the current activity comment. 2246 * @param object|null $comment Object of the activity comment. Usually unnecessary when used in 2247 * activity comment loop. 2248 * @return int $depth Depth for the current activity comment. 2243 2249 */ 2244 function bp_activity_get_comment_depth( ) {2250 function bp_activity_get_comment_depth( $comment = null ) { 2245 2251 global $activities_template; 2246 2252 2253 $depth = 1; 2254 if ( isset( $activities_template->activity->current_comment->depth ) ) { 2255 $depth = $activities_template->activity->current_comment->depth; 2256 } elseif ( ! empty( $comment->id ) ) { 2257 // Fetch the entire root comment tree... ugh. 2258 $comments = BP_Activity_Activity::get_activity_comments( $comment->item_id, 1, constant( 'PHP_INT_MAX' ) ); 2259 2260 // Recursively find our comment object from the comment tree. 2261 $iterator = new RecursiveArrayIterator( $comments ); 2262 $recursive = new RecursiveIteratorIterator( $iterator, RecursiveIteratorIterator::SELF_FIRST ); 2263 foreach ( $recursive as $cid => $cobj ) { 2264 // We found the activity comment! Set the depth. 2265 if ( $cid === $comment->id && isset( $cobj->depth ) ) { 2266 $depth = $cobj->depth; 2267 2268 /* 2269 * Here, we're iterating the depth to anticipate the next comment. 2270 * 2271 * We're doing this because: 2272 * - We're (probably) displaying activity comments in stream mode. 2273 * - We need to iterate so bp_blogs_can_comment_reply() knows how to 2274 * disable replies for activity comments. 2275 */ 2276 ++$depth; 2277 2278 break; 2279 } 2280 } 2281 } 2282 2247 2283 /** 2248 2284 * Filters the comment depth of the current activity comment. 2249 2285 * … … 2251 2287 * 2252 2288 * @param int $depth Depth for the current activity comment. 2253 2289 */ 2254 return apply_filters( 'bp_activity_get_comment_depth', $ activities_template->activity->current_comment->depth );2290 return apply_filters( 'bp_activity_get_comment_depth', $depth ); 2255 2291 } 2256 2292 2257 2293 /** -
src/bp-blogs/bp-blogs-activity.php
1147 1147 } 1148 1148 1149 1149 $allow_comments = bp_blogs_comments_open( $activity ); 1150 $thread_depth = bp_blogs_get_blogmeta( $activity->item_id, 'thread_comments_depth' );1150 $thread_depth = (int) bp_blogs_get_blogmeta( $activity->item_id, 'thread_comments_depth' ); 1151 1151 1152 1152 // Initialize a local object so we won't have to query this again in the 1153 1153 // comment loop. … … 1299 1299 } 1300 1300 1301 1301 // Check comment depth and disable if depth is too large. 1302 if ( isset( buddypress()->blogs->thread_depth[ $comment->item_id] ) ){1303 if ( bp_activity_get_comment_depth( ) > buddypress()->blogs->thread_depth[$comment->item_id] ) {1302 if ( isset( buddypress()->blogs->thread_depth[ $comment->item_id ] ) ) { 1303 if ( bp_activity_get_comment_depth( $comment ) > buddypress()->blogs->thread_depth[ $comment->item_id ] ) { 1304 1304 $retval = false; 1305 1305 } 1306 1306 } 1307 1307 1308 1308 // Check if we should disable activity replies based on the parent activity. 1309 if ( isset( buddypress()->blogs->allow_comments[ $comment->item_id] ) ){1309 if ( isset( buddypress()->blogs->allow_comments[ $comment->item_id ] ) ) { 1310 1310 // The blog post has closed off commenting, so we should disable all activity 1311 1311 // comments under the parent 'new_blog_post' activity entry. 1312 if ( empty( buddypress()->blogs->allow_comments[ $comment->item_id] ) ) {1312 if ( empty( buddypress()->blogs->allow_comments[ $comment->item_id ] ) ) { 1313 1313 $retval = false; 1314 1314 } 1315 1315 }