Exemplo n.º 1
0
>

<channel>
	<title><?php 
echo $bp->links->current_link->name;
?>
 - <?php 
_e('Link Activity', 'buddypress-links');
?>
</title>
	<atom:link href="<?php 
self_link();
?>
" rel="self" type="application/rss+xml" />
	<link><?php 
echo bp_get_link_permalink($bp->links->current_link) . $bp->activity->slug . '/feed';
?>
</link>
	<description><?php 
printf(__('%s - Link Activity Feed', 'buddypress-links'), $bp->links->current_link->name);
?>
</description>
	<pubDate><?php 
echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false);
?>
</pubDate>
	<generator>http://buddypress.org/?v=<?php 
echo BP_VERSION;
?>
</generator>
	<language><?php 
Exemplo n.º 2
0
function bp_get_link_activity_feed_link()
{
    global $bp;
    return apply_filters('bp_get_link_activity_feed_link', bp_get_link_permalink($bp->links->current_link) . '/feed/');
}
Exemplo n.º 3
0
/**
 * Cast a user vote for a link
 * 
 * Returns a BP_Links_Link object on successful vote
 * in case you need immediate access to the link data
 *
 * @see BP_Links_Link
 * @param integer $link_id
 * @param string $up_or_down "up" or "down"
 * @return BP_Links_Link|false
 */
function bp_links_cast_vote($link_id, $up_or_down)
{
    global $bp;
    $bp->links->current_link = new BP_Links_Link($link_id, true);
    if (false === bp_links_is_link_visibile($bp->links->current_link)) {
        return false;
    }
    $vote = $bp->links->current_link->vote();
    if (!$vote instanceof BP_Links_Vote) {
        return false;
    }
    // determine if member has voted for this link already
    $is_first_vote = is_numeric($vote->vote) ? false : true;
    // the default behavior is to allow members to change their vote,
    // which can be overriden with the configuration constant you see passed
    // to the filter below. use this filter to override the `configured` behavior
    // for special circumstances. you must return a boolean value!
    $allow_change = (bool) apply_filters('bp_links_cast_vote_allow_change', (bool) BP_LINKS_VOTE_ALLOW_CHANGE, $vote);
    // member can vote if its first time, or they are allowed to change vote
    if ($is_first_vote || $allow_change) {
        // the default behavior is to record vote activity.
        // this can be overriden with the configuration constant you see below.
        if ((bool) BP_LINKS_VOTE_RECORD_ACTIVITY === true) {
            // the default behavior is to only record activity if this is their
            // original vote. use the filter below to override this behavior.
            // you must return a boolean value!
            $record_activity = (bool) apply_filters('bp_links_cast_vote_record_activity', $is_first_vote, $vote);
        } else {
            // do not record activity per configuration constant
            $record_activity = false;
        }
        switch ($up_or_down) {
            case 'up':
                $vote->up();
                break;
            case 'down':
                $vote->down();
                break;
            default:
                return false;
        }
        if (true === $bp->links->current_link->save()) {
            if ($record_activity) {
                // translate up or down string
                $up_or_down_translated = 'up' == $up_or_down ? __('up', 'buddypress-links') : __('down', 'buddypress-links');
                // record the activity
                $activity_action = sprintf(__('%1$s voted %2$s the link %3$s', 'buddypress-links'), bp_core_get_userlink($bp->loggedin_user->id), $up_or_down_translated, '<a href="' . bp_get_link_permalink($bp->links->current_link) . '">' . attribute_escape($bp->links->current_link->name) . '</a>');
                bp_links_record_activity(array('action' => apply_filters('bp_links_activity_voted', $activity_action), 'primary_link' => apply_filters('bp_links_activity_voted_primary_link', bp_get_link_permalink($bp->links->current_link)), 'type' => BP_LINKS_ACTIVITY_ACTION_VOTE, 'item_id' => $bp->links->current_link->id));
            }
            do_action('bp_links_cast_vote_success', $bp->links->current_link->id);
            // return the link object
            return $bp->links->current_link;
        } else {
            return false;
        }
    } else {
        // member not allowed change vote
        // this is not an error, so return true!
        return true;
    }
}