本文整理汇总了PHP中bp_activity_get_specific函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_activity_get_specific函数的具体用法?PHP bp_activity_get_specific怎么用?PHP bp_activity_get_specific使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_activity_get_specific函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: buddyreshare_ajax_delete_reshare
/**
* Catches an activity to delete if js is enabled
*
* @package BP Reshare
* @since 1.0
*
* @uses check_ajax_referer() for security reasons
* @uses bp_activity_get_specific() to fetch the activity to delete
* @uses buddyreshare_reset_metas() to reset some metas for the parent activity
* @uses bp_activity_delete() to delete the reshare
*/
function buddyreshare_ajax_delete_reshare()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
check_ajax_referer('buddyreshare_delete', 'nonce');
$response = array('result' => 'error', 'message' => __('OOps, error while trying to delete your reshare..', 'bp-reshare'));
$reshare_id = intval($_POST['activity']);
if (empty($reshare_id)) {
$response['message'] = __('The reshare was not found.', 'bp-reshare');
exit(json_encode($response));
}
$reshare_to_delete = bp_activity_get_specific(array('activity_ids' => $reshare_id));
if (empty($reshare_to_delete)) {
$response['message'] = __('The reshare was not found.', 'bp-reshare');
exit(json_encode($response));
}
$reshare = $reshare_to_delete['activities'][0];
$reset = buddyreshare_reset_metas($reshare->secondary_item_id, $reshare->user_id);
if (empty($reset)) {
$response['message'] = __('Unable to reset the properties of the reshared activity', 'bp-reshare');
exit(json_encode($response));
}
$deleted_reshare = bp_activity_delete(array('type' => 'reshare_update', 'id' => $reshare_id));
if (!empty($deleted_reshare)) {
do_action('buddyreshare_reshare_deleted', $reshare_id);
$response['result'] = 'success';
$response['message'] = __('Reshare successfully deleted.', 'bp-reshare');
} else {
do_action('buddyreshare_reshare_deleted_error', $reshare_id);
}
exit(json_encode($response));
}
开发者ID:socialray,项目名称:surfied-2-0,代码行数:45,代码来源:ajax.php
示例3: bp_activity_action_permalink_router
/**
* Catch and route requests for single activity item permalinks.
*
* @since 1.2.0
*
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
* @uses bp_action_variable()
* @uses bp_activity_get_specific()
* @uses bp_is_active()
* @uses bp_core_get_user_domain()
* @uses groups_get_group()
* @uses bp_get_group_permalink()
* @uses apply_filters_ref_array() To call the 'bp_activity_permalink_redirect_url' hook.
* @uses bp_core_redirect()
* @uses bp_get_root_domain()
*
* @return bool False on failure.
*/
function bp_activity_action_permalink_router()
{
// Not viewing activity.
if (!bp_is_activity_component() || !bp_is_current_action('p')) {
return false;
}
// No activity to display.
if (!bp_action_variable(0) || !is_numeric(bp_action_variable(0))) {
return false;
}
// Get the activity details.
$activity = bp_activity_get_specific(array('activity_ids' => bp_action_variable(0), 'show_hidden' => true));
// 404 if activity does not exist
if (empty($activity['activities'][0])) {
bp_do_404();
return;
} else {
$activity = $activity['activities'][0];
}
// Do not redirect at default.
$redirect = false;
// Redirect based on the type of activity.
if (bp_is_active('groups') && $activity->component == buddypress()->groups->id) {
// Activity is a user update.
if (!empty($activity->user_id)) {
$redirect = bp_core_get_user_domain($activity->user_id, $activity->user_nicename, $activity->user_login) . bp_get_activity_slug() . '/' . $activity->id . '/';
// Activity is something else.
} else {
// Set redirect to group activity stream.
if ($group = groups_get_group(array('group_id' => $activity->item_id))) {
$redirect = bp_get_group_permalink($group) . bp_get_activity_slug() . '/' . $activity->id . '/';
}
}
// Set redirect to users' activity stream.
} elseif (!empty($activity->user_id)) {
$redirect = bp_core_get_user_domain($activity->user_id, $activity->user_nicename, $activity->user_login) . bp_get_activity_slug() . '/' . $activity->id . '/';
}
// If set, add the original query string back onto the redirect URL.
if (!empty($_SERVER['QUERY_STRING'])) {
$query_frags = array();
wp_parse_str($_SERVER['QUERY_STRING'], $query_frags);
$redirect = add_query_arg(urlencode_deep($query_frags), $redirect);
}
/**
* Filter the intended redirect url before the redirect occurs for the single activity item.
*
* @since 1.2.2
*
* @param array $value Array with url to redirect to and activity related to the redirect.
*/
if (!($redirect = apply_filters_ref_array('bp_activity_permalink_redirect_url', array($redirect, &$activity)))) {
bp_core_redirect(bp_get_root_domain());
}
// Redirect to the actual activity permalink page.
bp_core_redirect($redirect);
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:75,代码来源:bp-activity-actions.php
示例4: bp_reshare_prepare_reshare
function bp_reshare_prepare_reshare($activity_id)
{
global $bp;
$activity_to_reshare = bp_activity_get_specific('activity_ids=' . $activity_id);
$activity = $activity_to_reshare['activities'][0];
/* get and increment reshared count */
$rs_count = bp_activity_get_meta($activity_id, 'reshared_count');
$rs_count = !empty($rs_count) ? (int) $rs_count + 1 : 1;
bp_activity_update_meta($activity_id, 'reshared_count', $rs_count);
/* get an array of users that reshared the activity */
$reshared_by = bp_activity_get_meta($activity_id, 'reshared_by');
if (is_array($reshared_by) && !in_array($bp->loggedin_user->id, $reshared_by)) {
$reshared_by[] = $bp->loggedin_user->id;
} else {
$reshared_by[] = $bp->loggedin_user->id;
}
bp_activity_update_meta($activity_id, 'reshared_by', $reshared_by);
$secondary_avatar = bp_core_fetch_avatar(array('item_id' => $activity->user_id, 'object' => 'user', 'type' => 'thumb', 'alt' => $alt, 'class' => 'avatar', 'width' => 20, 'height' => 20));
$component = $activity->component;
$item_id = $activity->item_id;
if ($component != 'activity') {
if ($activity->type == 'new_blog_post') {
$action = sprintf(__('%s reshared a <a href="%s">blog post</a> originally posted by %s', 'bp-reshare'), bp_core_get_userlink($bp->loggedin_user->id), $activity->primary_link, $secondary_avatar . bp_core_get_userlink($activity->user_id));
} else {
if ($activity->type == 'new_blog_comment') {
$action = sprintf(__('%s reshared a <a href="%s">comment</a> originally posted by %s', 'bp-reshare'), bp_core_get_userlink($bp->loggedin_user->id), $activity->primary_link, $secondary_avatar . bp_core_get_userlink($activity->user_id));
} else {
if ($component == 'groups') {
$group = groups_get_group(array('group_id' => $item_id));
$group_link = '<a href="' . bp_get_group_permalink($group) . '">' . $group->name . '</a>';
if ($activity->type == 'new_forum_topic') {
$action = sprintf(__('%s reshared a <a href="%s">forum topic</a> originally posted by %s in the group %s', 'bp-reshare'), bp_core_get_userlink($bp->loggedin_user->id), $activity->primary_link, $secondary_avatar . bp_core_get_userlink($activity->user_id), $group_link);
} else {
if ($activity->type == 'new_forum_post') {
$action = sprintf(__('%s reshared a <a href="%s">forum reply</a> originally posted by %s in the group %s', 'bp-reshare'), bp_core_get_userlink($bp->loggedin_user->id), $activity->primary_link, $secondary_avatar . bp_core_get_userlink($activity->user_id), $group_link);
} else {
$action = sprintf(__("%s reshared an activity originally shared by %s in the group %s", 'bp-reshare'), bp_core_get_userlink($bp->loggedin_user->id), $secondary_avatar . bp_core_get_userlink($activity->user_id), $group_link);
}
}
}
}
}
} else {
$action = sprintf(__("%s reshared an activity originally shared by %s", 'bp-reshare'), bp_core_get_userlink($bp->loggedin_user->id), $secondary_avatar . bp_core_get_userlink($activity->user_id));
}
$reshared_args = array('action' => apply_filters('bp_reshare_action_parent_activity', $action, $activity->type), 'content' => $activity->content, 'component' => $component, 'type' => 'reshare_update', 'user_id' => $bp->loggedin_user->id, 'secondary_item_id' => $activity_id, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => $activity->hide_sitewide);
if (!empty($item_id)) {
$reshared_args['item_id'] = $item_id;
}
return apply_filters('bp_reshare_prepare_reshare', $reshared_args, $activity_id);
}
开发者ID:KristianI,项目名称:bp-reshare,代码行数:51,代码来源:bp-reshare-functions.php
示例5: bp_activity_action_permalink_router
/**
* Allow core components and dependent plugins to register activity actions
*
* @since BuddyPress (1.2)
*
* @global object $bp BuddyPress global settings
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
* @uses bp_action_variable()
* @uses bp_activity_get_specific()
* @uses bp_is_active()
* @uses bp_core_get_user_domain()
* @uses groups_get_group()
* @uses bp_get_group_permalink()
* @uses apply_filters_ref_array() To call the 'bp_activity_permalink_redirect_url' hook
* @uses bp_core_redirect()
* @uses bp_get_root_domain()
*
* @return bool False on failure
*/
function bp_activity_action_permalink_router()
{
global $bp;
// Not viewing activity
if (!bp_is_activity_component() || !bp_is_current_action('p')) {
return false;
}
// No activity to display
if (!bp_action_variable(0) || !is_numeric(bp_action_variable(0))) {
return false;
}
// Get the activity details
$activity = bp_activity_get_specific(array('activity_ids' => bp_action_variable(0), 'show_hidden' => true));
// 404 if activity does not exist
if (empty($activity['activities'][0])) {
bp_do_404();
return;
} else {
$activity = $activity['activities'][0];
}
// Do not redirect at default
$redirect = false;
// Redirect based on the type of activity
if (bp_is_active('groups') && $activity->component == $bp->groups->id) {
// Activity is a user update
if (!empty($activity->user_id)) {
$redirect = bp_core_get_user_domain($activity->user_id, $activity->user_nicename, $activity->user_login) . bp_get_activity_slug() . '/' . $activity->id . '/';
// Activity is something else
} else {
// Set redirect to group activity stream
if ($group = groups_get_group(array('group_id' => $activity->item_id))) {
$redirect = bp_get_group_permalink($group) . bp_get_activity_slug() . '/' . $activity->id . '/';
}
}
// Set redirect to users' activity stream
} else {
$redirect = bp_core_get_user_domain($activity->user_id, $activity->user_nicename, $activity->user_login) . bp_get_activity_slug() . '/' . $activity->id . '/';
}
// If set, add the original query string back onto the redirect URL
if (!empty($_SERVER['QUERY_STRING'])) {
$query_frags = array();
wp_parse_str($_SERVER['QUERY_STRING'], $query_frags);
$redirect = add_query_arg(urlencode_deep($query_frags), $redirect);
}
// Allow redirect to be filtered
if (!($redirect = apply_filters_ref_array('bp_activity_permalink_redirect_url', array($redirect, &$activity)))) {
bp_core_redirect(bp_get_root_domain());
}
// Redirect to the actual activity permalink page
bp_core_redirect($redirect);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:71,代码来源:bp-activity-actions.php
示例6: bp_reshare_ajax_delete_reshare
function bp_reshare_ajax_delete_reshare()
{
check_ajax_referer('_reshare_delete', 'nonce');
$reshare_id = intval($_POST['activity']);
$reshare_to_delete = bp_activity_get_specific('activity_ids=' . $reshare_id);
$reshare = $reshare_to_delete['activities'][0];
bp_reshare_delete($reshare->secondary_item_id, $reshare->user_id);
$deleted_reshare = bp_activity_delete(array('type' => 'reshare_update', 'id' => $reshare_id));
if ($deleted_reshare) {
echo '1';
} else {
_e('OOps, error while trying to delete your reshare..', 'bp-reshare');
}
die;
}
开发者ID:KristianI,项目名称:bp-reshare,代码行数:15,代码来源:bp-reshare-ajax.php
示例7: bp_reshare_delete_reshare
/**
* let's delete reshare update if js is disabled
*/
function bp_reshare_delete_reshare()
{
if (!empty($_GET['delete_reshare']) && is_numeric($_GET['delete_reshare'])) {
check_admin_referer('_reshare_delete');
$redirect = remove_query_arg(array('delete_reshare', '_wpnonce'), wp_get_referer());
$reshare_id = intval($_GET['delete_reshare']);
$reshare_to_delete = bp_activity_get_specific('activity_ids=' . $reshare_id);
$reshare = $reshare_to_delete['activities'][0];
bp_reshare_delete($reshare->secondary_item_id, $reshare->user_id);
$deleted_reshare = bp_activity_delete(array('type' => 'reshare_update', 'id' => $reshare_id));
if (!empty($deleted_reshare)) {
do_action('bp_reshare_handle_nojs_deleted', $reshare_id);
bp_core_add_message(__('Reshare deleted !', 'bp-reshare'));
bp_core_redirect($redirect);
} else {
do_action('bp_reshare_handle_nojs_missed', $reshare_id);
bp_core_add_message(__('OOps, error while trying to reshare..', 'bp-reshare'), 'error');
bp_core_redirect($redirect);
}
}
}
开发者ID:KristianI,项目名称:bp-reshare,代码行数:24,代码来源:bp-reshare-actions.php
示例8: bp_activity_get_user_favorites
function bp_activity_get_user_favorites( $user_id ) {
$my_favs = maybe_unserialize( get_user_meta( $user_id, 'bp_favorite_activities', true ) );
$existing_favs = bp_activity_get_specific( array( 'activity_ids' => $my_favs ) );
foreach( (array)$existing_favs['activities'] as $fav )
$new_favs[] = $fav->id;
$new_favs = array_unique( (array)$new_favs );
update_user_meta( $user_id, 'bp_favorite_activities', $new_favs );
return apply_filters( 'bp_activity_get_user_favorites', $new_favs );
}
开发者ID:n-sane,项目名称:zaroka,代码行数:12,代码来源:bp-activity.php
示例9: bp_dtheme_get_single_activity_content
/**
* Fetches full an activity's full, non-excerpted content via a POST request.
* Used for the 'Read More' link on long activity items.
*
* @return string HTML
* @since BuddyPress (1.5)
*/
function bp_dtheme_get_single_activity_content()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
$activity_array = bp_activity_get_specific(array('activity_ids' => $_POST['activity_id'], 'display_comments' => 'stream'));
$activity = !empty($activity_array['activities'][0]) ? $activity_array['activities'][0] : false;
if (empty($activity)) {
exit;
}
// @todo: error?
do_action_ref_array('bp_dtheme_get_single_activity_content', array(&$activity));
// Activity content retrieved through AJAX should run through normal filters, but not be truncated
remove_filter('bp_get_activity_content_body', 'bp_activity_truncate_entry', 5);
$content = apply_filters('bp_get_activity_content_body', $activity->content);
exit($content);
}
开发者ID:raminjan,项目名称:logicalbones_hug,代码行数:25,代码来源:ajax.php
示例10: bp_rbe_log_last_activity
/**
* When posting via email, we also update the last activity entries in BuddyPress.
*
* This is so your BuddyPress site doesn't look dormant when your members
* are emailing each other back and forth! :)
*
* @param array $args Depending on the filter that this function is hooked into, contents will vary
* @since 1.0-RC1
*/
function bp_rbe_log_last_activity($args)
{
// get user id from activity entry
if (!empty($args['user_id'])) {
$user_id = $args['user_id'];
} elseif (!empty($args['sender_id'])) {
$user_id = $args['sender_id'];
} else {
$user_id = false;
}
// if no user ID, return now
if (empty($user_id)) {
return;
}
// update user's last activity
bp_update_user_last_activity($user_id);
// now update 'last_activity' group meta entry if applicable
if (!empty($args['type'])) {
switch ($args['type']) {
case 'new_forum_topic':
case 'new_forum_post':
case 'bbp_topic_create':
case 'bbp_reply_create':
// sanity check!
if (!bp_is_active('groups')) {
return;
}
groups_update_last_activity($args['item_id']);
break;
// for group activity comments, we have to look up the parent activity to see
// if the activity comment came from a group
// for group activity comments, we have to look up the parent activity to see
// if the activity comment came from a group
case 'activity_comment':
// we don't need to proceed if the groups component was disabled
if (!bp_is_active('groups')) {
return;
}
// sanity check!
if (!bp_is_active('activity')) {
return;
}
// grab the parent activity
$activity = bp_activity_get_specific('activity_ids=' . $args['item_id']);
if (!empty($activity['activities'][0])) {
$parent_activity = $activity['activities'][0];
// if parent activity update is from the groups component,
// that means the activity comment was in a group!
// so update group 'last_activity' meta entry
if ($parent_activity->component == 'groups') {
groups_update_last_activity($parent_activity->item_id);
}
}
break;
}
}
}
开发者ID:r-a-y,项目名称:bp-reply-by-email,代码行数:66,代码来源:bp-rbe-functions.php
示例11: get_activity_id
/**
* Check for an existing activity stream entry for a given post_id
*
* @param int $post_id ID of the topic or reply
* @uses get_post_meta()
* @uses bp_activity_get_specific()
* @return int if an activity id is verified, false if not
*/
private static function get_activity_id($post_id = 0)
{
// Try to get the activity ID of the post
$activity_id = (int) get_post_meta($post_id, '_bbp_activity_id', true);
// Bail if no activity ID is in post meta
if (empty($activity_id)) {
return null;
}
// Get the activity stream item, bail if it doesn't exist
$existing = bp_activity_get_specific(array('activity_ids' => $activity_id, 'show_hidden' => true, 'spam' => 'all'));
if (empty($existing['total']) || 1 != $existing['total']) {
return null;
}
// Return the activity ID since we've verified the connection
return $activity_id;
}
开发者ID:hscale,项目名称:webento,代码行数:24,代码来源:activity.php
示例12: get_activity_user_id
/**
* Get the user id associated with a given activity item.
*
* Wraps bp_activity_get_specific(), with some additional logic for
* avoiding duplicate queries.
*
* @since BuddyPress (1.6.0)
*
* @param int $activity_id Activity ID to retrieve User ID for.
*
* @return int User ID of the activity item in question.
*/
protected function get_activity_user_id($activity_id)
{
// If there is an existing activity/user ID mapping, just return the user ID.
if (!empty($this->activity_user_id[$activity_id])) {
return $this->activity_user_id[$activity_id];
/**
* We don't have a mapping. This means the $activity_id is not on the current
* page of results, so fetch its details from the database.
*/
} else {
$activity = bp_activity_get_specific(array('activity_ids' => $activity_id, 'show_hidden' => true, 'spam' => 'all'));
/**
* If, somehow, the referenced activity has been deleted, leaving its associated
* activities as orphans, use the logged in user's ID to avoid errors.
*/
if (empty($activity['activities'])) {
return bp_loggedin_user_id();
}
// Store the new activity/user ID mapping for any later re-use
$this->activity_user_id[$activity['activities'][0]->id] = $activity['activities'][0]->user_id;
// Return the user ID
return $activity['activities'][0]->user_id;
}
}
开发者ID:un1coin,项目名称:ovn-space,代码行数:36,代码来源:bp-activity-admin.php
示例13: bp_dtheme_get_single_activity_content
/**
* AJAX handler for Read More link on long activity items
*
* @package BuddyPress
* @since 1.5
*/
function bp_dtheme_get_single_activity_content()
{
$activity_array = bp_activity_get_specific(array('activity_ids' => $_POST['activity_id'], 'display_comments' => 'stream'));
$activity = !empty($activity_array['activities'][0]) ? $activity_array['activities'][0] : false;
if (!$activity) {
exit;
}
// todo: error?
// Activity content retrieved through AJAX should run through normal filters, but not be
// truncated
remove_filter('bp_get_activity_content_body', 'bp_activity_truncate_entry', 5);
$content = apply_filters('bp_get_activity_content_body', $activity->content);
echo $content;
exit;
}
开发者ID:hscale,项目名称:webento,代码行数:21,代码来源:ajax.php
示例14: __construct
function __construct($page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude = false, $in = false)
{
global $bp;
$this->pag_page = isset($_REQUEST['acpage']) ? intval($_REQUEST['acpage']) : $page;
$this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page;
// Check if blog/forum replies are disabled
$this->disable_blogforum_replies = isset($bp->site_options['bp-disable-blogforum-comments']) ? $bp->site_options['bp-disable-blogforum-comments'] : false;
// Get an array of the logged in user's favorite activities
$this->my_favs = maybe_unserialize(bp_get_user_meta($bp->loggedin_user->id, 'bp_favorite_activities', true));
// Fetch specific activity items based on ID's
if (!empty($include)) {
$this->activities = bp_activity_get_specific(array('activity_ids' => explode(',', $include), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments, 'show_hidden' => $show_hidden));
} else {
$this->activities = bp_activity_get(array('display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden, 'exclude' => $exclude, 'in' => $in));
}
if (!$max || $max >= (int) $this->activities['total']) {
$this->total_activity_count = (int) $this->activities['total'];
} else {
$this->total_activity_count = (int) $max;
}
$this->activities = $this->activities['activities'];
if ($max) {
if ($max >= count($this->activities)) {
$this->activity_count = count($this->activities);
} else {
$this->activity_count = (int) $max;
}
} else {
$this->activity_count = count($this->activities);
}
$this->full_name = $bp->displayed_user->fullname;
// Fetch parent content for activity comments so we do not have to query in the loop
foreach ((array) $this->activities as $activity) {
if ('activity_comment' != $activity->type) {
continue;
}
$parent_ids[] = $activity->item_id;
}
if (!empty($parent_ids)) {
$activity_parents = bp_activity_get_specific(array('activity_ids' => $parent_ids));
}
if (!empty($activity_parents['activities'])) {
foreach ($activity_parents['activities'] as $parent) {
$this->activity_parents[$parent->id] = $parent;
}
unset($activity_parents);
}
if ((int) $this->total_activity_count && (int) $this->pag_num) {
$this->pag_links = paginate_links(array('base' => add_query_arg('acpage', '%#%'), 'format' => '', 'total' => ceil((int) $this->total_activity_count / (int) $this->pag_num), 'current' => (int) $this->pag_page, 'prev_text' => _x('←', 'Activity pagination previous text', 'buddypress'), 'next_text' => _x('→', 'Activity pagination next text', 'buddypress'), 'mid_size' => 1));
}
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:51,代码来源:bp-activity-template.php
示例15: bp_legacy_theme_get_single_activity_content
/**
* Fetches an activity's full, non-excerpted content via a POST request.
* Used for the 'Read More' link on long activity items.
*
* @return string HTML
* @since BuddyPress (1.5)
*/
function bp_legacy_theme_get_single_activity_content()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
$activity_array = bp_activity_get_specific(array('activity_ids' => $_POST['activity_id'], 'display_comments' => 'stream'));
$activity = !empty($activity_array['activities'][0]) ? $activity_array['activities'][0] : false;
if (empty($activity)) {
exit;
}
// @todo: error?
/**
* Fires before the return of an activity's full, non-excerpted content via a POST request.
*
* @since BuddyPress (1.7.0)
*
* @param string $activity Activity content. Passed by reference.
*/
do_action_ref_array('bp_legacy_theme_get_single_activity_content', array(&$activity));
// Activity content retrieved through AJAX should run through normal filters, but not be truncated
remove_filter('bp_get_activity_content_body', 'bp_activity_truncate_entry', 5);
/** This filter is documented in bp-activity/bp-activity-template.php */
$content = apply_filters('bp_get_activity_content_body', $activity->content);
exit($content);
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:33,代码来源:buddypress-functions.php
示例16: bp_like_button
/**
* bp_like_button()
*
* Outputs the 'Like/Unlike' and 'View likes/Hide likes' buttons.
*
*/
function bp_like_button($id = '', $type = '')
{
$users_who_like = 0;
$liked_count = 0;
/* Set the type if not already set, and check whether we are outputting the button on a blogpost or not. */
if (!$type && !is_single()) {
$type = 'activity';
} elseif (!$type && is_single()) {
$type = 'blogpost';
}
if ($type == 'activity') {
$activity = bp_activity_get_specific(array('activity_ids' => bp_get_activity_id()));
$activity_type = $activity['activities'][0]->type;
if (is_user_logged_in() && $activity_type !== 'activity_liked') {
if (bp_activity_get_meta(bp_get_activity_id(), 'liked_count', true)) {
$users_who_like = array_keys(bp_activity_get_meta(bp_get_activity_id(), 'liked_count', true));
$liked_count = count($users_who_like);
}
if (!bp_like_is_liked(bp_get_activity_id(), 'activity')) {
?>
<a href="#" class="like" id="like-activity-<?php
bp_activity_id();
?>
" title="<?php
echo bp_like_get_text('like_this_item');
?>
"><?php
echo bp_like_get_text('like');
if ($liked_count) {
echo ' (' . $liked_count . ')';
}
?>
</a>
<?php
} else {
?>
<a href="#" class="unlike" id="unlike-activity-<?php
bp_activity_id();
?>
" title="<?php
echo bp_like_get_text('unlike_this_item');
?>
"><?php
echo bp_like_get_text('unlike');
if ($liked_count) {
echo ' (' . $liked_count . ')';
}
?>
</a>
<?php
}
if ($users_who_like) {
?>
<a href="#" class="view-likes" id="view-likes-<?php
bp_activity_id();
?>
"><?php
echo bp_like_get_text('view_likes');
?>
</a>
<p class="users-who-like" id="users-who-like-<?php
bp_activity_id();
?>
"></p>
<?php
}
}
} elseif ($type == 'blogpost') {
global $post;
if (!$id && is_single()) {
$id = $post->ID;
}
if (is_user_logged_in() && get_post_meta($id, 'liked_count', true)) {
$liked_count = count(get_post_meta($id, 'liked_count', true));
}
if (!bp_like_is_liked($id, 'blogpost')) {
?>
<div class="like-box"><a href="#" class="like_blogpost" id="like-blogpost-<?php
echo $id;
?>
" title="<?php
echo bp_like_get_text('like_this_item');
?>
"><?php
echo bp_like_get_text('like');
if ($liked_count) {
echo ' (' . $liked_count . ')';
}
?>
</a></div>
<?php
} else {
//.........这里部分代码省略.........
开发者ID:Nightgunner5,项目名称:Pubcomp-CMS,代码行数:101,代码来源:bp-like.php
示例17: bp_activity_screen_single_activity_permalink
/**
* Reset the logged-in user's new mentions data when he visits his mentions screen
*
* @since BuddyPress (1.2)
*
* @global object $bp BuddyPress global settings
* @uses bp_is_activity_component()
* @uses bp_activity_get_specific()
* @uses bp_current_action()
* @uses bp_action_variables()
* @uses bp_do_404()
* @uses bp_is_active()
* @uses groups_get_group()
* @uses groups_is_user_member()
* @uses apply_filters_ref_array() To call the 'bp_activity_permalink_access' hook
* @uses do_action() To call the 'bp_activity_screen_single_activity_permalink' hook
* @uses bp_core_add_message()
* @uses is_user_logged_in()
* @uses bp_core_redirect()
* @uses site_url()
* @uses esc_url()
* @uses bp_get_root_domain()
* @uses bp_get_activity_root_slug()
* @uses bp_core_load_template()
* @uses apply_filters() To call the 'bp_activity_template_profile_activity_permalink' hook
*/
function bp_activity_screen_single_activity_permalink()
{
global $bp;
// No displayed user or not viewing activity component
if (!bp_is_activity_component()) {
return false;
}
if (!bp_current_action() || !is_numeric(bp_current_action())) {
return false;
}
// Get the activity details
$activity = bp_activity_get_specific(array('activity_ids' => bp_current_action(), 'show_hidden' => true, 'spam' => 'ham_only'));
// 404 if activity does not exist
if (empty($activity['activities'][0]) || bp_action_variables()) {
bp_do_404();
return;
} else {
$activity = $activity['activities'][0];
}
// Default access is true
$has_access = true;
// If activity is from a group, do an extra cap check
if (isset($bp->groups->id) && $activity->component == $bp->groups->id) {
// Activity is from a group, but groups is currently disabled
if (!bp_is_active('groups')) {
bp_do_404();
return;
}
// Check to see if the group is not public, if so, check the
// user has access to see this activity
if ($group = groups_get_group(array('group_id' => $activity->item_id))) {
// Group is not public
if ('public' != $group->status) {
// User is not a member of group
if (!groups_is_user_member(bp_loggedin_user_id(), $group->id)) {
$has_access = false;
}
}
}
}
// Allow access to be filtered
$has_access = apply_filters_ref_array('bp_activity_permalink_access', array($has_access, &$activity));
// Allow additional code execution
do_action('bp_activity_screen_single_activity_permalink', $activity, $has_access);
// Access is specifically disallowed
if (false === $has_access) {
// User feedback
bp_core_add_message(__('You do not have access to this activity.', 'buddypress'), 'error');
// Redirect based on logged in status
is_user_logged_in() ? bp_core_redirect(bp_loggedin_user_domain()) : bp_core_redirect(site_url('wp-login.php?redirect_to=' . esc_url(bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . bp_current_action() . '/')));
}
bp_core_load_template(apply_filters('bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink'));
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:79,代码来源:bp-activity-screens.php
示例18: buddyreshare_remove_reshare
/**
* Catches a reshare to delete 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_activity_get_specific() to fetch the activity to delete
* @uses bp_do_404() to eventually send the user on a 404
* @uses bp_core_get_user_domain() to build user's url
* @uses bp_get_activity_slug() to get activity slug
* @uses buddyreshare_reset_metas() to reset some metas for the parent activity
* @uses bp_core_add_message() to print a warning message
* @uses bp_core_redirect() to safely redirect user
* @uses bp_activity_delete() to delete the reshare
*/
function buddyreshare_remove_reshare()
{
// Not deleting a reshare
if (!bp_is_activity_component() || !bp_is_current_action(buddyreshare_get_component_slug())) {
return false;
}
// No reshare to delete
if (!bp_action_variable(0) || bp_action_variable(0) != 'delete' || !bp_action_variable(1) || !is_numeric(bp_action_variable(1))) {
return false;
}
$reshare_id = bp_action_variable(1);
check_admin_referer('buddyreshare_delete');
// Get the activity details
$activity = bp_activity_get_specific(array('activity_ids' => bp_action_variable(1), 'show_hidden' => true));
// 404 if activity does not exist
if (empty($activity['activities'][0])) {
bp_do_404();
return;
} else {
$reshare = $activity['activities'][0];
}
// redirecting to user's profile
$redirect = bp_core_get_user_domain($reshare->user_id, $reshare->user_nicename, $reshare->user_login) . bp_get_activity_slug() . '/';
$reset = buddyreshare_reset_metas($reshare->secondary_item_id, $reshare->user_id);
if (empty($reset)) {
bp_core_add_message(__('Unable to reset the properties of the reshared activity', 'bp-reshare'), 'error');
bp_core_redirect($redirect);
}
$deleted_reshare = bp_activity_delete(array('type' => 'reshare_update', 'id' => $reshare_id));
if (!empty($deleted_reshare)) {
do_action('buddyreshare_reshare_deleted', $reshare_id);
bp_core_add_message(__('Reshare deleted !', 'bp-reshare'));
bp_core_redirect($redirect);
} else {
do_action('buddyreshare_reshare_deleted_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,代码行数:59,代码来源:actions.php
示例19: wangguard_bp_report_button
/**
* Hook to insert the report user on BP blog post and activity
*
* @global type $l10n
* @global type $post
* @param type $id
*
|
请发表评论