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


PHP bp_activity_add函数代码示例

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


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

示例1: buddyreshare_handle_ajax_reshare

/**
 * Catches an activity to reshare if js is enabled
 *
 * @package BP Reshare
 * @since    1.0
 *
 * @uses  check_ajax_referer() for security reasons
 * @uses  buddyreshare_prepare_reshare() to build the reshare arguments
 * @uses  bp_activity_add() to save the reshare
 */
function buddyreshare_handle_ajax_reshare()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    check_ajax_referer('buddyreshare_update', 'nonce');
    $response = array('result' => 'error', 'message' => __('OOps, error while trying to reshare..', 'bp-reshare'));
    $activity_id = intval($_POST['activity']);
    if (empty($activity_id)) {
        $response['message'] = __('The activity was not found.', 'bp-reshare');
        exit(json_encode($response));
    }
    $args = buddyreshare_prepare_reshare($activity_id);
    if (isset($args['error'])) {
        $response['message'] = $args['error'];
        exit(json_encode($response));
    }
    $reshare_id = bp_activity_add($args);
    if (!empty($reshare_id)) {
        do_action('buddyreshare_reshare_added', $reshare_id);
        $response['result'] = 'success';
        $response['message'] = __('Activity successfully reshared.', 'bp-reshare');
    } else {
        do_action('buddyreshare_reshare_added_error', $reshare_id);
    }
    exit(json_encode($response));
}
开发者ID:socialray,项目名称:surfied-2-0,代码行数:38,代码来源:ajax.php

示例2: record_activity

 private static function record_activity($args = array())
 {
     // Default activity args
     $activity = array_merge(array('id' => null, 'user_id' => get_current_user_id(), 'type' => '', 'action' => '', 'item_id' => '', 'secondary_item_id' => '', 'content' => '', 'primary_link' => '', 'component' => 'dln-product-component', 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => false), $args);
     // Add the activity
     return bp_activity_add($activity);
 }
开发者ID:httvncoder,项目名称:151722441,代码行数:7,代码来源:dln-buddypress-loader.php

示例3: bp_like_post_to_stream

/**
 * bp_like_post_to_stream()
 * 
 * Posts to stream, depending on settings
 * 
 * TODO, Should we be posted that people like comments to the feed? This can get messy..
 * Also no point having 20 posts saying people liked the same status..
 * 
 */
function bp_like_post_to_stream($item_id, $user_id)
{
    if (bp_like_get_settings('post_to_activity_stream') == 1) {
        $activity = bp_activity_get_specific(array('activity_ids' => $item_id, 'component' => 'buddypress-like'));
        $author_id = $activity['activities'][0]->user_id;
        if ($user_id == $author_id) {
            $action = bp_like_get_text('record_activity_likes_own');
        } elseif ($user_id == 0) {
            $action = bp_like_get_text('record_activity_likes_an');
        } else {
            $action = bp_like_get_text('record_activity_likes_users');
        }
        $liker = bp_core_get_userlink($user_id);
        $author = bp_core_get_userlink($author_id);
        $activity_url = bp_activity_get_permalink($item_id);
        $content = '';
        //content must be defined...
        /* Grab the content and make it into an excerpt of 140 chars if we're allowed */
        if (bp_like_get_settings('show_excerpt') == 1) {
            $content = $activity['activities'][0]->content;
            if (strlen($content) > bp_like_get_settings('excerpt_length')) {
                $content = substr($content, 0, bp_like_get_settings('excerpt_length'));
                $content = strip_tags($content);
                $content = $content . '...';
            }
        }
        /* Filter out the placeholders */
        $action = str_replace('%user%', $liker, $action);
        $action = str_replace('%permalink%', $activity_url, $action);
        $action = str_replace('%author%', $author, $action);
        bp_activity_add(array('action' => $action, 'content' => $content, 'primary_link' => $activity_url, 'component' => 'bp-like', 'type' => 'activity_liked', 'user_id' => $user_id, 'item_id' => $item_id));
    }
}
开发者ID:pausaura,项目名称:agora_nodes,代码行数:42,代码来源:activity-functions.php

示例4: buddyreshare_add_reshare

/**
 * Catches an activity to reshare if js is disabled
 *
 * @package BP Reshare
 * @since    1.0
 *
 * @uses  bp_is_activity_component() are we in activity component
 * @uses  bp_is_current_action() to check current action
 * @uses  buddyreshare_get_component_slug() to get component slug
 * @uses  bp_action_variable() to check the variables
 * @uses  check_admin_referer() for security reasons
 * @uses  bp_core_get_user_domain() to build user's url
 * @uses  bp_loggedin_user_id() to get current user's id
 * @uses  bp_get_activity_slug() to get activity slug
 * @uses  buddyreshare_prepare_reshare() to build the reshare arguments
 * @uses  bp_core_add_message() to print a warning message
 * @uses  bp_core_redirect() to safely redirect user
 * @uses  bp_activity_add() to save the reshare
 */
function buddyreshare_add_reshare()
{
    // Not adding a reshare
    if (!bp_is_activity_component() || !bp_is_current_action(buddyreshare_get_component_slug())) {
        return false;
    }
    // No reshare to add
    if (!bp_action_variable(0) || bp_action_variable(0) != 'add' || !bp_action_variable(1) || !is_numeric(bp_action_variable(1))) {
        return false;
    }
    $reshare_id = bp_action_variable(1);
    check_admin_referer('buddyreshare_update');
    // redirecting to user's profile
    $redirect = bp_core_get_user_domain(bp_loggedin_user_id()) . bp_get_activity_slug() . '/';
    $reshared_args = buddyreshare_prepare_reshare($reshare_id);
    if (isset($reshared_args['error'])) {
        bp_core_add_message($reshared_args['error'], 'error');
        bp_core_redirect($redirect);
    }
    $reshared = bp_activity_add($reshared_args);
    if (!empty($reshared)) {
        do_action('buddyreshare_reshare_added', $reshare_id);
        bp_core_add_message(__('Activity reshared !', 'bp-reshare'));
        bp_core_redirect($redirect);
    } else {
        do_action('buddyreshare_reshare_added_error', $reshare_id);
        bp_core_add_message(__('OOps, error while trying to reshare..', 'bp-reshare'), 'error');
        bp_core_redirect($redirect);
    }
}
开发者ID:socialray,项目名称:surfied-2-0,代码行数:49,代码来源:actions.php

示例5: bp_reshare_post_reshare

/**
* let's add reshare if user's browser has javascript turned off
*/
function bp_reshare_post_reshare()
{
    if (!empty($_GET['to_reshare']) && is_numeric($_GET['to_reshare'])) {
        check_admin_referer('_reshare_update');
        $redirect = remove_query_arg(array('to_reshare', '_wpnonce'), wp_get_referer());
        /* We need to check if loggedin user is the author of the original activity
        		and if the loggedin user has already reshared this activity before posting the reshare */
        $to_reshare_id = intval($_GET['to_reshare']);
        if (bp_reshare_user_did_reshared($to_reshare_id)) {
            // user is the author of the original activity or already reshared
            do_action('bp_reshare_handle_nojs_already_reshared', $reshared_activity_id);
            bp_core_add_message(__('OOps, looks like you already reshared this activity or you are the author of it..', 'bp-reshare'), 'error');
            bp_core_redirect($redirect);
        } else {
            $reshared_args = bp_reshare_prepare_reshare($to_reshare_id);
            $reshared_activity_id = bp_activity_add($reshared_args);
            if (!empty($reshared_activity_id)) {
                do_action('bp_reshare_handle_nojs_posted', $reshared_activity_id);
                bp_core_add_message(__('Activity reshared !', 'bp-reshare'));
                bp_core_redirect($redirect);
            } else {
                do_action('bp_reshare_handle_nojs_missed', $reshared_activity_id);
                bp_core_add_message(__('OOps, error while trying to reshare..', 'bp-reshare'), 'error');
                bp_core_redirect($redirect);
            }
        }
    }
}
开发者ID:KristianI,项目名称:bp-reshare,代码行数:31,代码来源:bp-reshare-actions.php

示例6: create_object

 function create_object($args)
 {
     if (!isset($args['user_id'])) {
         $args['user_id'] = get_current_user_id();
     }
     return bp_activity_add($args);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:7,代码来源:factory.php

示例7: friends_record_activity

/**
 * Record an activity item related to the Friends component.
 *
 * A wrapper for {@link bp_activity_add()} that provides some Friends-specific
 * defaults.
 *
 * @since 1.0.0
 *
 * @see bp_activity_add() for more detailed description of parameters and
 *      return values.
 *
 * @param array|string $args {
 *     An array of arguments for the new activity item. Accepts all parameters
 *     of {@link bp_activity_add()}. The one difference is the following
 *     argument, which has a different default here:
 *     @type string $component Default: the id of your Friends component
 *                             (usually 'friends').
 * }
 * @return bool See {@link bp_activity_add()}.
 */
function friends_record_activity($args = '')
{
    if (!bp_is_active('activity')) {
        return false;
    }
    $r = wp_parse_args($args, array('user_id' => bp_loggedin_user_id(), 'action' => '', 'content' => '', 'primary_link' => '', 'component' => buddypress()->friends->id, 'type' => false, 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => false));
    return bp_activity_add($r);
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:28,代码来源:bp-friends-activity.php

示例8: bp_em_record_activity

/**
 * bp_em_record_activity()
 *
 * If the activity stream component is installed, this function will record activity items for your
 * component.
 */
function bp_em_record_activity($args = '')
{
    if (!function_exists('bp_activity_add')) {
        return false;
    }
    $defaults = array('id' => false, 'user_id' => '', 'action' => '', 'content' => '', 'primary_link' => '', 'component' => 'events-manager', 'type' => false, 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => gmdate("Y-m-d H:i:s"), 'hide_sitewide' => false);
    $r = wp_parse_args($args, $defaults);
    extract($r);
    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:batruji,项目名称:metareading,代码行数:16,代码来源:bp-em-activity.php

示例9: friends_record_activity

function friends_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->friends->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);
    return bp_activity_add(array('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:hornetalcala,项目名称:trunk,代码行数:11,代码来源:bp-friends-activity.php

示例10: bp_media_record_activity

function bp_media_record_activity($args = '')
{
    global $bp;
    if (!function_exists('bp_activity_add')) {
        return false;
    }
    $defaults = array('component' => BP_MEDIA_SLUG);
    add_filter('bp_activity_allowed_tags', 'bp_media_override_allowed_tags');
    $r = wp_parse_args($args, $defaults);
    $activity_id = bp_activity_add($r);
    return $activity_id;
}
开发者ID:nitun,项目名称:buddypress-media,代码行数:12,代码来源:bp-media-functions.php

示例11: bp_media_record_activity

function bp_media_record_activity($args = '')
{
    global $bp;
    if (!function_exists('bp_activity_add')) {
        return false;
    }
    $defaults = array('id' => false, 'action' => '', 'content' => '', 'component' => BP_MEDIA_SLUG, 'type' => false, 'primary_link' => '', 'user_id' => $bp->loggedin_user->id, 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => false);
    add_filter('bp_activity_allowed_tags', 'bp_media_override_allowed_tags');
    $r = wp_parse_args($args, $defaults);
    extract($r);
    $activity_id = 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));
    return $activity_id;
}
开发者ID:rolandinsh,项目名称:buddypress-media,代码行数:13,代码来源:bp-media-functions.php

示例12: bbpvotes_buddypress_voted_activity

function bbpvotes_buddypress_voted_activity($post_id, $user_id, $vote)
{
    //check vote value
    if (is_bool($vote) === false) {
        return new WP_Error('vote_is_not_bool', __('Vote is not a boolean', 'bbpvotes'));
    }
    $voteplus = $vote === true;
    $voteminus = $vote === false;
    $post = get_post($post_id);
    $user_link = bbp_get_user_profile_link($user_id);
    //build item link
    if ($post->post_type == bbp_get_topic_post_type()) {
        $topic_id = $post->ID;
        $post_permalink = get_permalink($post->ID);
    } elseif ($post->post_type == bbp_get_reply_post_type()) {
        $topic_id = bbp_get_reply_topic_id($post->ID);
        $post_permalink = bbp_get_reply_url($post->ID);
    }
    //topic infos
    $topic = get_post($topic_id);
    $topic_author_link = bbp_get_user_profile_link($topic->post_author);
    $topic_title = $topic->post_title;
    $post_link = '<a href="' . $post_permalink . '">' . $topic_title . '</a>';
    if ($voteplus) {
        $type = 'bbpvotes_voted_up';
        if ($post->post_type == bbp_get_topic_post_type()) {
            $action = sprintf(esc_html__('%1$s voted up to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        } elseif ($post->post_type == bbp_get_reply_post_type()) {
            $action = sprintf(esc_html__('%1$s voted up to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        }
    } else {
        $type = 'bbpvotes_voted_down';
        if ($post->post_type == bbp_get_topic_post_type()) {
            $action = sprintf(esc_html__('%1$s voted down to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        } elseif ($post->post_type == bbp_get_reply_post_type()) {
            $action = sprintf(esc_html__('%1$s voted down to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        }
    }
    $args = array('action' => $action, 'component' => 'bbpress', 'type' => $type, 'item_id' => $topic->ID);
    if ($post->post_type == bbp_get_reply_post_type()) {
        $args['secondary_item_id'] = $post->ID;
    }
    /*
        if ($is_update){
       $previous_activity_id = 
       $args['id'] = $previous_activity_id;
        }
    */
    bp_activity_add($args);
}
开发者ID:ptrck-r,项目名称:bbpress-votes,代码行数:50,代码来源:bbpvotes-buddypress.php

示例13: answer_posted_activity

 /**
  * Create a wall activity for this user after posting an answer.
  *
  * @param CMA_AnswerThread $instance
  * @param CMA_Answer $answer
  */
 static function answer_posted_activity(CMA_AnswerThread $instance, CMA_Answer $answer)
 {
     if (!$instance->isPublished()) {
         return;
     } else {
         if (!$answer->isApproved()) {
             return;
         }
     }
     $post = $instance->getPost();
     $user_id = $answer->getAuthorId();
     $permalink = $answer->getPermalink();
     bp_activity_add(array('action' => sprintf(CMA::__('%s answered to the question "%s"'), bp_core_get_userlink($user_id), sprintf('<a href="%s">%s</a>', esc_attr($permalink), esc_html($instance->getTitle()))), 'content' => CMA_AnswerThread::lightContent($answer->getContent()), 'component' => self::COMPONENT, 'type' => 'answer_posted', 'primary_link' => $permalink, 'user_id' => $user_id, 'item_id' => $answer->getId()));
 }
开发者ID:hemangsk,项目名称:TCB,代码行数:20,代码来源:BuddyPress.php

示例14: bp_group_documents_record_activity

/**
 * bp_group_documents_record_activity()
 *
 * If the activity stream component is installed, this function will record upload
 * and edit activity items.
 */
function bp_group_documents_record_activity($args = '')
{
    global $bp;
    if (!function_exists('bp_activity_add')) {
        return false;
    }
    $defaults = array('primary_link' => bp_get_group_permalink($bp->groups->current_group), 'component_name' => 'groups', 'component_action' => false, 'hide_sitewide' => false, 'user_id' => $bp->loggedin_user->id, 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => false, 'content' => '');
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    // If the group is not public, don't broadcast updates.
    if ('public' != $bp->groups->current_group->status) {
        $hide_sitewide = 1;
    }
    return bp_activity_add(array('content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'user_id' => $user_id, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'hide_sitewide' => $hide_sitewide, 'action' => $action));
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:21,代码来源:activity.php

示例15: bp_core_new_user_activity

/**
 * Create a "became a registered user" activity item when a user activates his account.
 *
 * @param array $user Array of userdata passed to bp_core_activated_user hook.
 *
 * @return bool
 */
function bp_core_new_user_activity($user)
{
    if (empty($user)) {
        return false;
    }
    if (is_array($user)) {
        $user_id = $user['user_id'];
    } else {
        $user_id = $user;
    }
    if (empty($user_id)) {
        return false;
    }
    bp_activity_add(array('user_id' => $user_id, 'component' => buddypress()->members->id, 'type' => 'new_member'));
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:22,代码来源:bp-members-activity.php


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