[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

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

BuddyPress Activity Classes

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

Defines 1 class

BP_Activity_Activity:: (28 methods):
  __construct()
  populate()
  save()
  get()
  get_activity_data()
  append_user_fullnames()
  prefetch_object_data()
  generate_action_strings()
  get_meta_query_sql()
  get_date_query_sql()
  get_scope_query_sql()
  get_specific()
  get_id()
  delete()
  delete_activity_item_comments()
  delete_activity_meta_entries()
  append_comments()
  get_activity_comments()
  rebuild_activity_comment_tree()
  get_child_comments()
  get_recorded_components()
  get_sitewide_items_for_feed()
  get_in_operator_sql()
  get_filter_sql()
  get_last_updated()
  total_favorite_count()
  check_exists_by_content()
  hide_all_for_user()


Class: BP_Activity_Activity  - X-Ref

Database interaction class for the BuddyPress activity component.
Instance methods are available for creating/editing an activity,
static methods for querying activities.

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

since: 1.5.0
param: int|bool $id Optional. The ID of a specific activity item.

populate()   X-Ref
Populate the object with data about the specific activity item.

since: 1.0.0

save()   X-Ref
Save the activity item to the database.

return: WP_Error|bool True on success.
since: 1.0.0

get( $args = array()   X-Ref
Get activity items, as specified by parameters.

return: array The array returned has two keys:
since: 1.2.0
since: 2.4.0 Introduced the `$fields` parameter.
since: 2.9.0 Introduced the `$order_by` parameter.
param: array $args {

get_activity_data( $activity_ids = array()   X-Ref
Convert activity IDs to activity objects, as expected in template loop.

return: array
since: 2.0.0
param: array $activity_ids Array of activity IDs.

append_user_fullnames( $activities )   X-Ref
Append xProfile fullnames to an activity array.

return: array
since: 2.0.0
param: array $activities Activities array.

prefetch_object_data( $activities )   X-Ref
Pre-fetch data for objects associated with activity items.

Activity items are associated with users, and often with other
BuddyPress data objects. Here, we pre-fetch data about these
associated objects, so that inline lookups - done primarily when
building action strings - do not result in excess database queries.

The only object data required for activity component activity types
(activity_update and activity_comment) is related to users, and that
info is fetched separately in BP_Activity_Activity::get_activity_data().
So this method contains nothing but a filter that allows other
components, such as bp-friends and bp-groups, to hook in and prime
their own caches at the beginning of an activity loop.

return: array $activities Array of activities.
since: 2.0.0
param: array $activities Array of activities.

generate_action_strings( $activities )   X-Ref
Generate action strings for the activities located in BP_Activity_Activity::get().

If no string can be dynamically generated for a given item
(typically because the activity type has not been properly
registered), the static 'action' value pulled from the database will
be left in place.

return: array
since: 2.0.0
param: array $activities Array of activities.

get_meta_query_sql( $meta_query = array()   X-Ref
Get the SQL for the 'meta_query' param in BP_Activity_Activity::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_Activity_Activity::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: 1.8.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_Activity_Activity::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_Activity_Activity::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.1.0
param: array $date_query An array of date_query parameters. See the

get_scope_query_sql( $scope = false, $r = array()   X-Ref
Get the SQL for the 'scope' param in BP_Activity_Activity::get().

A scope is a predetermined set of activity arguments.  This method is used
to grab these activity arguments and override any existing args if needed.

Can handle multiple scopes.

return: false|array 'sql' WHERE SQL string and 'override' activity args.
since: 2.2.0
param: mixed $scope  The activity scope. Accepts string or array of scopes.
param: array $r      Current activity arguments. Same as those of BP_Activity_Activity::get(),

get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false )   X-Ref
In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).

As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead.

return: array
since: 1.2.0
param: mixed    $activity_ids     Array or comma-separated string of activity IDs to retrieve.
param: int|bool $max              Maximum number of results to return. (Optional; default is no maximum).
param: int      $page             The set of results that the user is viewing. Used in pagination. (Optional; default is 1).
param: int      $per_page         Specifies how many results per page. Used in pagination. (Optional; default is 25).
param: string   $sort             MySQL column sort; ASC or DESC. (Optional; default is DESC).
param: bool     $display_comments Retrieve an activity item's associated comments or not. (Optional; default is false).

get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded )   X-Ref
Get the first activity ID that matches a set of criteria.

return: int|false Activity ID on success, false if none is found.
since: 1.2.0
param: int    $user_id           User ID to filter by.
param: string $component         Component to filter by.
param: string $type              Activity type to filter by.
param: int    $item_id           Associated item to filter by.
param: int    $secondary_item_id Secondary associated item to filter by.
param: string $action            Action to filter by.
param: string $content           Content to filter by.
param: string $date_recorded     Date to filter by.

delete( $args = array()   X-Ref
Delete activity items from the database.

To delete a specific activity item, pass an 'id' parameter.
Otherwise use the filters.

return: array|bool An array of deleted activity IDs on success, false on failure.
since: 1.2.0
param: array $args {

delete_activity_item_comments( $activity_ids = array()   X-Ref
Delete the comments associated with a set of activity items.

This method is no longer used by BuddyPress, and it is recommended not to
use it going forward, and use BP_Activity_Activity::delete() instead.

return: bool True on success.
since: 1.2.0
param: array $activity_ids Activity IDs whose comments should be deleted.
param: bool  $delete_meta  Should we delete the activity meta items for these comments.

delete_activity_meta_entries( $activity_ids = array()   X-Ref
Delete the meta entries associated with a set of activity items.

return: bool True on success.
since: 1.2.0
param: array $activity_ids Activity IDs whose meta should be deleted.

append_comments( $activities, $spam = 'ham_only' )   X-Ref
Append activity comments to their associated activity items.

return: array The updated activities with nested comments.
since: 1.2.0
param: array  $activities Activities to fetch comments for.
param: string $spam       Optional. 'ham_only' (default), 'spam_only' or 'all'.

get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 )   X-Ref
Get activity comments that are associated with a specific activity ID.

return: array The updated activities with nested comments.
since: 1.2.0
param: int    $activity_id         Activity ID to fetch comments for.
param: int    $left                Left-most node boundary.
param: int    $right               Right-most node boundary.
param: string $spam                Optional. 'ham_only' (default), 'spam_only' or 'all'.
param: int    $top_level_parent_id Optional. The id of the root-level parent activity item.

rebuild_activity_comment_tree( $parent_id, $left = 1 )   X-Ref
Rebuild nested comment tree under an activity or activity comment.

return: int Right Node boundary of activity or activity comment.
since: 1.2.0
param: int $parent_id ID of an activity or activity comment.
param: int $left      Node boundary start for activity or activity comment.

get_child_comments( $parent_id )   X-Ref
Get child comments of an activity or activity comment.

return: object Numerically indexed array of child comments.
since: 1.2.0
param: int $parent_id ID of an activity or activity comment.

get_recorded_components( $skip_last_activity = true )   X-Ref
Get a list of components that have recorded activity associated with them.

return: array List of component names.
since: 1.2.0
param: bool $skip_last_activity If true, components will not be

get_sitewide_items_for_feed( $limit = 35 )   X-Ref
Get sitewide activity items for use in an RSS feed.

return: array $activity_feed List of activity items, with RSS data added.
since: 1.0.0
param: int $limit Optional. Number of items to fetch. Default: 35.

get_in_operator_sql( $field, $items )   X-Ref
Create SQL IN clause for filter queries.

return: string|false
since: 1.5.0
param: string     $field The database field.
param: array|bool $items The values for the IN clause, or false when none are found.

get_filter_sql( $filter_array )   X-Ref
Create filter SQL clauses.

return: string The filter clause, for use in a SQL query.
since: 1.5.0
param: array $filter_array {

get_last_updated()   X-Ref
Get the date/time of last recorded activity.

return: string ISO timestamp.
since: 1.2.0

total_favorite_count( $user_id )   X-Ref
Get favorite count for a given user.

return: int $value A count of the user's favorites.
since: 1.2.0
param: int $user_id The ID of the user whose favorites you're counting.

check_exists_by_content( $content )   X-Ref
Check whether an activity item exists with a given string content.

return: int|false The ID of the first matching item if found, otherwise false.
since: 1.1.0
param: string $content The content to filter by.

hide_all_for_user( $user_id )   X-Ref
Hide all activity for a given user.

return: mixed
since: 1.2.0
param: int $user_id The ID of the user whose activity you want to mark hidden.



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