Ejemplo n.º 1
0
function bp_reshare_notajaxed_feed_url($feed_url)
{
    if ($_COOKIE['bp-activity-scope'] == 'reshares') {
        $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/reshares/feed/';
    }
    return $feed_url;
}
Ejemplo n.º 2
0
 public function test_member_activity_page()
 {
     $url = home_url($this->u->user_nicename) . '/' . bp_get_activity_slug();
     $this->go_to($url);
     $this->assertTrue(bp_is_user());
     $this->assertTrue(bp_is_my_profile());
     $this->assertEquals($this->u->ID, bp_displayed_user_id());
     $this->assertTrue(bp_is_activity_component());
 }
Ejemplo n.º 3
0
function bebop_get_feed_url()
{
    global $this_bp_feed;
    if (!empty($this_bp_feed)) {
        return bp_displayed_user_domain() . bp_get_activity_slug() . '/' . $this_bp_feed;
    } else {
        return false;
    }
}
Ejemplo n.º 4
0
 /**
  * Setup globals
  *
  * The BP_MEMBERS_SLUG constant is deprecated, and only used here for
  * backwards compatibility.
  *
  * @since 1.5
  * @global obj $bp
  */
 function setup_globals()
 {
     global $bp, $current_user, $displayed_user_id;
     // Define a slug, if necessary
     if (!defined('BP_MEMBERS_SLUG')) {
         define('BP_MEMBERS_SLUG', $this->id);
     }
     $globals = array('path' => BP_PLUGIN_DIR, 'slug' => BP_MEMBERS_SLUG, 'root_slug' => isset($bp->pages->members->slug) ? $bp->pages->members->slug : BP_MEMBERS_SLUG, 'has_directory' => true, 'search_string' => __('Search Members...', 'buddypress'));
     parent::setup_globals($globals);
     /** Logged in user ****************************************************/
     // Fetch the full name for the logged in user
     $bp->loggedin_user->fullname = bp_core_get_user_displayname(bp_loggedin_user_id());
     // Hits the DB on single WP installs so get this separately
     $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin(bp_loggedin_user_id());
     // The domain for the user currently logged in. eg: http://domain.com/members/andy
     $bp->loggedin_user->domain = bp_core_get_user_domain(bp_loggedin_user_id());
     // The core userdata of the user who is currently logged in.
     $bp->loggedin_user->userdata = bp_core_get_core_userdata(bp_loggedin_user_id());
     /** Displayed user ****************************************************/
     // The domain for the user currently being displayed
     $bp->displayed_user->domain = bp_core_get_user_domain(bp_displayed_user_id());
     // The core userdata of the user who is currently being displayed
     $bp->displayed_user->userdata = bp_core_get_core_userdata(bp_displayed_user_id());
     // Fetch the full name displayed user
     $bp->displayed_user->fullname = bp_core_get_user_displayname(bp_displayed_user_id());
     /** Profiles Fallback *************************************************/
     if (!bp_is_active('xprofile')) {
         $bp->profile->slug = 'profile';
         $bp->profile->id = 'profile';
     }
     /** Default Profile Component *****************************************/
     if (!defined('BP_DEFAULT_COMPONENT')) {
         if (bp_is_active('activity') && isset($bp->pages->activity)) {
             $bp->default_component = bp_get_activity_slug();
         } else {
             $bp->default_component = 'xprofile' == $bp->profile->id ? 'profile' : $bp->profile->id;
         }
     } else {
         $bp->default_component = BP_DEFAULT_COMPONENT;
     }
     if (!bp_current_component() && bp_displayed_user_id()) {
         /**
          * BuddyPress will attempt to resolve to the most specific URL possible,
          * to avoid search-engine-unfriendly content reduplication. Filter
          * bp_guarantee_unique_uris (and return false) to avoid this behavior
          */
         if (apply_filters('bp_guarantee_unique_uris', true)) {
             bp_core_redirect(bp_displayed_user_domain() . $bp->default_component);
         } else {
             $bp->current_component = $bp->default_component;
         }
     }
 }
Ejemplo n.º 5
0
/**
 * 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);
}
Ejemplo n.º 6
0
 /**
  * Setup globals
  *
  * The BP_MEMBERS_SLUG constant is deprecated, and only used here for
  * backwards compatibility.
  *
  * @since 1.5
  * @global obj $bp
  */
 function setup_globals()
 {
     global $bp, $current_user, $displayed_user_id;
     // Define a slug, if necessary
     if (!defined('BP_MEMBERS_SLUG')) {
         define('BP_MEMBERS_SLUG', $this->id);
     }
     $globals = array('path' => BP_PLUGIN_DIR, 'slug' => BP_MEMBERS_SLUG, 'root_slug' => isset($bp->pages->members->slug) ? $bp->pages->members->slug : BP_MEMBERS_SLUG, 'has_directory' => true, 'search_string' => __('Search Members...', 'buddypress'));
     parent::setup_globals($globals);
     /** Logged in user ****************************************************/
     // Fetch the full name for the logged in user
     $bp->loggedin_user->fullname = bp_core_get_user_displayname($bp->loggedin_user->id);
     // Hits the DB on single nxt installs so get this separately
     $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin();
     // The domain for the user currently logged in. eg: http://domain.com/members/andy
     $bp->loggedin_user->domain = bp_core_get_user_domain($bp->loggedin_user->id);
     // The core userdata of the user who is currently logged in.
     $bp->loggedin_user->userdata = bp_core_get_core_userdata($bp->loggedin_user->id);
     /** Displayed user ****************************************************/
     // The user id of the user currently being viewed:
     // $bp->displayed_user->id is set in /bp-core/bp-core-catchuri.php
     if (empty($bp->displayed_user->id)) {
         $bp->displayed_user->id = 0;
     }
     // The domain for the user currently being displayed
     $bp->displayed_user->domain = bp_core_get_user_domain($bp->displayed_user->id);
     // The core userdata of the user who is currently being displayed
     $bp->displayed_user->userdata = bp_core_get_core_userdata($bp->displayed_user->id);
     // Fetch the full name displayed user
     $bp->displayed_user->fullname = bp_core_get_user_displayname($bp->displayed_user->id);
     /** Profiles Fallback *************************************************/
     if (!bp_is_active('xprofile')) {
         $bp->profile->slug = 'profile';
         $bp->profile->id = 'profile';
     }
     /** Default Profile Component *****************************************/
     if (!defined('BP_DEFAULT_COMPONENT')) {
         if (bp_is_active('activity') && isset($bp->pages->activity)) {
             $bp->default_component = bp_get_activity_slug();
         } else {
             $bp->default_component = 'xprofile' == $bp->profile->id ? 'profile' : $bp->profile->id;
         }
     } else {
         $bp->default_component = BP_DEFAULT_COMPONENT;
     }
     if (!$bp->current_component && $bp->displayed_user->id) {
         $bp->current_component = $bp->default_component;
     }
 }
Ejemplo n.º 7
0
function bp_reshare_type_tabs()
{
    ?>
	<li id="activity-reshares"><a href="<?php 
    echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/reshares/';
    ?>
" title="<?php 
    _e('Activity that I have reshared.', 'bp-reshare');
    ?>
"><?php 
    _e('Reshares', 'bp-reshare');
    ?>
 <strong><?php 
    printf(__('<span>%s</span>', 'bp-reshare'), bp_reshare_get_total_reshare_count_for_user(bp_loggedin_user_id()));
    ?>
</strong></a></li>
	<?php 
}
 public function test_user_has_access_false_user_logged_in_others_profile_default_component_not_accessible()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $old_current_user = get_current_user_id();
     $this->set_current_user($u1);
     $this->go_to(bp_core_get_user_domain($u2));
     $old_bp_nav = buddypress()->bp_nav;
     $old_default_component = buddypress()->default_component;
     buddypress()->default_component = 'foo';
     buddypress()->bp_nav = array('foo' => array('show_for_displayed_user' => false));
     $subnav_item = array('user_has_access' => false);
     // Just test relevant info
     $found = bp_core_maybe_hook_new_subnav_screen_function($subnav_item);
     $this->assertSame('failure', $found['status']);
     $this->assertSame(bp_core_get_user_domain($u2) . bp_get_activity_slug() . '/', $found['redirect_args']['root']);
     // Clean up
     $this->set_current_user($old_current_user);
     buddypress()->default_component = $old_default_component;
     buddypress()->bp_nav = $old_bp_nav;
 }
Ejemplo n.º 9
0
function my_nav_menu_profile_link($menu)
{
    if (!is_user_logged_in()) {
        return $menu . '<li class="menu-item menu-item-type-post_type menu-item-object-page"><a title="Вход/Регистрация" href="' . wp_login_url(get_site_url()) . '">Вход/Регистрация</a></li>';
    } else {
        $profileextras = '<li id="menu-item" class="menu-item menu-item-type-post_type menu-item-object-page"><a title="Активност" href="' . get_site_url() . '/activity' . '">Активност</a></li>
                <li class="menu-item menu-item-type-post_type menu-item-object-page"><a data-toggle="dropdown"  class="dropdown-toggle" href="#">' . __('Моят профил') . '   <span class="glyphicon glyphicon-menu-down" aria-hidden="true"></span>' . '</a>
                <ul role="menu" class=" dropdown-menu">
                  <li id="menu-item" class="menu-item menu-item-type-post_type menu-item-object-page"><a title="Профил" href="' . bp_loggedin_user_domain('/') . '">Профил</a></li>
                  <li id="menu-item" class="menu-item menu-item-type-post_type menu-item-object-page"><a title="Съобщения" href="' . bp_loggedin_user_domain('/') . 'messages/' . '">Съобщения</a></li>
                  <li id="menu-item" class="menu-item menu-item-type-post_type menu-item-object-page"><a title="Моите пиеси" href="' . get_site_url() . '/my-plays/' . '">Моите пиеси</a></li>
                  <li id="menu-item" class="menu-item menu-item-type-post_type menu-item-object-page"><a title="Приятели" href="' . bp_loggedin_user_domain('/') . 'friends/' . '">Приятели</a></li>
                  <li id="menu-item" class="menu-item menu-item-type-post_type menu-item-object-page"><a title="Споменавания" href="' . bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/' . '">Споменавания</a></li>
                  <li id="menu-item" class="menu-item menu-item-type-post_type menu-item-object-page"><a title="Изход" href="' . wp_logout_url(get_site_url()) . '">Изход</a></li>
                </ul>
                </li>';
    }
    $menu = $menu . $profileextras;
    return $menu;
}
Ejemplo n.º 10
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_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));
}
/**
 * Format notifications related to activity.
 *
 * @since 1.5.0
 *
 * @uses bp_loggedin_user_domain()
 * @uses bp_get_activity_slug()
 * @uses bp_core_get_user_displayname()
 * @uses apply_filters() To call the 'bp_activity_multiple_at_mentions_notification' hook.
 * @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook.
 * @uses do_action() To call 'activity_format_notifications' hook.
 *
 * @param string $action            The type of activity item. Just 'new_at_mention' for now.
 * @param int    $item_id           The activity ID.
 * @param int    $secondary_item_id In the case of at-mentions, this is the mentioner's ID.
 * @param int    $total_items       The total number of notifications to format.
 * @param string $format            'string' to get a BuddyBar-compatible notification, 'array' otherwise.
 * @return string $return Formatted @mention notification.
 */
function bp_activity_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
{
    switch ($action) {
        case 'new_at_mention':
            $activity_id = $item_id;
            $poster_user_id = $secondary_item_id;
            $at_mention_link = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';
            $at_mention_title = sprintf(__('@%s Mentions', 'buddypress'), bp_get_loggedin_user_username());
            $amount = 'single';
            if ((int) $total_items > 1) {
                $text = sprintf(__('You have %1$d new mentions', 'buddypress'), (int) $total_items);
                $amount = 'multiple';
            } else {
                $user_fullname = bp_core_get_user_displayname($poster_user_id);
                $text = sprintf(__('%1$s mentioned you', 'buddypress'), $user_fullname);
            }
            break;
    }
    if ('string' == $format) {
        /**
         * Filters the @mention notification for the string format.
         *
         * This is a variable filter that is dependent on how many items
         * need notified about. The two possible hooks are bp_activity_single_at_mentions_notification
         * or bp_activity_multiple_at_mentions_notification.
         *
         * @since 1.5.0
         *
         * @param string $string          HTML anchor tag for the mention.
         * @param string $at_mention_link The permalink for the mention.
         * @param int    $total_items     How many items being notified about.
         * @param int    $activity_id     ID of the activity item being formatted.
         * @param int    $poster_user_id  ID of the user posting the mention.
         */
        $return = apply_filters('bp_activity_' . $amount . '_at_mentions_notification', '<a href="' . esc_url($at_mention_link) . '" title="' . esc_attr($at_mention_title) . '">' . esc_html($text) . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id);
    } else {
        /**
         * Filters the @mention notification for any non-string format.
         *
         * This is a variable filter that is dependent on how many items need notified about.
         * The two possible hooks are bp_activity_single_at_mentions_notification
         * or bp_activity_multiple_at_mentions_notification.
         *
         * @since 1.5.0
         *
         * @param array  $array           Array holding the content and permalink for the mention notification.
         * @param string $at_mention_link The permalink for the mention.
         * @param int    $total_items     How many items being notified about.
         * @param int    $activity_id     ID of the activity item being formatted.
         * @param int    $poster_user_id  ID of the user posting the mention.
         */
        $return = apply_filters('bp_activity_' . $amount . '_at_mentions_notification', array('text' => $text, 'link' => $at_mention_link), $at_mention_link, (int) $total_items, $activity_id, $poster_user_id);
    }
    /**
     * Fires right before returning the formatted activity notifications.
     *
     * @since 1.2.0
     *
     * @param string $action            The type of activity item.
     * @param int    $item_id           The activity ID.
     * @param int    $secondary_item_id @mention mentioner ID.
     * @param int    $total_items       Total amount of items to format.
     */
    do_action('activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items);
    return $return;
}
Ejemplo n.º 12
0
function groups_screen_group_activity_permalink()
{
    global $bp;
    if (!bp_is_groups_component() || !bp_is_active('activity') || bp_is_active('activity') && !bp_is_current_action(bp_get_activity_slug()) || !bp_action_variable(0)) {
        return false;
    }
    $bp->is_single_item = true;
    bp_core_load_template(apply_filters('groups_template_group_home', 'groups/single/home'));
}
Ejemplo n.º 13
0
/**
 * Handle the display of a single group activity item.
 */
function groups_screen_group_activity_permalink()
{
    if (!bp_is_groups_component() || !bp_is_active('activity') || bp_is_active('activity') && !bp_is_current_action(bp_get_activity_slug()) || !bp_action_variable(0)) {
        return false;
    }
    buddypress()->is_single_item = true;
    /** This filter is documented in bp-groups/bp-groups-screens.php */
    bp_core_load_template(apply_filters('groups_template_group_home', 'groups/single/home'));
}
Ejemplo n.º 14
0
 /**
  * Set up the component entries in the WordPress Admin Bar.
  *
  * @since 1.5.0
  *
  * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
  *      parameter array.
  * @uses is_user_logged_in()
  * @uses trailingslashit()
  * @uses bp_get_total_mention_count_for_user()
  * @uses bp_loggedin_user_id()
  * @uses bp_is_active()
  * @uses bp_get_friends_slug()
  * @uses bp_get_groups_slug()
  *
  * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
  *                            description.
  */
 public function setup_admin_bar($wp_admin_nav = array())
 {
     // Menus for logged in user.
     if (is_user_logged_in()) {
         // Setup the logged in user variables.
         $activity_link = trailingslashit(bp_loggedin_user_domain() . bp_get_activity_slug());
         // Unread message count.
         if (bp_activity_do_mentions()) {
             $count = bp_get_total_mention_count_for_user(bp_loggedin_user_id());
             if (!empty($count)) {
                 $title = sprintf(_x('Mentions <span class="count">%s</span>', 'Toolbar Mention logged in user', 'buddypress'), bp_core_number_format($count));
             } else {
                 $title = _x('Mentions', 'Toolbar Mention logged in user', 'buddypress');
             }
         }
         // Add the "Activity" sub menu.
         $wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => _x('Activity', 'My Account Activity sub nav', 'buddypress'), 'href' => $activity_link);
         // Personal.
         $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-personal', 'title' => _x('Personal', 'My Account Activity sub nav', 'buddypress'), 'href' => $activity_link);
         // Mentions.
         if (bp_activity_do_mentions()) {
             $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-mentions', 'title' => $title, 'href' => trailingslashit($activity_link . 'mentions'));
         }
         // Favorite activity items.
         if (bp_activity_can_favorite()) {
             $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-favorites', 'title' => _x('Favorites', 'My Account Activity sub nav', 'buddypress'), 'href' => trailingslashit($activity_link . 'favorites'));
         }
         // Friends?
         if (bp_is_active('friends')) {
             $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-friends', 'title' => _x('Friends', 'My Account Activity sub nav', 'buddypress'), 'href' => trailingslashit($activity_link . bp_get_friends_slug()));
         }
         // Groups?
         if (bp_is_active('groups')) {
             $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-groups', 'title' => _x('Groups', 'My Account Activity sub nav', 'buddypress'), 'href' => trailingslashit($activity_link . bp_get_groups_slug()));
         }
     }
     parent::setup_admin_bar($wp_admin_nav);
 }
Ejemplo n.º 15
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));
}
Ejemplo n.º 16
0
/**
 * Sets the "RSS" feed URL for the tab on the Sitewide Activity page.
 *
 * This occurs when the "Following" tab is clicked on the Sitewide Activity
 * page or when the activity scope is already set to "following".
 *
 * Only do this for BuddyPress 1.8+.
 *
 * @since 1.2.1
 *
 * @author r-a-y
 * @param string $retval The feed URL.
 * @return string The feed URL.
 */
function bp_follow_alter_activity_feed_url($retval)
{
    // only available in BP 1.8+
    if (!class_exists('BP_Activity_Feed')) {
        return $retval;
    }
    // this is done b/c we're filtering 'bp_get_sitewide_activity_feed_link' and
    // we only want to alter the feed link for the "RSS" tab
    if (!defined('DOING_AJAX') && !did_action('bp_before_directory_activity')) {
        return $retval;
    }
    // get the activity scope
    $scope = !empty($_COOKIE['bp-activity-scope']) ? $_COOKIE['bp-activity-scope'] : false;
    if ($scope == 'following' && bp_loggedin_user_id()) {
        $retval = bp_loggedin_user_domain() . bp_get_activity_slug() . '/' . constant('BP_FOLLOWING_SLUG') . '/feed/';
    }
    return $retval;
}
Ejemplo n.º 17
0
?>
">
    <div class="lwa cb-logged-in clearfix">

<?php 
if (class_exists('buddypress')) {
    global $bp;
    $cb_buddypress_current_user_id = $bp->loggedin_user->id;
    if (function_exists('bp_get_groups_root_slug')) {
        $cb_buddypress_user_group_link = bp_loggedin_user_domain() . bp_get_groups_root_slug();
    }
    if (function_exists('bp_get_messages_slug')) {
        $cb_buddypress_user_message_link = bp_loggedin_user_domain() . bp_get_messages_slug();
    }
    if (function_exists('bp_get_activity_slug')) {
        $cb_buddypress_user_activity_link = bp_loggedin_user_domain() . bp_get_activity_slug();
    }
    $cb_buddypress_user_avatar = bp_core_fetch_avatar(array('item_id' => $cb_buddypress_current_user_id, 'type' => 'full', 'width' => 120, 'height' => 120));
    $cb_buddypress_mystery_man = 'mystery-man.jpg';
    $cb_buddypress_avatar_check = strpos($cb_buddypress_user_avatar, $cb_buddypress_mystery_man);
    if ($cb_buddypress_avatar_check === false) {
        $cb_buddypress_final_avatar = $cb_buddypress_user_avatar;
    } else {
        $cb_buddypress_final_avatar = get_avatar($cb_author_id, $size = '150');
    }
    ?>
        
        <div class="cb-header">
                <div class="cb-title"><?php 
    echo $current_user->display_name;
    ?>
Ejemplo n.º 18
0
 /**
  * RSS handler for a user's followed sites.
  *
  * When a user lands on /members/USERNAME/activity/followblogs/feed/, this
  * method generates the RSS feed for their followed sites.
  */
 public static function rss_handler()
 {
     // only available in BP 1.8+
     if (!class_exists('BP_Activity_Feed')) {
         return;
     }
     if (!bp_is_user_activity() || !bp_is_current_action(constant('BP_FOLLOW_BLOGS_USER_ACTIVITY_SLUG')) || !bp_is_action_variable('feed', 0)) {
         return;
     }
     // get blog IDs that the user is following
     $following_ids = bp_get_following_ids(array('follow_type' => 'blogs'));
     // if $following_ids is empty, pass a negative number so no blogs can be found
     $following_ids = empty($following_ids) ? -1 : $following_ids;
     $args = array('user_id' => 0, 'object' => 'blogs', 'primary_id' => $following_ids);
     // setup the feed
     buddypress()->activity->feed = new BP_Activity_Feed(array('id' => 'followedsites', 'title' => sprintf(__('%1$s | %2$s | Followed Site Activity', 'bp-follow'), bp_get_site_name(), bp_get_displayed_user_fullname()), 'link' => trailingslashit(bp_displayed_user_domain() . bp_get_activity_slug() . '/' . constant('BP_FOLLOW_BLOGS_USER_ACTIVITY_SLUG')), 'description' => sprintf(__("Activity feed for sites that %s is following.", 'buddypress'), bp_get_displayed_user_fullname()), 'activity_args' => $args));
 }
Ejemplo n.º 19
0
 /**
  * @group bp_activity_remove_screen_notifications
  * @group mentions
  */
 public function test_bp_activity_remove_screen_notifications_on_mentions_wrong_user()
 {
     $this->create_notifications();
     $notifications = BP_Notifications_Notification::get(array('user_id' => $this->u1));
     // Double check it's there
     $this->assertEquals(array($this->a1), wp_list_pluck($notifications, 'item_id'));
     // Log out
     $this->set_current_user($this->u2);
     // Go to the My Activity page
     $this->go_to(bp_core_get_user_domain($this->u1) . bp_get_activity_slug() . '/mentions/');
     do_action('bp_activity_screen_mentions');
     $notifications = BP_Notifications_Notification::get(array('user_id' => $this->u1));
     // Should be untouched
     $this->assertEquals(array($this->a1), wp_list_pluck($notifications, 'item_id'));
     // clean up
     $this->set_current_user($this->u1);
 }
	<title><?php 
bp_site_name();
?>
 | <?php 
bp_displayed_user_fullname();
?>
 | <?php 
_e('Friends Activity', 'buddypress');
?>
</title>
	<atom:link href="<?php 
self_link();
?>
" rel="self" type="application/rss+xml" />
	<link><?php 
echo bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed';
?>
</link>
	<description><?php 
printf(__('%s - Friends Activity Feed', 'buddypress'), bp_get_displayed_user_fullname());
?>
</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 
	<title><?php 
bp_site_name();
?>
 | <?php 
echo $bp->groups->current_group->name;
?>
 | <?php 
_e('Group Activity', 'buddypress');
?>
</title>
	<atom:link href="<?php 
self_link();
?>
" rel="self" type="application/rss+xml" />
	<link><?php 
echo bp_get_group_permalink($bp->groups->current_group) . bp_get_activity_slug() . '/feed';
?>
</link>
	<description><?php 
printf(__('%s - Group Activity Feed', 'buddypress'), $bp->groups->current_group->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 
Ejemplo n.º 22
0
/**
 * Formats notifications related to activity
 *
 * @since 1.5.0
 *
 * @param string $action The type of activity item. Just 'new_at_mention' for now
 * @param int $item_id The activity id
 * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's id
 * @param int $total_items The total number of notifications to format
 * @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise
 *
 * @global object $bp BuddyPress global settings
 * @uses bp_loggedin_user_domain()
 * @uses bp_get_activity_slug()
 * @uses bp_core_get_user_displayname()
 * @uses apply_filters() To call the 'bp_activity_multiple_at_mentions_notification' hook
 * @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook
 * @uses do_action() To call 'activity_format_notifications' hook
 *
 * @return string $return Formatted @mention notification
 */
function bp_activity_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
{
    global $bp;
    switch ($action) {
        case 'new_at_mention':
            $activity_id = $item_id;
            $poster_user_id = $secondary_item_id;
            $at_mention_link = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';
            $at_mention_title = sprintf(__('@%s Mentions', 'buddypress'), $bp->loggedin_user->userdata->user_nicename);
            if ((int) $total_items > 1) {
                $text = sprintf(__('You have %1$d new activity mentions', 'buddypress'), (int) $total_items);
                $filter = 'bp_activity_multiple_at_mentions_notification';
            } else {
                $user_fullname = bp_core_get_user_displayname($poster_user_id);
                $text = sprintf(__('%1$s mentioned you in an activity update', 'buddypress'), $user_fullname);
                $filter = 'bp_activity_single_at_mentions_notification';
            }
            break;
    }
    if ('string' == $format) {
        $return = apply_filters($filter, '<a href="' . $at_mention_link . '" title="' . $at_mention_title . '">' . $text . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id);
    } else {
        $return = apply_filters($filter, array('text' => $text, 'link' => $at_mention_link), $at_mention_link, (int) $total_items, $activity_id, $poster_user_id);
    }
    do_action('activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items);
    return $return;
}
Ejemplo n.º 23
0
        ?>
"><?php 
        printf(__('My Favorites <span>%s</span>', 'buddypress'), bp_get_total_favorite_count_for_user(bp_loggedin_user_id()));
        ?>
</a></li>

						<?php 
    }
    ?>

						<?php 
    do_action('bp_before_activity_type_tab_mentions');
    ?>

						<li id="activity-mentions"><a href="<?php 
    echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';
    ?>
" title="<?php 
    _e('Activity that I have been mentioned in.', 'buddypress');
    ?>
"><?php 
    _e('Mentions', 'buddypress');
    if (bp_get_total_mention_count_for_user(bp_loggedin_user_id())) {
        ?>
 <strong><?php 
        printf(__('<span>%s new</span>', 'buddypress'), bp_get_total_mention_count_for_user(bp_loggedin_user_id()));
        ?>
</strong><?php 
    }
    ?>
</a></li>
Ejemplo n.º 24
0
/**
 * Add RSS feed support for a user's following activity.
 *
 * eg. example.com/members/USERNAME/activity/following/feed/
 *
 * Only available in BuddyPress 1.8+.
 *
 * @since 1.2.1
 * @author r-a-y
 */
function bp_follow_my_following_feed()
{
    // only available in BP 1.8+
    if (!class_exists('BP_Activity_Feed')) {
        return;
    }
    if (!bp_is_user_activity() || !bp_is_current_action(constant('BP_FOLLOWING_SLUG')) || !bp_is_action_variable('feed', 0)) {
        return false;
    }
    global $bp;
    // setup the feed
    $bp->activity->feed = new BP_Activity_Feed(array('id' => 'myfollowing', 'title' => sprintf(__('%1$s | %2$s | Following Activity', 'bp-follow'), bp_get_site_name(), bp_get_displayed_user_fullname()), 'link' => trailingslashit(bp_displayed_user_domain() . bp_get_activity_slug() . '/' . constant('BP_FOLLOWING_SLUG')), 'description' => sprintf(__("Activity feed for people that %s is following.", 'buddypress'), bp_get_displayed_user_fullname()), 'activity_args' => array('user_id' => bp_get_following_ids(), 'display_comments' => 'threaded')));
}
Ejemplo n.º 25
0
 /**
  * Set up canonical stack for this component.
  *
  * @since BuddyPress (2.1.0)
  */
 public function setup_canonical_stack()
 {
     $bp = buddypress();
     /** Default Profile Component *****************************************/
     if (defined('BP_DEFAULT_COMPONENT') && BP_DEFAULT_COMPONENT) {
         $bp->default_component = BP_DEFAULT_COMPONENT;
     } else {
         if (bp_is_active('activity') && isset($bp->pages->activity)) {
             $bp->default_component = bp_get_activity_slug();
         } else {
             $bp->default_component = 'xprofile' === $bp->profile->id ? 'profile' : $bp->profile->id;
         }
     }
     /** Canonical Component Stack *****************************************/
     if (bp_displayed_user_id()) {
         $bp->canonical_stack['base_url'] = bp_displayed_user_domain();
         if (bp_current_component()) {
             $bp->canonical_stack['component'] = bp_current_component();
         }
         if (bp_current_action()) {
             $bp->canonical_stack['action'] = bp_current_action();
         }
         if (!empty($bp->action_variables)) {
             $bp->canonical_stack['action_variables'] = bp_action_variables();
         }
         // Looking at the single member root/home, so assume the default
         if (!bp_current_component()) {
             $bp->current_component = $bp->default_component;
             // The canonical URL will not contain the default component
         } elseif (bp_is_current_component($bp->default_component) && !bp_current_action()) {
             unset($bp->canonical_stack['component']);
         }
         // if we're on a spammer's profile page, only users with the 'bp_moderate' cap
         // can view subpages on the spammer's profile
         //
         // users without the cap trying to access a spammer's subnav page will get
         // redirected to the root of the spammer's profile page.  this occurs by
         // by removing the component in the canonical stack.
         if (bp_is_user_spammer(bp_displayed_user_id()) && !bp_current_user_can('bp_moderate')) {
             unset($bp->canonical_stack['component']);
         }
     }
 }
Ejemplo n.º 26
0
/**
 * For a given subnav item, either hook the screen function or generate redirect arguments, as necessary.
 *
 * @since BuddyPress (2.1.0)
 *
 * @param array $subnav_item The subnav array added to bp_options_nav in `bp_core_new_subnav_item()`.
 *
 * @return array
 */
function bp_core_maybe_hook_new_subnav_screen_function($subnav_item)
{
    $retval = array('status' => '');
    // Is this accessible by site admins only?
    $site_admin_restricted = false;
    if (!empty($subnav_item['site_admin_only']) && !bp_current_user_can('bp_moderate')) {
        $site_admin_restricted = true;
    }
    // User has access, so let's try to hook the display callback
    if (!empty($subnav_item['user_has_access']) && !$site_admin_restricted) {
        // Screen function is invalid
        if (!is_callable($subnav_item['screen_function'])) {
            $retval['status'] = 'failure';
            // Success - hook to bp_screens
        } else {
            add_action('bp_screens', $subnav_item['screen_function'], 3);
            $retval['status'] = 'success';
        }
        // User doesn't have access. Determine redirect arguments based on
        // user status
    } else {
        $retval['status'] = 'failure';
        if (is_user_logged_in()) {
            $bp = buddypress();
            // If a redirect URL has been passed to the subnav
            // item, respect it
            if (!empty($subnav_item['no_access_url'])) {
                $message = __('You do not have access to this page.', 'buddypress');
                $redirect_to = trailingslashit($subnav_item['no_access_url']);
                // In the case of a user page, we try to assume a
                // redirect URL
            } elseif (bp_is_user()) {
                // Redirect to the displayed user's default
                // component, as long as that component is
                // publicly accessible.
                if (bp_is_my_profile() || !empty($bp->bp_nav[$bp->default_component]['show_for_displayed_user'])) {
                    $message = __('You do not have access to this page.', 'buddypress');
                    $redirect_to = bp_displayed_user_domain();
                    // In some cases, the default tab is not accessible to
                    // the logged-in user. So we fall back on a tab that we
                    // know will be accessible.
                } else {
                    // Try 'activity' first
                    if (bp_is_active('activity') && isset($bp->pages->activity)) {
                        $redirect_to = trailingslashit(bp_displayed_user_domain() . bp_get_activity_slug());
                        // Then try 'profile'
                    } else {
                        $redirect_to = trailingslashit(bp_displayed_user_domain() . ('xprofile' == $bp->profile->id ? 'profile' : $bp->profile->id));
                    }
                    $message = '';
                }
                // Fall back to the home page
            } else {
                $message = __('You do not have access to this page.', 'buddypress');
                $redirect_to = bp_get_root_domain();
            }
            $retval['redirect_args'] = array('message' => $message, 'root' => $redirect_to, 'redirect' => false);
        } else {
            // When the user is logged out, pass an empty array
            // This indicates that the default arguments should be
            // used in bp_core_no_access()
            $retval['redirect_args'] = array();
        }
    }
    return $retval;
}
function bp_group_is_activity_permalink()
{
    if (!bp_is_single_item() || !bp_is_groups_component() || !bp_is_current_action(bp_get_activity_slug())) {
        return false;
    }
    return true;
}
Ejemplo n.º 28
0
function bebop_rss_buttons()
{
    global $bp;
    $count = 0;
    $rss_active_extensions = array();
    $extensions = bebop_extensions::bebop_get_active_extension_names();
    $user = $bp->displayed_user->userdata;
    echo '<div class="rss_feed_container">';
    foreach ($extensions as $extension) {
        if (bebop_tables::get_option_value('bebop_' . $extension . '_rss_feed') == 'on') {
            $extension = bebop_extensions::bebop_get_extension_config_by_name(strtolower($extension));
            if (bebop_tables::get_user_meta_value($user->ID, 'bebop_' . $extension['name'] . '_active_for_user') == 1) {
                echo '<a class="button bp-secondary-action" href="' . get_bloginfo('url') . '/' . bp_get_members_slug() . '/' . $user->user_nicename . '/' . bp_get_activity_slug() . '/' . $extension['name'] . '"><img style="vertical-align: text-top;"' . 'src="' . plugins_url() . '/bebop/core/resources/images/feed_14px.png"> ' . $extension['display_name'] . '</a>';
                $count++;
            }
        }
    }
    if ($count >= 2) {
        echo ' <a class="button bp-secondary-action" href="' . get_bloginfo('url') . '/' . bp_get_members_slug() . '/' . $user->user_nicename . '/' . bp_get_activity_slug() . '/all_oers"><img style="vertical-align: text-top;"' . 'src="' . plugins_url() . '/bebop/core/resources/images/feed_14px.png"> All</a>';
    }
    echo '</div>';
}
Ejemplo n.º 29
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);
}
Ejemplo n.º 30
0
 function setup_admin_bar()
 {
     global $wp_admin_bar;
     $wp_admin_bar->add_menu(array('parent' => 'my-account-' . bp_get_activity_slug(), 'title' => __('Reshares', 'bp-reshare'), 'href' => bp_loggedin_user_domain() . bp_get_activity_slug() . '/reshares/'));
 }