[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-messages/classes/ -> class-bp-messages-thread.php (summary)

BuddyPress Messages Classes.

File Size: 1158 lines (35 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

BP_Messages_Thread:: (21 methods):
  __construct()
  populate()
  mark_read()
  mark_unread()
  get_recipients()
  get_messages()
  get_recipients_for_thread()
  delete()
  exit_thread()
  get_current_threads_for_user()
  get_meta_query_sql()
  mark_as_read()
  mark_as_unread()
  get_total_threads_for_user()
  user_is_sender()
  get_last_sender()
  get_inbox_count()
  check_access()
  is_valid()
  get_recipient_links()
  update_tables()


Class: BP_Messages_Thread  - X-Ref

BuddyPress Message Thread class.

__construct( $thread_id = 0, $order = 'ASC', $args = array()   X-Ref
Constructor.

param: int    $thread_id          The message thread ID.
param: string $order              The order to sort the messages. Either 'ASC' or 'DESC'.
param: array  $args               {
since: 1.0.0
since: 10.0.0 Updated the `$args` with new paremeters.

populate( $thread_id = 0, $order = 'ASC', $args = array()   X-Ref
Populate method.

Used in the constructor.

param: int    $thread_id                   The message thread ID.
param: string $order                       The order to sort the messages. Either 'ASC' or 'DESC'.
param: array  $args                        {
since: 1.0.0
since: 10.0.0 Updated the `$args` with new paremeters.
return: bool False if there are no messages.

mark_read()   X-Ref
Mark a thread initialized in this class as read.

since: 1.0.0

mark_unread()   X-Ref
Mark a thread initialized in this class as unread.

since: 1.0.0

get_recipients( $thread_id = 0, $args = array()   X-Ref
Returns recipients for a message thread.

param: int   $thread_id Message thread ID.
param: array $args      {
since: 1.0.0
since: 2.3.0  Added `$thread_id` as a parameter.
since: 10.0.0 Added `$args` as a parameter.
return: array

get_messages( $thread_id = 0, $args = array()   X-Ref
Get messages associated with a thread.

param: int   $thread_id The message thread ID.
param: array $args      {
since: 2.3.0
since: 10.0.0 Added `$args` as a parameter.
return: array

get_recipients_for_thread( $thread_id = 0 )   X-Ref
Static method to get message recipients by thread ID.

param: int $thread_id The thread ID.
since: 2.3.0
return: array

delete( $thread_id = 0, $user_id = 0 )   X-Ref
Mark messages in a thread as deleted or delete all messages in a thread.

Note: All messages in a thread are deleted once every recipient in a thread
has marked the thread as deleted.

param: int $thread_id The message thread ID.
param: int $user_id The ID of the user in the thread to mark messages as
since: 1.0.0
since: 2.7.0 The $user_id parameter was added. Previously the current user
return: bool

exit_thread( $thread_id = 0, $user_id = 0 )   X-Ref
Exit a user from a thread.

param: int $thread_id The message thread ID.
param: int $user_id The ID of the user in the thread.
since: 10.0.0
return: bool

get_current_threads_for_user( $args = array()   X-Ref
Get current message threads for a user.

param: array $args {
since: 1.0.0
return: array|bool Array on success. False on failure.

get_meta_query_sql( $meta_query = array()   X-Ref
Get the SQL for the 'meta_query' param in BP_Messages_Thread::get_current_threads_for_user().

We use WP_Meta_Query to do the heavy lifting of parsing the meta_query array
and creating the necessary SQL clauses.

param: array $meta_query An array of meta_query filters. See the
since: 2.2.0
return: array $sql_array 'join' and 'where' clauses.

mark_as_read( $thread_id = 0, $user_id = 0 )   X-Ref
Mark a thread as read.

param: int $thread_id The message thread ID.
param: int $user_id   The user the thread will be marked as read.
since: 1.0.0
since: 9.0.0 Added the `user_id` parameter.
return: bool|int Number of threads marked as read or false on error.

mark_as_unread( $thread_id = 0, $user_id = 0 )   X-Ref
Mark a thread as unread.

param: int $thread_id The message thread ID.
param: int $user_id   The user the thread will be marked as unread.
since: 1.0.0
since: 9.0.0 Added the `user_id` parameter.
return: bool|int Number of threads marked as unread or false on error.

get_total_threads_for_user( $user_id, $box = 'inbox', $type = 'all' )   X-Ref
Returns the total number of message threads for a user.

param: int    $user_id The user ID.
param: string $box     The type of mailbox to get. Either 'inbox' or 'sentbox'.
param: string $type    The type of messages to get. Either 'all' or 'unread'.
since: 1.0.0
return: int Total thread count for the provided user.

user_is_sender( $thread_id )   X-Ref
Determine if the logged-in user is a sender of any message in a thread.

param: int $thread_id The message thread ID.
since: 1.0.0
return: bool

get_last_sender( $thread_id )   X-Ref
Returns the userlink of the last sender in a message thread.

param: int $thread_id The message thread ID.
since: 1.0.0
return: string|bool The user link on success. Boolean false on failure.

get_inbox_count( $user_id = 0 )   X-Ref
Gets the unread message count for a user.

param: int $user_id The user ID.
since: 1.0.0
return: int Total inbox unread count for user.

check_access( $thread_id, $user_id = 0 )   X-Ref
Checks whether a user is a part of a message thread discussion.

param: int $thread_id The message thread ID.
param: int $user_id   The user ID. Default: ID of the logged-in user.
since: 1.0.0
return: int|null The recorded recipient ID on success, null on failure.

is_valid( $thread_id = 0 )   X-Ref
Checks whether a message thread exists.

param: int $thread_id The message thread ID.
since: 1.0.0
return: bool|int|null The message thread ID on success, null on failure.

get_recipient_links( $recipients )   X-Ref
Returns a string containing all the message recipient userlinks.

String is comma-delimited.

If a message thread has more than four users, the returned string is simply
"X Recipients" where "X" is the number of recipients in the message thread.

param: array $recipients Array containing the message recipients (array of objects).
since: 1.0.0
return: string String of message recipent userlinks.

update_tables()   X-Ref
Upgrade method for the older BP message thread DB table.

since: 1.2.0
return: bool



Generated: Sat Apr 27 01:00:55 2024 Cross-referenced by PHPXref 0.7.1