当前位置: 首页>>代码示例>>PHP>>正文


PHP bp_activity_get_activity_id函数代码示例

本文整理汇总了PHP中bp_activity_get_activity_id函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_activity_get_activity_id函数的具体用法?PHP bp_activity_get_activity_id怎么用?PHP bp_activity_get_activity_id使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bp_activity_get_activity_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_bp_blogs_record_comment_sync_activity_comment

 /**
  * @goup bp_blogs_record_comment_sync_activity_comment
  * @group post_type_comment_activities
  */
 public function test_bp_blogs_record_comment_sync_activity_comment()
 {
     $u = $this->factory->user->create();
     $user = $this->factory->user->get_object_by_id($u);
     add_filter('bp_disable_blogforum_comments', '__return_false');
     $post_id = $this->factory->post->create(array('post_status' => 'publish', 'post_type' => 'using_old_filter', 'post_author' => $u));
     $parent_activity_id = bp_activity_get_activity_id(array('component' => 'blogs', 'type' => 'new_blog_post', 'item_id' => get_current_blog_id(), 'secondary_item_id' => $post_id));
     $comment_id = $this->factory->comment->create(array('user_id' => $u, 'comment_author_email' => $user->user_email, 'comment_post_ID' => $post_id));
     // Approve the comment
     $this->factory->comment->update_object($comment_id, array('comment_approved' => 1));
     $this->assertTrue($this->activity_exists_for_post_type($parent_activity_id, '', 'activity_comment', 'stream'), 'Generated activity for comments about a post type registering using the bp_blogs_record_post_post_types filter having sync on should have a activity_comment action');
     remove_filter('bp_disable_blogforum_comments', '__return_false');
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:17,代码来源:filters.php

示例2: test_bp_activity_catch_transition_post_type_status_publish_existing_post

 /**
  * @group bp_activity_catch_transition_post_type_status
  * @group activity_tracking
  */
 public function test_bp_activity_catch_transition_post_type_status_publish_existing_post()
 {
     $u = $this->factory->user->create();
     $labels = array('bp_activity_admin_filter' => 'New Foo', 'bp_activity_front_filter' => 'Foos', 'bp_activity_new_post' => '%1$s posted a new <a href="%2$s">foo</a>', 'bp_activity_new_post_ms' => '%1$s posted a new <a href="%2$s">foo</a>, on the site %3$s');
     /**
      * 'public' must be set to true, otherwise bp_activity_get_post_types_tracking_args() fails.
      */
     register_post_type('foo', array('labels' => $labels, 'public' => true, 'supports' => array('buddypress-activity'), 'bp_activity' => array('action_id' => 'new_foo', 'contexts' => array('activity'), 'position' => 40)));
     // Temporarily remove post type activity hook so activity item isn't created.
     remove_action('transition_post_status', 'bp_activity_catch_transition_post_type_status', 10, 3);
     // Create the initial post.
     $p = $this->factory->post->create(array('post_author' => $u, 'post_type' => 'foo'));
     $this->assertEmpty(bp_activity_get_activity_id(array('type' => 'new_foo')));
     // Add the post type activity hook back.
     add_action('transition_post_status', 'bp_activity_catch_transition_post_type_status', 10, 3);
     // Emulate updating a post; this should create an activity item.
     wp_update_post(array('ID' => $p, 'post_title' => 'This is an edit'));
     // Assert!
     $this->assertNotEmpty(bp_activity_get_activity_id(array('type' => 'new_foo')), 'Activity item was not created during an edit of an existing WordPress post.');
     // Clean up.
     _unregister_post_type('foo');
 }
开发者ID:dcavins,项目名称:buddypress-svn,代码行数:26,代码来源:actions.php

示例3: bp_blogs_record_activity

function bp_blogs_record_activity($args = '')
{
    global $bp;
    if (!bp_is_active('activity')) {
        return false;
    }
    $defaults = array('user_id' => bp_loggedin_user_id(), 'action' => '', 'content' => '', 'primary_link' => '', 'component' => $bp->blogs->id, 'type' => false, 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => false);
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    // Remove large images and replace them with just one image thumbnail
    if (bp_is_active('activity') && !empty($content)) {
        $content = bp_activity_thumbnail_content_images($content, $primary_link);
    }
    if (!empty($action)) {
        $action = apply_filters('bp_blogs_record_activity_action', $action);
    }
    if (!empty($content)) {
        $content = apply_filters('bp_blogs_record_activity_content', bp_create_excerpt($content), $content);
    }
    // Check for an existing entry and update if one exists.
    $id = bp_activity_get_activity_id(array('user_id' => $user_id, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id));
    return bp_activity_add(array('id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide));
}
开发者ID:newington,项目名称:buddypress,代码行数:23,代码来源:bp-blogs-activity.php

示例4: test_bp_blogs_remove_comment_should_remove_spammed_activity_comment

 /**
  * @group bp_blogs_transition_activity_status
  * @group bp_blogs_remove_comment
  */
 public function test_bp_blogs_remove_comment_should_remove_spammed_activity_comment()
 {
     // save the current user and override logged-in user
     $old_user = get_current_user_id();
     $u = $this->factory->user->create();
     $this->set_current_user($u);
     $userdata = get_userdata($u);
     // create the blog post
     $post_id = $this->factory->post->create(array('post_status' => 'publish', 'post_type' => 'post', 'post_title' => 'First title'));
     // let's use activity comments instead of single "new_blog_comment" activity items
     add_filter('bp_disable_blogforum_comments', '__return_false');
     $c1 = wp_new_comment(array('comment_post_ID' => $post_id, 'comment_author' => $userdata->user_nicename, 'comment_author_url' => 'http://buddypress.org', 'comment_author_email' => $userdata->user_email, 'comment_content' => 'this is a blog comment', 'comment_type' => '', 'comment_parent' => 0, 'user_id' => $u));
     // save the corresponding activity comment ID
     $a1 = bp_activity_get_activity_id(array('type' => 'activity_comment', 'display_comments' => 'stream', 'meta_query' => array(array('key' => 'bp_blogs_post_comment_id', 'value' => $c1))));
     // trash the parent comment.
     // corresponding activity comment should now be marked as spam
     // @see bp_blogs_transition_activity_status()
     wp_trash_comment($c1);
     // now permanently delete the comment
     wp_delete_comment($c1, true);
     // activity comment should no longer exist
     $a = bp_activity_get(array('in' => $a1, 'display_comments' => 'stream', 'spam' => 'all'));
     // this is a convoluted way of testing if the activity comment still exists
     $this->assertTrue(empty($a['activities'][0]));
     // reset
     $this->set_current_user($old_user);
     remove_filter('bp_disable_blogforum_comments', '__return_false');
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:32,代码来源:functions.php

示例5: groups_update_group_forum_post

/**
 * Update an existing group forum post.
 *
 * Uses the bundled version of bbPress packaged with BuddyPress.
 *
 * @since BuddyPress (1.1.0)
 *
 * @param int    $post_id   The post ID of the existing forum post.
 * @param string $post_text The text for the forum post.
 * @param int    $topic_id  The topic ID of the existing forum topic.
 * @param mixed  $page      The page number where the new forum post should reside. Optional.
 *
 * @return mixed The forum post ID on success. Boolean false on failure.
 */
function groups_update_group_forum_post($post_id, $post_text, $topic_id, $page = false)
{
    $bp = buddypress();
    /** This filter is documented in bp-groups/bp-groups-forums.php */
    $post_text = apply_filters('group_forum_post_text_before_save', $post_text);
    /** This filter is documented in bp-groups/bp-groups-forums.php */
    $topic_id = apply_filters('group_forum_post_topic_id_before_save', $topic_id);
    $post = bp_forums_get_post($post_id);
    $post_id = bp_forums_insert_post(array('post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id));
    if (empty($post_id)) {
        return false;
    }
    $topic = bp_forums_get_topic_details($topic_id);
    $activity_action = sprintf(__('%1$s replied to the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink($post->poster_id), '<a href="' . bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic->topic_slug . '">' . esc_attr($topic->topic_title) . '</a>', '<a href="' . bp_get_group_permalink(groups_get_current_group()) . '">' . esc_attr(bp_get_current_group_name()) . '</a>');
    $activity_content = bp_create_excerpt($post_text);
    $primary_link = bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic->topic_slug . '/';
    if (!empty($page)) {
        $primary_link .= "?topic_page=" . $page;
    }
    // Get the corresponding activity item
    if (bp_is_active('activity')) {
        $id = bp_activity_get_activity_id(array('user_id' => $post->poster_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post', 'item_id' => bp_get_current_group_id(), 'secondary_item_id' => $post_id));
    }
    /** This filter is documented in bp-groups/bp-groups-forums.php */
    $action = apply_filters_ref_array('groups_activity_new_forum_post_action', array($activity_action, $post_text, &$topic, &$topic));
    /** This filter is documented in bp-groups/bp-groups-forums.php */
    $content = apply_filters_ref_array('groups_activity_new_forum_post_content', array($activity_content, $post_text, &$topic, &$topic));
    /** This filter is documented in bp-groups/bp-groups-forums.php */
    $filtered_primary_link = apply_filters('groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id);
    groups_record_activity(array('id' => $id, 'action' => $action, 'content' => $content, 'primary_link' => $filtered_primary_link, 'type' => 'new_forum_post', 'item_id' => (int) bp_get_current_group_id(), 'user_id' => (int) $post->poster_id, 'secondary_item_id' => $post_id, 'recorded_time' => $post->post_time));
    /**
     * Fires after the update of a group forum post.
     *
     * @since BuddyPress (1.1.0)
     *
     * @param object $post  Object holding current post being updated.
     * @param object $topic Object holding current topic details. Passed by reference.
     */
    do_action_ref_array('groups_update_group_forum_post', array($post, &$topic));
    return $post_id;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:55,代码来源:bp-groups-forums.php

示例6: bp_groupblogs_fetch_group_feeds

 /**
  * Function to fetch group feeds and save RSS entries as BP activity items.
  *
  * @param int $group_id The group ID.
  */
 function bp_groupblogs_fetch_group_feeds($group_id = false)
 {
     if (empty($group_id)) {
         $group_id = bp_get_current_group_id();
     }
     if ($group_id == bp_get_current_group_id()) {
         $group = groups_get_current_group();
     } else {
         $group = new BP_Groups_Group($group_id);
     }
     if (!$group) {
         return false;
     }
     $group_blogs = groups_get_groupmeta($group_id, 'blogfeeds');
     $items = array();
     foreach ((array) $group_blogs as $feed_url) {
         $feed_url = trim($feed_url);
         if (empty($feed_url)) {
             continue;
         }
         // Make sure the feed is accessible
         $test = wp_remote_get($feed_url);
         if (is_wp_error($test)) {
             continue;
         }
         try {
             $rss = new SimpleXmlElement($test['body']);
         } catch (Exception $e) {
             continue;
         }
         $rss = fetch_feed(trim($feed_url));
         if (!is_wp_error($rss)) {
             $maxitems = $rss->get_item_quantity(10);
             $rss_items = $rss->get_items(0, $maxitems);
             foreach ($rss_items as $item) {
                 $key = $item->get_date('U');
                 $items[$key]['title'] = $item->get_title();
                 $items[$key]['subtitle'] = $item->get_title();
                 //$items[$key]['author'] = $item->get_author()->get_name();
                 $items[$key]['blogname'] = $item->get_feed()->get_title();
                 $items[$key]['link'] = $item->get_permalink();
                 $items[$key]['blogurl'] = $item->get_feed()->get_link();
                 $items[$key]['description'] = $item->get_description();
                 $items[$key]['source'] = $item->get_source();
                 $items[$key]['copyright'] = $item->get_copyright();
                 $items[$key]['primary_link'] = $item->get_link();
                 $items[$key]['guid'] = $item->get_id();
                 $items[$key]['feedurl'] = $feed_url;
             }
         }
     }
     if (!empty($items)) {
         ksort($items);
         $items = array_reverse($items, true);
     } else {
         return false;
     }
     /* Set the visibility */
     $hide_sitewide = 'public' != $group->status ? true : false;
     /* Record found blog posts in activity streams */
     foreach ((array) $items as $post_date => $post) {
         $activity_action = sprintf(__('Blog: %s from %s in the group %s', 'bp-groups-externalblogs'), '<a class="feed-link" href="' . esc_attr($post['link']) . '">' . esc_attr($post['title']) . '</a>', '<a class="feed-author" href="' . esc_attr($post['blogurl']) . '">' . esc_attr($post['blogname']) . '</a>', '<a href="' . bp_get_group_permalink($group) . '">' . esc_attr($group->name) . '</a>');
         $activity_content = '<div>' . strip_tags(bp_create_excerpt($post['description'], 175)) . '</div>';
         $activity_content = apply_filters('bp_groupblogs_activity_content', $activity_content, $post, $group);
         /* Fetch an existing activity_id if one exists. */
         // backpat
         $id = bp_activity_get_activity_id(array('user_id' => false, 'action' => $activity_action, 'component' => 'groups', 'type' => 'exb', 'item_id' => $group_id, 'secondary_item_id' => wp_hash($post['blogurl'])));
         // new method
         if (empty($id)) {
             $existing = bp_activity_get(array('user_id' => false, 'component' => 'groups', 'type' => 'exb', 'item_id' => $group_id, 'update_meta_cache' => false, 'display_comments' => false, 'meta_query' => array(array('key' => 'exb_guid', 'value' => $post['guid']))));
             // we've found an existing entry
             if (!empty($existing['activities'])) {
                 $id = (int) $existing['activities'][0]->id;
             }
         }
         /* Record or update in activity streams. */
         // Skip if it already exists
         if (empty($id)) {
             $aid = groups_record_activity(array('id' => $id, 'user_id' => false, 'action' => $activity_action, 'content' => $activity_content, 'primary_link' => $post['primary_link'], 'type' => 'exb', 'item_id' => $group_id, 'recorded_time' => gmdate("Y-m-d H:i:s", $post_date), 'hide_sitewide' => $hide_sitewide));
             // save rss guid as activity meta
             bp_activity_update_meta($aid, 'exb_guid', $post['guid']);
             bp_activity_update_meta($aid, 'exb_feedurl', $post['feedurl']);
         }
     }
     return $items;
 }
开发者ID:rpi-virtuell,项目名称:external-group-blogs,代码行数:91,代码来源:bp-groups-externalblogs.php

示例7: bp_blogs_record_activity

/**
 * Record blog-related activity to the activity stream.
 *
 * @since 1.0.0
 *
 * @see bp_activity_add() for description of parameters.
 *
 * @param array|string $args {
 *     See {@link bp_activity_add()} for complete description of arguments.
 *     The arguments listed here have different default values from
 *     bp_activity_add().
 *     @type string $component Default: 'blogs'.
 * }
 * @return int|bool On success, returns the activity ID. False on failure.
 */
function bp_blogs_record_activity($args = '')
{
    $defaults = array('user_id' => bp_loggedin_user_id(), 'action' => '', 'content' => '', 'primary_link' => '', 'component' => buddypress()->blogs->id, 'type' => false, 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => false);
    $r = wp_parse_args($args, $defaults);
    if (!empty($r['action'])) {
        /**
         * Filters the action associated with activity for activity stream.
         *
         * @since 1.2.0
         *
         * @param string $value Action for the activity stream.
         */
        $r['action'] = apply_filters('bp_blogs_record_activity_action', $r['action']);
    }
    if (!empty($r['content'])) {
        /**
         * Filters the content associated with activity for activity stream.
         *
         * @since 1.2.0
         *
         * @param string $value Generated summary from content for the activity stream.
         * @param string $value Content for the activity stream.
         * @param array  $r     Array of arguments used for the activity stream item.
         */
        $r['content'] = apply_filters('bp_blogs_record_activity_content', bp_activity_create_summary($r['content'], $r), $r['content'], $r);
    }
    // Check for an existing entry and update if one exists.
    $id = bp_activity_get_activity_id(array('user_id' => $r['user_id'], 'component' => $r['component'], 'type' => $r['type'], 'item_id' => $r['item_id'], 'secondary_item_id' => $r['secondary_item_id']));
    return bp_activity_add(array('id' => $id, 'user_id' => $r['user_id'], 'action' => $r['action'], 'content' => $r['content'], 'primary_link' => $r['primary_link'], 'component' => $r['component'], 'type' => $r['type'], 'item_id' => $r['item_id'], 'secondary_item_id' => $r['secondary_item_id'], 'recorded_time' => $r['recorded_time'], 'hide_sitewide' => $r['hide_sitewide']));
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:45,代码来源:bp-blogs-activity.php

示例8: bp_like_remove_user_like

/**
 * bp_like_remove_user_like()
 *
 * Registers that the user has unliked a given item.
 *
 */
function bp_like_remove_user_like($item_id = '', $type = 'activity')
{
    global $bp;
    if (!$item_id) {
        return false;
    }
    if (!isset($user_id)) {
        $user_id = $bp->loggedin_user->id;
    }
    if ($user_id == 0) {
        echo bp_like_get_text('must_be_logged_in');
        return false;
    }
    if ($type == 'activity') {
        /* Remove this from the users liked activities. */
        $user_likes = get_user_meta($user_id, 'bp_liked_activities', true);
        unset($user_likes[$item_id]);
        update_user_meta($user_id, 'bp_liked_activities', $user_likes);
        /* Update the total number of users who have liked this activity. */
        $users_who_like = bp_activity_get_meta($item_id, 'liked_count', true);
        unset($users_who_like[$user_id]);
        /* If nobody likes the activity, delete the meta for it to save space, otherwise, update the meta */
        if (empty($users_who_like)) {
            bp_activity_delete_meta($item_id, 'liked_count');
        } else {
            bp_activity_update_meta($item_id, 'liked_count', $users_who_like);
        }
        $liked_count = count($users_who_like);
        /* Remove the update on the users profile from when they liked the activity. */
        $update_id = bp_activity_get_activity_id(array('item_id' => $item_id, 'component' => 'bp-like', 'type' => 'activity_liked', 'user_id' => $user_id));
        bp_activity_delete(array('id' => $update_id, 'item_id' => $item_id, 'component' => 'bp-like', 'type' => 'activity_liked', 'user_id' => $user_id));
    } elseif ($type == 'blogpost') {
        /* Remove this from the users liked activities. */
        $user_likes = get_user_meta($user_id, 'bp_liked_blogposts', true);
        unset($user_likes[$item_id]);
        update_user_meta($user_id, 'bp_liked_blogposts', $user_likes);
        /* Update the total number of users who have liked this blog post. */
        $users_who_like = get_post_meta($item_id, 'liked_count', true);
        unset($users_who_like[$user_id]);
        /* If nobody likes the blog post, delete the meta for it to save space, otherwise, update the meta */
        if (empty($users_who_like)) {
            delete_post_meta($item_id, 'liked_count');
        } else {
            update_post_meta($item_id, 'liked_count', $users_who_like);
        }
        $liked_count = count($users_who_like);
        /* Remove the update on the users profile from when they liked the activity. */
        $update_id = bp_activity_get_activity_id(array('item_id' => $item_id, 'component' => 'bp-like', 'type' => 'blogpost_liked', 'user_id' => $user_id));
        bp_activity_delete(array('id' => $update_id, 'item_id' => $item_id, 'component' => 'bp-like', 'type' => 'blogpost_liked', 'user_id' => $user_id));
    }
    echo bp_like_get_text('like');
    if ($liked_count) {
        echo ' (' . $liked_count . ')';
    }
}
开发者ID:Grendel61,项目名称:BuddyPress-Like,代码行数:61,代码来源:like-functions.php

示例9: catch_idea_comment

 /**
  * 2/ Catch the idea in order to use it just before the activity is saved
  * @see  $this->adjust_activity_args();
  *
  * We won't change anything to the $activity_content.
  *
  * @package WP Idea Stream
  * @subpackage buddypress/activity
  *
  * @since 2.1.0
  *
  * @param  string  $activity_content the excerpt created by BuddyPress
  * @param  WP_Post $post             the post object (can be an idea)
  * @param  string  $post_permalink   the permalink to this object
  * @uses   bp_activity_get_activity_id() to get an activity id
  * @uses   bp_activity_delete()      to delete an activity
  * @return string                    the activity content unchanged
  */
 public function catch_idea_comment($activity_content = '', $post = null, $post_permalink = '')
 {
     // If it's a comment, BuddyPress is attaching it into the post var of the comment object
     if (empty($post->post->post_type) || $this->post_type != $post->post->post_type) {
         return $activity_content;
     }
     $this->idea = $post->post;
     $this->secondary_item_id = $post->comment_ID;
     /**
      * For this particular case, we need to check for a previous entry to delete it
      * As a the 'edit_comment' hook will be fired if the comment was edited from the
      * 'wp-admin/comment.php?action=editcomment..' screen, bp_blogs_record_comment()
      * will not find the new_blog_comment activity to edit and will post a new one
      */
     $id = bp_activity_get_activity_id(array('type' => 'new_' . $this->post_type . '_comment', 'secondary_item_id' => $this->secondary_item_id));
     // Found one, delete it to prevent duplicates
     if (!empty($id)) {
         bp_activity_delete(array('id' => $id));
     }
     // return without editing.
     return $activity_content;
 }
开发者ID:BoweFrankema,项目名称:wp-idea-stream,代码行数:40,代码来源:activity.php

示例10: humcore_get_deposit_activity_id

/**
 * Return the deposit activity id.
 *
 * @uses apply_filters() To call the 'humcore_get_deposit_activity_id' hook.
 *
 * @return The deposit id.
 */
function humcore_get_deposit_activity_id()
{
    global $bp;
    $activity_id = bp_activity_get_activity_id(array('type' => 'new_deposit', 'component' => $bp->humcore_deposits->id, 'secondary_item_id' => humcore_get_deposit_record_identifier()));
    return apply_filters('humcore_get_deposit_activity_id', $activity_id);
}
开发者ID:MartinPaulEve,项目名称:humcore,代码行数:13,代码来源:template.php

示例11: ccgn_create_activity_items

function ccgn_create_activity_items($post_id)
{
    $bp = buddypress();
    // We want to fetch the saved post, because WP has done some filtering on save.
    $post_object = get_post($post_id);
    $author_id = (int) $post_object->post_author;
    $user_link = bp_core_get_userlink($author_id);
    $post_type_object = get_post_type_object($post_object->post_type);
    $post_type_label = strtolower($post_type_object->labels->singular_name);
    // A single narrative may be associated with more than one group
    $origin_group_id = ccgn_get_origin_group($post_id);
    $associated_groups = ccgn_get_associated_group_ids($post_id);
    $type = $post_object->post_type . '_created';
    foreach ($associated_groups as $group_id) {
        // Does an activity item already exist?
        $exists = bp_activity_get_activity_id(array('component' => $bp->groups->id, 'type' => $type, 'item_id' => $group_id, 'secondary_item_id' => $post_id));
        if (!empty($exists)) {
            continue;
        }
        // Create a post url that is relative to this group.
        $post_url = trailingslashit(ccgn_get_home_permalink($group_id)) . $post_object->post_name;
        $post_link = sprintf('<a href="%s">%s</a>', $post_url, $post_object->post_title);
        $group = groups_get_group(array('group_id' => $group_id));
        $group_url = bp_get_group_permalink($group);
        $group_link = '<a href="' . $group_url . '">' . $group->name . '</a>';
        // Only set hide_sitewide to false if this is the origin group and it is a public group.
        if ($group_id == $origin_group_id && 'public' == bp_get_group_status($group)) {
            $hide_sitewide = false;
        } else {
            $hide_sitewide = true;
        }
        $action = sprintf(__('%1$s published the %2$s %3$s in the Hub %4$s', 'cc-group-narratives'), $user_link, $post_type_label, $post_link, $group_link);
        $args = array('user_id' => $author_id, 'action' => $action, 'primary_link' => $post_link, 'component' => $bp->groups->id, 'type' => $type, 'item_id' => $group_id, 'secondary_item_id' => $post_id, 'recorded_time' => $post_object->post_date, 'hide_sitewide' => $hide_sitewide, 'content' => bp_create_excerpt($post_object->post_content, 358));
        do_action($post_object->post_type . '_before_activity_save', $args);
        $activity_id = bp_activity_add(apply_filters($post_object->post_type . '_activity_args', $args, $post_id));
    }
}
开发者ID:careshub,项目名称:cc-group-narratives,代码行数:37,代码来源:ccgn-functions.php

示例12: test_bp_activity_get_activity_id

 /**
  * @group bp_activity_get_activity_id
  */
 public function test_bp_activity_get_activity_id()
 {
     $args = array('user_id' => 5, 'component' => 'foo', 'type' => 'bar', 'item_id' => 12, 'secondary_item_id' => 44);
     $a = $this->factory->activity->create($args);
     $this->assertEquals($a, bp_activity_get_activity_id($args));
 }
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:9,代码来源:functions.php

示例13: ac_notifier_remove_notification_for_topic

/**
 * @since 1.0.3
 * it is not used any more because qwe are linking to threaded view
 * Remove notification for group forum posts/new topic
 */
function ac_notifier_remove_notification_for_topic()
{
    global $bp;
    //is group & group forum active ?
    if (!(bp_is_active("groups") && bp_is_active("forums"))) {
        return;
    }
    //if either group or forum is not actuive do not do anything
    //check if we are on single topic screen, right?
    if (bp_is_group_forum_topic() && is_user_logged_in()) {
        $topic_id = bp_forums_get_topic_id_from_slug($bp->action_variables[1]);
        //get id from slug
        $topic = get_topic($topic_id);
        $group_id = $bp->groups->current_group->id;
        //find activity id for this topic
        $activity_id = bp_activity_get_activity_id(array('user_id' => $topic->poster_id, 'component' => $bp->groups->id, 'type' => "new_forum_topic", "item_id" => $group_id, 'secondary_item_id' => $topic_id));
        //remove notification for new topic comments: easy
        if (!empty($activity_id)) {
            bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $activity_id, $bp->ac_notifier->id, 'new_activity_comment_' . $activity_id);
        }
        $posts = ac_notifier_get_forum_post_ids($topic_id);
        if (!empty($posts)) {
            //find all activities for the post
            $activities = ac_notifier_get_activity_ids(array("item_id" => $group_id, "secondary_ids" => $posts, "component" => $bp->groups->id, "type" => "new_forum_post"));
            //pass the array
            foreach ((array) $activities as $ac_id) {
                bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $ac_id, $bp->ac_notifier->id, 'new_activity_comment_' . $ac_id);
            }
        }
    }
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:36,代码来源:ac-notify.php

示例14: bp_groupblogs_fetch_group_feeds

 function bp_groupblogs_fetch_group_feeds($group_id = false)
 {
     global $bp;
     include_once ABSPATH . 'wp-includes/rss.php';
     if (empty($group_id)) {
         $group_id = $bp->groups->current_group->id;
     }
     if ($group_id == $bp->groups->current_group->id) {
         $group = $bp->groups->current_group;
     } else {
         $group = new BP_Groups_Group($group_id);
     }
     if (!$group) {
         return false;
     }
     $group_blogs = groups_get_groupmeta($group_id, 'blogfeeds');
     $group_blogs = explode(";", $group_blogs[0]);
     /* Set the visibility */
     $hide_sitewide = 'public' != $group->status ? true : false;
     foreach ((array) $group_blogs as $feed_url) {
         $rss = fetch_feed(trim($feed_url));
         if (!is_wp_error($rss)) {
             foreach ($rss->get_items(0, 10) as $item) {
                 $key = $item->get_date('U');
                 $items[$key]['title'] = $item->get_title();
                 $items[$key]['subtitle'] = $item->get_title();
                 //$items[$key]['author'] = $item->get_author()->get_name();
                 $items[$key]['blogname'] = $item->get_feed()->get_title();
                 $items[$key]['link'] = $item->get_permalink();
                 $items[$key]['blogurl'] = $item->get_feed()->get_link();
                 $items[$key]['description'] = $item->get_description();
                 $items[$key]['source'] = $item->get_source();
                 $items[$key]['copyright'] = $item->get_copyright();
             }
         }
     }
     if ($items) {
         ksort($items);
         $items = array_reverse($items, true);
     } else {
         return false;
     }
     /* Record found blog posts in activity streams */
     foreach ((array) $items as $post_date => $post) {
         //var_dump($post);
         if (substr($post['blogname'], 0, 7) == "Twitter") {
             $activity_action = sprintf(__('%s from %s in the group %s', 'bp-groups-externalblogs'), '<a class="feed-link" href="' . esc_attr($post['link']) . '">Tweet</a>', '<a class="feed-author" href="' . esc_attr($post['blogurl']) . '">' . attribute_escape($post['blogname']) . '</a>', '<a href="' . bp_get_group_permalink($group) . '">' . attribute_escape($group->name) . '</a>');
         } else {
             $activity_action = sprintf(__('Blog: %s from %s in the group %s', 'bp-groups-externalblogs'), '<a class="feed-link" href="' . esc_attr($post['link']) . '">' . esc_attr($post['title']) . '</a>', '<a class="feed-author" href="' . esc_attr($post['blogurl']) . '">' . attribute_escape($post['blogname']) . '</a>', '<a href="' . bp_get_group_permalink($group) . '">' . attribute_escape($group->name) . '</a>');
         }
         $activity_content = '<div>' . strip_tags(bp_create_excerpt($post['description'], 175)) . '</div>';
         $activity_content = apply_filters('bp_groupblogs_activity_content', $activity_content, $post, $group);
         /* Fetch an existing activity_id if one exists. */
         if (function_exists('bp_activity_get_activity_id')) {
             $id = bp_activity_get_activity_id(array('user_id' => false, 'action' => $activity_action, 'component' => $bp->groups->id, 'type' => 'exb', 'item_id' => $group_id, 'secondary_item_id' => wp_hash($post['blogurl'])));
         }
         /* Record or update in activity streams. */
         groups_record_activity(array('id' => $id, 'user_id' => false, 'action' => $activity_action, 'content' => $activity_content, 'primary_link' => $item->get_link(), 'type' => 'exb', 'item_id' => $group_id, 'secondary_item_id' => wp_hash($post['blogurl']), 'recorded_time' => gmdate("Y-m-d H:i:s", $post_date), 'hide_sitewide' => $hide_sitewide));
     }
     return $items;
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:61,代码来源:bp-groups-externalblogs.php

示例15: bp_blogs_comment_sync_activity_comment

/**
 * Update Activity and blogs meta and eventually sync comment with activity comment
 *
 * @since  2.5.0
 *
 * @param  int|bool        $activity_id          ID of recorded activity, or false if sync is active.
 * @param  WP_Comment|null $comment              The comment object.
 * @param  array           $activity_args        Array of activity arguments.
 * @param  object|null     $activity_post_object The post type tracking args object.
 * @return int|bool Returns false if no activity, the activity id otherwise.
 */
function bp_blogs_comment_sync_activity_comment(&$activity_id, $comment = null, $activity_args = array(), $activity_post_object = null)
{
    if (empty($activity_args) || empty($comment->post->ID) || empty($activity_post_object->comment_action_id)) {
        return false;
    }
    // Set the current blog id.
    $blog_id = get_current_blog_id();
    // These activity metadatas are used to build the new_blog_comment action string
    if (!empty($activity_id) && !empty($activity_args['item_id']) && 'new_blog_comment' === $activity_post_object->comment_action_id) {
        // add some post info in activity meta
        bp_activity_update_meta($activity_id, 'post_title', $comment->post->post_title);
        bp_activity_update_meta($activity_id, 'post_url', esc_url_raw(add_query_arg('p', $comment->post->ID, home_url('/'))));
    }
    // Sync comment - activity comment
    if (!bp_disable_blogforum_comments()) {
        if (!empty($_REQUEST['action'])) {
            $existing_activity_id = get_comment_meta($comment->comment_ID, 'bp_activity_comment_id', true);
            if (!empty($existing_activity_id)) {
                $activity_args['id'] = $existing_activity_id;
            }
        }
        if (empty($activity_post_object)) {
            $activity_post_object = bp_activity_get_post_type_tracking_args($comment->post->post_type);
        }
        if (isset($activity_post_object->action_id) && isset($activity_post_object->component_id)) {
            // find the parent 'new_post_type' activity entry
            $parent_activity_id = bp_activity_get_activity_id(array('component' => $activity_post_object->component_id, 'type' => $activity_post_object->action_id, 'item_id' => $blog_id, 'secondary_item_id' => $comment->comment_post_ID));
            // Try to create a new activity item for the parent blog post.
            if (empty($parent_activity_id)) {
                $parent_activity_id = bp_activity_post_type_publish($comment->post->ID, $comment->post);
            }
        }
        // we found the parent activity entry
        // so let's go ahead and reconfigure some activity args
        if (!empty($parent_activity_id)) {
            // set the parent activity entry ID
            $activity_args['activity_id'] = $parent_activity_id;
            // now see if the WP parent comment has a BP activity ID
            $comment_parent = 0;
            if (!empty($comment->comment_parent)) {
                $comment_parent = get_comment_meta($comment->comment_parent, 'bp_activity_comment_id', true);
            }
            // WP parent comment does not have a BP activity ID
            // so set to 'new_' . post_type activity ID
            if (empty($comment_parent)) {
                $comment_parent = $parent_activity_id;
            }
            $activity_args['parent_id'] = $comment_parent;
            $activity_args['skip_notification'] = true;
            // could not find corresponding parent activity entry
            // so wipe out $args array
        } else {
            $activity_args = array();
        }
        // Record in activity streams
        if (!empty($activity_args)) {
            $activity_id = bp_activity_new_comment($activity_args);
            if (empty($activity_args['id'])) {
                // The activity metadata to inform about the corresponding comment ID
                bp_activity_update_meta($activity_id, "bp_blogs_{$comment->post->post_type}_comment_id", $comment->comment_ID);
                // The comment metadata to inform about the corresponding activity ID
                add_comment_meta($comment->comment_ID, 'bp_activity_comment_id', $activity_id);
                // These activity metadatas are used to build the new_blog_comment action string
                if ('new_blog_comment' === $activity_post_object->comment_action_id) {
                    bp_activity_update_meta($activity_id, 'post_title', $comment->post->post_title);
                    bp_activity_update_meta($activity_id, 'post_url', esc_url_raw(add_query_arg('p', $comment->post->ID, home_url('/'))));
                }
            }
            /**
             * Fires after an activity comment is added from a WP post comment.
             *
             * @since 2.6.0
             *
             * @param int        $activity_id          The activity comment ID.
             * @param WP_Comment $post_type_comment    WP Comment object.
             * @param array      $activity_args        Activity comment arguments.
             * @param object     $activity_post_object The post type tracking args object.
             */
            do_action('bp_blogs_comment_sync_activity_comment', $activity_id, $comment, $activity_args, $activity_post_object);
        }
    }
    // Update the blogs last active date
    bp_blogs_update_blogmeta($blog_id, 'last_activity', bp_core_current_time());
    if ('new_blog_comment' === $activity_post_object->comment_action_id) {
        /**
         * Fires after BuddyPress has recorded metadata about a published blog post comment.
         *
         * @since 2.5.0
         *
//.........这里部分代码省略.........
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:101,代码来源:bp-blogs-functions.php


注:本文中的bp_activity_get_activity_id函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。