本文整理汇总了PHP中BP_Activity_Activity::get_activity_comments方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Activity_Activity::get_activity_comments方法的具体用法?PHP BP_Activity_Activity::get_activity_comments怎么用?PHP BP_Activity_Activity::get_activity_comments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BP_Activity_Activity
的用法示例。
在下文中一共展示了BP_Activity_Activity::get_activity_comments方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: append_comments
function append_comments($activities)
{
global $bp, $nxtdb;
$activity_comments = array();
/* Now fetch the activity comments and parse them into the correct position in the activities array. */
foreach ((array) $activities as $activity) {
if ('activity_comment' != $activity->type && $activity->mptt_left && $activity->mptt_right) {
$activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments($activity->id, $activity->mptt_left, $activity->mptt_right);
}
}
/* Merge the comments with the activity items */
foreach ((array) $activities as $key => $activity) {
if (isset($activity_comments[$activity->id])) {
$activities[$key]->children = $activity_comments[$activity->id];
}
}
return $activities;
}
示例2: ON
function migrate_single_media($result, $album = false)
{
$blog_id = get_current_blog_id();
$old = $result;
if (function_exists('bp_core_get_table_prefix')) {
$bp_prefix = bp_core_get_table_prefix();
} else {
$bp_prefix = '';
}
global $wpdb;
if (false !== $album && !is_object($result)) {
$id = $wpdb->get_var($wpdb->prepare("select ID from {$this->bmp_table} where media_id = %d", $result));
if (null == $id) {
$sql = "select\n a.post_id as 'post_id',\n a.meta_value as 'privacy',\n b.meta_value as 'context_id',\n c.meta_value as 'activity_id',\n p.post_type,\n p.post_mime_type,\n p.post_author as 'media_author',\n p.post_title as 'media_title',\n p.post_parent as 'parent'\n from\n {$wpdb->postmeta} a\n left join\n {$wpdb->postmeta} b ON ((a.post_id = b.post_id)\n and (b.meta_key = 'bp-media-key'))\n left join\n {$wpdb->postmeta} c ON (a.post_id = c.post_id)\n and (c.meta_key = 'bp_media_child_activity')\n left join\n {$wpdb->posts} p ON (a.post_id = p.ID)\n where\n a.post_id = %d and (NOT p.ID IS NULL)\n and a.meta_key = 'bp_media_privacy'";
$result = $wpdb->get_row($wpdb->prepare($sql, $result));
} else {
return $id;
}
}
if (!isset($result) || !isset($result->post_id)) {
return $old;
}
$media_id = $result->post_id;
if (intval($result->context_id) > 0) {
$media_context = 'profile';
$prefix = 'users/' . abs(intval($result->context_id));
} else {
$media_context = 'group';
$prefix = bp_get_groups_root_slug() . abs(intval($result->context_id));
}
$old_type = '';
if ('attachment' != $result->post_type) {
$media_type = 'album';
} else {
$mime_type = strtolower($result->post_mime_type);
$old_type = '';
if (0 === strpos($mime_type, 'image')) {
$media_type = 'photo';
$old_type = 'photos';
} else {
if (0 === strpos($mime_type, 'audio')) {
$media_type = 'music';
$old_type = 'music';
} else {
if (0 === strpos($mime_type, 'video')) {
$media_type = 'video';
$old_type = 'videos';
} else {
$media_type = 'other';
}
}
}
}
$activity_data = $wpdb->get_row($wpdb->prepare("select * from {$bp_prefix}bp_activity where id= %d", $result->activity_id));
if ('album' != $media_type) {
$this->importmedia($media_id, $prefix);
}
if ($this->table_exists($bp_prefix . 'bp_activity') && class_exists('BP_Activity_Activity')) {
$bp_activity = new BP_Activity_Activity();
$activity_sql = $wpdb->prepare("SELECT\n *\n FROM\n {$bp_prefix}bp_activity\n where\n id in (select distinct\n a.meta_value\n from\n {$wpdb->postmeta} a\n left join\n {$wpdb->posts} p ON (a.post_id = p.ID)\n where\n (NOT p.ID IS NULL) and p.ID = %d\n and a.meta_key = 'bp_media_child_activity')", $media_id);
$all_activity = $wpdb->get_results($activity_sql);
remove_all_actions('wp_insert_comment');
foreach ($all_activity as $activity) {
$comments = $bp_activity->get_activity_comments($activity->id, $activity->mptt_left, $activity->mptt_right);
$exclude = get_post_meta($media_id, 'rtmedia_imported_activity', true);
if (!is_array($exclude)) {
$exclude = array();
}
if ($comments) {
$this->insert_comment($media_id, $comments, $exclude);
}
}
}
if (0 !== intval($result->parent)) {
$album_id = $this->migrate_single_media($result->parent, true);
} else {
$album_id = 0;
}
if (function_exists('bp_activity_get_meta')) {
$likes = bp_activity_get_meta($result->activity_id, 'favorite_count');
} else {
$likes = 0;
}
$wpdb->insert($this->bmp_table, array('blog_id' => $blog_id, 'media_id' => $media_id, 'media_type' => $media_type, 'context' => $media_context, 'context_id' => abs(intval($result->context_id)), 'activity_id' => $result->activity_id, 'privacy' => intval($result->privacy) * 10, 'media_author' => $result->media_author, 'media_title' => $result->media_title, 'album_id' => $album_id, 'likes' => $likes), array('%d', '%d', '%s', '%s', '%d', '%d', '%d', '%d', '%s', '%d', '%d'));
$last_id = $wpdb->insert_id;
// Photo tag meta migration
//$photo_tag_meta = get_post_meta($media_id, "bp-media-user-tags", true);
// if($photo_tag_meta && !empty($photo_tag_meta)){
// $wpdb->insert(
// $wpdb->prefix . "rt_rtm_media_meta", array(
// 'media_id' => $media_id,
// 'meta_key' => "user-tags",
// "meta_value" => maybe_serialize($photo_tag_meta)), array('%d', '%s', '%s'));
// }
if ('album' != $media_type && function_exists('bp_core_get_user_domain') && $activity_data) {
if (function_exists('bp_core_get_table_prefix')) {
$bp_prefix = bp_core_get_table_prefix();
} else {
$bp_prefix = '';
}
//.........这里部分代码省略.........
示例3: test_get_activity_comments_format
/**
* @group get_activity_comments
*
* Verify the format of the activity comments array, for internal
* refactoring
*/
public function test_get_activity_comments_format()
{
$now = time();
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
$a1 = $this->factory->activity->create(array('content' => 'Life Rules', 'recorded_time' => date('Y-m-d H:i:s', $now), 'user_id' => $u1));
$a2 = bp_activity_new_comment(array('activity_id' => $a1, 'content' => 'Candy is good', 'recorded_time' => date('Y-m-d H:i:s', $now - 50), 'user_id' => $u1));
$a3 = bp_activity_new_comment(array('activity_id' => $a1, 'content' => 'Bread is good', 'recorded_time' => date('Y-m-d H:i:s', $now - 25), 'user_id' => $u2));
$keys = array('id', 'item_id', 'secondary_item_id', 'user_id', 'primary_link', 'component', 'type', 'action', 'content', 'date_recorded', 'hide_sitewide', 'mptt_left', 'mptt_right', 'is_spam');
$a2_obj = new BP_Activity_Activity($a2);
$e2 = new stdClass();
foreach ($keys as $key) {
$e2->{$key} = $a2_obj->{$key};
}
$e2_user = new WP_User($a2_obj->user_id);
$e2->user_email = $e2_user->user_email;
$e2->user_nicename = $e2_user->user_nicename;
$e2->user_login = $e2_user->user_login;
$e2->display_name = $e2_user->display_name;
$e2->user_fullname = bp_core_get_user_displayname($e2->user_id);
$e2->children = array();
$e2->depth = 1;
$a3_obj = new BP_Activity_Activity($a3);
$e3 = new stdClass();
foreach ($keys as $key) {
$e3->{$key} = $a3_obj->{$key};
}
$e3_user = new WP_User($e3->user_id);
$e3->user_email = $e3_user->user_email;
$e3->user_nicename = $e3_user->user_nicename;
$e3->user_login = $e3_user->user_login;
$e3->display_name = $e3_user->display_name;
$e3->user_fullname = bp_core_get_user_displayname($e3->user_id);
$e3->children = array();
$e3->depth = 1;
$expected = array($a2 => $e2, $a3 => $e3);
$a1_obj = new BP_Activity_Activity($a1);
$comments = BP_Activity_Activity::get_activity_comments($a1, $a1_obj->mptt_left, $a1_obj->mptt_right, 'ham_only', $a1);
$this->assertEquals($expected, $comments);
}
示例4: append_comments
/**
* Append activity comments to their associated activity items
*
* @global wpdb $wpdb WordPress database object
* @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)
*/
function append_comments($activities, $spam = 'ham_only')
{
global $wpdb;
$activity_comments = array();
// Now fetch the activity comments and parse them into the correct position in the activities array.
foreach ((array) $activities as $activity) {
$top_level_parent_id = 'activity_comment' == $activity->type ? $activity->item_id : 0;
$activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments($activity->id, $activity->mptt_left, $activity->mptt_right, $spam, $top_level_parent_id);
}
// Merge the comments with the activity items
foreach ((array) $activities as $key => $activity) {
if (isset($activity_comments[$activity->id])) {
$activities[$key]->children = $activity_comments[$activity->id];
}
}
return $activities;
}
示例5: get_comments
protected function get_comments()
{
$count = BP_Activity_Activity::get_activity_comments($this->activity->id, $this->activity->mptt_left, $this->activity->mptt_right);
return count($count);
}
示例6: crowdmentions_mark_notifications_group_single_activity_visited
/**
* Mark read a notification after the activity item is seen.
*
* @since 1.0.0
*
* @param object $activity The activity item info.
*/
function crowdmentions_mark_notifications_group_single_activity_visited($activity)
{
if (!bp_is_current_action($activity->id)) {
return;
}
$comments = BP_Activity_Activity::get_activity_comments($activity->id, $activity->mptt_left, $activity->mptt_right);
if ($comments === false) {
crowdmentions_mark_notification(bp_loggedin_user_id(), false, false, 'mention_group_' . $activity->id, false);
crowdmentions_mark_notification(bp_loggedin_user_id(), false, false, 'mention_moderators_' . $activity->id, false);
crowdmentions_mark_notification(bp_loggedin_user_id(), false, false, 'mention_administrators_' . $activity->id, false);
crowdmentions_mark_notification(bp_loggedin_user_id(), false, false, 'mention_friends_' . $activity->id, false);
} else {
foreach ($comments as $comment) {
crowdmentions_mark_notification(bp_loggedin_user_id(), false, false, 'mention_group_' . $comment->id, false);
crowdmentions_mark_notification(bp_loggedin_user_id(), false, false, 'mention_moderators_' . $comment->id, false);
crowdmentions_mark_notification(bp_loggedin_user_id(), false, false, 'mention_administrators_' . $comment->id, false);
crowdmentions_mark_notification(bp_loggedin_user_id(), false, false, 'mention_friends_' . $comment->id, false);
}
}
}