[ 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.

return: bool False if there are no messages.
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.

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.

return: array
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.

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

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

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

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

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.

return: bool
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

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

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

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

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

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.

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

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

return: bool|int Number of threads marked as read or false on error.
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.

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

return: bool|int Number of threads marked as unread or false on error.
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.

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

return: int Total thread count for the provided 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

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

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

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

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

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

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

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

return: int|null The recorded recipient ID on success, null on failure.
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

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

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

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.

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

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

return: bool
since: 1.2.0



Generated: Thu Nov 21 01:00:57 2024 Cross-referenced by PHPXref 0.7.1