Esempio n. 1
0
function bp_dtheme_activity_template_loader()
{
    global $bp;
    $scope = '';
    if (!empty($_POST['scope'])) {
        $scope = $_POST['scope'];
    }
    // We need to calculate and return the feed URL for each scope
    switch ($scope) {
        case 'friends':
            $feed_url = $bp->loggedin_user->domain . bp_get_activity_slug() . '/friends/feed/';
            break;
        case 'groups':
            $feed_url = $bp->loggedin_user->domain . bp_get_activity_slug() . '/groups/feed/';
            break;
        case 'favorites':
            $feed_url = $bp->loggedin_user->domain . bp_get_activity_slug() . '/favorites/feed/';
            break;
        case 'mentions':
            $feed_url = $bp->loggedin_user->domain . bp_get_activity_slug() . '/mentions/feed/';
            bp_activity_clear_new_mentions($bp->loggedin_user->id);
            break;
        default:
            $feed_url = home_url(bp_get_activity_root_slug() . '/feed/');
            break;
    }
    /* Buffer the loop in the template to a var for JS to spit out. */
    ob_start();
    gconnect_locate_template(array('activity/activity-loop.php'), true);
    $result['contents'] = ob_get_contents();
    $result['feed_url'] = apply_filters('bp_dtheme_activity_feed_url', $feed_url, $scope);
    ob_end_clean();
    echo json_encode($result);
}
/**
 * Load the activity loop template when activity is requested via AJAX,
 *
 * @return string JSON object containing 'contents' (output of the template loop
 * for the Activity component) and 'feed_url' (URL to the relevant RSS feed).
 *
 * @since BuddyPress (1.2)
 */
function bp_legacy_theme_activity_template_loader()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    $scope = '';
    if (!empty($_POST['scope'])) {
        $scope = $_POST['scope'];
    }
    // We need to calculate and return the feed URL for each scope
    switch ($scope) {
        case 'friends':
            $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/friends/feed/';
            break;
        case 'groups':
            $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/groups/feed/';
            break;
        case 'favorites':
            $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
            break;
        case 'mentions':
            $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
            bp_activity_clear_new_mentions(bp_loggedin_user_id());
            break;
        default:
            $feed_url = home_url(bp_get_activity_root_slug() . '/feed/');
            break;
    }
    // Buffer the loop in the template to a var for JS to spit out.
    ob_start();
    bp_get_template_part('activity/activity-loop');
    $result['contents'] = ob_get_contents();
    /**
     * Filters the feed URL for when activity is requested via AJAX.
     *
     * @since BuddyPress (1.7.0)
     *
     * @param string $feed_url URL for the feed to be used.
     * @param string $scope    Scope for the activity request.
     */
    $result['feed_url'] = apply_filters('bp_legacy_theme_activity_feed_url', $feed_url, $scope);
    ob_end_clean();
    exit(json_encode($result));
}
/**
 * Reset the logged-in user's new mentions data when he visits his mentions screen.
 *
 * @since 1.5.0
 *
 * @uses bp_is_my_profile()
 * @uses bp_activity_clear_new_mentions()
 * @uses bp_loggedin_user_id()
 */
function bp_activity_reset_my_new_mentions()
{
    if (bp_is_my_profile()) {
        bp_activity_clear_new_mentions(bp_loggedin_user_id());
    }
}
Esempio n. 4
0
/**
 * Load the activity loop template when activity is requested via AJAX,
 *
 * @return string JSON object containing 'contents' (output of the template loop for the Activity component) and 'feed_url' (URL to the relevant RSS feed).
 * @since BuddyPress (1.2)
 */
function bp_dtheme_activity_template_loader()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    $scope = '';
    if (!empty($_POST['scope'])) {
        $scope = $_POST['scope'];
    }
    // We need to calculate and return the feed URL for each scope
    switch ($scope) {
        case 'friends':
            $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/friends/feed/';
            break;
        case 'groups':
            $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/groups/feed/';
            break;
        case 'favorites':
            $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
            break;
        case 'mentions':
            $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
            bp_activity_clear_new_mentions(bp_loggedin_user_id());
            break;
        default:
            $feed_url = home_url(bp_get_activity_root_slug() . '/feed/');
            break;
    }
    // Buffer the loop in the template to a var for JS to spit out.
    ob_start();
    locate_template(array('activity/activity-loop.php'), true);
    $result['contents'] = ob_get_contents();
    $result['feed_url'] = apply_filters('bp_dtheme_activity_feed_url', $feed_url, $scope);
    ob_end_clean();
    exit(json_encode($result));
}
function bpcustom_activity_template_loader()
{
    global $bp;
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    bpcustom_setup_components();
    $action = bpcustom_get_current_action();
    $scope = $action;
    // We need to calculate and return the feed URL for each scope
    switch ($scope) {
        case 'friends':
            $feed_url = $bp->loggedin_user->domain . bp_get_activity_slug() . '/friends/feed/';
            break;
        case 'groups':
            $feed_url = $bp->loggedin_user->domain . bp_get_activity_slug() . '/groups/feed/';
            break;
        case 'favorites':
            $feed_url = $bp->loggedin_user->domain . bp_get_activity_slug() . '/favorites/feed/';
            break;
        case 'mentions':
            $feed_url = $bp->loggedin_user->domain . bp_get_activity_slug() . '/mentions/feed/';
            bp_activity_clear_new_mentions($bp->loggedin_user->id);
            break;
        default:
            $feed_url = home_url(bp_get_activity_root_slug() . '/feed/');
            break;
    }
    /* Buffer the loop in the template to a var for JS to spit out. */
    ob_start();
    locate_template(array('members/single/activity.php'), true);
    $result = array();
    $result['contents'] = ob_get_contents();
    $result['feed_url'] = apply_filters('bp_dtheme_activity_feed_url', $feed_url, $scope);
    ob_end_clean();
    echo json_encode($result);
}
Esempio n. 6
0
 /**
  * @group bp_activity_remove_screen_notifications
  * @group mentions
  * @ticket BP6687
  */
 public function test_bp_activity_remove_screen_notifications_on_new_mentions_cleared()
 {
     $this->create_notifications();
     $notifications = BP_Notifications_Notification::get(array('item_id' => $this->a1));
     // Double check it's there
     $this->assertEquals(array($this->a1), wp_list_pluck($notifications, 'item_id'));
     $this->assertEquals(1, bp_get_total_mention_count_for_user($this->u1));
     // Clear notifications for $this->u1
     bp_activity_clear_new_mentions($this->u1);
     $notifications = BP_Notifications_Notification::get(array('item_id' => $this->a1));
     $this->assertEmpty($notifications, 'Notifications should be cleared when new mention metas are removed');
     $this->assertEmpty(bp_get_total_mention_count_for_user($this->u1));
 }