Пример #1
0
/**
 * Loads the templates for the user's profile reshare tab
 * 
 * @package BP Reshare
 * @since    1.0
 * 
 * @uses  buddyreshare_is_user_profile_reshares() to check we're on a user's profile reshare tab
 * @uses  bp_core_load_template() to load the template
 */
function buddyreshare_screen_user_reshares()
{
    if (!buddyreshare_is_user_profile_reshares()) {
        return;
    }
    do_action('bpuddyreshare_screen_my_reshares');
    bp_core_load_template(apply_filters('buddyreshare_screen_user_reshares', 'members/single/home'));
}
Пример #2
0
/**
 * Catches the activity query string to eventually edit it
 *
 * @package BP Reshare
 * @since    1.0
 * 
 * @param  string $query_string
 * @param  string $object
 * @uses   wp_parse_args() to merge user's args with defaults
 * @uses   buddyreshare_is_user_profile_reshares() to check we're on a user's profile reshare tab
 * @uses   bp_displayed_user_id() to get displayed user's id
 * @uses   bp_loggedin_user_id() to get current user's id
 * @uses   bp_is_user() to check we're on user's profile
 * @return string|array $query_string
 */
function buddyreshare_activity_querystring_filter($query_string, $object)
{
    if ($object != 'activity') {
        return $query_string;
    }
    $r = wp_parse_args($query_string, array('scope' => false, 'action' => false, 'type' => false, 'user_id' => false, 'page' => 1));
    /* global activities */
    if ($r['scope'] == 'reshares' || buddyreshare_is_user_profile_reshares()) {
        $r['user_id'] = bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id();
        $r['action'] = $r['type'] = 'reshare_update';
        $query_string = empty($r) ? $query_string : http_build_query($r);
    }
    /* most reshared */
    if ($r['action'] == 'activity_mostreshared') {
        unset($r['action'], $r['type']);
        // on user's profile, shows the most reshared activities for displayed user
        if (bp_is_user()) {
            $r['user_id'] = bp_displayed_user_id();
        }
        $r['meta_query'] = array(array('key' => 'reshared_count', 'value' => 1, 'type' => 'numeric', 'compare' => '>='));
        $query_string = empty($r) ? $query_string : $r;
    }
    return apply_filters('bp_reshare_activity_querystring_filter', $query_string, $object);
}
Пример #3
0
/**
 * Can this activity be reshared
 *
 * @package BP Reshare
 * @since    1.0
 * 
 * @param  BP_Activity_Activity $activity the activity object
 * @uses   is_user_logged_in() to check we have a logged in user
 * @uses   buddyreshare_activity_types() to get the "resharable" activities
 * @uses   buddyreshare_is_user_profile_reshares() to check for the user reshare tab of his profile
 * @uses   bp_is_my_profile() to check if the displayed profile is the one of the loggedin user
 * @return boolean true|false
 */
function buddyreshare_can_reshare($activity = null)
{
    if (empty($activity)) {
        return false;
    }
    if (!is_user_logged_in()) {
        return false;
    }
    if (!empty($activity->hide_sitewide)) {
        return false;
    }
    if (!in_array($activity->type, buddyreshare_activity_types())) {
        return false;
    }
    if (buddyreshare_is_user_profile_reshares() && !bp_is_my_profile()) {
        return false;
    }
    return true;
}