Skip to:
Content

BuddyPress.org

Ticket #7096: 7096.2.diff

File 7096.2.diff, 9.8 KB (added by boonebgorges, 8 years ago)
  • src/bp-messages/bp-messages-template.php

    diff --git src/bp-messages/bp-messages-template.php src/bp-messages/bp-messages-template.php
    index ad380b132..812629611 100644
    function bp_message_thread_to() { 
    273273/**
    274274 * Output the permalink for a particular thread.
    275275 *
     276 * @since 2.9.0 Introduced `$user_id` parameter.
     277 *
    276278 * @param int $thread_id Optional. ID of the thread. Default: current thread
    277279 *                       being iterated on in the loop.
     280 * @param int $user_id   Optional. ID of the user relative to whom the link
     281 *                       should be generated. Default: ID of logged-in user.
    278282 */
    279 function bp_message_thread_view_link( $thread_id = 0 ) {
    280         echo bp_get_message_thread_view_link( $thread_id );
     283function bp_message_thread_view_link( $thread_id = 0, $user_id = null ) {
     284        echo bp_get_message_thread_view_link( $thread_id, $user_id );
    281285}
    282286        /**
    283287         * Get the permalink of a particular thread.
    284288         *
     289         * @since 2.9.0 Introduced `$user_id` parameter.
     290         *
    285291         * @param int $thread_id Optional. ID of the thread. Default: current
    286292         *                       thread being iterated on in the loop.
     293         * @param int $user_id   Optional. ID of the user relative to whom the link
     294         *                       should be generated. Default: ID of logged-in user.
    287295         * @return string
    288296         */
    289         function bp_get_message_thread_view_link( $thread_id = 0 ) {
     297        function bp_get_message_thread_view_link( $thread_id = 0, $user_id = null ) {
    290298                global $messages_template;
    291299
    292300                if ( empty( $messages_template ) && (int) $thread_id > 0 ) {
    function bp_message_thread_view_link( $thread_id = 0 ) { 
    295303                        $thread_id = $messages_template->thread->thread_id;
    296304                }
    297305
     306                if ( null === $user_id ) {
     307                        $user_id = bp_loggedin_user_id();
     308                }
     309
     310                $domain = bp_core_get_user_domain( $user_id );
     311
    298312                /**
    299313                 * Filters the permalink of a particular thread.
    300314                 *
    301315                 * @since 1.0.0
    302316                 * @since 2.6.0 Added the `$thread_id` parameter.
     317                 * @since 2.9.0 Added the `$user_id` parameter.
    303318                 *
    304319                 * @param string $value     Permalink of a particular thread.
    305320                 * @param int    $thread_id ID of the thread.
    306321                 */
    307                 return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id ), $thread_id );
     322                return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( $domain . bp_get_messages_slug() . '/view/' . $thread_id ), $thread_id, $user_id );
    308323        }
    309324
    310325/**
    311326 * Output the URL for deleting the current thread.
     327 *
     328 * @since 2.9.0 Introduced `$user_id` parameter.
     329 *
     330 * @param int $user_id Optional. ID of the user relative to whom the link
     331 *                     should be generated. Default: ID of logged-in user.
    312332 */
    313 function bp_message_thread_delete_link() {
    314         echo esc_url( bp_get_message_thread_delete_link() );
     333function bp_message_thread_delete_link( $user_id = null ) {
     334        echo esc_url( bp_get_message_thread_delete_link( $user_id ) );
    315335}
    316336        /**
    317337         * Generate the URL for deleting the current thread.
    318338         *
     339         * @since 2.9.0 Introduced `$user_id` parameter.
     340         *
     341         * @param int $user_id Optional. ID of the user relative to whom the link
     342         *                     should be generated. Default: ID of logged-in user.
    319343         * @return string
    320344         */
    321         function bp_get_message_thread_delete_link() {
     345        function bp_get_message_thread_delete_link( $user_id = null ) {
    322346                global $messages_template;
    323347
     348                if ( null === $user_id ) {
     349                        $user_id = bp_loggedin_user_id();
     350                }
     351
     352                $domain = bp_core_get_user_domain( $user_id );
     353
    324354                /**
    325355                 * Filters the URL for deleting the current thread.
    326356                 *
    function bp_message_thread_delete_link() { 
    329359                 * @param string $value URL for deleting the current thread.
    330360                 * @param string $value Text indicating action being executed.
    331361                 */
    332                 return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ) );
     362                return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ) );
    333363        }
    334364
    335365/**
    function bp_message_thread_delete_link() { 
    338368 * Since this function directly outputs a URL, it is escaped.
    339369 *
    340370 * @since 2.2.0
     371 * @since 2.9.0 Introduced `$user_id` parameter.
     372 *
     373 * @param int $user_id Optional. ID of the user relative to whom the link
     374 *                     should be generated. Default: ID of logged-in user.
    341375 */
    342 function bp_the_message_thread_mark_unread_url() {
    343         echo esc_url( bp_get_the_message_thread_mark_unread_url() );
     376function bp_the_message_thread_mark_unread_url( $user_id = null ) {
     377        echo esc_url( bp_get_the_message_thread_mark_unread_url( $user_id ) );
    344378}
    345379        /**
    346380         * Return the URL used for marking a single message thread as unread.
    347381         *
    348382         * @since 2.2.0
     383         * @since 2.9.0 Introduced `$user_id` parameter.
    349384         *
     385         * @param int $user_id Optional. ID of the user relative to whom the link
     386         *                     should be generated. Default: ID of logged-in user.
    350387         * @return string
    351388         */
    352         function bp_get_the_message_thread_mark_unread_url() {
     389        function bp_get_the_message_thread_mark_unread_url( $user_id = null ) {
    353390
    354391                // Get the message ID.
    355392                $id = bp_get_message_thread_id();
    function bp_the_message_thread_mark_unread_url() { 
    360397                        'message_id' => $id
    361398                );
    362399
     400                if ( null === $user_id ) {
     401                        $user_id = bp_loggedin_user_id();
     402                }
     403
     404                $domain = bp_core_get_user_domain( $user_id );
     405
    363406                // Base unread URL.
    364                 $url = trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' );
     407                $url = trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' );
    365408
    366409                // Add the args to the URL.
    367410                $url = add_query_arg( $args, $url );
    function bp_the_message_thread_mark_unread_url() { 
    385428 * Since this function directly outputs a URL, it is escaped.
    386429 *
    387430 * @since 2.2.0
     431 * @since 2.9.0 Introduced `$user_id` parameter.
     432 *
     433 * @param int $user_id Optional. ID of the user relative to whom the link
     434 *                     should be generated. Default: ID of logged-in user.
    388435 */
    389 function bp_the_message_thread_mark_read_url() {
    390         echo esc_url( bp_get_the_message_thread_mark_read_url() );
     436function bp_the_message_thread_mark_read_url( $user_id = null ) {
     437        echo esc_url( bp_get_the_message_thread_mark_read_url( $user_id ) );
    391438}
    392439        /**
    393440         * Return the URL used for marking a single message thread as read.
    394441         *
    395442         * @since 2.2.0
     443         * @since 2.9.0 Introduced `$user_id` parameter.
    396444         *
     445         * @param int $user_id Optional. ID of the user relative to whom the link
     446         *                     should be generated. Default: ID of logged-in user.
    397447         * @return string
    398448         */
    399         function bp_get_the_message_thread_mark_read_url() {
     449        function bp_get_the_message_thread_mark_read_url( $user_id = null ) {
    400450
    401451                // Get the message ID.
    402452                $id = bp_get_message_thread_id();
    function bp_the_message_thread_mark_read_url() { 
    407457                        'message_id' => $id
    408458                );
    409459
     460                if ( null === $user_id ) {
     461                        $user_id = bp_loggedin_user_id();
     462                }
     463
     464                $domain = bp_core_get_user_domain( $user_id );
     465
    410466                // Base read URL.
    411                 $url = trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/read' );
     467                $url = trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/read' );
    412468
    413469                // Add the args to the URL.
    414470                $url = add_query_arg( $args, $url );
  • src/bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php

    diff --git src/bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php src/bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php
    index d71ded236..7720e99fc 100644
    do_action( 'bp_before_member_messages_loop' ); ?> 
    115115                                                <?php endif; ?>
    116116
    117117                                                <td class="thread-info">
    118                                                         <p><a href="<?php bp_message_thread_view_link(); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( "View Message", 'buddypress' ); ?>" aria-label="<?php esc_attr_e( "View Message", 'buddypress' ); ?>"><?php bp_message_thread_subject(); ?></a></p>
     118                                                        <p><a href="<?php bp_message_thread_view_link( bp_get_message_thread_id(), bp_displayed_user_id() ); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( "View Message", 'buddypress' ); ?>" aria-label="<?php esc_attr_e( "View Message", 'buddypress' ); ?>"><?php bp_message_thread_subject(); ?></a></p>
    119119                                                        <p class="thread-excerpt"><?php bp_message_thread_excerpt(); ?></p>
    120120                                                </td>
    121121
    do_action( 'bp_before_member_messages_loop' ); ?> 
    139139
    140140                                                <td class="thread-options">
    141141                                                        <?php if ( bp_message_thread_has_unread() ) : ?>
    142                                                                 <a class="read" href="<?php bp_the_message_thread_mark_read_url();?>"><?php _e( 'Read', 'buddypress' ); ?></a>
     142                                                                <a class="read" href="<?php bp_the_message_thread_mark_read_url( bp_displayed_user_id() );?>"><?php _e( 'Read', 'buddypress' ); ?></a>
    143143                                                        <?php else : ?>
    144                                                                 <a class="unread" href="<?php bp_the_message_thread_mark_unread_url();?>"><?php _e( 'Unread', 'buddypress' ); ?></a>
     144                                                                <a class="unread" href="<?php bp_the_message_thread_mark_unread_url( bp_displayed_user_id() );?>"><?php _e( 'Unread', 'buddypress' ); ?></a>
    145145                                                        <?php endif; ?>
    146146                                                         |
    147                                                         <a class="delete" href="<?php bp_message_thread_delete_link(); ?>"><?php _e( 'Delete', 'buddypress' ); ?></a>
     147                                                        <a class="delete" href="<?php bp_message_thread_delete_link( bp_displayed_user_id() ); ?>"><?php _e( 'Delete', 'buddypress' ); ?></a>
    148148
    149149                                                        <?php
    150150