[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-notifications/classes/ -> class-bp-notifications-notification.php (summary)

BuddyPress Notifications Classes. Classes used for the Notifications component.

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

Defines 1 class

BP_Notifications_Notification:: (29 methods):
  __construct()
  save()
  populate()
  _insert()
  _update()
  _delete()
  get_where_sql()
  get_order_by_sql()
  get_paged_sql()
  get_query_clauses()
  check_access()
  parse_args()
  get()
  get_total_count()
  get_meta_query_sql()
  get_date_query_sql()
  update()
  update_id_list()
  delete()
  delete_by_id_list()
  delete_by_id()
  get_all_for_user()
  get_unread_for_user()
  get_read_for_user()
  get_current_notifications_for_user()
  mark_all_for_user()
  mark_all_from_user()
  mark_all_by_type()
  get_grouped_notifications_for_user()


Class: BP_Notifications_Notification  - X-Ref

BuddyPress Notification items.

Use this class to create, access, edit, or delete BuddyPress Notifications.

__construct( $id = 0 )   X-Ref
Constructor method.

param: int $id Optional. Provide an ID to access an existing
since: 1.9.0

save()   X-Ref
Update or insert notification details into the database.

since: 1.9.0
return: bool True on success, false on failure.

populate()   X-Ref
Fetch data for an existing notification from the database.

since: 1.9.0

_insert( $data = array()   X-Ref
Create a notification entry.

param: array $data {
param: array $data_format See {@link wpdb::insert()}.
since: 1.9.0
return: int|false The number of rows inserted, or false on error.

_update( $data = array()   X-Ref
Update notifications.

param: array $data         Array of notification data to update, passed to
param: array $where        The WHERE params as passed to wpdb::update().
param: array $data_format  See {@link wpdb::insert()}.
param: array $where_format See {@link wpdb::insert()}.
since: 1.9.0
return: int|false The number of rows updated, or false on error.

_delete( $where = array()   X-Ref
Delete notifications.

param: array $where        Array of WHERE clauses to filter by, passed to
param: array $where_format See {@link wpdb::insert()}.
since: 1.9.0
return: int|false The number of rows updated, or false on error.

get_where_sql( $args = array()   X-Ref
Assemble the WHERE clause of a get() SQL statement.

Used by BP_Notifications_Notification::get() to create its WHERE
clause.

param: array  $args           See {@link BP_Notifications_Notification::get()}
param: string $select_sql     SQL SELECT fragment.
param: string $from_sql       SQL FROM fragment.
param: string $join_sql       SQL JOIN fragment.
param: string $meta_query_sql SQL meta query fragment.
since: 1.9.0
return: string WHERE clause.

get_order_by_sql( $args = array()   X-Ref
Assemble the ORDER BY clause of a get() SQL statement.

Used by BP_Notifications_Notification::get() to create its ORDER BY
clause.

param: array $args See {@link BP_Notifications_Notification::get()}
since: 1.9.0
return: string ORDER BY clause.

get_paged_sql( $args = array()   X-Ref
Assemble the LIMIT clause of a get() SQL statement.

Used by BP_Notifications_Notification::get() to create its LIMIT clause.

param: array $args See {@link BP_Notifications_Notification::get()}
since: 1.9.0
return: string $retval LIMIT clause.

get_query_clauses( $args = array()   X-Ref
Assemble query clauses, based on arguments, to pass to $wpdb methods.

The insert(), update(), and delete() methods of {@link wpdb} expect
arguments of the following forms:

- associative arrays whose key/value pairs are column => value, to
be used in WHERE, SET, or VALUES clauses.
- arrays of "formats", which tell $wpdb->prepare() which type of
value to expect when sanitizing (eg, array( '%s', '%d' ))

This utility method can be used to assemble both kinds of params,
out of a single set of associative array arguments, such as:

$args = array(
'user_id' => 4,
'component_name' => 'groups',
);

This will be converted to:

array(
'data' => array(
'user_id' => 4,
'component_name' => 'groups',
),
'format' => array(
'%d',
'%s',
),
)

which can easily be passed as arguments to the $wpdb methods.

param: array $args Associative array of filter arguments.
since: 1.9.0
return: array Associative array of 'data' and 'format' args.

check_access( $user_id = 0, $notification_id = 0 )   X-Ref
Check that a specific notification is for a specific user.

param: int $user_id         ID of the user being checked.
param: int $notification_id ID of the notification being checked.
since: 1.9.0
return: bool True if the notification belongs to the user, otherwise false.

parse_args( $args = '' )   X-Ref
Parse notifications query arguments.

param: array|string $args Args to parse.
since: 2.3.0
return: array

get( $args = array()   X-Ref
Get notifications, based on provided filter parameters.

param: array $args {
since: 1.9.0
return: array Located notifications.

get_total_count( $args )   X-Ref
Get a count of total notifications matching a set of arguments.

param: array|string $args See {@link BP_Notifications_Notification::get()}.
since: 1.9.0
return: int Count of located items.

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

We use WP_Meta_Query to do the heavy lifting of parsing the
meta_query array and creating the necessary SQL clauses. However,
since BP_Notifications_Notification::get() builds its SQL differently than
WP_Query, we have to alter the return value (stripping the leading
AND keyword from the 'where' clause).

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

get_date_query_sql( $date_query = array()   X-Ref
Get the SQL for the 'date_query' param in BP_Notifications_Notification::get().

We use BP_Date_Query, which extends WP_Date_Query, to do the heavy lifting
of parsing the date_query array and creating the necessary SQL clauses.

param: array $date_query An array of date_query parameters. See the
since: 2.3.0
return: string

update( $update_args = array()   X-Ref
Update notifications.

param: array $update_args Associative array of fields to update,
param: array $where_args  Associative array of columns/values, to
since: 1.9.0
return: int|false Number of rows updated on success, false on failure.

update_id_list( $field, $items = array()   X-Ref
Update notifications using a list of ids/items_ids.

param: string $field The name of the db field of the items to update.
param: int[]  $items The list of items to update.
param: array  $data  Array of notification data to update.
param: array  $where The WHERE params to use to specify the item IDs to update.
since: 10.0.0
return: int|false    The number of updated rows. False on error.

delete( $args = array()   X-Ref
Delete notifications.

param: array $args Associative array of columns/values, to determine
since: 1.9.0
return: int|false Number of rows deleted on success, false on failure.

delete_by_id_list( $field, $items = array()   X-Ref
Delete notifications using a list of ids/items_ids.

param: string $field The name of the db field of the items to delete.
param: int[]  $items The list of items to delete.
param: array  $args  The WHERE arguments to use to specify the item IDs to delete.
since: 10.0.0
return: int|false    The number of deleted rows. False on error.

delete_by_id( $id )   X-Ref
Delete a single notification by ID.

param: int $id ID of the notification item to be deleted.
since: 1.9.0
return: int|false True on success, false on failure.

get_all_for_user( $user_id, $status = 'is_new' )   X-Ref
Fetch all the notifications in the database for a specific user.

param: int    $user_id ID of the user whose notifications are being
param: string $status  Optional. Status of notifications to fetch.
since: 1.9.0
return: array Associative array of notification items.

get_unread_for_user( $user_id = 0 )   X-Ref
Fetch all the unread notifications in the database for a specific user.

param: int $user_id ID of the user whose notifications are being
since: 1.9.0
return: array Associative array of unread notification items.

get_read_for_user( $user_id = 0 )   X-Ref
Fetch all the read notifications in the database for a specific user.

param: int $user_id ID of the user whose notifications are being
since: 1.9.0
return: array Associative array of unread notification items.

get_current_notifications_for_user( $args = array()   X-Ref
Get unread notifications for a user, in a pagination-friendly format.

param: array $args {
since: 1.9.0
return: array {

mark_all_for_user( $user_id, $is_new = 0, $item_id = 0, $component_name = '', $component_action = '', $secondary_item_id = 0 )   X-Ref
Mark all user notifications as read.

param: int    $user_id           The ID of the user who the notifications are for.
param: int    $is_new            Mark as read (1) or unread (0).
param: int    $item_id           Item ID being acted on.
param: string $component_name    Name of component the notifications are for.
param: string $component_action  Name of the component action.
param: int    $secondary_item_id The ID of the secondary item.
since: 1.9.0
return: int|false False on failure to update. ID on success.

mark_all_from_user( $user_id, $is_new = 0, $component_name = '', $component_action = '', $secondary_item_id = 0 )   X-Ref
Mark all notifications from a user as read.

param: int    $user_id           The ID of the user who the notifications are from.
param: int    $is_new            Mark as read (1) or unread (0).
param: string $component_name    Name of component the notifications are for.
param: string $component_action  Name of the component action.
param: int    $secondary_item_id The ID of the secondary item.
since: 1.9.0
return: int|false

mark_all_by_type( $item_id, $is_new = 0, $component_name = '', $component_action = '', $secondary_item_id = 0 )   X-Ref
Mark all notifications for all users as read by item id, and optional
secondary item id, and component name and action.

param: int    $item_id           The ID of the item associated with the
param: int    $is_new            Mark as read (1) or unread (0).
param: string $component_name    The component that the notifications
param: string $component_action  The action that the notifications
param: int    $secondary_item_id Optional. ID of the secondary
since: 1.9.0
return: int|false

get_grouped_notifications_for_user( $user_id )   X-Ref
Get a user's unread notifications, grouped by component and action.

Multiple notifications of the same type (those that share the same component_name
and component_action) are collapsed for formatting as "You have 5 pending
friendship requests", etc. See bp_notifications_get_notifications_for_user().
For a full-fidelity list of user notifications, use
bp_notifications_get_all_notifications_for_user().

param: int $user_id ID of the user whose notifications are being fetched.
since: 3.0.0
return: array Notifications items for formatting into a list.



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