/**
 * Query for XProfile groups and fields.
 *
 * @since 1.0.0
 *
 * @global object $profile_template
 * @see BP_XProfile_Group::get() for full description of `$args` array.
 *
 * @param array|string $args {
 *     Array of arguments. See BP_XProfile_Group::get() for full description. Those arguments whose defaults differ
 *     from that method are described here:
 *     @type string|array $member_type            Default: 'any'.
 *     @type bool         $hide_empty_groups      Default: true.
 *     @type bool         $hide_empty_fields      Defaults to true on the Dashboard, on a user's Edit Profile page,
 *                                                or during registration. Otherwise false.
 *     @type bool         $fetch_visibility_level Defaults to true when an admin is viewing a profile, or when a user is
 *                                                viewing her own profile, or during registration. Otherwise false.
 *     @type bool         $fetch_fields           Default: true.
 *     @type bool         $fetch_field_data       Default: true.
 * }
 *
 * @return bool
 */
function bp_has_profile($args = '')
{
    global $profile_template;
    // Only show empty fields if we're on the Dashboard, or we're on a user's
    // profile edit page, or this is a registration page.
    $hide_empty_fields_default = !is_network_admin() && !is_admin() && !bp_is_user_profile_edit() && !bp_is_register_page();
    // We only need to fetch visibility levels when viewing your own profile.
    if (bp_is_my_profile() || bp_current_user_can('bp_moderate') || bp_is_register_page()) {
        $fetch_visibility_level_default = true;
    } else {
        $fetch_visibility_level_default = false;
    }
    // Parse arguments.
    $r = bp_parse_args($args, array('user_id' => bp_displayed_user_id(), 'member_type' => 'any', 'profile_group_id' => false, 'hide_empty_groups' => true, 'hide_empty_fields' => $hide_empty_fields_default, 'fetch_fields' => true, 'fetch_field_data' => true, 'fetch_visibility_level' => $fetch_visibility_level_default, 'exclude_groups' => false, 'exclude_fields' => false, 'update_meta_cache' => true), 'has_profile');
    // Populate the template loop global.
    $profile_template = new BP_XProfile_Data_Template($r);
    /**
     * Filters whether or not a group has a profile to display.
     *
     * @since 1.1.0
     * @since 2.6.0 Added the `$r` parameter.
     *
     * @param bool   $has_groups       Whether or not there are group profiles to display.
     * @param string $profile_template Current profile template being used.
     * @param array  $r                Array of arguments passed into the BP_XProfile_Data_Template class.
     */
    return apply_filters('bp_has_profile', $profile_template->has_groups(), $profile_template, $r);
}
function messages_action_view_message()
{
    global $thread_id, $bp;
    if (!bp_is_messages_component() || !bp_is_current_action('view')) {
        return false;
    }
    $thread_id = (int) bp_action_variable(0);
    if (!$thread_id || !messages_is_valid_thread($thread_id) || !messages_check_thread_access($thread_id) && !is_super_admin()) {
        bp_core_redirect(bp_displayed_user_domain() . bp_get_messages_slug());
    }
    // Check if a new reply has been submitted
    if (isset($_POST['send'])) {
        // Check the nonce
        check_admin_referer('messages_send_message', 'send_message_nonce');
        // Send the reply
        if (messages_new_message(array('thread_id' => $thread_id, 'subject' => $_POST['subject'], 'content' => $_POST['content']))) {
            bp_core_add_message(__('Your reply was sent successfully', 'buddypress'));
        } else {
            bp_core_add_message(__('There was a problem sending your reply, please try again', 'buddypress'), 'error');
        }
        bp_core_redirect(bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/');
    }
    // Mark message read
    messages_mark_thread_read($thread_id);
    // Decrease the unread count in the nav before it's rendered
    $name = sprintf(__('Messages <span>%s</span>', 'buddypress'), bp_get_total_unread_messages_count());
    $bp->bp_nav[$bp->messages->slug]['name'] = $name;
    do_action('messages_action_view_message');
    bp_core_new_subnav_item(array('name' => sprintf(__('From: %s', 'buddypress'), BP_Messages_Thread::get_last_sender($thread_id)), 'slug' => 'view', 'parent_url' => trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug()), 'parent_slug' => bp_get_messages_slug(), 'screen_function' => true, 'position' => 40, 'user_has_access' => bp_is_my_profile(), 'link' => bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . (int) $thread_id));
    bp_core_load_template(apply_filters('messages_template_view_message', 'members/single/home'));
}
/**
 * Adds the User Admin top-level menu to user pages
 *
 * @package BuddyPress
 * @since 1.5
 */
function bp_members_admin_bar_user_admin_menu()
{
    global $bp, $wp_admin_bar;
    // Only show if viewing a user
    if (!bp_is_user()) {
        return false;
    }
    // Don't show this menu to non site admins or if you're viewing your own profile
    if (!current_user_can('edit_users') || bp_is_my_profile()) {
        return false;
    }
    // User avatar
    $avatar = bp_core_fetch_avatar(array('item_id' => $bp->displayed_user->id, 'email' => $bp->displayed_user->userdata->user_email, 'width' => 16, 'height' => 16));
    // Unique ID for the 'My Account' menu
    $bp->user_admin_menu_id = !empty($avatar) ? 'user-admin-with-avatar' : 'user-admin';
    // Add the top-level User Admin button
    $wp_admin_bar->add_menu(array('id' => $bp->user_admin_menu_id, 'title' => $avatar . bp_get_displayed_user_fullname(), 'href' => bp_displayed_user_domain()));
    // User Admin > Edit this user's profile
    $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => 'edit-profile', 'title' => __("Edit Profile", 'buddypress'), 'href' => bp_get_members_component_link('profile', 'edit')));
    // User Admin > Edit this user's avatar
    $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => 'change-avatar', 'title' => __("Edit Avatar", 'buddypress'), 'href' => bp_get_members_component_link('profile', 'change-avatar')));
    // User Admin > Spam/unspam
    if (!bp_core_is_user_spammer(bp_displayed_user_id())) {
        $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => 'spam-user', 'title' => __('Mark as Spammer', 'buddypress'), 'href' => wp_nonce_url(bp_displayed_user_domain() . 'admin/mark-spammer/', 'mark-unmark-spammer'), 'meta' => array('onclick' => 'confirm(" ' . __('Are you sure you want to mark this user as a spammer?', 'buddypress') . '");')));
    } else {
        $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => 'unspam-user', 'title' => __('Not a Spammer', 'buddypress'), 'href' => wp_nonce_url(bp_displayed_user_domain() . 'admin/unmark-spammer/', 'mark-unmark-spammer'), 'meta' => array('onclick' => 'confirm(" ' . __('Are you sure you want to mark this user as not a spammer?', 'buddypress') . '");')));
    }
    // User Admin > Delete Account
    $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => 'delete-user', 'title' => __('Delete Account', 'buddypress'), 'href' => wp_nonce_url(bp_displayed_user_domain() . 'admin/delete-user/', 'delete-user'), 'meta' => array('onclick' => 'confirm(" ' . __("Are you sure you want to delete this user's account?", 'buddypress') . '");')));
}
Example #4
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;
}
Example #5
0
/**
 * bp_em_setup_nav()
 *
 * Sets up the user profile navigation items for the component. This adds the top level nav
 * item and all the sub level nav items to the navigation array. This is then
 * rendered in the template.
 */
function bp_em_setup_nav()
{
    global $bp;
    $count = 0;
    /* Add 'Events' to the main user profile navigation */
    bp_core_new_nav_item(array('name' => __('Events', 'bp-em'), 'slug' => $bp->events->slug, 'position' => 80, 'screen_function' => bp_is_my_profile() ? 'bp_em_my_events' : 'bp_em_events', 'default_subnav_slug' => bp_is_my_profile() ? 'my-events' : ''));
    $em_link = $bp->loggedin_user->domain . $bp->events->slug . '/';
    /* Create two sub nav items for this component */
    bp_core_new_subnav_item(array('name' => __('My Profile', 'dbem'), 'slug' => 'profile', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_events', 'position' => 10, 'user_has_access' => bp_is_my_profile()));
    bp_core_new_subnav_item(array('name' => __('Events I\'m Attending', 'dbem'), 'slug' => 'attending', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_attending', 'position' => 20, 'user_has_access' => bp_is_my_profile()));
    bp_core_new_subnav_item(array('name' => __('My Events', 'dbem'), 'slug' => 'my-events', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_events', 'position' => 30, 'user_has_access' => bp_is_my_profile()));
    bp_core_new_subnav_item(array('name' => __('My Locations', 'dbem'), 'slug' => 'my-locations', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_locations', 'position' => 40, 'user_has_access' => bp_is_my_profile()));
    bp_core_new_subnav_item(array('name' => __('My Event Bookings', 'dbem'), 'slug' => 'my-bookings', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_bookings', 'position' => 50, 'user_has_access' => bp_is_my_profile()));
    /* Add a nav item for this component under the settings nav item. */
    bp_core_new_subnav_item(array('name' => __('Events', 'dbem'), 'slug' => 'group-events', 'parent_slug' => $bp->groups->slug, 'parent_url' => $bp->loggedin_user->domain . $bp->groups->slug . '/', 'screen_function' => 'bp_em_my_group_events', 'position' => 60, 'user_has_access' => bp_is_my_profile()));
    /* Add a nav item for this component under the settings nav item. */
    bp_core_new_subnav_item(array('name' => __('Events', 'dbem'), 'slug' => 'events-settings', 'parent_slug' => $bp->settings->slug, 'parent_url' => $bp->loggedin_user->domain . $bp->settings->slug . '/', 'screen_function' => 'bp_em_screen_settings_menu', 'position' => 40, 'user_has_access' => bp_is_my_profile()));
    /* Create two sub nav items for this component */
    $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';
    if ($bp->current_component == 'groups') {
        $count = EM_Events::count(array('group' => $bp->groups->current_group->id));
        if (empty($count)) {
            $count = 0;
        }
    }
    bp_core_new_subnav_item(array('name' => sprintf(__('Events (%s)', 'dbem'), $count), 'slug' => 'events', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'bp_em_group_events', 'position' => 50, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums'));
}
/**
 * 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());
        }
    }
}
/**
 * Add the User Admin top-level menu to user pages.
 *
 * @since 1.5.0
 */
function bp_members_admin_bar_user_admin_menu()
{
    global $wp_admin_bar;
    // Only show if viewing a user
    if (!bp_is_user()) {
        return false;
    }
    // Don't show this menu to non site admins or if you're viewing your own profile
    if (!current_user_can('edit_users') || bp_is_my_profile()) {
        return false;
    }
    $bp = buddypress();
    // Unique ID for the 'My Account' menu
    $bp->user_admin_menu_id = 'user-admin';
    // Add the top-level User Admin button
    $wp_admin_bar->add_menu(array('id' => $bp->user_admin_menu_id, 'title' => __('Edit Member', 'buddypress'), 'href' => bp_displayed_user_domain()));
    if (bp_is_active('xprofile')) {
        // User Admin > Edit this user's profile
        $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => $bp->user_admin_menu_id . '-edit-profile', 'title' => __("Edit Profile", 'buddypress'), 'href' => bp_get_members_component_link('profile', 'edit')));
        // User Admin > Edit this user's avatar
        if (buddypress()->avatar->show_avatars) {
            $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => $bp->user_admin_menu_id . '-change-avatar', 'title' => __("Edit Profile Photo", 'buddypress'), 'href' => bp_get_members_component_link('profile', 'change-avatar')));
        }
    }
    if (bp_is_active('settings')) {
        // User Admin > Spam/unspam
        $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => $bp->user_admin_menu_id . '-user-capabilities', 'title' => __('User Capabilities', 'buddypress'), 'href' => bp_displayed_user_domain() . 'settings/capabilities/'));
        // User Admin > Delete Account
        $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => $bp->user_admin_menu_id . '-delete-user', 'title' => __('Delete Account', 'buddypress'), 'href' => bp_displayed_user_domain() . 'settings/delete-account/'));
    }
}
 /**
  * Setup BuddyBar navigation
  */
 function setup_nav()
 {
     // Define local variable
     $sub_nav = array();
     // Add the settings navigation item
     $main_nav = array('name' => __('Settings', 'buddypress'), 'slug' => $this->slug, 'position' => 100, 'show_for_displayed_user' => bp_core_can_edit_settings(), 'screen_function' => 'bp_settings_screen_general', 'default_subnav_slug' => 'general');
     // Determine user to use
     if (bp_displayed_user_domain()) {
         $user_domain = bp_displayed_user_domain();
     } elseif (bp_loggedin_user_domain()) {
         $user_domain = bp_loggedin_user_domain();
     } else {
         return;
     }
     $settings_link = trailingslashit($user_domain . $this->slug);
     // Add General Settings nav item
     $sub_nav[] = array('name' => __('General', 'buddypress'), 'slug' => 'general', 'parent_url' => $settings_link, 'parent_slug' => $this->slug, 'screen_function' => 'bp_settings_screen_general', 'position' => 10, 'user_has_access' => bp_core_can_edit_settings());
     // Add Notifications nav item
     $sub_nav[] = array('name' => __('Notifications', 'buddypress'), 'slug' => 'notifications', 'parent_url' => $settings_link, 'parent_slug' => $this->slug, 'screen_function' => 'bp_settings_screen_notification', 'position' => 20, 'user_has_access' => bp_core_can_edit_settings());
     // Add Spam Account nav item
     if (bp_current_user_can('bp_moderate')) {
         $sub_nav[] = array('name' => __('Capabilities', 'buddypress'), 'slug' => 'capabilities', 'parent_url' => $settings_link, 'parent_slug' => $this->slug, 'screen_function' => 'bp_settings_screen_capabilities', 'position' => 80, 'user_has_access' => !bp_is_my_profile());
     }
     // Add Delete Account nav item
     if (!bp_disable_account_deletion() || bp_current_user_can('delete_users')) {
         $sub_nav[] = array('name' => __('Delete Account', 'buddypress'), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $this->slug, 'screen_function' => 'bp_settings_screen_delete_account', 'position' => 90, 'user_has_access' => bp_is_my_profile() || !is_super_admin(bp_displayed_user_id()));
     }
     parent::setup_nav($main_nav, $sub_nav);
 }
/**
 * Allows a site admin to delete a user from the adminbar menu.
 *
 * @package BuddyPress Core
 * @global object $bp Global BuddyPress settings object
 */
function bp_core_action_delete_user()
{
    global $bp;
    if (!is_super_admin() || bp_is_my_profile() || !$bp->displayed_user->id) {
        return false;
    }
    if ('admin' == $bp->current_component && 'delete-user' == $bp->current_action) {
        // 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->displayed_user->fullname));
        } else {
            bp_core_add_message(sprintf(__('There was an error deleting %s from the system. Please try again.', 'buddypress'), $bp->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);
        }
    }
}
Example #10
0
/**
 * Filter the bbPress is_user_home function with BuddyPress eqivalent
 *
 * @since bbPress (r3552)
 *
 * @param bool $is Optional. Default false
 * @return bool True if viewing single user, false if not
 */
function bbp_filter_is_user_home($is = false)
{
    if (!empty($is)) {
        return $is;
    }
    return bp_is_my_profile();
}
 /**
  * Set up navigation.
  *
  * @param array $main_nav Array of main nav items.
  * @param array $sub_nav  Array of sub nav items.
  */
 public function setup_nav($main_nav = array(), $sub_nav = array())
 {
     // Determine user to use
     if (bp_displayed_user_domain()) {
         $user_domain = bp_displayed_user_domain();
     } elseif (bp_loggedin_user_domain()) {
         $user_domain = bp_loggedin_user_domain();
     } else {
         return;
     }
     $access = bp_core_can_edit_settings();
     $slug = bp_get_settings_slug();
     $settings_link = trailingslashit($user_domain . $slug);
     // Add the settings navigation item
     $main_nav = array('name' => __('Settings', 'buddypress'), 'slug' => $slug, 'position' => 100, 'show_for_displayed_user' => $access, 'screen_function' => 'bp_settings_screen_general', 'default_subnav_slug' => 'general');
     // Add General Settings nav item
     $sub_nav[] = array('name' => __('General', 'buddypress'), 'slug' => 'general', 'parent_url' => $settings_link, 'parent_slug' => $slug, 'screen_function' => 'bp_settings_screen_general', 'position' => 10, 'user_has_access' => $access);
     // Add Email nav item. Formerly called 'Notifications', we
     // retain the old slug and function names for backward compat
     $sub_nav[] = array('name' => __('Email', 'buddypress'), 'slug' => 'notifications', 'parent_url' => $settings_link, 'parent_slug' => $slug, 'screen_function' => 'bp_settings_screen_notification', 'position' => 20, 'user_has_access' => $access);
     // Add Spam Account nav item
     if (bp_current_user_can('bp_moderate')) {
         $sub_nav[] = array('name' => __('Capabilities', 'buddypress'), 'slug' => 'capabilities', 'parent_url' => $settings_link, 'parent_slug' => $slug, 'screen_function' => 'bp_settings_screen_capabilities', 'position' => 80, 'user_has_access' => !bp_is_my_profile());
     }
     // Add Delete Account nav item
     if (!bp_disable_account_deletion() && bp_is_my_profile() || bp_current_user_can('delete_users')) {
         $sub_nav[] = array('name' => __('Delete Account', 'buddypress'), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $slug, 'screen_function' => 'bp_settings_screen_delete_account', 'position' => 90, 'user_has_access' => !is_super_admin(bp_displayed_user_id()));
     }
     parent::setup_nav($main_nav, $sub_nav);
 }
Example #12
0
function ec_bp_setup_nav()
{
    global $bp;
    $events_link = $bp->displayed_user->domain . 'eventos/';
    bp_core_new_nav_item(array('name' => 'Eventos', 'slug' => 'eventos', 'screen_function' => 'ec_show_events_list', 'position' => 0));
    bp_core_new_subnav_item(array('name' => 'Eventos', 'slug' => 'mis-eventos', 'parent_url' => $events_link, 'parent_slug' => 'eventos', 'screen_function' => 'ec_show_events_list', 'position' => 10));
    bp_core_new_subnav_item(array('name' => 'Calendario', 'slug' => 'mi-calendario', 'parent_url' => $events_link, 'parent_slug' => 'eventos', 'screen_function' => 'ec_show_events_calendar', 'position' => 20));
    bp_core_new_subnav_item(array('name' => 'Crear Evento', 'slug' => 'evento_nuevo', 'parent_url' => $events_link, 'parent_slug' => 'eventos', 'screen_function' => 'ec_show_events_editor', 'user_has_access' => bp_is_my_profile(), 'position' => 30));
}
Example #13
0
 public function test_member_activity_page()
 {
     $url = home_url($this->u->user_nicename) . '/' . bp_get_activity_slug();
     $this->go_to($url);
     $this->assertTrue(bp_is_user());
     $this->assertTrue(bp_is_my_profile());
     $this->assertEquals($this->u->ID, bp_displayed_user_id());
     $this->assertTrue(bp_is_activity_component());
 }
 /** constructor -- name this the same as the class above */
 function wplms_instructor_dash_stats()
 {
     $widget_ops = array('classname' => 'wplms_instructor_dash_stats', 'description' => __('Simple stats scores for instructors', 'wplms-dashboard'));
     $control_ops = array('width' => 300, 'height' => 350, 'id_base' => 'wplms_instructor_dash_stats');
     $this->WP_Widget('wplms_instructor_dash_stats', __(' DASHBOARD : Instructor Simple Stats', 'wplms-dashboard'), $widget_ops, $control_ops);
     if (function_exists('bp_is_my_profile') && bp_is_my_profile()) {
         wp_enqueue_script('wplms-student-simple-stats', WPLMS_DASHBOARD_URL . '/js/jquery.sparkline.min.js', array('jquery'), true);
     }
 }
function bppp_title($user_id = false)
{
    $user_id = bppp_get_user_id($user_id);
    $title = bppp_get_title($user_id);
    if (bp_is_my_profile()) {
        $title = '<a title="' . bppp_get_caption($user_id) . '" href="' . bppp_get_link($user_id) . '">' . $title . '</a>';
    }
    echo $title;
}
 function setup_nav()
 {
     global $bp;
     $access = 0;
     if (function_exists('bp_is_my_profile')) {
         $access = apply_filters('wplms_student_dashboard_access', bp_is_my_profile());
     }
     bp_core_new_nav_item(array('name' => __('Dashboard', 'wplms-dashboard'), 'slug' => WPLMS_DASHBOARD_SLUG, 'position' => 4, 'screen_function' => 'wplms_dashboard_template', 'show_for_displayed_user' => $access));
 }
 public function setup_nav($main = array(), $sub = array())
 {
     $bp = buddypress();
     $component = 'members';
     $component_id = mpp_get_current_component_id();
     if (!mpp_is_enabled($component, $component_id)) {
         //allow to disable user galleries in case they don't want it
         return false;
     }
     $view_helper = MPP_Gallery_Screens::get_instance();
     // Add 'Gallery' to the user's main navigation
     $main_nav = array('name' => sprintf(__('Gallery <span>%d</span>', 'mediapress'), mpp_get_total_gallery_for_user()), 'slug' => $this->slug, 'position' => 86, 'screen_function' => array($view_helper, 'user_galleries'), 'default_subnav_slug' => 'my-galleries', 'item_css_id' => $this->id);
     if (bp_is_user()) {
         $user_domain = bp_displayed_user_domain();
     } else {
         $user_domain = bp_loggedin_user_domain();
     }
     $gallery_link = trailingslashit($user_domain . $this->slug);
     //with a trailing slash
     // Add the My Gallery nav item
     $sub_nav[] = array('name' => __('My Gallery', 'mediapress'), 'slug' => 'my-galleries', 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'position' => 10, 'item_css_id' => 'gallery-my-gallery');
     if (mpp_user_can_create_gallery($component, get_current_user_id())) {
         // Add the Create gallery link to gallery nav
         $sub_nav[] = array('name' => __('Create a Gallery', 'mediapress'), 'slug' => 'create', 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'user_has_access' => bp_is_my_profile(), 'position' => 20);
     }
     if (mpp_component_has_type_filters_enabled($component, $component_id)) {
         $i = 10;
         $supported_types = mpp_component_get_supported_types($component);
         foreach ($supported_types as $type) {
             if (!mpp_is_active_type($type)) {
                 continue;
             }
             $type_object = mpp_get_type_object($type);
             $sub_nav[] = array('name' => $type_object->label, 'slug' => 'type/' . $type, 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'position' => 20 + $i);
             $i = $i + 10;
             //increment the position
         }
     }
     // Add the Upload link to gallery nav
     /*$sub_nav[] = array(
           'name'				=> __( 'Upload', 'mediapress'),
           'slug'				=> 'upload',
           'parent_url'		=> $gallery_link,
           'parent_slug'		=> $this->slug,
           'screen_function'	=> array( $view_helper, 'upload_media' ),
           'user_has_access'	=> bp_is_my_profile(),
           'position'			=> 30
       );*/
     parent::setup_nav($main_nav, $sub_nav);
     //disallow these names in various lists
     //we have yet to implement it
     $this->forbidden_names = apply_filters('mpp_forbidden_names', array('gallery', 'galleries', 'my-gallery', 'create', 'delete', 'upload', 'add', 'edit', 'admin', 'request', 'upload', 'tags', 'audio', 'video', 'photo'));
     //use this to extend the valid status
     $this->valid_status = apply_filters('mpp_valid_gallery_status', array_keys(mpp_get_active_statuses()));
     do_action('mpp_setup_nav');
     // $bp->gallery->current_gallery->user_has_access
 }
Example #18
0
 /** constructor -- name this the same as the class above */
 function wplms_student_stats()
 {
     $widget_ops = array('classname' => 'wplms_student_stats', 'description' => __('Student Statistics widget', 'wplms-dashboard'));
     $control_ops = array('width' => 300, 'height' => 350, 'id_base' => 'wplms_student_stats');
     $this->WP_Widget('wplms_student_stats', __(' DASHBOARD : Student Stats', 'wplms-dashboard'), $widget_ops, $control_ops);
     if (function_exists('bp_is_my_profile') && bp_is_my_profile()) {
         wp_enqueue_script('wplms-raphael', WPLMS_DASHBOARD_URL . '/js/raphael-min.js', array('jquery'), true);
         wp_enqueue_script('wplms-morris', WPLMS_DASHBOARD_URL . '/js/morris.min.js', array('jquery'), true);
     }
 }
 /** constructor -- name this the same as the class above */
 function wplms_instructor_commission_stats()
 {
     $widget_ops = array('classname' => 'wplms_instructor_commission_stats', 'description' => __('WooCommerce Commission Stats  for instructors', 'wplms-dashboard'));
     $control_ops = array('width' => 300, 'height' => 350, 'id_base' => 'wplms_instructor_commission_stats');
     $this->WP_Widget('wplms_instructor_commission_stats', __(' DASHBOARD : Instructor Commission Stats', 'wplms-dashboard'), $widget_ops, $control_ops);
     if (function_exists('bp_is_my_profile') && bp_is_my_profile()) {
         wp_enqueue_script('wplms-raphael', 'http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js', array('jquery'), true);
         wp_enqueue_script('wplms-morris', 'http://cdn.oesmith.co.uk/morris-0.5.0.min.js', array('jquery'), true);
     }
     add_action('wp_ajax_generate_commission_data', array($this, 'generate_commission_data'));
 }
Example #20
0
 /** constructor -- name this the same as the class above */
 function wplms_instructor_stats()
 {
     $widget_ops = array('classname' => 'wplms_instructor_stats', 'description' => __('Instructor Statistics widget', 'wplms-dashboard'));
     $control_ops = array('width' => 300, 'height' => 350, 'id_base' => 'wplms_instructor_stats');
     $this->WP_Widget('wplms_instructor_stats', __(' DASHBOARD : Instructor Stats', 'wplms-dashboard'), $widget_ops, $control_ops);
     add_action('wp_ajax_generate_ranges', array($this, 'generate_ranges'));
     add_action('wp_ajax_load_quiz_assignment_list', array($this, 'load_quiz_assignment_list'));
     if (function_exists('bp_is_my_profile') && bp_is_my_profile()) {
         wp_enqueue_script('wplms-raphael', WPLMS_DASHBOARD_URL . '/js/raphael-min.js', array('jquery'), true);
         wp_enqueue_script('wplms-morris', WPLMS_DASHBOARD_URL . '/js/morris.min.js', array('jquery'), true);
     }
 }
/**
 * Adds feedback messages when successfully saving profile field settings.
 *
 * @since 2.0.0
 *
 * @uses bp_core_add_message()
 * @uses bp_is_my_profile()
 */
function bp_xprofile_settings_add_feedback_message()
{
    // Default message type is success.
    $type = 'success';
    $message = __('Your profile settings have been saved.', 'buddypress');
    // Community moderator editing another user's settings.
    if (!bp_is_my_profile() && bp_core_can_edit_settings()) {
        $message = __("This member's profile settings have been saved.", 'buddypress');
    }
    // Add the message.
    bp_core_add_message($message, $type);
}
Example #22
0
/**
 * bp_em_screen_one()
 *
 * Sets up and displays the screen output for the sub nav item "em/screen-one"
 */
function bp_em_events()
{
    global $bp, $EM_Notices;
    if (bp_is_my_profile()) {
        $EM_Notices->add_info(__('You are currently viewing your public page, this is what other users will see.', 'dbem'));
    }
    /* Add a do action here, so your component can be extended by others. */
    do_action('bp_em_events');
    add_action('bp_template_title', 'bp_em_events_title');
    add_action('bp_template_content', 'bp_em_events_content');
    bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
    //bp_core_load_template( apply_filters( 'bp_em_template_screen_one', 'em/screen-one' ) );
}
Example #23
0
function bebop_setup_user_nav()
{
    global $bp;
    $should_users_verify_content = bebop_tables::get_option_value('bebop_content_user_verification');
    //Shows in the profile all the time.
    bp_core_new_nav_item(array('name' => __('Resources', 'bebop'), 'slug' => 'bebop', 'position' => 30, 'show_for_displayed_user' => true, 'screen_function' => 'bebop_user_settings', 'default_subnav_slug' => 'bebop-content'));
    bp_core_new_subnav_item(array('name' => __('Content', 'bebop'), 'slug' => 'bebop-content', 'parent_url' => bp_displayed_user_domain() . 'bebop/', 'parent_slug' => 'bebop', 'screen_function' => 'bebop_user_settings', 'position' => 10));
    //only show if current user is the owner of the profile.
    if (bp_is_my_profile()) {
        if ($should_users_verify_content != 'no') {
            bp_core_new_subnav_item(array('name' => __('Content Manager', 'bebop'), 'slug' => 'bebop-manager', 'parent_url' => $bp->loggedin_user->domain . 'bebop/', 'parent_slug' => 'bebop', 'screen_function' => 'bebop_user_settings', 'position' => 20));
        }
        bp_core_new_subnav_item(array('name' => __('Accounts', 'bebop'), 'slug' => 'bebop-accounts', 'parent_url' => $bp->loggedin_user->domain . 'bebop/', 'parent_slug' => 'bebop', 'screen_function' => 'bebop_user_settings', 'position' => 20));
    }
}
/**
 * Get a user's count viewable by others
 *
 * @since  1.2.2
 *
 * @param  int $count the number of files for the displayed user
 */
function buddydrive_view_add_script_data($count = 0)
{
    global $wp_scripts;
    if (!bp_is_user() || bp_is_my_profile() || defined('DOING_AJAX') && DOING_AJAX) {
        return;
    }
    $data = $wp_scripts->get_data('buddydrive-view', 'data');
    $count_data = array('id' => 'user-' . buddydrive_get_slug(), 'count' => $count);
    // Extend the script data
    $script = 'var BuddyDriveFilesCount = ' . json_encode($count_data) . ';';
    if ($data) {
        $script = "{$data}\n{$script}";
    }
    $wp_scripts->add_data('buddydrive-view', 'data', $script);
}
/**
 * Check to see if a high five is being given, and if so, save it.
 *
 * Hooked to bp_actions, this function will fire before the screen function. We use our function
 * bp_is_example_component(), along with the bp_is_current_action() and bp_is_action_variable()
 * functions, to detect (based on the requested URL) whether the user has clicked on "send high
 * five". If so, we do a bit of simple logic to see what should happen next.
 *
 * @package BuddyPress_Skeleton_Component
 * @since 1.6
 */
function bp_example_high_five_save()
{
    if (bp_is_example_component() && bp_is_current_action('screen-one') && bp_is_action_variable('send-h5', 0)) {
        // The logged in user has clicked on the 'send high five' link
        if (bp_is_my_profile()) {
            // Don't let users high five themselves
            bp_core_add_message(__('No self-fives! :)', 'bp-example'), 'error');
        } else {
            if (bp_example_send_highfive(bp_displayed_user_id(), bp_loggedin_user_id())) {
                bp_core_add_message(__('High-five sent!', 'bp-example'));
            } else {
                bp_core_add_message(__('High-five could not be sent.', 'bp-example'), 'error');
            }
        }
        bp_core_redirect(bp_displayed_user_domain() . bp_get_example_slug() . '/screen-one');
    }
}
/**
 * This function runs when an action is set for a screen:
 * example.com/members/andy/profile/change-avatar/ [delete-avatar]
 *
 * The function will delete the active avatar for a user.
 *
 * @package BuddyPress Xprofile
 * @uses bp_core_delete_avatar() Deletes the active avatar for the logged in user.
 * @uses add_action() Runs a specific function for an action when it fires.
 */
function xprofile_action_delete_avatar()
{
    if (!bp_is_user_change_avatar() || !bp_is_action_variable('delete-avatar', 0)) {
        return false;
    }
    // Check the nonce
    check_admin_referer('bp_delete_avatar_link');
    if (!bp_is_my_profile() && !bp_current_user_can('bp_moderate')) {
        return false;
    }
    if (bp_core_delete_existing_avatar(array('item_id' => bp_displayed_user_id()))) {
        bp_core_add_message(__('Your avatar was deleted successfully!', 'buddypress'));
    } else {
        bp_core_add_message(__('There was a problem deleting that avatar, please try again.', 'buddypress'), 'error');
    }
    bp_core_redirect(wp_get_referer());
}
Example #27
0
function wplms_dashboard_template()
{
    if (!is_user_logged_in()) {
        wp_redirect(site_url());
    }
    $template = 'templates/dashboard';
    if (function_exists('bp_is_my_profile') && bp_is_my_profile()) {
        wp_enqueue_style('wplms-dashboard-css', WPLMS_DASHBOARD_URL . '/css/wplms-dashboard.css', array(), '1.0');
        wp_enqueue_script('wplms-dashboard-js', WPLMS_DASHBOARD_URL . '/js/wplms-dashboard.js', array('jquery'), '1.0');
        $translation_array = array('earnings' => __('Earnings', 'wplms-dashboard'), 'payout' => __('Payout', 'wplms-dashboard'), 'students' => __('# Students', 'wplms-dashboard'), 'saved' => __('SAVED', 'wplms-dashboard'), 'saving' => __('SAVING ...', 'wplms-dashboard'), 'stats_calculated' => __('Stats Calculated, reloading page ...', 'wplms-dashboard'));
        wp_localize_script('wplms-dashboard-js', 'wplms_dashboard_strings', $translation_array);
    }
    $located_template = apply_filters('bp_located_template', locate_template($template, false), $template);
    if ($located_template && $located_template != '') {
        bp_get_template_part(apply_filters('bp_load_template', $located_template));
    } else {
        bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/dashboard'));
    }
}
function mtc_setup_nav()
{
    global $bp;
    /* Add 'My Content' to the main user profile navigation */
    bp_core_new_nav_item(array('name' => __('My Content', 'bp-mtc'), 'slug' => $bp->mtc->slug, 'position' => 80, 'screen_function' => 'bp_mtc_screen_one', 'default_subnav_slug' => 'Content'));
    $mtc_link = $bp->loggedin_user->domain . $bp->mtc->slug . '/';
    /* Create two sub nav items for this component */
    bp_core_new_subnav_item(array('name' => __('Content', 'bp-mtc'), 'slug' => 'my-content', 'parent_slug' => $bp->mtc->slug, 'parent_url' => $mtc_link, 'screen_function' => 'bp_mtc_screen_one', 'position' => 10));
    bp_core_new_subnav_item(array('name' => __('Select Tags', 'bp-mtc'), 'slug' => 'select-tags', 'parent_slug' => $bp->mtc->slug, 'parent_url' => $mtc_link, 'screen_function' => 'bp_mtc_screen_two', 'position' => 20, 'user_has_access' => bp_is_my_profile()));
    /* Add a nav item for this component under the settings nav item. See bp_example_screen_settings_menu() for more info */
    /*	bp_core_new_subnav_item( array(
    		'name' => __( 'Example', 'mtc' ),
    		'slug' => 'example-admin',
    		'parent_slug' => $bp->settings->slug,
    		'parent_url' => $bp->loggedin_user->domain . $bp->settings->slug . '/',
    		'screen_function' => 'bp_example_screen_settings_menu',
    		'position' => 40,
    		'user_has_access' => bp_is_my_profile() // Only the logged in user can access this on his/her profile
    	) );*/
}
Example #29
0
function bp_core_add_settings_nav() {
	global $bp;

	/* Set up settings as a sudo-component for identification and nav selection */
	$bp->settings->id = 'settings';
	$bp->settings->slug = BP_SETTINGS_SLUG;

	/* Register this in the active components array */
	$bp->active_components[$bp->settings->slug] = $bp->settings->id;

	/* Add the settings navigation item */
	bp_core_new_nav_item( array( 'name' => __('Settings', 'buddypress'), 'slug' => $bp->settings->slug, 'position' => 100, 'show_for_displayed_user' => false, 'screen_function' => 'bp_core_screen_general_settings', 'default_subnav_slug' => 'general' ) );

	$settings_link = $bp->loggedin_user->domain . $bp->settings->slug . '/';

	bp_core_new_subnav_item( array( 'name' => __( 'General', 'buddypress' ), 'slug' => 'general', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_general_settings', 'position' => 10, 'user_has_access' => bp_is_my_profile() ) );
	bp_core_new_subnav_item( array( 'name' => __( 'Notifications', 'buddypress' ), 'slug' => 'notifications', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_notification_settings', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) );

	if ( !is_super_admin() && !(int) $bp->site_options['bp-disable-account-deletion'] )
		bp_core_new_subnav_item( array( 'name' => __( 'Delete Account', 'buddypress' ), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_delete_account', 'position' => 90, 'user_has_access' => bp_is_my_profile() ) );
}
Example #30
0
 function setup_nav()
 {
     global $blog_id;
     //check multisite or normal mode for correct permission checking
     if (is_multisite() && $blog_id != BP_ROOT_BLOG) {
         //FIXME MS mode doesn't seem to recognize cross subsite caps, using the proper functions, for now we use switch_blog.
         $current_blog = $blog_id;
         switch_to_blog(BP_ROOT_BLOG);
         $can_manage_events = current_user_can_for_blog(BP_ROOT_BLOG, 'edit_events');
         $can_manage_locations = current_user_can_for_blog(BP_ROOT_BLOG, 'edit_locations');
         $can_manage_bookings = current_user_can_for_blog(BP_ROOT_BLOG, 'manage_bookings');
         switch_to_blog($current_blog);
     } else {
         $can_manage_events = current_user_can('edit_events');
         $can_manage_locations = current_user_can('edit_locations');
         $can_manage_bookings = current_user_can('manage_bookings');
     }
     /* Add 'Events' to the main user profile navigation */
     $main_nav = array('name' => __('Events', 'dbem'), 'slug' => em_bp_get_slug(), 'position' => 80, 'screen_function' => 'bp_em_events', 'default_subnav_slug' => 'profile');
     $em_link = trailingslashit(bp_loggedin_user_domain() . em_bp_get_slug());
     /* Create SubNav Items */
     $sub_nav[] = array('name' => __('My Profile', 'dbem'), 'slug' => 'profile', 'parent_slug' => em_bp_get_slug(), 'parent_url' => $em_link, 'screen_function' => 'bp_em_events', 'position' => 10);
     $sub_nav[] = array('name' => __('Events I\'m Attending', 'dbem'), 'slug' => 'attending', 'parent_slug' => em_bp_get_slug(), 'parent_url' => $em_link, 'screen_function' => 'bp_em_attending', 'position' => 20, 'user_has_access' => bp_is_my_profile());
     if ($can_manage_events) {
         $sub_nav[] = array('name' => __('My Events', 'dbem'), 'slug' => 'my-events', 'parent_slug' => em_bp_get_slug(), 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_events', 'position' => 30, 'user_has_access' => bp_is_my_profile());
     }
     if ($can_manage_locations && get_option('dbem_locations_enabled')) {
         $sub_nav[] = array('name' => __('My Locations', 'dbem'), 'slug' => 'my-locations', 'parent_slug' => em_bp_get_slug(), 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_locations', 'position' => 40, 'user_has_access' => bp_is_my_profile());
     }
     if ($can_manage_bookings && get_option('dbem_rsvp_enabled')) {
         $sub_nav[] = array('name' => __('My Event Bookings', 'dbem'), 'slug' => 'my-bookings', 'parent_slug' => em_bp_get_slug(), 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_bookings', 'position' => 50, 'user_has_access' => bp_is_my_profile());
     }
     if (bp_is_active('groups')) {
         /* Create Profile Group Sub-Nav */
         $sub_nav[] = array('name' => __('Events', 'dbem'), 'slug' => 'group-events', 'parent_slug' => bp_get_groups_slug(), 'parent_url' => trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()), 'screen_function' => 'bp_em_my_group_events', 'position' => 60, 'user_has_access' => bp_is_my_profile());
     }
     parent::setup_nav($main_nav, $sub_nav);
     add_action('bp_init', array(&$this, 'setup_group_nav'));
 }