Beispiel #1
0
 /**
  * Override bbPress profile URL with BuddyPress profile URL
  *
  * @since bbPress (r3401)
  * @param string $url
  * @param int $user_id
  * @param string $user_nicename
  * @return string
  */
 public function user_profile_url($user_id)
 {
     // Define local variable(s)
     $profile_url = '';
     // Special handling for forum component
     if (bp_is_current_component('forums')) {
         // Empty action or 'topics' action
         if (!bp_current_action() || bp_is_current_action('topics')) {
             $profile_url = bp_core_get_user_domain($user_id) . 'forums/topics';
             // Empty action or 'topics' action
         } elseif (bp_is_current_action('replies')) {
             $profile_url = bp_core_get_user_domain($user_id) . 'forums/replies';
             // 'favorites' action
         } elseif (bbp_is_favorites_active() && bp_is_current_action('favorites')) {
             $profile_url = $this->get_favorites_permalink('', $user_id);
             // 'subscriptions' action
         } elseif (bbp_is_subscriptions_active() && bp_is_current_action('subscriptions')) {
             $profile_url = $this->get_subscriptions_permalink('', $user_id);
         }
         // Not in users' forums area
     } else {
         $profile_url = bp_core_get_user_domain($user_id);
     }
     return trailingslashit($profile_url);
 }
/**
 * Are we on Gallery Directory or User Gallery Pages?
 * 
 * @return boolean
 */
function mpp_is_gallery_component()
{
    if (function_exists('bp_is_current_component') && bp_is_current_component('mediapress')) {
        return true;
    }
    return false;
}
Beispiel #3
0
/**
 * Are we on Gallery Directory or User Gallery Pages?
 * 
 * @return boolean
 */
function mpp_is_gallery_component()
{
    if (bp_is_current_component('mediapress')) {
        return true;
    }
    return false;
}
 /**
  * Set filters
  *
  * @package Rendez Vous
  * @subpackage Screens
  *
  * @since Rendez Vous (1.0.0)
  */
 private function setup_filters()
 {
     if (bp_is_current_component('rendez_vous')) {
         add_filter('bp_located_template', array($this, 'template_filter'), 20, 2);
         add_filter('bp_get_template_stack', array($this, 'add_to_template_stack'), 10, 1);
     }
 }
/**
 * When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu
 * this action will fire and mark or unmark the user and their blogs as spam.
 * Must be a site admin for this function to run.
 *
 * @package BuddyPress Core
 * @param int $user_id Optional user ID to mark as spam
 * @global object $nxtdb Global NXTClass Database object
 */
function bp_core_action_set_spammer_status($user_id = 0)
{
    // Use displayed user if it's not yourself
    if (empty($user_id)) {
        $user_id = bp_displayed_user_id();
    }
    if (bp_is_current_component('admin') && in_array(bp_current_action(), array('mark-spammer', 'unmark-spammer'))) {
        // Check the nonce
        check_admin_referer('mark-unmark-spammer');
        // To spam or not to spam
        $status = bp_is_current_action('mark-spammer') ? 'spam' : 'ham';
        // The heavy lifting
        bp_core_process_spammer_status($user_id, $status);
        // Add feedback message. @todo - Error reporting
        if ('spam' == $status) {
            bp_core_add_message(__('User marked as spammer. Spam users are visible only to site admins.', 'buddypress'));
        } else {
            bp_core_add_message(__('User removed as spammer.', 'buddypress'));
        }
        // Deprecated. Use bp_core_process_spammer_status.
        $is_spam = 'spam' == $status;
        do_action('bp_core_action_set_spammer_status', bp_displayed_user_id(), $is_spam);
        // Redirect back to where we came from
        bp_core_redirect(nxt_get_referer());
    }
}
Beispiel #6
0
/**
 * Inject options nav onto end of active displayed user nav component
 *
 * @param string $html
 * @param array $user_nav_item
 * @return string
 */
function infinity_bp_nav_inject_options_filter($html, $user_nav_item)
{
    // slug of nav item being filtered
    $component = $user_nav_item['slug'];
    // show options nav?
    $show = bp_is_current_component($component);
    // special hack to handle profile in BP versions < 1.7
    if ('profile' == $component && -1 == version_compare(BP_VERSION, '1.7') && false == bp_is_my_profile()) {
        // force hide it
        $show = false;
    }
    // filter the show var because i love developers
    $show = (bool) apply_filters('infinity_bp_nav_inject_options_show', $show, $user_nav_item);
    // ok, finally... should we show it?
    if (true === $show) {
        // yes, need to capture options nav output
        ob_start();
        // run options nav template tag
        bp_get_options_nav();
        // grab buffer and wipe it
        $nav = trim((string) ob_get_clean());
        // make sure the result has some meat
        if ('' != $nav) {
            // yep, inject options nav onto end of list item wrapped in special <ul>
            return preg_replace('/(<\\/li>.*)$/', '<ul class="profile-subnav">' . $nav . '</ul>$1', $html, 1);
        }
    }
    // no changes
    return $html;
}
/**
 * Process user deletion requests.
 *
 * Note: No longer called here. See the Settings component.
 */
function bp_core_action_delete_user()
{
    $userID = bp_displayed_user_id();
    echo "Buddypress:";
    echo $userID;
    $now = current_time('mysql');
    $args = array('date_query' => array('after' => '5 minute ago', 'before' => $now, 'inclusive' => true), 'post_id' => $postID, 'user_id' => $userID, 'count' => true);
    $userActivityCount = get_comments($args);
    if (!bp_current_user_can('bp_moderate') || bp_is_my_profile() || !bp_displayed_user_id() || $userActivityCount != 0) {
        return false;
    }
    if (bp_is_current_component('admin') && bp_is_current_action('delete-user') && $userActivityCount == 0) {
        // Check the nonce.
        check_admin_referer('delete-user');
        $errors = false;
        $style = "<style> #account-delete-form .submit{ display:none !important;} </style>";
        if ($userActivityCount != 0) {
            $errors = true;
            return $style;
        }
        do_action('bp_core_before_action_delete_user', $errors);
        if (bp_core_delete_account(bp_displayed_user_id()) || $userActivityCount == 0) {
            bp_core_add_message(sprintf(__('%s has been deleted from the system.', 'buddypress'), bp_get_displayed_user_fullname()));
        } else {
            bp_core_add_message(sprintf(__('There was an error deleting %s from the system. Please try again.', 'buddypress'), bp_get_displayed_user_fullname()), 'error');
            $errors = true;
        }
        do_action('bp_core_action_delete_user', $errors);
        if ($errors) {
            bp_core_redirect(bp_displayed_user_domain());
        } else {
            bp_core_redirect(bp_loggedin_user_domain());
        }
    }
}
/**
 * Filters template for the user compliments tab.
 *
 * @since 0.0.1
 * @package BuddyPress_Compliments
 *
 * @global object $bp BuddyPress instance.
 * @param string $found_template Located template file.
 * @param array $templates The template array.
 * @return string Template file.
 */
function bp_compliments_load_template_filter($found_template, $templates)
{
    global $bp;
    // Only filter the template location when we're on the compliments component pages.
    if (!bp_is_current_component($bp->compliments->compliments->slug)) {
        return $found_template;
    }
    if (empty($found_template)) {
        bp_register_template_stack('bp_compliments_get_template_directory', 14);
        // locate_template() will attempt to find the plugins.php template in the
        // child and parent theme and return the located template when found
        //
        // plugins.php is the preferred template to use, since all we'd need to do is
        // inject our content into BP
        //
        // note: this is only really relevant for bp-default themes as theme compat
        // will kick in on its own when this template isn't found
        $found_template = locate_template('members/single/plugins.php', false, false);
        // add our hook to inject content into BP
        add_action('bp_template_content', 'bp_compliments_single_compliments_content');
    }
    /**
     * Filters the compliment page template.
     *
     * @since 0.0.1
     * @package BuddyPress_Compliments
     *
     * @param string $found_template Located template file.
     */
    return apply_filters('bp_compliments_load_template_filter', $found_template);
}
 public function check_legacy($tpl)
 {
     $status = function_exists('buddypress');
     if (!$status) {
         return $tpl;
     }
     $this->bp_plugin_name = bp_get_name_from_root_slug();
     // This check fails for some plugins
     // $status = $this->bp_plugin_name != false;
     if ($status) {
         $bp_defaults = array('members', 'xprofile', 'activity', 'blogs', 'messages', 'friends', 'groups', 'forums', 'settings');
         foreach ($bp_defaults as $bp_default) {
             if (bp_is_current_component($bp_default)) {
                 break;
             }
         }
     }
     if ($status && bp_is_directory()) {
         $this->is_legacy = $status = false;
     }
     if ($status && false === (bool) locate_template(array('members/single/item-header.php'), false)) {
         add_action('wp_footer', array($this, 'item_header'));
     }
     if ($status) {
         add_action('wp_footer', array($this, 'page_title'));
         add_action('wp_footer', array($this, 'echo_legacy_tpl'));
     }
     return $tpl;
 }
function bp_checkins_if_category_place()
{
    if (!bp_displayed_user_id() && bp_is_current_component('checkins') && bp_is_current_action('place') && bp_action_variable(0) && 'category' == bp_action_variable(0) && bp_action_variable(1)) {
        return true;
    } else {
        return false;
    }
}
/**
 * Are we dealing with blog categories pages?
 * @return type 
 */
function bcg_is_component()
{
    $bp = buddypress();
    if (bp_is_current_component($bp->groups->slug) && bp_is_current_action(BCG_SLUG)) {
        return true;
    }
    return false;
}
/**
 * Adds a navigation item to the main navigation array used in BuddyPress themes.
 *
 * @package BuddyPress Core
 * @global object $bp Global BuddyPress settings object
 */
function bp_core_new_nav_item($args = '')
{
    global $bp;
    $defaults = array('name' => false, 'slug' => false, 'item_css_id' => false, 'show_for_displayed_user' => true, 'site_admin_only' => false, 'position' => 99, 'screen_function' => false, 'default_subnav_slug' => false);
    $r = nxt_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    // If we don't have the required info we need, don't create this subnav item
    if (empty($name) || empty($slug)) {
        return false;
    }
    // If this is for site admins only and the user is not one, don't create the subnav item
    if ($site_admin_only && !is_super_admin()) {
        return false;
    }
    if (empty($item_css_id)) {
        $item_css_id = $slug;
    }
    $bp->bp_nav[$slug] = array('name' => $name, 'slug' => $slug, 'link' => $bp->loggedin_user->domain . $slug . '/', 'css_id' => $item_css_id, 'show_for_displayed_user' => $show_for_displayed_user, 'position' => $position, 'screen_function' => &$screen_function);
    /***
     * If this nav item is hidden for the displayed user, and
     * the logged in user is not the displayed user
     * looking at their own profile, don't create the nav item.
     */
    if (!$show_for_displayed_user && !bp_user_has_access()) {
        return false;
    }
    /***
     * If the nav item is visible, we are not viewing a user, and this is a root
     * component, don't attach the default subnav function so we can display a
     * directory or something else.
     */
    if (-1 != $position && bp_is_root_component($slug) && !bp_displayed_user_id()) {
        return;
    }
    // Look for current component
    if (bp_is_current_component($slug) && !bp_current_action()) {
        if (!is_object($screen_function[0])) {
            add_action('bp_screens', $screen_function);
        } else {
            add_action('bp_screens', array(&$screen_function[0], $screen_function[1]), 3);
        }
        if (!empty($default_subnav_slug)) {
            $bp->current_action = apply_filters('bp_default_component_subnav', $default_subnav_slug, $r);
        }
        // Look for current item
    } elseif (bp_is_current_item($slug) && !bp_current_action()) {
        if (!is_object($screen_function[0])) {
            add_action('bp_screens', $screen_function);
        } else {
            add_action('bp_screens', array(&$screen_function[0], $screen_function[1]), 3);
        }
        if (!empty($default_subnav_slug)) {
            $bp->current_action = apply_filters('bp_default_component_subnav', $default_subnav_slug, $r);
        }
    }
    do_action('bp_core_new_nav_item', $r, $args, $defaults);
}
 public function is_bp_plugin()
 {
     if (bp_is_current_component('articles')) {
         // first we reset the post
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         // then we filter ‘the_content’ thanks to bp_replace_the_content
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
     }
 }
/**
 * Redirects users that are not logged in to the 'wp-login.php' page.
 *
 * @since 0.1.0
 * @uses is_user_logged_in() Checks if the current user is logged in.
 * @uses auth_redirect() Redirects people that are not logged in to the login page.
 */
function members_please_log_in()
{
    /* Check if the private blog feature is active. */
    if (members_get_setting('private_blog')) {
        /* If using BuddyPress and on the register page, don't do anything. */
        if (function_exists('bp_is_current_component') && bp_is_current_component('register')) {
            return;
        } elseif (!is_user_logged_in()) {
            auth_redirect();
        }
    }
}
/**
 * Redirects users that are not logged in to the 'wp-login.php' page.
 *
 * @since  0.1.0
 * @access public
 * @return void
 */
function members_please_log_in()
{
    // Check if the private blog feature is active and if the user is not logged in.
    if (members_is_private_blog() && !is_user_logged_in()) {
        // If using BuddyPress and on the register page, don't do anything.
        if (function_exists('bp_is_current_component') && bp_is_current_component('register')) {
            return;
        }
        // Redirect to the login page.
        auth_redirect();
        exit;
    }
}
Beispiel #16
0
 /**
  * Fixes the ProSites checkout if BuddyPress registration page is set to checkout page
  */
 public static function fix_registration()
 {
     global $psts;
     if (function_exists('bp_core_get_directory_page_ids')) {
         $bp_directory_page_ids = bp_core_get_directory_page_ids();
         if (!empty($bp_directory_page_ids['register'])) {
             $register_url = get_permalink($bp_directory_page_ids['register']);
         }
         if (bp_is_current_component('register') && $register_url == $psts->checkout_url()) {
             remove_action('bp_init', 'bp_core_wpsignup_redirect');
             remove_action('bp_screens', 'bp_core_screen_signup');
         }
     }
 }
/**
 * Enqueues JavaScript files.
 *
 * @since 2.0
 * @global object $bp BuddyPress global settings
 */
function dpa_add_js()
{
    global $bp;
    if (!bp_is_current_component($bp->achievements->slug)) {
        return;
    }
    if (DPA_SLUG_CREATE == $bp->current_action && dpa_permission_can_user_create() || DPA_SLUG_ACHIEVEMENT_EDIT == $bp->current_action && dpa_permission_can_user_edit() || DPA_SLUG_ACHIEVEMENT_CHANGE_PICTURE == $bp->current_action && dpa_permission_can_user_change_picture() || DPA_SLUG_ACHIEVEMENT_GRANT == $bp->current_action && dpa_permission_can_user_grant()) {
        nxt_enqueue_script('achievements-admin-js', plugins_url('/js/admin.js', __FILE__), array(), ACHIEVEMENTS_VERSION);
    }
    if ($bp->is_single_item) {
        nxt_enqueue_script('achievements-detail-js', plugins_url('/js/detail.js', __FILE__), array(), ACHIEVEMENTS_VERSION);
    } else {
        nxt_enqueue_script('achievements-directory-js', plugins_url('/js/directory.js', __FILE__), array(), ACHIEVEMENTS_VERSION);
    }
}
/**
 * BP Follow template loader.
 *
 * This function sets up BP Follow to use custom templates.
 *
 * If a template does not exist in the current theme, we will use our own
 * bundled templates.
 *
 * We're doing two things here:
 *  1) Support the older template format for themes that are using them
 *     for backwards-compatibility (the template passed in
 *     {@link bp_core_load_template()}).
 *  2) Route older template names to use our new template locations and
 *     format.
 *
 * View the inline doc for more details.
 *
 * @since 1.0
 */
function bp_follow_load_template_filter($found_template, $templates)
{
    global $bp;
    // Only filter the template location when we're on the follow component pages.
    if (!bp_is_current_component($bp->follow->followers->slug) && !bp_is_current_component($bp->follow->following->slug)) {
        return $found_template;
    }
    // $found_template is not empty when the older template files are found in the
    // parent and child theme
    //
    //  /wp-content/themes/YOUR-THEME/members/single/following.php
    //  /wp-content/themes/YOUR-THEME/members/single/followers.php
    //
    // The older template files utilize a full template ( get_header() +
    // get_footer() ), which sucks for themes and theme compat.
    //
    // When the older template files are not found, we use our new template method,
    // which will act more like a template part.
    if (empty($found_template)) {
        // register our theme compat directory
        //
        // this tells BP to look for templates in our plugin directory last
        // when the template isn't found in the parent / child theme
        bp_register_template_stack('bp_follow_get_template_directory', 14);
        // locate_template() will attempt to find the plugins.php template in the
        // child and parent theme and return the located template when found
        //
        // plugins.php is the preferred template to use, since all we'd need to do is
        // inject our content into BP
        //
        // note: this is only really relevant for bp-default themes as theme compat
        // will kick in on its own when this template isn't found
        $found_template = locate_template('members/single/plugins.php', false, false);
        // add AJAX support to the members loop
        // can disable with the 'bp_follow_allow_ajax_on_follow_pages' filter
        if (apply_filters('bp_follow_allow_ajax_on_follow_pages', true)) {
            // add the "Order by" dropdown filter
            add_action('bp_member_plugin_options_nav', 'bp_follow_add_members_dropdown_filter');
            // add ability to use AJAX
            add_action('bp_after_member_plugin_template', 'bp_follow_add_ajax_to_members_loop');
        }
        // add our hook to inject content into BP
        //
        // note the new template name for our template part
        add_action('bp_template_content', create_function('', "\n\t\t\tbp_get_template_part( 'members/single/follow' );\n\t\t"));
    }
    return apply_filters('bp_follow_load_template_filter', $found_template);
}
function social_articles_load_template_filter($found_template, $templates)
{
    global $bp;
    if (!bp_sa_is_bp_default() || !bp_is_current_component($bp->social_articles->slug)) {
        return $found_template;
    }
    foreach ((array) $templates as $template) {
        if (file_exists(STYLESHEETPATH . '/' . $template)) {
            $filtered_templates[] = STYLESHEETPATH . '/' . $template;
        } else {
            $filtered_templates[] = dirname(__FILE__) . '/templates/' . $template;
        }
    }
    $found_template = $filtered_templates[0];
    return apply_filters('social_articles_load_template_filter', $found_template);
}
 public function restrict_blocked()
 {
     global $bp;
     // if site admin, skip check
     if ($bp->loggedin_user->is_site_admin == 1) {
         return;
     }
     if (bp_is_user() && !bp_is_my_profile() && is_user_logged_in()) {
         $displayed_id = bp_displayed_user_id();
         $user_id = get_current_user_id();
         if ($this->check_blocking($user_id, $displayed_id)) {
             if (bp_is_current_component('blocked')) {
                 bp_register_template_stack('BP_Block_User::register_template_location');
                 add_filter('bp_get_template_part', array($this, 'replace_template'), 10, 3);
                 bp_core_load_template('members/single/plugins');
             } else {
                 wp_redirect(bp_get_members_component_link('') . 'blocked/');
                 exit;
             }
         }
     }
 }
/**
 * Catches clicks on a "Unfollow" button and tries to make that happen.
 *
 * @uses check_admin_referer() Checks to make sure the WP security nonce matches.
 * @uses bp_follow_is_following() Checks to see if a user is following another user already.
 * @uses bp_follow_stop_following() Stops a user following another user.
 * @uses bp_core_add_message() Adds an error/success message to be displayed after redirect.
 * @uses bp_core_redirect() Safe redirects the user to a particular URL.
 */
function bp_follow_action_stop()
{
    global $bp;
    if (!bp_is_current_component($bp->follow->followers->slug) || !bp_is_current_action('stop')) {
        return;
    }
    if (bp_displayed_user_id() == bp_loggedin_user_id()) {
        return;
    }
    check_admin_referer('stop_following');
    if (!bp_follow_is_following(array('leader_id' => bp_displayed_user_id(), 'follower_id' => bp_loggedin_user_id()))) {
        bp_core_add_message(sprintf(__('You are not following %s.', 'bp-follow'), bp_get_displayed_user_fullname()), 'error');
    } else {
        if (!bp_follow_stop_following(array('leader_id' => bp_displayed_user_id(), 'follower_id' => bp_loggedin_user_id()))) {
            bp_core_add_message(sprintf(__('There was a problem when trying to stop following %s, please try again.', 'bp-follow'), bp_get_displayed_user_fullname()), 'error');
        } else {
            bp_core_add_message(sprintf(__('You are no longer following %s.', 'bp-follow'), bp_get_displayed_user_fullname()));
        }
    }
    // it's possible that wp_get_referer() returns false, so let's fallback to the displayed user's page
    $redirect = wp_get_referer() ? wp_get_referer() : bp_displayed_user_domain();
    bp_core_redirect($redirect);
}
/**
 * Process user deletion requests.
 *
 * Note: No longer called here. See the Settings component.
 */
function bp_core_action_delete_user()
{
    if (!bp_current_user_can('bp_moderate') || bp_is_my_profile() || !bp_displayed_user_id()) {
        return false;
    }
    if (bp_is_current_component('admin') && bp_is_current_action('delete-user')) {
        // Check the nonce
        check_admin_referer('delete-user');
        $errors = false;
        do_action('bp_core_before_action_delete_user', $errors);
        if (bp_core_delete_account(bp_displayed_user_id())) {
            bp_core_add_message(sprintf(__('%s has been deleted from the system.', 'buddypress'), bp_get_displayed_user_fullname()));
        } else {
            bp_core_add_message(sprintf(__('There was an error deleting %s from the system. Please try again.', 'buddypress'), bp_get_displayed_user_fullname()), 'error');
            $errors = true;
        }
        do_action('bp_core_action_delete_user', $errors);
        if ($errors) {
            bp_core_redirect(bp_displayed_user_domain());
        } else {
            bp_core_redirect(bp_loggedin_user_domain());
        }
    }
}
/**
 * Handle the loading of the Activate screen.
 *
 * @todo Move the actual activation process into an action in bp-members-actions.php
 */
function bp_core_screen_activation()
{
    // Bail if not viewing the activation page
    if (!bp_is_current_component('activate')) {
        return false;
    }
    // If the user is already logged in, redirect away from here
    if (is_user_logged_in()) {
        // If activation page is also front page, set to members directory to
        // avoid an infinite loop. Otherwise, set to root domain.
        $redirect_to = bp_is_component_front_page('activate') ? bp_get_root_domain() . '/' . bp_get_members_root_slug() : bp_get_root_domain();
        // Trailing slash it, as we expect these URL's to be
        $redirect_to = trailingslashit($redirect_to);
        /**
         * Filters the URL to redirect logged in users to when visiting activation page.
         *
         * @since BuddyPress (1.9.0)
         *
         * @param string $redirect_to URL to redirect user to.
         */
        $redirect_to = apply_filters('bp_loggedin_activate_page_redirect_to', $redirect_to);
        // Redirect away from the activation page
        bp_core_redirect($redirect_to);
    }
    // grab the key (the old way)
    $key = isset($_GET['key']) ? $_GET['key'] : '';
    // grab the key (the new way)
    if (empty($key)) {
        $key = bp_current_action();
    }
    // Get BuddyPress
    $bp = buddypress();
    // we've got a key; let's attempt to activate the signup
    if (!empty($key)) {
        /**
         * Filters the activation signup.
         *
         * @since BuddyPress (1.1.0)
         *
         * @param bool|int $value Value returned by activation.
         *                        Integer on success, boolean on failure.
         */
        $user = apply_filters('bp_core_activate_account', bp_core_activate_signup($key));
        // If there were errors, add a message and redirect
        if (!empty($user->errors)) {
            bp_core_add_message($user->get_error_message(), 'error');
            bp_core_redirect(trailingslashit(bp_get_root_domain() . '/' . $bp->pages->activate->slug));
        }
        $hashed_key = wp_hash($key);
        // Check if the signup avatar folder exists. If it does, move the folder to
        // the BP user avatars directory
        if (file_exists(bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key)) {
            @rename(bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user);
        }
        bp_core_add_message(__('Your account is now active!', 'buddypress'));
        $bp->activation_complete = true;
    }
    /**
     * Filters the template to load for the Member activation page screen.
     *
     * @since BuddyPress (1.1.1)
     *
     * @param string $value Path to the Member activation template to load.
     */
    bp_core_load_template(apply_filters('bp_core_template_activate', array('activate', 'registration/activate')));
}
 /**
  * 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']);
         }
     }
 }
/**
 * A javascript-free implementation of the search functions in BuddyPress.
 *
 * @param string $slug The slug to redirect to for searching.
 */
function bp_core_action_search_site($slug = '')
{
    if (!bp_is_current_component(bp_get_search_slug())) {
        return;
    }
    if (empty($_POST['search-terms'])) {
        bp_core_redirect(bp_get_root_domain());
        return;
    }
    $search_terms = stripslashes($_POST['search-terms']);
    $search_which = !empty($_POST['search-which']) ? $_POST['search-which'] : '';
    $query_string = '/?s=';
    if (empty($slug)) {
        switch ($search_which) {
            case 'posts':
                $slug = '';
                $var = '/?s=';
                // If posts aren't displayed on the front page, find the post page's slug.
                if ('page' == get_option('show_on_front')) {
                    $page = get_post(get_option('page_for_posts'));
                    if (!is_wp_error($page) && !empty($page->post_name)) {
                        $slug = $page->post_name;
                        $var = '?s=';
                    }
                }
                break;
            case 'blogs':
                $slug = bp_is_active('blogs') ? bp_get_blogs_root_slug() : '';
                break;
            case 'forums':
                $slug = bp_is_active('forums') ? bp_get_forums_root_slug() : '';
                $query_string = '/?fs=';
                break;
            case 'groups':
                $slug = bp_is_active('groups') ? bp_get_groups_root_slug() : '';
                break;
            case 'members':
            default:
                $slug = bp_get_members_root_slug();
                break;
        }
        if (empty($slug) && 'posts' != $search_which) {
            bp_core_redirect(bp_get_root_domain());
            return;
        }
    }
    bp_core_redirect(apply_filters('bp_core_search_site', home_url($slug . $query_string . urlencode($search_terms)), $search_terms));
}
 /**
  * Filter the default theme compatibility root template hierarchy, and prepend
  * a page template to the front if it's set.
  *
  * @see https://buddypress.trac.wordpress.org/ticket/6065
  *
  * @since BuddyPress (2.2.0)
  *
  * @param  array $templates
  * @uses   apply_filters() call 'bp_legacy_theme_compat_page_templates_directory_only' and return false
  *                         to use the defined page template for component's directory and its single items
  * @return array
  */
 public function theme_compat_page_templates($templates = array())
 {
     /**
      * Filters whether or not we are looking at a directory to determine if to return early.
      *
      * @since BuddyPress (2.2.0)
      *
      * @param bool $value Whether or not we are viewing a directory.
      */
     if (true === (bool) apply_filters('bp_legacy_theme_compat_page_templates_directory_only', !bp_is_directory())) {
         return $templates;
     }
     // No page ID yet
     $page_id = 0;
     // Get the WordPress Page ID for the current view.
     foreach ((array) buddypress()->pages as $component => $bp_page) {
         // Handles the majority of components.
         if (bp_is_current_component($component)) {
             $page_id = (int) $bp_page->id;
         }
         // Stop if not on a user page.
         if (!bp_is_user() && !empty($page_id)) {
             break;
         }
         // The Members component requires an explicit check due to overlapping components.
         if (bp_is_user() && 'members' === $component) {
             $page_id = (int) $bp_page->id;
             break;
         }
     }
     // Bail if no directory page set
     if (0 === $page_id) {
         return $templates;
     }
     // Check for page template
     $page_template = get_page_template_slug($page_id);
     // Add it to the beginning of the templates array so it takes precedence
     // over the default hierarchy.
     if (!empty($page_template)) {
         /**
          * Check for existence of template before adding it to template
          * stack to avoid accidentally including an unintended file.
          *
          * @see: https://buddypress.trac.wordpress.org/ticket/6190
          */
         if ('' !== locate_template($page_template)) {
             array_unshift($templates, $page_template);
         }
     }
     return $templates;
 }
function bp_checkins_activity_querystring_filter($query_string, $object)
{
    // not on a checkin area, then return the query without changing it!
    if (!bp_is_current_component('checkins') && !bp_checkins_is_group_checkins_area()) {
        return $query_string;
    }
    /* Set up the cookies passed on this AJAX request. Store a local var to avoid conflicts */
    if (!empty($_POST['cookie'])) {
        $_BP_CI_COOKIE = wp_parse_args(str_replace('; ', '&', urldecode($_POST['cookie'])));
    } else {
        $_BP_CI_COOKIE =& $_COOKIE;
    }
    $defaults = array('page' => false);
    $r = wp_parse_args($query_string, $defaults);
    extract($r, EXTR_SKIP);
    //default values to filter on
    $object = 'checkins,groups';
    $action = 'activity_checkin,foursquare_checkin,place_checkin';
    $bp_ci_qs = false;
    $bp_ci_qs[] = 'object=' . $object;
    /***
     * Check if any cookie values are set. If there are then override the default params passed to the
     * template loop
     */
    if (!empty($_BP_CI_COOKIE['bp-checkins-filter']) && '-1' != $_BP_CI_COOKIE['bp-checkins-filter'] && $_BP_CI_COOKIE['bp-checkins-filter'] != 'friends_checkin') {
        $bp_ci_qs[] = 'type=' . $_BP_CI_COOKIE['bp-checkins-filter'];
        $bp_ci_qs[] = 'action=' . $_BP_CI_COOKIE['bp-checkins-filter'];
    } else {
        $bp_ci_qs[] = 'type=' . $object;
        $bp_ci_qs[] = 'action=' . $action;
    }
    if (!empty($_BP_CI_COOKIE['bp-checkins-filter']) && '-1' != $_BP_CI_COOKIE['bp-checkins-filter'] && $_BP_CI_COOKIE['bp-checkins-filter'] == 'friends_checkin') {
        // this is my trick to transsform a filter to a scope !
        $bp_ci_qs[] = 'scope=friends';
    }
    //includes the !public group checkins
    if (bp_checkins_is_user_area() && bp_is_my_profile()) {
        $bp_ci_qs[] = 'show_hidden=1';
    }
    if (!empty($page)) {
        $bp_ci_qs[] = 'page=' . $page;
    }
    //builds the bp_checkins query
    $query_string = empty($bp_ci_qs) ? '' : join('&', (array) $bp_ci_qs);
    return apply_filters('bp_checkins_activity_querystring_filter', $query_string, $object, $action);
}
Beispiel #28
0
/**
 * AJAX handler for autocomplete. Displays friends only, unless BP_MESSAGES_AUTOCOMPLETE_ALL is defined.
 *
 * @global BuddyPress $bp The one true BuddyPress instance
 * @return string HTML
 * @since BuddyPress (1.2)
 */
function bp_dtheme_ajax_messages_autocomplete_results()
{
    global $bp;
    // Include everyone in the autocomplete, or just friends?
    if (bp_is_current_component(bp_get_messages_slug())) {
        $autocomplete_all = $bp->messages->autocomplete_all;
    }
    $pag_page = 1;
    $limit = $_GET['limit'] ? $_GET['limit'] : apply_filters('bp_autocomplete_max_results', 10);
    // Get the user ids based on the search terms
    if (!empty($autocomplete_all)) {
        $users = BP_Core_User::search_users($_GET['q'], $limit, $pag_page);
        if (!empty($users['users'])) {
            // Build an array with the correct format
            $user_ids = array();
            foreach ($users['users'] as $user) {
                if ($user->id != bp_loggedin_user_id()) {
                    $user_ids[] = $user->id;
                }
            }
            $user_ids = apply_filters('bp_core_autocomplete_ids', $user_ids, $_GET['q'], $limit);
        }
    } else {
        if (bp_is_active('friends')) {
            $users = friends_search_friends($_GET['q'], bp_loggedin_user_id(), $limit, 1);
            // Keeping the bp_friends_autocomplete_list filter for backward compatibility
            $users = apply_filters('bp_friends_autocomplete_list', $users, $_GET['q'], $limit);
            if (!empty($users['friends'])) {
                $user_ids = apply_filters('bp_friends_autocomplete_ids', $users['friends'], $_GET['q'], $limit);
            }
        }
    }
    if (!empty($user_ids)) {
        foreach ($user_ids as $user_id) {
            $ud = get_userdata($user_id);
            if (!$ud) {
                continue;
            }
            if (bp_is_username_compatibility_mode()) {
                $username = $ud->user_login;
            } else {
                $username = $ud->user_nicename;
            }
            // Note that the final line break acts as a delimiter for the
            // autocomplete javascript and thus should not be removed
            echo '<span id="link-' . $username . '" href="' . bp_core_get_user_domain($user_id) . '"></span>' . bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15, 'alt' => $ud->display_name)) . ' &nbsp;' . bp_core_get_user_displayname($user_id) . ' (' . $username . ')' . "\n";
        }
    }
    exit;
}
/**
 * Mark notification(s) as read
 *
 * @package WP Idea Stream
 * @subpackage buddypress/notifications
 *
 * @since  2.0.0
 *
 * @uses   wp_idea_stream_is_single_idea() to check if viewing the single template of an idea
 * @uses   bp_notifications_mark_notifications_by_item_id() to mark notifications as read
 * @uses   bp_loggedin_user_id() to get the logged in user ID
 * @uses   wp_idea_stream_get_single_idea_id() to get the ID of the idea being viewed
 * @uses   buddypress() to get BuddyPress instance
 * @uses   wp_idea_stream_get_post_type() to get the ideas post type identifier
 * @uses   bp_is_user() to check a user's profile is displayed
 * @uses   bp_is_current_component( 'ideastream' ) to check it's an IdeaStream part of the profile
 * @uses   bp_notifications_mark_notifications_by_type() to mark notifications as read
 */
function wp_idea_stream_buddypress_comments_mark_notifications_read()
{
    if (!empty($_GET['notif'])) {
        if (wp_idea_stream_is_single_idea()) {
            bp_notifications_mark_notifications_by_item_id(bp_loggedin_user_id(), wp_idea_stream_get_single_idea_id(), buddypress()->ideastream->id, 'new_' . wp_idea_stream_get_post_type() . '_comment');
            bp_notifications_mark_notifications_by_item_id(bp_loggedin_user_id(), wp_idea_stream_get_single_idea_id(), buddypress()->ideastream->id, 'new_' . wp_idea_stream_get_post_type() . '_rate');
        }
        if (bp_is_user() && bp_is_current_component('ideastream')) {
            bp_notifications_mark_notifications_by_type(bp_loggedin_user_id(), buddypress()->ideastream->id, 'new_' . wp_idea_stream_get_post_type() . '_comment');
            bp_notifications_mark_notifications_by_type(bp_loggedin_user_id(), buddypress()->ideastream->id, 'new_' . wp_idea_stream_get_post_type() . '_rate');
        }
    }
}
				</div><!-- #secondary -->	
		
		<!-- if Multisite is activated AND there are widgets in the Blogs: Directory sidebar -->	
		<?php 
    } elseif (is_active_sidebar('blogs') && is_multisite() && bp_is_current_component('blogs') && !bp_is_user()) {
        ?>
		
				<div id="secondary" class="widget-area" role="complementary">
					<?php 
        dynamic_sidebar('blogs');
        ?>
				</div><!-- #secondary -->

		<!-- if Legacy Forums (not bbPress) are activated AND there are widgets in the Forums: Directory sidebar -->	
		<?php 
    } elseif (is_active_sidebar('forums') && bp_is_current_component('forums') && !bp_is_user()) {
        ?>
		
				<div id="secondary" class="widget-area" role="complementary">
					<?php 
        dynamic_sidebar('forums');
        ?>
				</div><!-- #secondary -->
			
		<!-- otherwise, no sidebar! -->
		
		<?php 
    }
    ?>

	<?php