[ 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: 1180 lines (38 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

BP_Notifications_Notification:: (27 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()
  delete()
  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.

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

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

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

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.

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

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

return: int|false The number of rows updated, or false on error.
since: 1.9.0
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()}.

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

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

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.

return: string WHERE clause.
since: 1.9.0
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.

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.

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

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.

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

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.

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

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

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

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

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

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

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

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

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

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

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

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.
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 query).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

return: int|false False on failure to update. ID on success.
since: 1.9.0
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.

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.

return: int|false
since: 1.9.0
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.

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.

return: int|false
since: 1.9.0
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

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().

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



Generated: Wed Dec 11 01:01:37 2019 Cross-referenced by PHPXref 0.7.1