<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][7393] trunk/bp-activity/bp-activity-classes.php: Additional documentation and docs standards adherence in bp-activity-classes.php</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://buddypress.trac.wordpress.org/changeset/7393">7393</a></dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2013-10-07 21:57:01 +0000 (Mon, 07 Oct 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Additional documentation and docs standards adherence in bp-activity-classes.php
See <a href="http://buddypress.trac.wordpress.org/ticket/5022">#5022</a>
Props ericlewis</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivityclassesphp">trunk/bp-activity/bp-activity-classes.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivitybpactivityclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-classes.php (7392 => 7393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-classes.php 2013-10-07 16:14:22 UTC (rev 7392)
+++ trunk/bp-activity/bp-activity-classes.php 2013-10-07 21:57:01 UTC (rev 7393)
</span><span class="lines">@@ -9,22 +9,121 @@
</span><span class="cx"> // Exit if accessed directly
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx">
</span><ins>+/**
+ * Database interaction class for the BuddyPress activity component.
+ *
+ * Instance methods are available for creating/editing an activity,
+ * static methods for querying activities.
+ *
+ * @since BuddyPress (1.0)
+ */
</ins><span class="cx"> class BP_Activity_Activity {
</span><ins>+
+ /** Properties ************************************************************/
+
+ /**
+ * ID of the activity item.
+ *
+ * @var int
+ */
</ins><span class="cx"> var $id;
</span><ins>+
+ /**
+ * ID of the associated item.
+ *
+ * @var int
+ */
</ins><span class="cx"> var $item_id;
</span><ins>+
+ /**
+ * ID of the associated secondary item.
+ *
+ * @var int
+ */
</ins><span class="cx"> var $secondary_item_id;
</span><ins>+
+ /**
+ * ID of user associated with the activity item.
+ *
+ * @var int
+ */
</ins><span class="cx"> var $user_id;
</span><ins>+
+ /**
+ * The primary URL for the activity in RSS feeds.
+ *
+ * @var string
+ */
</ins><span class="cx"> var $primary_link;
</span><ins>+
+ /**
+ * BuddyPress component the activity item relates to.
+ *
+ * @var string
+ */
</ins><span class="cx"> var $component;
</span><ins>+
+ /**
+ * Activity type, eg 'new_blog_post'.
+ *
+ * @var string
+ */
</ins><span class="cx"> var $type;
</span><ins>+
+ /**
+ * Description of the activity, eg 'Alex updated his profile.'
+ *
+ * @var string
+ */
</ins><span class="cx"> var $action;
</span><ins>+
+ /**
+ * The content of the activity item.
+ *
+ * @var string
+ */
</ins><span class="cx"> var $content;
</span><ins>+
+ /**
+ * The date the activity item was recorded, in 'Y-m-d h:i:s' format.
+ *
+ * @var string
+ */
</ins><span class="cx"> var $date_recorded;
</span><ins>+
+ /**
+ * Whether the item should be hidden in sitewide streams.
+ *
+ * @var int
+ */
</ins><span class="cx"> var $hide_sitewide = false;
</span><ins>+
+ /**
+ * Node boundary start for activity or activity comment.
+ *
+ * @var int
+ */
</ins><span class="cx"> var $mptt_left;
</span><ins>+
+ /**
+ * Node boundary end for activity or activity comment.
+ *
+ * @var int
+ */
</ins><span class="cx"> var $mptt_right;
</span><ins>+
+ /**
+ * Whether this item is marked as spam.
+ *
+ * @var int
+ */
</ins><span class="cx"> var $is_spam;
</span><span class="cx">
</span><ins>+ /**
+ * Constructor method.
+ *
+ * @param int $id Optional. The ID of a specific activity item.
+ */
</ins><span class="cx"> public function __construct( $id = false ) {
</span><span class="cx"> if ( !empty( $id ) ) {
</span><span class="cx"> $this->id = $id;
</span><span class="lines">@@ -32,6 +131,9 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Populate the object with data about the specific activity item.
+ */
</ins><span class="cx"> public function populate() {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="lines">@@ -55,6 +157,11 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Save the activity item to the database.
+ *
+ * @return bool True on success.
+ */
</ins><span class="cx"> public function save() {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="lines">@@ -104,12 +211,26 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // Static Functions
</del><ins>+ /** Static Methods ***************************************************/
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Get activity items, as specified by parameters
</span><span class="cx"> *
</span><del>- * @param array $args See $defaults for explanation of arguments
</del><ins>+ * @param array $args {
+ * An array of arguments. Optional.
+ * @int $page The current page number. Default: 1.
+ * @int $per_page The number of items to display per page. Default: 25.
+ * @int $max Maximum number of items to show. Default: false.
+ * @string $sort ASC or DESC. Default: 'DESC'.
+ * @array $exclude Array of activity IDs to exclude. Default: false.
+ * @array $in Array of ids to limit query by (IN). Default: false.
+ * @array $meta_query
+ * @array $filter
+ * @string $search_terms Limit results by a search term. Default: false.
+ * @bool $display_comments Whether to include activity comments. Default: false.
+ * @bool $show_hidden Whether to show items marked hide_sitewide. Default: false.
+ * @string $spam Spam status. Default: 'ham_only'
+ * }
</ins><span class="cx"> * @return array
</span><span class="cx"> */
</span><span class="cx"> public static function get( $args = array() ) {
</span><span class="lines">@@ -295,7 +416,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Get the SQL for the 'meta_query' param in BP_Activity_Activity::get()
</del><ins>+ * Get the SQL for the 'meta_query' param in BP_Activity_Activity::get().
</ins><span class="cx"> *
</span><span class="cx"> * We use WP_Meta_Query to do the heavy lifting of parsing the
</span><span class="cx"> * meta_query array and creating the necessary SQL clauses. However,
</span><span class="lines">@@ -307,7 +428,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @param array $meta_query An array of meta_query filters. See the
</span><span class="cx"> * documentation for WP_Meta_Query for details.
</span><del>- * @return array $sql_array 'join' and 'where' clauses
</del><ins>+ * @return array $sql_array 'join' and 'where' clauses.
</ins><span class="cx"> */
</span><span class="cx"> public static function get_meta_query_sql( $meta_query = array() ) {
</span><span class="cx"> global $wpdb;
</span><span class="lines">@@ -336,10 +457,14 @@
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
</span><ins>+ *
</ins><span class="cx"> * As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead.
</span><span class="cx"> *
</span><ins>+ * @since BuddyPress (1.2)
+ *
</ins><span class="cx"> * @deprecated 1.5
</span><span class="cx"> * @deprecated Use BP_Activity_Activity::get() with an 'in' parameter instead.
</span><ins>+ *
</ins><span class="cx"> * @param mixed $activity_ids Array or comma-separated string of activity IDs to retrieve
</span><span class="cx"> * @param int $max Maximum number of results to return. (Optional; default is no maximum)
</span><span class="cx"> * @param int $page The set of results that the user is viewing. Used in pagination. (Optional; default is 1)
</span><span class="lines">@@ -347,13 +472,25 @@
</span><span class="cx"> * @param string MySQL column sort; ASC or DESC. (Optional; default is DESC)
</span><span class="cx"> * @param bool $display_comments Retrieve an activity item's associated comments or not. (Optional; default is false)
</span><span class="cx"> * @return array
</span><del>- * @since BuddyPress (1.2)
</del><span class="cx"> */
</span><span class="cx"> public static function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
</span><span class="cx"> _deprecated_function( __FUNCTION__, '1.5', 'Use BP_Activity_Activity::get() with the "in" parameter instead.' );
</span><span class="cx"> return BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Get the first activity ID that matches a set of criteria.
+ *
+ * @param int $user_id The user ID to filter by.
+ * @param string $component The component to filter by.
+ * @param string $type The activity type to filter by.
+ * @param int $item_id The associated item to filter by.
+ * @param int $secondary_item_id The secondary associated item to filter by.
+ * @param string $action The action to filter by.
+ * @param string $content The content to filter by.
+ * @param string $date_recorded The date to filter by.
+ * @return int|bool Activity ID on success, false if none is found.
+ */
</ins><span class="cx"> public static function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) {
</span><span class="cx"> global $bp, $wpdb;
</span><span class="cx">
</span><span class="lines">@@ -391,6 +528,27 @@
</span><span class="cx"> return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Delete activity items from the database.
+ *
+ * To delete a specific activity item, pass an 'id' parameter.
+ * Otherwise use the filters.
+ *
+ * @param array $args {
+ * @int $id Optional. The ID of a specific item to delete.
+ * @string $action Optional. The action to filter by.
+ * @string $content Optional. The content to filter by.
+ * @string $component Optional. The component name to filter by.
+ * @string $type Optional. The activity type to filter by.
+ * @string $primary_link Optional. The primary URL to filter by.
+ * @int $user_id Optional. The user ID to filter by.
+ * @int $item_id Optional. The associated item ID to filter by.
+ * @int $secondary_item_id Optional. The secondary associated item ID to filter by.
+ * @string $date_recorded Optional. The date to filter by.
+ * @int $hide_sitewide Optional. Default: false.
+ * }
+ * @return array|bool An array of deleted activity IDs on success, false on failure.
+ */
</ins><span class="cx"> public static function delete( $args = array() ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="lines">@@ -466,6 +624,12 @@
</span><span class="cx"> return $activity_ids;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Delete the comments associated with a set of activity items.
+ *
+ * @param array $activity_ids Activity IDs whose comments should be deleted.
+ * @return bool True on success.
+ */
</ins><span class="cx"> public static function delete_activity_item_comments( $activity_ids = array() ) {
</span><span class="cx"> global $bp, $wpdb;
</span><span class="cx">
</span><span class="lines">@@ -474,6 +638,12 @@
</span><span class="cx"> return $wpdb->query( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Delete the meta entries associated with a set of activity items.
+ *
+ * @param array $activity_ids Activity IDs whose meta should be deleted.
+ * @return bool True on success.
+ */
</ins><span class="cx"> public static function delete_activity_meta_entries( $activity_ids = array() ) {
</span><span class="cx"> global $bp, $wpdb;
</span><span class="cx">
</span><span class="lines">@@ -487,13 +657,15 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Append activity comments to their associated activity items
</del><ins>+ * Append activity comments to their associated activity items.
</ins><span class="cx"> *
</span><ins>+ * @since BuddyPress (1.2)
+ *
</ins><span class="cx"> * @global wpdb $wpdb WordPress database object
</span><del>- * @param array $activities
- * @param bool $spam Optional; 'ham_only' (default), 'spam_only' or 'all'.
- * @return array The updated activities with nested comments
- * @since BuddyPress (1.2)
</del><ins>+ *
+ * @param array $activities Activities to fetch comments for.
+ * @param bool $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
+ * @return array The updated activities with nested comments.
</ins><span class="cx"> */
</span><span class="cx"> public static function append_comments( $activities, $spam = 'ham_only' ) {
</span><span class="cx"> $activity_comments = array();
</span><span class="lines">@@ -513,17 +685,19 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Get activity comments that are associated with a specific activity ID
</del><ins>+ * Get activity comments that are associated with a specific activity ID.
</ins><span class="cx"> *
</span><del>- * @global BuddyPress $bp The one true BuddyPress instance
- * @global wpdb $wpdb WordPress database object
- * @param int $activity_id Activity ID to fetch comments for
- * @param int $left Left-most node boundary
- * @param into $right Right-most node boundary
- * @param bool $spam Optional; 'ham_only' (default), 'spam_only' or 'all'.
- * @param int $top_level_parent_id The id of the root-level parent activity item
- * @return array The updated activities with nested comments
</del><span class="cx"> * @since BuddyPress (1.2)
</span><ins>+ *
+ * @global BuddyPress $bp The one true BuddyPress instance.
+ * @global wpdb $wpdb WordPress database object.
+ *
+ * @param int $activity_id Activity ID to fetch comments for.
+ * @param int $left Left-most node boundary.
+ * @param into $right Right-most node boundary.
+ * @param bool $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.
+ * @return array The updated activities with nested comments.
</ins><span class="cx"> */
</span><span class="cx"> public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="lines">@@ -582,6 +756,18 @@
</span><span class="cx"> return $comments;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Rebuild nested comment tree under an activity or activity comment.
+ *
+ * @since BuddyPress (1.2)
+ *
+ * @global BuddyPress $bp The one true BuddyPress instance.
+ * @global wpdb $wpdb WordPress database object.
+ *
+ * @param int $parent_id ID of an activty or activity comment.
+ * @param int $left Node boundary start for activity or activity comment.
+ * @return int Right node boundary of activity or activity comment.
+ */
</ins><span class="cx"> public static function rebuild_activity_comment_tree( $parent_id, $left = 1 ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="lines">@@ -606,6 +792,17 @@
</span><span class="cx"> return $right + 1;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Get child comments of an activity or activity comment.
+ *
+ * @since BuddyPress (1.2)
+ *
+ * @global BuddyPress $bp The one true BuddyPress instance.
+ * @global wpdb $wpdb WordPress database object.
+ *
+ * @param int $parent_id ID of an activty or activity comment.
+ * @return object Numerically indexed array of child comments.
+ */
</ins><span class="cx"> public static function get_child_comments( $parent_id ) {
</span><span class="cx"> global $bp, $wpdb;
</span><span class="cx">
</span><span class="lines">@@ -613,30 +810,46 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Fetch a list of all components that have activity items recorded
</del><ins>+ * Get a list of components that have recorded activity associated with them
</ins><span class="cx"> *
</span><del>- * @return array
</del><ins>+ * @return array List of component names.
</ins><span class="cx"> */
</span><span class="cx"> public static function get_recorded_components() {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx"> return $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Get sitewide activity items for use in an RSS feed.
+ *
+ * @param int $limit Optional. Number of items to fetch. Default: 35.
+ * @return array $activity_feed List of activity items, with RSS data added.
+ */
</ins><span class="cx"> public static function get_sitewide_items_for_feed( $limit = 35 ) {
</span><span class="cx"> $activities = bp_activity_get_sitewide( array( 'max' => $limit ) );
</span><span class="cx"> $activity_feed = array();
</span><span class="cx">
</span><span class="cx"> for ( $i = 0, $count = count( $activities ); $i < $count; ++$i ) {
</span><del>- $title = explode( '<span', $activities[$i]['content'] );
- $activity_feed[$i]['title'] = trim( strip_tags( $title[0] ) );
- $activity_feed[$i]['link'] = $activities[$i]['primary_link'];
- $activity_feed[$i]['description'] = @sprintf( $activities[$i]['content'], '' );
- $activity_feed[$i]['pubdate'] = $activities[$i]['date_recorded'];
</del><ins>+ $title = explode( '<span', $activities[$i]['content'] );
+ $activity_feed[$i]['title'] = trim( strip_tags( $title[0] ) );
+ $activity_feed[$i]['link'] = $activities[$i]['primary_link'];
+ $activity_feed[$i]['description'] = @sprintf( $activities[$i]['content'], '' );
+ $activity_feed[$i]['pubdate'] = $activities[$i]['date_recorded'];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return $activity_feed;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Create SQL IN clause for filter queries.
+ *
+ * @since BuddyPress (1.3)
+ *
+ * @see BP_Activity_Activity::get_filter_sql()
+ *
+ * @param string $field The database field.
+ * @param array|bool $items The values for the IN clause, or false when none are found.
+ */
</ins><span class="cx"> public static function get_in_operator_sql( $field, $items ) {
</span><span class="cx"> global $wpdb;
</span><span class="cx">
</span><span class="lines">@@ -661,6 +874,14 @@
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Create filter SQL clauses.
+ *
+ * @since BuddyPress (1.3)
+ *
+ * @param array $filter_array Multidimensional array of fields to filter and values.
+ * @return string The filter clause, for use in a SQL query.
+ */
</ins><span class="cx"> public static function get_filter_sql( $filter_array ) {
</span><span class="cx">
</span><span class="cx"> $filter_sql = array();
</span><span class="lines">@@ -701,12 +922,27 @@
</span><span class="cx"> return join( ' AND ', $filter_sql );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Get the date/time of last recorded activity.
+ *
+ * @since BuddyPress (1.2)
+ *
+ * @return string ISO timestamp.
+ */
</ins><span class="cx"> public static function get_last_updated() {
</span><span class="cx"> global $bp, $wpdb;
</span><span class="cx">
</span><span class="cx"> return $wpdb->get_var( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Get favorite count for a given user.
+ *
+ * @since BuddyPress (1.2)
+ *
+ * @param int The ID of the user whose favorites you're counting.
+ * @return int A count of the user's favorites.
+ */
</ins><span class="cx"> public static function total_favorite_count( $user_id ) {
</span><span class="cx"> if ( !$favorite_activity_entries = bp_get_user_meta( $user_id, 'bp_favorite_activities', true ) )
</span><span class="cx"> return 0;
</span><span class="lines">@@ -714,12 +950,24 @@
</span><span class="cx"> return count( maybe_unserialize( $favorite_activity_entries ) );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Check whether an activity item exists with a given string content.
+ *
+ * @param string $content The content to filter by.
+ * @return int|bool The ID of the first matching item if found, otherwise false.
+ */
</ins><span class="cx"> public static function check_exists_by_content( $content ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="cx"> return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Hide all activity for a given user.
+ *
+ * @param int $user_id The ID of the user whose activity you want to mark hidden.
+ * @param int
+ */
</ins><span class="cx"> public static function hide_all_for_user( $user_id ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="lines">@@ -858,6 +1106,8 @@
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Setup and validate the class properties.
</span><ins>+ *
+ * @access protected
</ins><span class="cx"> */
</span><span class="cx"> protected function setup_properties() {
</span><span class="cx"> $this->id = sanitize_title( $this->id );
</span><span class="lines">@@ -880,6 +1130,8 @@
</span><span class="cx"> *
</span><span class="cx"> * Currently, these hooks are used to maintain backwards compatibility with
</span><span class="cx"> * the RSS feeds previous to BP 1.8.
</span><ins>+ *
+ * @access protected
</ins><span class="cx"> */
</span><span class="cx"> protected function setup_hooks() {
</span><span class="cx"> add_action( 'bp_activity_feed_rss_attributes', array( $this, 'backpat_rss_attributes' ) );
</span><span class="lines">@@ -889,14 +1141,23 @@
</span><span class="cx">
</span><span class="cx"> /** BACKPAT HOOKS ********************************************************/
</span><span class="cx">
</span><ins>+ /**
+ * Fire a hook to ensure backward compatibility for RSS attributes.
+ */
</ins><span class="cx"> public function backpat_rss_attributes() {
</span><span class="cx"> do_action( 'bp_activity_' . $this->id . '_feed' );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Fire a hook to ensure backward compatibility for channel elements.
+ */
</ins><span class="cx"> public function backpat_channel_elements() {
</span><span class="cx"> do_action( 'bp_activity_' . $this->id . '_feed_head' );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Fire a hook to ensure backward compatibility for item elements.
+ */
</ins><span class="cx"> public function backpat_item_elements() {
</span><span class="cx"> switch ( $this->id ) {
</span><span class="cx">
</span><span class="lines">@@ -920,6 +1181,8 @@
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Output the feed's item content.
</span><ins>+ *
+ * @access protected
</ins><span class="cx"> */
</span><span class="cx"> protected function feed_content() {
</span><span class="cx"> bp_activity_content_body();
</span><span class="lines">@@ -947,6 +1210,8 @@
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Output the RSS feed.
</span><ins>+ *
+ * @access protected
</ins><span class="cx"> */
</span><span class="cx"> protected function output() {
</span><span class="cx"> // set up some additional headers if not on a directory page
</span></span></pre>
</div>
</div>
</body>
</html>