Example #1
0
/**
 * Catch and process the Requests page.
 */
function friends_screen_requests()
{
    if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_accept_friendship');
        if (friends_accept_friendship(bp_action_variable(1))) {
            bp_core_add_message(__('Friendship accepted', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error');
        }
        bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
    } elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_reject_friendship');
        if (friends_reject_friendship(bp_action_variable(1))) {
            bp_core_add_message(__('Friendship rejected', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error');
        }
        bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
    } elseif (bp_is_action_variable('cancel', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_withdraw_friendship');
        if (friends_withdraw_friendship(bp_loggedin_user_id(), bp_action_variable(1))) {
            bp_core_add_message(__('Friendship request withdrawn', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship request could not be withdrawn', 'buddypress'), 'error');
        }
        bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
    }
    do_action('friends_screen_requests');
    bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home'));
}
/**
 * Catch and process Remove Friendship requests.
 *
 * @since 1.0.1
 */
function friends_action_remove_friend()
{
    if (!bp_is_friends_component() || !bp_is_current_action('remove-friend')) {
        return false;
    }
    if (!($potential_friend_id = (int) bp_action_variable(0))) {
        return false;
    }
    if ($potential_friend_id == bp_loggedin_user_id()) {
        return false;
    }
    $friendship_status = BP_Friends_Friendship::check_is_friend(bp_loggedin_user_id(), $potential_friend_id);
    if ('is_friend' == $friendship_status) {
        if (!check_admin_referer('friends_remove_friend')) {
            return false;
        }
        if (!friends_remove_friend(bp_loggedin_user_id(), $potential_friend_id)) {
            bp_core_add_message(__('Friendship could not be canceled.', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('Friendship canceled', 'buddypress'));
        }
    } elseif ('is_friends' == $friendship_status) {
        bp_core_add_message(__('You are not yet friends with this user', 'buddypress'), 'error');
    } else {
        bp_core_add_message(__('You have a pending friendship request with this user', 'buddypress'), 'error');
    }
    bp_core_redirect(wp_get_referer());
    return false;
}
function friends_screen_requests()
{
    if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_accept_friendship');
        if (friends_accept_friendship(bp_action_variable(1))) {
            bp_core_add_message(__('Friendship accepted', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error');
        }
        bp_core_redirect(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action());
    } elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_reject_friendship');
        if (friends_reject_friendship(bp_action_variable(1))) {
            bp_core_add_message(__('Friendship rejected', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error');
        }
        bp_core_redirect(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action());
    }
    do_action('friends_screen_requests');
    if (isset($_GET['new'])) {
        bp_core_delete_notifications_by_type(bp_loggedin_user_id(), 'friends', 'friendship_request');
    }
    bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home'));
}
function bp_checkins_is_group_places_area()
{
    if (bp_is_groups_component() && bp_is_single_item() && bp_is_current_action('checkins') && bp_action_variable(0) == 'places') {
        return true;
    } else {
        return false;
    }
}
/**
 * Add an item to the main BuddyPress navigation array.
 *
 * @global BuddyPress $bp The one true BuddyPress instance.
 *
 * @param array $args {
 *     Array describing the new nav item.
 *     @type string $name Display name for the nav item.
 *     @type string $slug Unique URL slug for the nav item.
 *     @type bool|string $item_css_id Optional. 'id' attribute for the nav
 *           item. Default: the value of $slug.
 *     @type bool $show_for_displayed_user Optional. Whether the nav item
 *           should be visible when viewing a member profile other than your
 *           own. Default: true.
 *     @type bool $site_admin_only Optional. Whether the nav item should be
 *           visible only to site admins (those with the 'bp_moderate' cap).
 *           Default: false.
 *     @type int $position Optional. Numerical index specifying where the item
 *           should appear in the nav array. Default: 99.
 *     @type callable $screen_function The callback function that will run
 *           when the nav item is clicked.
 *     @type bool|string $default_subnav_slug Optional. The slug of the default
 *           subnav item to select when the nav item is clicked.
 * }
 * @return bool|null Returns false on failure.
 */
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 = wp_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 (!empty($site_admin_only) && !bp_current_user_can('bp_moderate')) {
        return false;
    }
    if (empty($item_css_id)) {
        $item_css_id = $slug;
    }
    $bp->bp_nav[$slug] = array('name' => $name, 'slug' => $slug, 'link' => trailingslashit(bp_loggedin_user_domain() . $slug), 'css_id' => $item_css_id, 'show_for_displayed_user' => $show_for_displayed_user, 'position' => $position, 'screen_function' => &$screen_function, 'default_subnav_slug' => $default_subnav_slug);
    /**
     * 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 (empty($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_is_current_item($slug)) {
        // The requested URL has explicitly included the default subnav
        // (eg: http://example.com/members/membername/activity/just-me/)
        // The canonical version will not contain this subnav slug.
        if (!empty($default_subnav_slug) && bp_is_current_action($default_subnav_slug) && !bp_action_variable(0)) {
            unset($bp->canonical_stack['action']);
        } elseif (!bp_current_action()) {
            // Add our screen hook if screen function is callable
            if (is_callable($screen_function)) {
                add_action('bp_screens', $screen_function, 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 display()
 {
     //switch based on current view
     $current_action = bp_action_variable(0);
     if ($current_action == 'create') {
         $this->view_create();
     } elseif (bcg_is_single_post()) {
         $this->view_single();
     } else {
         $this->view_blog();
     }
     //just load the plugins template, above functions will attach the content generators
     bp_core_load_template('groups/single/plugins');
 }
/**
 * Delte an item 
 */
function bp_portfolio_item_delete()
{
    if (bp_is_portfolio_component() and bp_is_current_action('delete') and bp_displayed_user_id() == bp_loggedin_user_id()) {
        if ($project_id = bp_action_variable() and wp_verify_nonce($_REQUEST['_wpnonce'], 'delete_project')) {
            if (bp_portfolio_delete_item($project_id)) {
                bp_core_add_message(__('Project deleted !', 'bp-portfolio'));
            } else {
                bp_core_add_message(__('An error occured, please try again.', 'bp-portfolio'), 'error');
            }
        } else {
            bp_core_add_message(__('An error occured, please try again.', 'bp-portfolio'), 'error');
        }
        bp_core_redirect(bp_core_get_user_domain(bp_loggedin_user_id()) . bp_get_portfolio_slug());
    }
}
/**
 * Catch and process the Requests page.
 */
function friends_screen_requests()
{
    if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_accept_friendship');
        if (friends_accept_friendship(bp_action_variable(1))) {
            bp_core_add_message(__('Friendship accepted', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error');
        }
        bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
    } elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_reject_friendship');
        if (friends_reject_friendship(bp_action_variable(1))) {
            bp_core_add_message(__('Friendship rejected', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error');
        }
        bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
    } elseif (bp_is_action_variable('cancel', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_withdraw_friendship');
        if (friends_withdraw_friendship(bp_loggedin_user_id(), bp_action_variable(1))) {
            bp_core_add_message(__('Friendship request withdrawn', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship request could not be withdrawn', 'buddypress'), 'error');
        }
        bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
    }
    /**
     * Fires before the loading of template for the friends requests page.
     *
     * @since BuddyPress (1.0.0)
     */
    do_action('friends_screen_requests');
    /**
     * Filters the template used to display the My Friends page.
     *
     * @since BuddyPress (1.0.0)
     *
     * @param string $template Path to the friends request template to load.
     */
    bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home'));
}
 /**
  * Sets up the current view when viewing a user page
  *
  * @since 1.2
  */
 function get_current_view($view, $item_type)
 {
     global $wp_rewrite;
     if ($item_type == 'user') {
         $current_action = bp_current_action();
         if (empty($current_action) || in_array($current_action, array(BP_DOCS_STARTED_SLUG, BP_DOCS_EDITED_SLUG))) {
             // An empty $bp->action_variables[0] means that you're looking at a list.
             // A url like members/terry/docs/started/page/3 also means you're looking at a list.
             $view = 'list';
         } else {
             if ($current_action == BP_DOCS_CATEGORY_SLUG) {
                 // Category view
                 $view = 'category';
             } else {
                 if ($current_action == BP_DOCS_CREATE_SLUG) {
                     // Create new doc
                     $view = 'create';
                 } else {
                     if (!bp_action_variable(0)) {
                         // $bp->action_variables[1] is the slug for this doc. If there's no
                         // further chunk, then we're attempting to view a single item
                         $view = 'single';
                     } else {
                         if (bp_is_action_variable(BP_DOCS_EDIT_SLUG, 0)) {
                             // This is an edit page
                             $view = 'edit';
                         } else {
                             if (bp_is_action_variable(BP_DOCS_DELETE_SLUG, 0)) {
                                 // This is an delete request
                                 $view = 'delete';
                             } else {
                                 if (bp_is_action_variable(BP_DOCS_HISTORY_SLUG, 0)) {
                                     // This is a history request
                                     $view = 'history';
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $view;
 }
 /**
  * Sets up the current view when viewing a user page
  *
  * @since 1.2
  */
 function get_current_view($view, $item_type)
 {
     if ($item_type == 'user') {
         if (!bp_current_action()) {
             // An empty $bp->action_variables[0] means that you're looking at a list
             $view = 'list';
         } else {
             if (bp_is_current_action(BP_DOCS_CATEGORY_SLUG)) {
                 // Category view
                 $view = 'category';
             } else {
                 if (bp_is_current_action(BP_DOCS_CREATE_SLUG)) {
                     // Create new doc
                     $view = 'create';
                 } else {
                     if (!bp_action_variable(0)) {
                         // $bp->action_variables[1] is the slug for this doc. If there's no
                         // further chunk, then we're attempting to view a single item
                         $view = 'single';
                     } else {
                         if (bp_is_action_variable(BP_DOCS_EDIT_SLUG, 0)) {
                             // This is an edit page
                             $view = 'edit';
                         } else {
                             if (bp_is_action_variable(BP_DOCS_DELETE_SLUG, 0)) {
                                 // This is an delete request
                                 $view = 'delete';
                             } else {
                                 if (bp_is_action_variable(BP_DOCS_HISTORY_SLUG, 0)) {
                                     // This is a history request
                                     $view = 'history';
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $view;
 }
function messages_screen_notices()
{
    global $notice_id;
    if (!is_super_admin()) {
        return false;
    }
    $notice_id = (int) bp_action_variable(1);
    if (!empty($notice_id) && is_numeric($notice_id)) {
        $notice = new BP_Messages_Notice($notice_id);
        if (bp_is_action_variable('deactivate', 0)) {
            if (!$notice->deactivate()) {
                bp_core_add_message(__('There was a problem deactivating that notice.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Notice deactivated.', 'buddypress'));
            }
        } else {
            if (bp_is_action_variable('activate', 0)) {
                if (!$notice->activate()) {
                    bp_core_add_message(__('There was a problem activating that notice.', 'buddypress'), 'error');
                } else {
                    bp_core_add_message(__('Notice activated.', 'buddypress'));
                }
            } else {
                if (bp_is_action_variable('delete')) {
                    if (!$notice->delete()) {
                        bp_core_add_message(__('There was a problem deleting that notice.', 'buddypress'), 'buddypress');
                    } else {
                        bp_core_add_message(__('Notice deleted.', 'buddypress'));
                    }
                }
            }
        }
        bp_core_redirect(bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices');
    }
    if (bp_action_variables()) {
        bp_do_404();
        return;
    }
    do_action('messages_screen_notices');
    bp_core_load_template(apply_filters('messages_template_notices', 'members/single/home'));
}
/**
 * Process a request to delete a message.
 *
 * @return bool False on failure.
 */
function messages_action_delete_message()
{
    if (!bp_is_messages_component() || bp_is_current_action('notices') || !bp_is_action_variable('delete', 0)) {
        return false;
    }
    $thread_id = bp_action_variable(1);
    if (!$thread_id || !is_numeric($thread_id) || !messages_check_thread_access($thread_id)) {
        bp_core_redirect(trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action()));
    } else {
        if (!check_admin_referer('messages_delete_thread')) {
            return false;
        }
        // Delete message
        if (!messages_delete_thread($thread_id)) {
            bp_core_add_message(__('There was an error deleting that message.', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('Message deleted.', 'buddypress'));
        }
        bp_core_redirect(trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action()));
    }
}
function bcg_get_query()
{
    $bp = buddypress();
    $cats = bcg_get_categories($bp->groups->current_group->id);
    $qs = array('post_type' => bcg_get_post_type(), 'post_status' => 'publish');
    if (empty($cats)) {
        $qs['name'] = -1;
        //we know it will not find anything
    }
    if (bcg_is_single_post()) {
        $slug = $bp->action_variables[0];
        $qs['name'] = $slug;
        //tax query
        $qs['tax_query'] = array(array('taxonomy' => bcg_get_taxonomy(), 'terms' => $cats, 'field' => 'id', 'operator' => 'IN'));
    }
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    if (bcg_is_category()) {
        $qs['tax_query'] = array(array('taxonomy' => bcg_get_taxonomy(), 'terms' => (int) bp_action_variable(1), 'field' => 'id', 'operator' => 'IN'));
    } else {
        $qs['tax_query'] = array(array('taxonomy' => bcg_get_taxonomy(), 'terms' => $cats, 'field' => 'id', 'operator' => 'IN'));
    }
    $qs['paged'] = $paged;
    return apply_filters("bcg_get_query", $qs);
}
/**
 * Returns the current group admin tab slug.
 *
 * @since 1.6.0
 *
 * @uses apply_filters() Filter bp_get_current_group_admin_tab to modify return value.
 *
 * @return string $tab The current tab's slug.
 */
function bp_get_group_current_admin_tab()
{
    if (bp_is_groups_component() && bp_is_current_action('admin')) {
        $tab = bp_action_variable(0);
    } else {
        $tab = '';
    }
    /**
     * Filters the current group admin tab slug.
     *
     * @since 1.6.0
     *
     * @param string $tab Current group admin tab slug.
     */
    return apply_filters('bp_get_current_group_admin_tab', $tab);
}
/**
 * Handles the display of the profile edit page by loading the correct template file.
 * Also checks to make sure this can only be accessed for the logged in users profile.
 *
 * @package BuddyPress XProfile
 * @uses bp_is_my_profile() Checks to make sure the current user being viewed equals the logged in user
 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
 */
function xprofile_screen_edit_profile()
{
    global $bp;
    if (!bp_is_my_profile() && !is_super_admin()) {
        return false;
    }
    // Make sure a group is set.
    if (!bp_action_variable(1)) {
        bp_core_redirect(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/1');
    }
    // Check the field group exists
    if (!bp_is_action_variable('group') || !xprofile_get_field_group(bp_action_variable(1))) {
        bp_do_404();
        return;
    }
    // Check to see if any new information has been submitted
    if (isset($_POST['field_ids'])) {
        // Check the nonce
        check_admin_referer('bp_xprofile_edit');
        // Check we have field ID's
        if (empty($_POST['field_ids'])) {
            bp_core_redirect(trailingslashit($bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . bp_action_variable(1)));
        }
        // Explode the posted field IDs into an array so we know which
        // fields have been submitted
        $posted_field_ids = explode(',', $_POST['field_ids']);
        $is_required = array();
        // Loop through the posted fields formatting any datebox values
        // then validate the field
        foreach ((array) $posted_field_ids as $field_id) {
            if (!isset($_POST['field_' . $field_id])) {
                if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) {
                    // Concatenate the values
                    $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
                    // Turn the concatenated value into a timestamp
                    $_POST['field_' . $field_id] = date('Y-m-d H:i:s', strtotime($date_value));
                }
            }
            $is_required[$field_id] = xprofile_check_is_required_field($field_id);
            if ($is_required[$field_id] && empty($_POST['field_' . $field_id])) {
                $errors = true;
            }
        }
        // There are errors
        if (!empty($errors)) {
            bp_core_add_message(__('Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress'), 'error');
            // No errors
        } else {
            // Reset the errors var
            $errors = false;
            // Now we've checked for required fields, lets save the values.
            foreach ((array) $posted_field_ids as $field_id) {
                // Certain types of fields (checkboxes, multiselects) may come through empty. Save them as an empty array so that they don't get overwritten by the default on the next edit.
                if (empty($_POST['field_' . $field_id])) {
                    $value = array();
                } else {
                    $value = $_POST['field_' . $field_id];
                }
                if (!xprofile_set_field_data($field_id, $bp->displayed_user->id, $value, $is_required[$field_id])) {
                    $errors = true;
                } else {
                    do_action('xprofile_profile_field_data_updated', $field_id, $value);
                }
            }
            do_action('xprofile_updated_profile', $bp->displayed_user->id, $posted_field_ids, $errors);
            // Set the feedback messages
            if ($errors) {
                bp_core_add_message(__('There was a problem updating some of your profile information, please try again.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Changes saved.', 'buddypress'));
            }
            // Redirect back to the edit screen to display the updates and message
            bp_core_redirect(trailingslashit(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . bp_action_variable(1)));
        }
    }
    do_action('xprofile_screen_edit_profile');
    bp_core_load_template(apply_filters('xprofile_template_edit_profile', 'members/single/home'));
}
Example #16
0
/**
 * Redirect from old 'accept-invitation' and 'opt-out' email formats
 *
 * Invite Anyone used to use the current_action and action_variables for
 * subpages of the registration screen. This caused some problems with URL
 * encoding, and it also broke with BP 2.1. In IA 1.3.4, this functionality
 * was moved to URL arguments; the current function handles backward
 * compatibility with the old addresses.
 *
 * @since 1.3.4
 */
function invite_anyone_accept_invitation_backward_compatibility()
{
    if (!bp_is_register_page()) {
        return;
    }
    if (!bp_current_action()) {
        return;
    }
    $action = bp_current_action();
    if (!in_array($action, array('accept-invitation', 'opt-out'))) {
        return;
    }
    $redirect_to = add_query_arg('iaaction', $action, bp_get_root_domain() . '/' . bp_get_signup_slug() . '/');
    $email = bp_action_variable(0);
    $email = str_replace(' ', '+', $email);
    if (!empty($email)) {
        $redirect_to = add_query_arg('email', $email, $redirect_to);
    }
    bp_core_redirect($redirect_to);
    die;
}
/**
 * Displays group filter titles
 *
 * @package BuddyPress
 * @todo Deprecate?
 */
function bp_groups_filter_title()
{
    $current_filter = bp_action_variable(0);
    switch ($current_filter) {
        case 'recently-active':
        default:
            _e('Recently Active', 'buddypress');
            break;
        case 'recently-joined':
            _e('Recently Joined', 'buddypress');
            break;
        case 'most-popular':
            _e('Most Popular', 'buddypress');
            break;
        case 'admin-of':
            _e('Administrator Of', 'buddypress');
            break;
        case 'mod-of':
            _e('Moderator Of', 'buddypress');
            break;
        case 'alphabetically':
            _e('Alphabetically', 'buddypress');
            break;
    }
    do_action('bp_groups_filter_title');
}
/**
 * Returns the current group admin tab slug
 *
 * @since 1.6
 *
 * @uses apply_filters() Filter bp_get_current_group_admin_tab to modify return value
 * @return str $tab The current tab's slug
 */
function bp_get_group_current_admin_tab()
{
    if (bp_is_groups_component() && bp_is_current_action('admin')) {
        $tab = bp_action_variable(0);
    } else {
        $tab = '';
    }
    return apply_filters('bp_get_current_group_admin_tab', $tab);
}
 /**
  * Constructor.
  *
  * @param array $args {
  *     An array of optional arguments.
  *     @type int $group_id ID of the group whose members are being
  *	     queried. Default: current group ID.
  *     @type int $page Page of results to be queried. Default: 1.
  *     @type int $per_page Number of items to return per page of
  *           results. Default: 20.
  *     @type int $max Optional. Max number of items to return.
  *     @type array $exclude Optional. Array of user IDs to exclude.
  *     @type bool|int True (or 1) to exclude admins and mods from
  *           results. Default: 1.
  *     @type bool|int True (or 1) to exclude banned users from results.
  *           Default: 1.
  *     @type array $group_role Optional. Array of group roles to include.
  *     @type string $search_terms Optional. Search terms to match.
  * }
  */
 function __construct($args = array())
 {
     // Backward compatibility with old method of passing arguments
     if (!is_array($args) || func_num_args() > 1) {
         _deprecated_argument(__METHOD__, '2.0.0', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress'), __METHOD__, __FILE__));
         $old_args_keys = array(0 => 'group_id', 1 => 'per_page', 2 => 'max', 3 => 'exclude_admins_mods', 4 => 'exclude_banned', 5 => 'exclude', 6 => 'group_role');
         $func_args = func_get_args();
         $args = bp_core_parse_args_array($old_args_keys, $func_args);
     }
     $r = wp_parse_args($args, array('group_id' => bp_get_current_group_id(), 'page' => 1, 'per_page' => 20, 'max' => false, 'exclude' => false, 'exclude_admins_mods' => 1, 'exclude_banned' => 1, 'group_role' => false, 'search_terms' => false, 'type' => 'last_joined'));
     // @todo No
     extract($r);
     $this->pag_page = isset($_REQUEST['mlpage']) ? intval($_REQUEST['mlpage']) : $r['page'];
     $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page;
     /**
      * Check the current group is the same as the supplied group ID.
      * It can differ when using {@link bp_group_has_members()} outside the Groups screens.
      */
     $current_group = groups_get_current_group();
     if (!$current_group || $current_group && $current_group->id !== bp_get_current_group_id()) {
         $current_group = groups_get_group(array('group_id' => $r['group_id']));
     }
     // Assemble the base URL for pagination
     $base_url = trailingslashit(bp_get_group_permalink($current_group) . bp_current_action());
     if (bp_action_variable()) {
         $base_url = trailingslashit($base_url . bp_action_variable());
     }
     $members_args = $r;
     $members_args['page'] = $this->pag_page;
     $members_args['per_page'] = $this->pag_num;
     $this->members = groups_get_group_members($members_args);
     if (!$max || $max >= (int) $this->members['count']) {
         $this->total_member_count = (int) $this->members['count'];
     } else {
         $this->total_member_count = (int) $max;
     }
     $this->members = $this->members['members'];
     if ($max) {
         if ($max >= count($this->members)) {
             $this->member_count = count($this->members);
         } else {
             $this->member_count = (int) $max;
         }
     } else {
         $this->member_count = count($this->members);
     }
     $this->pag_links = paginate_links(array('base' => add_query_arg(array('mlpage' => '%#%'), $base_url), 'format' => '', 'total' => !empty($this->pag_num) ? ceil($this->total_member_count / $this->pag_num) : $this->total_member_count, 'current' => $this->pag_page, 'prev_text' => '←', 'next_text' => '→', 'mid_size' => 1));
 }
Example #20
0
/**
 * Filters the title for the Friends component
 *
 * @deprecated 1.6.0
 * @deprecated No longer used
 */
function bp_friends_filter_title()
{
    _deprecated_function(__FUNCTION__, '1.6', 'Since BuddyPress 1.2, BP has not supported ordering of friend lists by URL parameters.');
    $current_filter = bp_action_variable(0);
    switch ($current_filter) {
        case 'recently-active':
        default:
            _e('Recently Active', 'buddypress');
            break;
        case 'newest':
            _e('Newest', 'buddypress');
            break;
        case 'alphabetically':
            _e('Alphabetically', 'buddypress');
            break;
    }
}
/**
 * Handle the display of Admin > Membership Requests.
 */
function groups_screen_group_admin_requests()
{
    $bp = buddypress();
    if ('membership-requests' != bp_get_group_current_admin_tab()) {
        return false;
    }
    if (!bp_is_item_admin() || 'public' == $bp->groups->current_group->status) {
        return false;
    }
    $request_action = (string) bp_action_variable(1);
    $membership_id = (int) bp_action_variable(2);
    if (!empty($request_action) && !empty($membership_id)) {
        if ('accept' == $request_action && is_numeric($membership_id)) {
            // Check the nonce first.
            if (!check_admin_referer('groups_accept_membership_request')) {
                return false;
            }
            // Accept the membership request.
            if (!groups_accept_membership_request($membership_id)) {
                bp_core_add_message(__('There was an error accepting the membership request. Please try again.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Group membership request accepted', 'buddypress'));
            }
        } elseif ('reject' == $request_action && is_numeric($membership_id)) {
            /* Check the nonce first. */
            if (!check_admin_referer('groups_reject_membership_request')) {
                return false;
            }
            // Reject the membership request.
            if (!groups_reject_membership_request($membership_id)) {
                bp_core_add_message(__('There was an error rejecting the membership request. Please try again.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Group membership request rejected', 'buddypress'));
            }
        }
        /**
         * Fires before the redirect if a group membership request has been handled.
         *
         * @since 1.0.0
         *
         * @param int    $id             ID of the group that was edited.
         * @param string $request_action Membership request action being performed.
         * @param int    $membership_id  The key of the action_variables array that you want.
         */
        do_action('groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id);
        bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/membership-requests/');
    }
    /**
     * Fires before the loading of the group membership request page template.
     *
     * @since 1.0.0
     *
     * @param int $id ID of the group that is being displayed.
     */
    do_action('groups_screen_group_admin_requests', $bp->groups->current_group->id);
    /**
     * Filters the template to load for a group's membership request page.
     *
     * @since 1.0.0
     *
     * @param string $value Path to a group's membership request template.
     */
    bp_core_load_template(apply_filters('groups_template_group_admin_requests', 'groups/single/home'));
}
/**
 * Handles the display of the profile edit page by loading the correct template file.
 * Also checks to make sure this can only be accessed for the logged in users profile.
 *
 * @package BuddyPress XProfile
 * @uses bp_is_my_profile() Checks to make sure the current user being viewed equals the logged in user
 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
 */
function xprofile_screen_edit_profile()
{
    if (!bp_is_my_profile() && !bp_current_user_can('bp_moderate')) {
        return false;
    }
    $bp = buddypress();
    // Make sure a group is set.
    if (!bp_action_variable(1)) {
        bp_core_redirect(trailingslashit(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/1'));
    }
    // Check the field group exists
    if (!bp_is_action_variable('group') || !xprofile_get_field_group(bp_action_variable(1))) {
        bp_do_404();
        return;
    }
    // No errors
    $errors = false;
    // Check to see if any new information has been submitted
    if (isset($_POST['field_ids'])) {
        // Check the nonce
        check_admin_referer('bp_xprofile_edit');
        // Check we have field ID's
        if (empty($_POST['field_ids'])) {
            bp_core_redirect(trailingslashit(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . bp_action_variable(1)));
        }
        // Explode the posted field IDs into an array so we know which
        // fields have been submitted
        $posted_field_ids = wp_parse_id_list($_POST['field_ids']);
        $is_required = array();
        // Loop through the posted fields formatting any datebox values
        // then validate the field
        foreach ((array) $posted_field_ids as $field_id) {
            if (!isset($_POST['field_' . $field_id])) {
                if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) {
                    // Concatenate the values
                    $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
                    // Turn the concatenated value into a timestamp
                    $_POST['field_' . $field_id] = date('Y-m-d H:i:s', strtotime($date_value));
                }
            }
            $is_required[$field_id] = xprofile_check_is_required_field($field_id);
            if ($is_required[$field_id] && empty($_POST['field_' . $field_id])) {
                $errors = true;
            }
        }
        // There are errors
        if (!empty($errors)) {
            bp_core_add_message(__('Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress'), 'error');
            // No errors
        } else {
            // Reset the errors var
            $errors = false;
            // Now we've checked for required fields, lets save the values.
            $old_values = $new_values = array();
            foreach ((array) $posted_field_ids as $field_id) {
                // Certain types of fields (checkboxes, multiselects) may come through empty. Save them as an empty array so that they don't get overwritten by the default on the next edit.
                $value = isset($_POST['field_' . $field_id]) ? $_POST['field_' . $field_id] : '';
                $visibility_level = !empty($_POST['field_' . $field_id . '_visibility']) ? $_POST['field_' . $field_id . '_visibility'] : 'public';
                // Save the old and new values. They will be
                // passed to the filter and used to determine
                // whether an activity item should be posted
                $old_values[$field_id] = array('value' => xprofile_get_field_data($field_id, bp_displayed_user_id()), 'visibility' => xprofile_get_field_visibility_level($field_id, bp_displayed_user_id()));
                // Update the field data and visibility level
                xprofile_set_field_visibility_level($field_id, bp_displayed_user_id(), $visibility_level);
                $field_updated = xprofile_set_field_data($field_id, bp_displayed_user_id(), $value, $is_required[$field_id]);
                $value = xprofile_get_field_data($field_id, bp_displayed_user_id());
                $new_values[$field_id] = array('value' => $value, 'visibility' => xprofile_get_field_visibility_level($field_id, bp_displayed_user_id()));
                if (!$field_updated) {
                    $errors = true;
                } else {
                    /**
                     * Fires on each iteration of an XProfile field being saved with no error.
                     *
                     * @since BuddyPress (1.1.0)
                     *
                     * @param int    $field_id ID of the field that was saved.
                     * @param string $value    Value that was saved to the field.
                     */
                    do_action('xprofile_profile_field_data_updated', $field_id, $value);
                }
            }
            /**
             * Fires after all XProfile fields have been saved for the current profile.
             *
             * @since BuddyPress (1.0.0)
             *
             * @param int   $value            Displayed user ID.
             * @param array $posted_field_ids Array of field IDs that were edited.
             * @param bool  $errors           Whether or not any errors occurred.
             * @param array $old_values       Array of original values before updated.
             * @param array $new_values       Array of newly saved values after update.
             */
            do_action('xprofile_updated_profile', bp_displayed_user_id(), $posted_field_ids, $errors, $old_values, $new_values);
            // Set the feedback messages
            if (!empty($errors)) {
                bp_core_add_message(__('There was a problem updating some of your profile information. Please try again.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Changes saved.', 'buddypress'));
            }
            // Redirect back to the edit screen to display the updates and message
            bp_core_redirect(trailingslashit(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . bp_action_variable(1)));
        }
    }
    /**
     * Fires right before the loading of the XProfile edit screen template file.
     *
     * @since BuddyPress (1.0.0)
     */
    do_action('xprofile_screen_edit_profile');
    /**
     * Filters the template to load for the XProfile edit screen.
     *
     * @since BuddyPress (1.0.0)
     *
     * @param string $template Path to the XProfile edit template to load.
     */
    bp_core_load_template(apply_filters('xprofile_template_edit_profile', 'members/single/home'));
}
Example #23
0
        /**
         * Set the content part of the template
         *
         * @package WP Idea Stream
         * @subpackage buddypress/screens
         *
         * @since  2.0.0
         *
         * @uses   bp_action_variable() to get an action variable
         * @uses   wp_idea_stream_cpage_slug() to get the pagination slug for user comments
         * @uses   wp_idea_stream_paged_slug() to get the pagination slug
         * @uses   bp_is_my_profile() to check if logged in user is displaying his own profile
         * @uses   add_filter() to temporarly customize IdeaStream Loop
         * @uses   wp_idea_stream_template_part() to get the needed IdeaStream template part
         * @uses   remove_filter() to remove the temporary filters
         */
        public function set_content()
        {
            // Init vars
            $this->user_args = array();
            $template_slug = 'idea';
            $template_name = 'loop';
            $filters = array('is_user_profile', 'ideas_query_args');
            /**
             * Make sure the pagination is set
             *
             * For idea queries the pagination slug is the same than WordPress
             * the paged query var is set to it's not necessary.
             * For comments queries, as the pagination slug is different then the one
             * of WordPress, it's necessary.
             */
            if (in_array(bp_action_variable(0), array(wp_idea_stream_cpage_slug(), wp_idea_stream_paged_slug())) && is_numeric(bp_action_variable(1))) {
                $this->user_args['page'] = (int) bp_action_variable(1);
            }
            /**
             * About rates, we don't need the ideas the user submitted
             * but the ideas he rated, so the author must not be set.
             */
            if ('rates' == $this->screen) {
                // Building the meta query, no need to edit query orderby
                // for user rates.
                $this->user_args['meta_query'] = array(array('key' => '_ideastream_rates', 'value' => ';i:' . $this->user_id . ';', 'compare' => 'LIKE'));
                $filters = array_merge($filters, array('is_user_profile_rates', 'users_displayed_user_id'));
                /**
                 * About comments, we are using specific loop, template
                 * and filter.
                 */
            } else {
                if ('comments' == $this->screen) {
                    $template_slug = 'user';
                    $template_name = 'comments';
                    $this->user_args['user_id'] = $this->user_id;
                    $filters = array('comments_query_args');
                    // Default is user ideas, we need to set the author.
                } else {
                    $this->user_args['author'] = $this->user_id;
                    // Show private ideas only if on current user is on his profile
                    if (bp_is_my_profile()) {
                        $filters = array_merge($filters, array('ideas_get_status'));
                    }
                }
            }
            // Add temporary filters
            foreach ($filters as $filter) {
                $this_filter = str_replace(array('ideas', 'comments', '_rates', 'users_'), array('filter', 'filter', '', ''), $filter);
                add_filter('wp_idea_stream_' . $filter, array($this, $this_filter), 10, 1);
            }
            ?>

		<div id="wp-idea-stream">

			<?php 
            wp_idea_stream_template_part($template_slug, $template_name);
            ?>

		</div>

		<?php 
            // Remove temporary filters
            foreach ($filters as $filter) {
                $this_filter = str_replace(array('ideas', 'comments', '_rates', 'users_'), array('filter', 'filter', '', ''), $filter);
                remove_filter('wp_idea_stream_' . $filter, array($this, $this_filter), 10, 1);
            }
        }
/**
 * Initialize the messages template loop for a specific thread.
 *
 * @param array|string $args {
 *     Array of arguments. All are optional.
 *     @type int    $thread_id         ID of the thread whose messages you are displaying.
 *                                     Default: if viewing a thread, the thread ID will be parsed from
 *                                     the URL (bp_action_variable( 0 )).
 *     @type string $order             'ASC' or 'DESC'. Default: 'ASC'.
 *     @type bool   $update_meta_cache Whether to pre-fetch metadata for
 *                                     queried message items. Default: true.
 * }
 * @return bool True if there are messages to display, otherwise false.
 */
function bp_thread_has_messages($args = '')
{
    global $thread_template;
    $r = bp_parse_args($args, array('thread_id' => false, 'order' => 'ASC', 'update_meta_cache' => true), 'thread_has_messages');
    if (empty($r['thread_id']) && bp_is_messages_component() && bp_is_current_action('view')) {
        $r['thread_id'] = (int) bp_action_variable(0);
    }
    // Set up extra args.
    $extra_args = $r;
    unset($extra_args['thread_id'], $extra_args['order']);
    $thread_template = new BP_Messages_Thread_Template($r['thread_id'], $r['order'], $extra_args);
    return $thread_template->has_messages();
}
/**
 * Return the text to edit when editing a post.
 *
 * @return string Editable text.
 */
function bp_get_the_topic_post_edit_text()
{
    $post = bp_forums_get_post(bp_action_variable(4));
    return apply_filters('bp_get_the_topic_post_edit_text', esc_attr($post->post_text));
}
 /**
  * Set up component global data.
  *
  * The BP_GROUPS_SLUG constant is deprecated, and only used here for
  * backwards compatibility.
  *
  * @since 1.5.0
  *
  * @see BP_Component::setup_globals() for a description of arguments.
  *
  * @param array $args See BP_Component::setup_globals() for a description.
  */
 public function setup_globals($args = array())
 {
     $bp = buddypress();
     // Define a slug, if necessary.
     if (!defined('BP_GROUPS_SLUG')) {
         define('BP_GROUPS_SLUG', $this->id);
     }
     // Global tables for groups component.
     $global_tables = array('table_name' => $bp->table_prefix . 'bp_groups', 'table_name_members' => $bp->table_prefix . 'bp_groups_members', 'table_name_groupmeta' => $bp->table_prefix . 'bp_groups_groupmeta');
     // Metadata tables for groups component.
     $meta_tables = array('group' => $bp->table_prefix . 'bp_groups_groupmeta');
     // All globals for groups component.
     // Note that global_tables is included in this array.
     $args = array('slug' => BP_GROUPS_SLUG, 'root_slug' => isset($bp->pages->groups->slug) ? $bp->pages->groups->slug : BP_GROUPS_SLUG, 'has_directory' => true, 'directory_title' => _x('Groups', 'component directory title', 'buddypress'), 'notification_callback' => 'groups_format_notifications', 'search_string' => _x('Search Groups...', 'Component directory search', 'buddypress'), 'global_tables' => $global_tables, 'meta_tables' => $meta_tables);
     parent::setup_globals($args);
     /* Single Group Globals **********************************************/
     // Are we viewing a single group?
     if (bp_is_groups_component() && ($group_id = BP_Groups_Group::group_exists(bp_current_action()))) {
         $bp->is_single_item = true;
         /**
          * Filters the current PHP Class being used.
          *
          * @since 1.5.0
          *
          * @param string $value Name of the class being used.
          */
         $current_group_class = apply_filters('bp_groups_current_group_class', 'BP_Groups_Group');
         if ($current_group_class == 'BP_Groups_Group') {
             $this->current_group = groups_get_group(array('group_id' => $group_id, 'populate_extras' => true));
         } else {
             /**
              * Filters the current group object being instantiated from previous filter.
              *
              * @since 1.5.0
              *
              * @param object $value Newly instantiated object for the group.
              */
             $this->current_group = apply_filters('bp_groups_current_group_object', new $current_group_class($group_id));
         }
         // When in a single group, the first action is bumped down one because of the
         // group name, so we need to adjust this and set the group name to current_item.
         $bp->current_item = bp_current_action();
         $bp->current_action = bp_action_variable(0);
         array_shift($bp->action_variables);
         // Using "item" not "group" for generic support in other components.
         if (bp_current_user_can('bp_moderate')) {
             bp_update_is_item_admin(true, 'groups');
         } else {
             bp_update_is_item_admin(groups_is_user_admin(bp_loggedin_user_id(), $this->current_group->id), 'groups');
         }
         // If the user is not an admin, check if they are a moderator.
         if (!bp_is_item_admin()) {
             bp_update_is_item_mod(groups_is_user_mod(bp_loggedin_user_id(), $this->current_group->id), 'groups');
         }
         // Is the logged in user a member of the group?
         if (is_user_logged_in() && groups_is_user_member(bp_loggedin_user_id(), $this->current_group->id)) {
             $this->current_group->is_user_member = true;
         } else {
             $this->current_group->is_user_member = false;
         }
         // Should this group be visible to the logged in user?
         if ('public' == $this->current_group->status || $this->current_group->is_user_member) {
             $this->current_group->is_visible = true;
         } else {
             $this->current_group->is_visible = false;
         }
         // If this is a private or hidden group, does the user have access?
         if ('private' == $this->current_group->status || 'hidden' == $this->current_group->status) {
             if ($this->current_group->is_user_member && is_user_logged_in() || bp_current_user_can('bp_moderate')) {
                 $this->current_group->user_has_access = true;
             } else {
                 $this->current_group->user_has_access = false;
             }
         } else {
             $this->current_group->user_has_access = true;
         }
         // Check once if the current group has a custom front template.
         $this->current_group->front_template = bp_groups_get_front_template($this->current_group);
         // Set current_group to 0 to prevent debug errors.
     } else {
         $this->current_group = 0;
     }
     /**
      * Filters the list of illegal groups names/slugs.
      *
      * @since 1.0.0
      *
      * @param array $value Array of illegal group names/slugs.
      */
     $this->forbidden_names = apply_filters('groups_forbidden_names', array('my-groups', 'create', 'invites', 'send-invites', 'forum', 'delete', 'add', 'admin', 'request-membership', 'members', 'settings', 'avatar', $this->slug, $this->root_slug));
     // If the user was attempting to access a group, but no group by that name was found, 404.
     if (bp_is_groups_component() && empty($this->current_group) && bp_current_action() && !in_array(bp_current_action(), $this->forbidden_names)) {
         bp_do_404();
         return;
     }
     /**
      * Filters the preconfigured groups creation steps.
      *
      * @since 1.1.0
      *
      * @param array $value Array of preconfigured group creation steps.
      */
     $this->group_creation_steps = apply_filters('groups_create_group_steps', array('group-details' => array('name' => _x('Details', 'Group screen nav', 'buddypress'), 'position' => 0), 'group-settings' => array('name' => _x('Settings', 'Group screen nav', 'buddypress'), 'position' => 10)));
     // If avatar uploads are not disabled, add avatar option.
     $disabled_avatar_uploads = (int) bp_disable_group_avatar_uploads();
     if (!$disabled_avatar_uploads && $bp->avatar->show_avatars) {
         $this->group_creation_steps['group-avatar'] = array('name' => _x('Photo', 'Group screen nav', 'buddypress'), 'position' => 20);
     }
     if (bp_group_use_cover_image_header()) {
         $this->group_creation_steps['group-cover-image'] = array('name' => _x('Cover Image', 'Group screen nav', 'buddypress'), 'position' => 25);
     }
     // If friends component is active, add invitations.
     if (bp_is_active('friends')) {
         $this->group_creation_steps['group-invites'] = array('name' => _x('Invites', 'Group screen nav', 'buddypress'), 'position' => 30);
     }
     /**
      * Filters the list of valid groups statuses.
      *
      * @since 1.1.0
      *
      * @param array $value Array of valid group statuses.
      */
     $this->valid_status = apply_filters('groups_valid_status', array('public', 'private', 'hidden'));
     // Auto join group when non group member performs group activity.
     $this->auto_join = defined('BP_DISABLE_AUTO_GROUP_JOIN') && BP_DISABLE_AUTO_GROUP_JOIN ? false : true;
 }
Example #27
0
/**
 * Reset the week parameter of the WordPress main query if needed.
 *
 * When cropping an avatar, a $_POST['w'] var is sent, setting the 'week'
 * parameter of the WordPress main query to this posted var. To avoid
 * notices, we need to make sure this 'week' query var is reset to 0.
 *
 * @since  2.2.0
 *
 * @param  WP_Query|null $posts_query the main query object.
 *
 * @uses   bp_is_group_create()
 * @uses   bp_is_group_admin_page()
 * @uses   bp_is_group_admin_screen() to check for a group admin screen
 * @uses   bp_action_variable() to check for the group's avatar creation step
 * @uses   bp_is_user_change_avatar() to check for the user's change profile screen
 */
function bp_core_avatar_reset_query($posts_query = null)
{
    $reset_w = false;
    // Group's avatar edit screen
    if (bp_is_group_admin_page()) {
        $reset_w = bp_is_group_admin_screen('group-avatar');
        // Group's avatar create screen
    } elseif (bp_is_group_create()) {
        /**
         * we can't use bp_get_groups_current_create_step()
         * as it's not set yet
         */
        $reset_w = 'group-avatar' === bp_action_variable(1);
        // User's change avatar screen
    } else {
        $reset_w = bp_is_user_change_avatar();
    }
    // A user or a group is cropping an avatar
    if (true === $reset_w && isset($_POST['avatar-crop-submit'])) {
        $posts_query->set('w', 0);
    }
}
function bp_checkins_browser_header($title_and_sep, $title, $sep, $seplocation)
{
    if (bp_checkins_if_single_place()) {
        $place_title = ucfirst(bp_get_checkins_slug()) . ' ' . $sep . ' Place' . $title_and_sep;
        $place = wp_cache_get('single_query', 'bp_checkins_single');
        if (false === $place || is_null($place->query->post->ID)) {
            $place = new BP_Checkins_Place();
            $place->get(array('p' => bp_action_variable(0)));
        }
        $place_title = apply_filters('get_the_title', $place->query->post->post_title) . ' ' . $sep . ' Place' . $title_and_sep;
        return $place_title;
    } elseif (bp_checkins_if_category_place()) {
        return ucfirst(bp_get_checkins_places_term_info('name', bp_action_variable(1))) . $title_and_sep;
    } elseif (bp_checkins_if_place_home()) {
        return __('Browse or Search Places', 'bp-checkins') . $title_and_sep;
    } elseif (bp_checkins_is_directory()) {
        return ucfirst(bp_get_checkins_slug()) . ' &amp Places ' . $sep . ' ';
    } else {
        return $title_and_sep;
    }
}
function bp_has_links($args = array())
{
    global $links_template, $bp;
    if (empty($args)) {
        // The following code will auto set parameters based on the page being viewed.
        // for example on example.com/members/marshall/links/my-links/popular/
        // $type = 'popular'
        //
        if (true === bp_is_directory() && 'my-links' == $bp->current_action) {
            $order = $bp->action_variables[0];
            if ('active' == $order) {
                $type = 'active';
            } elseif ('all' == $order) {
                $type = 'all';
            } elseif ('newest' == $order) {
                $type = 'newest';
            } else {
                if ('popular' == $order) {
                    $type = 'popular';
                } else {
                    if ('most-votes' == $order) {
                        $type = 'most-votes';
                    } else {
                        if ('high-votes' == $order) {
                            $type = 'high-votes';
                        }
                    }
                }
            }
        } else {
            if ($bp->links->current_link->slug) {
                $type = 'single-link';
                $args['slug'] = $bp->links->current_link->slug;
            }
        }
        $args['order'] = $order;
        $args['type'] = $type;
    }
    // default args to use IF args is not empty
    $defaults = array('type' => false, 'page' => 1, 'per_page' => 10, 'max' => false, 'avatar_size' => false, 'user_id' => false, 'slug' => false, 'search_terms' => false, 'category_id' => false, 'category_slug' => null);
    // args to pass to template class
    $template_args = wp_parse_args($args, $defaults);
    // category slug in path overrides any category id that is set
    if (false === defined('DOING_AJAX') && true === bp_is_directory() && BP_LINKS_CAT_URL_SLUG == bp_current_action()) {
        // get current item
        $category_slug = bp_action_variable(0);
        // have a category slug?
        if (false === empty($category_slug)) {
            // yes, set it
            $template_args['category_slug'] = $category_slug;
            // ...and kill any category id that is set
            $template_args['category_id'] = false;
        }
    }
    switch (true) {
        case isset($_REQUEST['link-filter-box']):
            $template_args['search_terms'] = $_REQUEST['link-filter-box'];
            break;
        case isset($_REQUEST['s']):
            $template_args['search_terms'] = $_REQUEST['s'];
            break;
    }
    $template_args = apply_filters('bp_has_links_template_args', $template_args);
    $links_template = new BP_Links_Template($template_args);
    return apply_filters('bp_has_links', $links_template->has_links(), $links_template);
}
function bp_forums_screen_single_topic()
{
    global $bp;
    if (!bp_is_forums_component() || !bp_is_current_action('topic') || !bp_action_variable(0)) {
        return false;
    }
    do_action('bp_forums_screen_single_topic');
    bp_core_load_template(apply_filters('bp_forums_screen_single_topic', 'forums/single/topic'));
}