Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/02/2021 01:10:12 AM (3 years ago)
Author:
espellcaste
Message:

Adding a user ID parameter to the messages_mark_thread_read and messages_mark_thread_unread functions.

Allowing those functions to be used in other BuddyPress API.

Props imath
Fixes #8489 (trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/classes/class-bp-messages-thread.php

    r12592 r12984  
    613613     *
    614614     * @since 1.0.0
     615     * @since 9.0.0 Added the `user_id` parameter.
    615616     *
    616617     * @param int $thread_id The message thread ID.
     618     * @param int $user_id   The user the thread will be marked as read.
    617619     *
    618620     * @return false|int Number of threads marked as read or false on error.
    619621     */
    620     public static function mark_as_read( $thread_id = 0 ) {
    621         global $wpdb;
    622 
    623         $user_id =
    624             bp_displayed_user_id() ?
    625             bp_displayed_user_id() :
    626             bp_loggedin_user_id();
     622    public static function mark_as_read( $thread_id = 0, $user_id = 0 ) {
     623        global $wpdb;
     624
     625        if ( empty( $user_id ) ) {
     626            $user_id =
     627                bp_displayed_user_id() ?
     628                bp_displayed_user_id() :
     629                bp_loggedin_user_id();
     630        }
    627631
    628632        $bp     = buddypress();
     
    636640         *
    637641         * @since 2.8.0
     642         * @since 9.0.0 Added the `user_id` parameter.
    638643         *
    639644         * @param int $thread_id The message thread ID.
     645         * @param int $user_id   The user the thread will be marked as read.
    640646         */
    641         do_action( 'messages_thread_mark_as_read', $thread_id );
     647        do_action( 'messages_thread_mark_as_read', $thread_id, $user_id );
    642648
    643649        return $retval;
     
    648654     *
    649655     * @since 1.0.0
     656     * @since 9.0.0 Added the `user_id` parameter.
    650657     *
    651658     * @param int $thread_id The message thread ID.
     659     * @param int $user_id   The user the thread will be marked as unread.
    652660     *
    653661     * @return false|int Number of threads marked as unread or false on error.
    654662     */
    655     public static function mark_as_unread( $thread_id = 0 ) {
    656         global $wpdb;
    657 
    658         $user_id =
    659             bp_displayed_user_id() ?
    660             bp_displayed_user_id() :
    661             bp_loggedin_user_id();
     663    public static function mark_as_unread( $thread_id = 0, $user_id = 0 ) {
     664        global $wpdb;
     665
     666        if ( empty( $user_id ) ) {
     667            $user_id =
     668                bp_displayed_user_id() ?
     669                bp_displayed_user_id() :
     670                bp_loggedin_user_id();
     671        }
    662672
    663673        $bp     = buddypress();
     
    671681         *
    672682         * @since 2.8.0
     683         * @since 9.0.0 Added the `user_id` parameter.
    673684         *
    674685         * @param int $thread_id The message thread ID.
     686         * @param int $user_id   The user the thread will be marked as unread.
    675687         */
    676         do_action( 'messages_thread_mark_as_unread', $thread_id );
     688        do_action( 'messages_thread_mark_as_unread', $thread_id, $user_id );
    677689
    678690        return $retval;
Note: See TracChangeset for help on using the changeset viewer.