Ticket #3359: 3359.diff
File 3359.diff, 4.4 KB (added by , 5 years ago) |
---|
-
trunk/src/includes/replies/functions.php
543 543 544 544 // Filter anonymous data 545 545 $anonymous_data = bbp_filter_anonymous_post_data(); 546 547 // Anonymous data checks out, so set cookies, etc... 548 bbp_set_current_anonymous_user_data( $anonymous_data ); 546 549 } 547 550 } 548 551 … … 2227 2230 */ 2228 2231 function bbp_check_reply_edit() { 2229 2232 2230 // Bail if not editing a topic2233 // Bail if not editing a reply 2231 2234 if ( ! bbp_is_reply_edit() ) { 2232 2235 return; 2233 2236 } 2234 2237 2235 // User cannot edit topic, so redirect back to reply2236 if ( ! current_user_can( 'edit_reply', bbp_get_reply_id() ) ) {2238 // User cannot edit reply, so redirect back to reply 2239 if ( ! current_user_can( 'edit_reply', bbp_get_reply_id() ) && ! bbp_anonymous_user_can( 'edit_reply', bbp_get_reply_id() ) ) { 2237 2240 bbp_redirect( bbp_get_reply_url() ); 2238 2241 } 2239 2242 } -
trunk/src/includes/replies/template.php
1855 1855 if ( ! current_user_can( 'edit_others_replies' ) ) { 1856 1856 1857 1857 // User cannot edit or it is past the lock time 1858 if ( empty( $reply ) || ! current_user_can( 'edit_reply', $reply->ID) || bbp_past_edit_lock( $reply->post_date_gmt ) ) {1858 if ( empty( $reply ) || (! current_user_can( 'edit_reply', $reply->ID ) && ! bbp_anonymous_user_can( 'edit_reply', $reply->ID ) ) || bbp_past_edit_lock( $reply->post_date_gmt ) ) { 1859 1859 return; 1860 1860 } 1861 1861 } -
trunk/src/includes/topics/functions.php
460 460 461 461 // Filter anonymous data 462 462 $anonymous_data = bbp_filter_anonymous_post_data(); 463 464 // Anonymous data checks out, so set cookies, etc... 465 bbp_set_current_anonymous_user_data( $anonymous_data ); 463 466 } 464 467 } 465 468 … … 3838 3841 } 3839 3842 3840 3843 // User cannot edit topic, so redirect back to topic 3841 if ( ! current_user_can( 'edit_topic', bbp_get_topic_id() ) ) {3844 if ( ! current_user_can( 'edit_topic', bbp_get_topic_id() ) && ! bbp_anonymous_user_can( 'edit_topic', bbp_get_topic_id() ) ) { 3842 3845 bbp_redirect( bbp_get_topic_permalink() ); 3843 3846 } 3844 3847 } -
trunk/src/includes/topics/template.php
2410 2410 if ( ! current_user_can( 'edit_others_topics' ) ) { 2411 2411 2412 2412 // User cannot edit or it is past the lock time 2413 if ( empty( $topic ) || ! current_user_can( 'edit_topic', $topic->ID) || bbp_past_edit_lock( $topic->post_date_gmt ) ) {2413 if ( empty( $topic ) || (! current_user_can( 'edit_topic', $topic->ID ) && ! bbp_anonymous_user_can( 'edit_topic', $topic->ID ) ) || bbp_past_edit_lock( $topic->post_date_gmt ) ) { 2414 2414 return; 2415 2415 } 2416 2416 } -
trunk/src/includes/users/capabilities.php
826 826 // Filter & return 827 827 return (array) apply_filters( 'bbp_get_moderators', $users, $object_id, $object_type ); 828 828 } 829 830 function bbp_anonymous_user_can( $capability, ...$args ) { 831 832 switch ( $capability ) { 833 834 default: 835 return false; 836 837 case 'edit_topic': 838 case 'edit_reply': 839 840 $post_id = $args[0]; 841 $post = ( 'edit_topic' == $capability ) ? bbp_get_topic( $post_id ) : bbp_get_reply( $post_id ); 842 843 if ( empty( $post ) ) { 844 return false; 845 } 846 847 if ( $post->post_author ) { 848 return false; 849 } 850 851 $current_user = wp_get_current_user(); 852 853 if ( $current_user->ID ) { 854 return false; 855 } 856 857 $anonymous_data = wp_get_current_commenter(); 858 859 $retval = $anonymous_data['comment_author'] == get_post_meta( $post_id, '_bbp_anonymous_name', true ) && 860 $anonymous_data['comment_author_email'] == get_post_meta( $post_id, '_bbp_anonymous_email', true ) && 861 $anonymous_data['comment_author_url'] == get_post_meta( $post_id, '_bbp_anonymous_website', true ); 862 863 return $retval; 864 } 865 }