本文整理汇总了PHP中BP_Activity_Activity::append_comments方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Activity_Activity::append_comments方法的具体用法?PHP BP_Activity_Activity::append_comments怎么用?PHP BP_Activity_Activity::append_comments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BP_Activity_Activity
的用法示例。
在下文中一共展示了BP_Activity_Activity::append_comments方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
function get($max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false, $exclude = false, $in = false)
{
global $nxtdb, $bp;
// Select conditions
$select_sql = "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
$from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$nxtdb->users} u ON a.user_id = u.ID";
// Where conditions
$where_conditions = array();
// Searching
if ($search_terms) {
$search_terms = $nxtdb->escape($search_terms);
$where_conditions['search_sql'] = "a.content LIKE '%%" . like_escape($search_terms) . "%%'";
}
// Filtering
if ($filter && ($filter_sql = BP_Activity_Activity::get_filter_sql($filter))) {
$where_conditions['filter_sql'] = $filter_sql;
}
// Sorting
if ($sort != 'ASC' && $sort != 'DESC') {
$sort = 'DESC';
}
// Hide Hidden Items?
if (!$show_hidden) {
$where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
}
// Exclude specified items
if (!empty($exclude)) {
$exclude = implode(',', nxt_parse_id_list($exclude));
$where_conditions['exclude'] = "a.id NOT IN ({$exclude})";
}
// The specific ids to which you want to limit the query
if (!empty($in)) {
$in = implode(',', nxt_parse_id_list($in));
$where_conditions['in'] = "a.id IN ({$in})";
}
// Alter the query based on whether we want to show activity item
// comments in the stream like normal comments or threaded below
// the activity.
if (false === $display_comments || 'threaded' === $display_comments) {
$where_conditions[] = "a.type != 'activity_comment'";
}
$where_sql = 'WHERE ' . join(' AND ', $where_conditions);
if (!empty($per_page) && !empty($page)) {
// Make sure page values are absolute integers
$page = absint($page);
$per_page = absint($per_page);
$pag_sql = $nxtdb->prepare("LIMIT %d, %d", absint(($page - 1) * $per_page), $per_page);
$activities = $nxtdb->get_results(apply_filters('bp_activity_get_user_join_filter', $nxtdb->prepare("{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}"), $select_sql, $from_sql, $where_sql, $sort, $pag_sql));
} else {
$activities = $nxtdb->get_results(apply_filters('bp_activity_get_user_join_filter', $nxtdb->prepare("{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}"), $select_sql, $from_sql, $where_sql, $sort));
}
$total_activities_sql = apply_filters('bp_activity_total_activities_sql', $nxtdb->prepare("SELECT count(a.id) FROM {$bp->activity->table_name} a {$where_sql} ORDER BY a.date_recorded {$sort}"), $where_sql, $sort);
$total_activities = $nxtdb->get_var($total_activities_sql);
// Get the fullnames of users so we don't have to query in the loop
if (bp_is_active('xprofile') && $activities) {
foreach ((array) $activities as $activity) {
if ((int) $activity->user_id) {
$activity_user_ids[] = $activity->user_id;
}
}
$activity_user_ids = implode(',', array_unique((array) $activity_user_ids));
if (!empty($activity_user_ids)) {
if ($names = $nxtdb->get_results($nxtdb->prepare("SELECT user_id, value AS user_fullname FROM {$bp->profile->table_name_data} WHERE field_id = 1 AND user_id IN ({$activity_user_ids})"))) {
foreach ((array) $names as $name) {
$tmp_names[$name->user_id] = $name->user_fullname;
}
foreach ((array) $activities as $i => $activity) {
if (!empty($tmp_names[$activity->user_id])) {
$activities[$i]->user_fullname = $tmp_names[$activity->user_id];
}
}
unset($names);
unset($tmp_names);
}
}
}
if ($activities && $display_comments) {
$activities = BP_Activity_Activity::append_comments($activities);
}
// If $max is set, only return up to the max results
if (!empty($max)) {
if ((int) $total_activities > (int) $max) {
$total_activities = $max;
}
}
return array('activities' => $activities, 'total' => (int) $total_activities);
}
示例2: get
//.........这里部分代码省略.........
// Filtering
if ($filter && ($filter_sql = BP_Activity_Activity::get_filter_sql($filter))) {
$where_conditions['filter_sql'] = $filter_sql;
}
// Sorting
if ($sort != 'ASC' && $sort != 'DESC') {
$sort = 'DESC';
}
// Hide Hidden Items?
if (!$show_hidden) {
$where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
}
// Exclude specified items
if (!empty($exclude)) {
$exclude = implode(',', wp_parse_id_list($exclude));
$where_conditions['exclude'] = "a.id NOT IN ({$exclude})";
}
// The specific ids to which you want to limit the query
if (!empty($in)) {
$in = implode(',', wp_parse_id_list($in));
$where_conditions['in'] = "a.id IN ({$in})";
}
// Process meta_query into SQL
$meta_query_sql = self::get_meta_query_sql($meta_query);
if (!empty($meta_query_sql['join'])) {
$join_sql .= $meta_query_sql['join'];
}
if (!empty($meta_query_sql['where'])) {
$where_conditions[] = $meta_query_sql['where'];
}
// Alter the query based on whether we want to show activity item
// comments in the stream like normal comments or threaded below
// the activity.
if (false === $display_comments || 'threaded' === $display_comments) {
$where_conditions[] = "a.type != 'activity_comment'";
}
$where_sql = 'WHERE ' . join(' AND ', $where_conditions);
// Define the preferred order for indexes
$indexes = apply_filters('bp_activity_preferred_index_order', array('user_id', 'item_id', 'secondary_item_id', 'date_recorded', 'component', 'type', 'hide_sitewide', 'is_spam'));
foreach ($indexes as $key => $index) {
if (false !== strpos($where_sql, $index)) {
$the_index = $index;
break;
// Take the first one we find
}
}
if (!empty($the_index)) {
$index_hint_sql = "USE INDEX ({$the_index})";
} else {
$index_hint_sql = '';
}
if (!empty($per_page) && !empty($page)) {
// Make sure page values are absolute integers
$page = absint($page);
$per_page = absint($per_page);
$pag_sql = $wpdb->prepare("LIMIT %d, %d", absint(($page - 1) * $per_page), $per_page);
$activities = $wpdb->get_results(apply_filters('bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql));
} else {
$activities = $wpdb->get_results(apply_filters('bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort));
}
$total_activities_sql = apply_filters('bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$index_hint_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $where_sql, $sort);
$total_activities = $wpdb->get_var($total_activities_sql);
// Get the fullnames of users so we don't have to query in the loop
if (bp_is_active('xprofile') && !empty($activities)) {
$activity_user_ids = wp_list_pluck($activities, 'user_id');
$activity_user_ids = implode(',', wp_parse_id_list($activity_user_ids));
if (!empty($activity_user_ids)) {
if ($names = $wpdb->get_results("SELECT user_id, value AS user_fullname FROM {$bp->profile->table_name_data} WHERE field_id = 1 AND user_id IN ({$activity_user_ids})")) {
foreach ((array) $names as $name) {
$tmp_names[$name->user_id] = $name->user_fullname;
}
foreach ((array) $activities as $i => $activity) {
if (!empty($tmp_names[$activity->user_id])) {
$activities[$i]->user_fullname = $tmp_names[$activity->user_id];
}
}
unset($names);
unset($tmp_names);
}
}
}
// Get activity meta
$activity_ids = array();
foreach ((array) $activities as $activity) {
$activity_ids[] = $activity->id;
}
if (!empty($activity_ids)) {
bp_activity_update_meta_cache($activity_ids);
}
if ($activities && $display_comments) {
$activities = BP_Activity_Activity::append_comments($activities, $spam);
}
// If $max is set, only return up to the max results
if (!empty($max)) {
if ((int) $total_activities > (int) $max) {
$total_activities = $max;
}
}
return array('activities' => $activities, 'total' => (int) $total_activities);
}
示例3: get
//.........这里部分代码省略.........
*
* @param bool $value Whether to use legacy structure or not.
* @param BP_Activity_Activity $value Current method being called.
* @param array $r Parsed arguments passed into method.
*/
if (apply_filters('bp_use_legacy_activity_query', false, __METHOD__, $r)) {
// Legacy queries joined against the user table.
$select_sql = "SELECT DISTINCT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
$from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
if (!empty($page) && !empty($per_page)) {
$pag_sql = $wpdb->prepare("LIMIT %d, %d", absint(($page - 1) * $per_page), $per_page);
/** This filter is documented in bp-activity/bp-activity-classes.php */
$activities = $wpdb->get_results(apply_filters('bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql));
} else {
$pag_sql = '';
/**
* Filters the legacy MySQL query statement so plugins can alter before results are fetched.
*
* @since 1.5.0
*
* @param string $value Concatenated MySQL statement pieces to be query results with for legacy query.
* @param string $select_sql Final SELECT MySQL statement portion for legacy query.
* @param string $from_sql Final FROM MySQL statement portion for legacy query.
* @param string $where_sql Final WHERE MySQL statement portion for legacy query.
* @param string $sort Final sort direction for legacy query.
*/
$activities = $wpdb->get_results(apply_filters('bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql));
}
} else {
// Query first for activity IDs.
$activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
if (!empty($per_page) && !empty($page)) {
// We query for $per_page + 1 items in order to
// populate the has_more_items flag.
$activity_ids_sql .= $wpdb->prepare(" LIMIT %d, %d", absint(($page - 1) * $per_page), $per_page + 1);
}
/**
* Filters the paged activities MySQL statement.
*
* @since 2.0.0
*
* @param string $activity_ids_sql MySQL statement used to query for Activity IDs.
* @param array $r Array of arguments passed into method.
*/
$activity_ids_sql = apply_filters('bp_activity_paged_activities_sql', $activity_ids_sql, $r);
$activity_ids = $wpdb->get_col($activity_ids_sql);
$retval['has_more_items'] = !empty($per_page) && count($activity_ids) > $per_page;
// If we've fetched more than the $per_page value, we
// can discard the extra now.
if (!empty($per_page) && count($activity_ids) === $per_page + 1) {
array_pop($activity_ids);
}
if ('ids' === $r['fields']) {
$activities = array_map('intval', $activity_ids);
} else {
$activities = self::get_activity_data($activity_ids);
}
}
if ('ids' !== $r['fields']) {
// Get the fullnames of users so we don't have to query in the loop.
$activities = self::append_user_fullnames($activities);
// Get activity meta.
$activity_ids = array();
foreach ((array) $activities as $activity) {
$activity_ids[] = $activity->id;
}
if (!empty($activity_ids) && $r['update_meta_cache']) {
bp_activity_update_meta_cache($activity_ids);
}
if ($activities && $r['display_comments']) {
$activities = BP_Activity_Activity::append_comments($activities, $r['spam']);
}
// Pre-fetch data associated with activity users and other objects.
BP_Activity_Activity::prefetch_object_data($activities);
// Generate action strings.
$activities = BP_Activity_Activity::generate_action_strings($activities);
}
$retval['activities'] = $activities;
// If $max is set, only return up to the max results.
if (!empty($r['count_total'])) {
/**
* Filters the total activities MySQL statement.
*
* @since 1.5.0
*
* @param string $value MySQL statement used to query for total activities.
* @param string $where_sql MySQL WHERE statement portion.
* @param string $sort Sort direction for query.
*/
$total_activities_sql = apply_filters('bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort);
$total_activities = $wpdb->get_var($total_activities_sql);
if (!empty($r['max'])) {
if ((int) $total_activities > (int) $r['max']) {
$total_activities = $r['max'];
}
}
$retval['total'] = $total_activities;
}
return $retval;
}
示例4: get
//.........这里部分代码省略.........
// the activity.
if (false === $display_comments || 'threaded' === $display_comments) {
$excluded_types[] = 'activity_comment';
}
// Exclude 'last_activity' items unless the 'action' filter has
// been explicitly set
if (empty($filter['object'])) {
$excluded_types[] = 'last_activity';
}
// Exclude 'new_member' items if xprofile component is not active
if (!bp_is_active('xprofile')) {
$excluded_types[] = 'new_member';
}
// Build the excluded type sql part
if (!empty($excluded_types)) {
$not_in = "'" . implode("', '", esc_sql($excluded_types)) . "'";
$where_conditions['excluded_types'] = "a.type NOT IN ({$not_in})";
}
// Filter the where conditions
$where_conditions = apply_filters('bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql);
// Join the where conditions together
$where_sql = 'WHERE ' . join(' AND ', $where_conditions);
// Define the preferred order for indexes
$indexes = apply_filters('bp_activity_preferred_index_order', array('user_id', 'item_id', 'secondary_item_id', 'date_recorded', 'component', 'type', 'hide_sitewide', 'is_spam'));
foreach ($indexes as $key => $index) {
if (false !== strpos($where_sql, $index)) {
$the_index = $index;
break;
// Take the first one we find
}
}
if (!empty($the_index)) {
$index_hint_sql = "USE INDEX ({$the_index})";
} else {
$index_hint_sql = '';
}
// Sanitize page and per_page parameters
$page = absint($page);
$per_page = absint($per_page);
$retval = array('activities' => null, 'total' => null, 'has_more_items' => null);
// Filter and return true to use the legacy query structure (not recommended)
if (apply_filters('bp_use_legacy_activity_query', false, __METHOD__, $r)) {
// Legacy queries joined against the user table
$select_sql = "SELECT DISTINCT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
$from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
if (!empty($page) && !empty($per_page)) {
$pag_sql = $wpdb->prepare("LIMIT %d, %d", absint(($page - 1) * $per_page), $per_page);
$activities = $wpdb->get_results(apply_filters('bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql));
} else {
$activities = $wpdb->get_results(apply_filters('bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort));
}
} else {
// Query first for activity IDs
$activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
if (!empty($per_page) && !empty($page)) {
// We query for $per_page + 1 items in order to
// populate the has_more_items flag
$activity_ids_sql .= $wpdb->prepare(" LIMIT %d, %d", absint(($page - 1) * $per_page), $per_page + 1);
}
$activity_ids_sql = apply_filters('bp_activity_paged_activities_sql', $activity_ids_sql, $r);
$activity_ids = $wpdb->get_col($activity_ids_sql);
$retval['has_more_items'] = !empty($per_page) && count($activity_ids) > $per_page;
// If we've fetched more than the $per_page value, we
// can discard the extra now
if (!empty($per_page) && count($activity_ids) === $per_page + 1) {
array_pop($activity_ids);
}
$activities = self::get_activity_data($activity_ids);
}
// Get the fullnames of users so we don't have to query in the loop
$activities = self::append_user_fullnames($activities);
// Get activity meta
$activity_ids = array();
foreach ((array) $activities as $activity) {
$activity_ids[] = $activity->id;
}
if (!empty($activity_ids) && $update_meta_cache) {
bp_activity_update_meta_cache($activity_ids);
}
if ($activities && $display_comments) {
$activities = BP_Activity_Activity::append_comments($activities, $spam);
}
// Pre-fetch data associated with activity users and other objects
BP_Activity_Activity::prefetch_object_data($activities);
// Generate action strings
$activities = BP_Activity_Activity::generate_action_strings($activities);
$retval['activities'] = $activities;
// If $max is set, only return up to the max results
if (!empty($r['count_total'])) {
$total_activities_sql = apply_filters('bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort);
$total_activities = $wpdb->get_var($total_activities_sql);
if (!empty($max)) {
if ((int) $total_activities > (int) $max) {
$total_activities = $max;
}
}
$retval['total'] = $total_activities;
}
return $retval;
}
示例5: get_specific
function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
global $wpdb, $bp;
if ( is_array( $activity_ids ) )
$activity_ids = implode( ',', $activity_ids );
$activity_ids = $wpdb->escape( $activity_ids );
if ( empty( $activity_ids ) )
return false;
if ( $per_page && $page )
$pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
if ( $sort != 'ASC' && $sort != 'DESC' )
$sort = 'DESC';
$activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$activity_ids}) ORDER BY date_recorded {$sort} $pag_sql" ) );
$total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE id IN ({$activity_ids})" ) );
if ( $display_comments )
$activities = BP_Activity_Activity::append_comments( $activities );
/* If $max is set, only return up to the max results */
if ( !empty( $max ) ) {
if ( (int)$total_activities > (int)$max )
$total_activities = $max;
}
return array( 'activities' => $activities, 'total' => (int)$total_activities );
}
示例6: get
public function get($max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false)
{
global $wpdb, $bp;
/* Select conditions */
$select_sql = "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
//from conditions
$from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
/* Sorting */
if ($sort != 'ASC' && $sort != 'DESC') {
$sort = 'DESC';
}
//get or sql, to support your component, please filter on fb_like_activity_or_sql
$or_sql = apply_filters("fb_like_activity_or_sql", self::get_filter_sql($filter), $filter);
//get and sql
$and_sql = apply_filters("fb_like_activity_or_sql", self::get_action_sql($filter), $filter);
if (!empty($or_sql)) {
$where_sql = "( " . $or_sql . " )";
}
if (!empty($and_sql)) {
$where_sql = $where_sql . " AND " . $and_sql;
}
$activity_sql = "{$select_sql} {$from_sql} WHERE {$where_sql} ORDER BY date_recorded {$sort}";
if ($per_page && $page) {
$pag_sql = $wpdb->prepare("LIMIT %d, %d", intval(($page - 1) * $per_page), intval($per_page));
$activities = $wpdb->get_results("{$activity_sql} {$pag_sql}");
} else {
$activities = $wpdb->get_results("{$activity_sql} {$pag_sql}");
}
// echo //needs mod
$total_activities = $wpdb->get_var("SELECT count(a.id) FROM {$bp->activity->table_name} a WHERE {$where_sql} ORDER BY a.date_recorded {$sort}");
/* Get the fullnames of users so we don't have to query in the loop */
if (function_exists('xprofile_install') && $activities) {
foreach ((array) $activities as $activity) {
if ((int) $activity->user_id) {
$activity_user_ids[] = $activity->user_id;
}
}
$activity_user_ids = implode(',', array_unique((array) $activity_user_ids));
if (!empty($activity_user_ids)) {
if ($names = $wpdb->get_results("SELECT user_id, value AS user_fullname FROM {$bp->profile->table_name_data} WHERE field_id = 1 AND user_id IN ({$activity_user_ids})")) {
foreach ((array) $names as $name) {
$tmp_names[$name->user_id] = $name->user_fullname;
}
foreach ((array) $activities as $i => $activity) {
if (!empty($tmp_names[$activity->user_id])) {
$activities[$i]->user_fullname = $tmp_names[$activity->user_id];
}
}
unset($names);
unset($tmp_names);
}
}
}
if ($activities && $display_comments) {
$activities = BP_Activity_Activity::append_comments($activities);
}
/* If $max is set, only return up to the max results */
if (!empty($max)) {
if ((int) $total_activities > (int) $max) {
$total_activities = $max;
}
}
return array('activities' => $activities, 'total' => (int) $total_activities);
}