function bp_course_add_js()
{
    global $bp;
    if (!function_exists('vibe_logo_url')) {
        return;
    }
    // Checks if WPLMS is active in current site in WP Multisite
    wp_enqueue_script('bp-extras-js', plugins_url('/vibe-course-module/includes/js/course-module-js.min.js'), array('jquery'), bp_course_version(), true);
    if (function_exists('vibe_get_option')) {
        if (is_singular('unit') || is_singular('question') || is_singular('quiz') || is_singular('wplms-assignment') || is_page(vibe_get_option('take_course_page')) || is_page(vibe_get_option('create_course')) || isset($_GET['edit'])) {
            wp_enqueue_script('jquery-ui-core');
            wp_enqueue_script('jquery-ui-sortable');
            wp_enqueue_script('jquery-ui-droppable');
            wp_enqueue_script('jquery-ui-datepicker');
            wp_enqueue_script('knob-js', plugins_url('/vibe-course-module/includes/js/jquery.knob.min.js'));
        }
    }
    if (function_exists('bp_is_directory')) {
        if (bp_is_directory() && bp_current_component() == 'course') {
            wp_enqueue_script('jquery-ui-datepicker');
        }
    }
    $action = bp_current_action();
    if (isset($_GET['action'])) {
        $action = $_GET['action'];
    }
    if (in_array($action, array('admin', 'submissions', 'stats'))) {
        wp_enqueue_script('knob-js', plugins_url('/vibe-course-module/includes/js/jquery.knob.min.js'));
    }
    wp_enqueue_script('bp-course-js', plugins_url('/vibe-course-module/includes/js/course.js'), array('jquery', 'wp-mediaelement', 'buddypress-js'), bp_course_version(), true);
    $color = bp_wplms_get_theme_color();
    $single_dark_color = bp_wplms_get_theme_single_dark_color();
    $translation_array = array('too_fast_answer' => _x('Too Fast or Answer not marked.', 'Quiz answer being marked very fast', 'vibe'), 'answer_saved' => _x('Answer Saved.', 'Save answer on every question, confirmation message', 'vibe'), 'processing' => _x('Processing...', 'Quiz question anwer save under progress', 'vibe'), 'saving_answer' => _x('Saving Answer...please wait', 'Saving quiz answers under progress', 'vibe'), 'remove_user_text' => __('This step is irreversible. Are you sure you want to remove the User from the course ?', 'vibe'), 'remove_user_button' => __('Confirm, Remove User from Course', 'vibe'), 'confirm' => _x('Confirm', 'Confirm button for various popup confirmation messages', 'vibe'), 'cancel' => _x('Cancel', 'Cancel button for various popup confirmation messages', 'vibe'), 'reset_user_text' => __('This step is irreversible. All Units, Quiz results would be reset for this user. Are you sure you want to Reset the Course for this User?', 'vibe'), 'reset_user_button' => __('Confirm, Reset Course for this User', 'vibe'), 'quiz_reset' => __('This step is irreversible. All Questions answers would be reset for this user. Are you sure you want to Reset the Quiz for this User? ', 'vibe'), 'quiz_reset_button' => __('Confirm, Reset Quiz for this User', 'vibe'), 'marks_saved' => __('Marks Saved', 'vibe'), 'quiz_marks_saved' => __('Quiz Marks Saved', 'vibe'), 'submit_quiz' => __('Submit Quiz', 'vibe'), 'sending_messages' => __('Sending Messages ...', 'vibe'), 'adding_students' => __('Adding Students to Course ...', 'vibe'), 'successfuly_added_students' => __('Students successfully added to Course', 'vibe'), 'unable_add_students' => __('Unable to Add students to Course', 'vibe'), 'select_fields' => __('Please select fields to download', 'vibe'), 'download' => __('Download', 'vibe'), 'timeout' => __('TIMEOUT', 'vibe'), 'theme_color' => $color, 'single_dark_color' => $single_dark_color, 'for_course' => __('for Course', 'vibe'), 'active_filters' => __('Active Filters', 'vibe'), 'clear_filters' => __('Clear all filters', 'vibe'), 'remove_comment' => __('Are you sure you want to remove this note?', 'vibe'), 'remove_comment_button' => __('Confirm, remove note', 'vibe'), 'private_comment' => __('Make Private', 'vibe'), 'add_comment' => __('Add your note', 'vibe'), 'submit_quiz_error' => __('Please add questions or retake the quiz !', 'vibe'), 'remove_announcement' => __('Are you sure you want to remove this Annoucement?', 'vibe'), 'start_quiz_notification' => __('You\'re about to start the Quiz. Please click confirm to begin the quiz.', 'vibe'), 'submit_quiz_notification' => __('Are you sure you want to submit the quiz. Submitting the quiz will freeze all your answers, you can not change them.  Please confirm.', 'vibe'), 'check_results' => __('Check results', 'vibe'), 'correct' => __('Correct', 'vibe'), 'incorrect' => __('Incorrect', 'vibe'), 'confirm_apply' => _x('Are you sure you want to apply for this Course ?', 'confirmation message when user clicks on apply for course', 'vibe'), 'instructor_uncomplete_unit' => _x('Are you sure you want mark this unit "uncomplete" for the user ?', 'Popup confirmation message when instructor marks the unit uncomplete for the user.', 'vibe'), 'instructor_complete_unit' => _x('Are you sure you want to mark this unit "complete" for the user ?', 'Popup confirmation message ', 'vibe'), 'unanswered_questions' => __('You have few unanswered questions. Are you sure you want to continue ?', 'vibe'));
    wp_localize_script('bp-course-js', 'vibe_course_module_strings', $translation_array);
}
Beispiel #2
0
 /**
  * Override bbPress profile URL with BuddyPress profile URL
  *
  * @since bbPress (r3401)
  * @param string $url
  * @param int $user_id
  * @param string $user_nicename
  * @return string
  */
 public function user_profile_url($user_id)
 {
     // Define local variable(s)
     $profile_url = '';
     // Special handling for forum component
     if (bp_is_current_component('forums')) {
         // Empty action or 'topics' action
         if (!bp_current_action() || bp_is_current_action('topics')) {
             $profile_url = bp_core_get_user_domain($user_id) . 'forums/topics';
             // Empty action or 'topics' action
         } elseif (bp_is_current_action('replies')) {
             $profile_url = bp_core_get_user_domain($user_id) . 'forums/replies';
             // 'favorites' action
         } elseif (bbp_is_favorites_active() && bp_is_current_action('favorites')) {
             $profile_url = $this->get_favorites_permalink('', $user_id);
             // 'subscriptions' action
         } elseif (bbp_is_subscriptions_active() && bp_is_current_action('subscriptions')) {
             $profile_url = $this->get_subscriptions_permalink('', $user_id);
         }
         // Not in users' forums area
     } else {
         $profile_url = bp_core_get_user_domain($user_id);
     }
     return trailingslashit($profile_url);
 }
/**
 * Filter the activity loop when we're on a "Following" page
 *
 * This is done:
 *   - On the activity directory and clicking on the "Following" tab
 *   - On a user's "Activity > Following" page
 *
 * @since 1.0.0
 *
 * @param string|array Current activity querystring
 * @param string $object The current object or component
 * @return array
 */
function bp_follow_add_activity_scope_filter($qs, $object)
{
    global $bp;
    // not on the activity object? stop now!
    if ($object != 'activity') {
        return $qs;
    }
    $set = false;
    // activity directory
    // can't use bp_is_activity_directory() yet since that's a BP 2.0 function
    if (!bp_displayed_user_id() && bp_is_activity_component() && !bp_current_action()) {
        // check if activity scope is following before manipulating
        if (isset($_COOKIE['bp-activity-scope']) && 'following' === $_COOKIE['bp-activity-scope']) {
            $set = true;
        }
        // user's activity following page
    } elseif (bp_is_user_activity() && bp_is_current_action('following')) {
        $set = true;
    }
    // not on a user page? stop now!
    if (!$set) {
        return $qs;
    }
    // set internal marker noting that our activity scope is applied
    $bp->follow->activity_scope_set = 1;
    $qs = wp_parse_args($qs);
    $following_ids = bp_get_following_ids(array('user_id' => bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id()));
    // if $following_ids is empty, pass a negative number so no activity can be found
    $following_ids = empty($following_ids) ? -1 : $following_ids;
    $qs['user_id'] = $following_ids;
    return apply_filters('bp_follow_add_activity_scope_filter', $qs, false);
}
Beispiel #4
0
function bebop_feeds()
{
    global $bp, $wp_query, $this_bp_feed;
    if (bp_is_activity_component()) {
        $active_extensions = bebop_extensions::bebop_get_active_extension_names();
        $active_extensions[] = 'all_oers';
        foreach ($active_extensions as $extension) {
            if (bp_current_action() == $extension) {
                if ($extension == 'all_oers') {
                    $this_bp_feed = $extension;
                } else {
                    if (bebop_tables::check_option_exists('bebop_' . $extension . '_rss_feed')) {
                        if (bebop_tables::get_option_value('bebop_' . $extension . '_rss_feed') == 'on') {
                            $this_bp_feed = $extension;
                        }
                    }
                }
            }
        }
    }
    if (empty($this_bp_feed)) {
        return false;
    }
    $wp_query->is_404 = false;
    status_header(200);
    include_once 'templates/user/bebop-feed-template.php';
    die;
}
Beispiel #5
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'));
}
 /**
  * Are we looking at something that needs Blogs theme compatibility?
  *
  * @since 1.7.0
  */
 public function is_blogs()
 {
     // Bail if not looking at a group.
     if (!bp_is_blogs_component()) {
         return;
     }
     // Bail if looking at a users sites.
     if (bp_is_user()) {
         return;
     }
     // Blog Directory.
     if (is_multisite() && !bp_current_action()) {
         bp_update_is_directory(true, 'blogs');
         /**
          * Fires if in the blog directory and BuddyPress needs Blog theme compatibility,
          * before the actions and filters are added.
          *
          * @since 1.5.0
          */
         do_action('bp_blogs_screen_index');
         add_filter('bp_get_buddypress_template', array($this, 'directory_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
         // Create blog.
     } elseif (is_user_logged_in() && bp_blog_signup_enabled()) {
         add_filter('bp_get_buddypress_template', array($this, 'create_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'create_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'create_content'));
     }
 }
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'));
}
/**
 * Catch a "Mark as Spammer/Not Spammer" click from the toolbar.
 *
 * When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu
 * this action will fire and mark or unmark the user and their blogs as spam.
 * Must be a site admin for this function to run.
 *
 * Note: no longer used in the current state. See the Settings component.
 *
 * @param int $user_id Optional. User ID to mark as spam. Defaults to displayed
 *        user.
 */
function bp_core_action_set_spammer_status($user_id = 0)
{
    // Only super admins can currently spam users (but they can't spam
    // themselves)
    if (!is_super_admin() || bp_is_my_profile()) {
        return;
    }
    // Use displayed user if it's not yourself
    if (empty($user_id)) {
        $user_id = bp_displayed_user_id();
    }
    if (bp_is_current_component('admin') && in_array(bp_current_action(), array('mark-spammer', 'unmark-spammer'))) {
        // Check the nonce
        check_admin_referer('mark-unmark-spammer');
        // To spam or not to spam
        $status = bp_is_current_action('mark-spammer') ? 'spam' : 'ham';
        // The heavy lifting
        bp_core_process_spammer_status($user_id, $status);
        // Add feedback message. @todo - Error reporting
        if ('spam' == $status) {
            bp_core_add_message(__('User marked as spammer. Spam users are visible only to site admins.', 'buddypress'));
        } else {
            bp_core_add_message(__('User removed as spammer.', 'buddypress'));
        }
        // Deprecated. Use bp_core_process_spammer_status.
        $is_spam = 'spam' == $status;
        do_action('bp_core_action_set_spammer_status', bp_displayed_user_id(), $is_spam);
        // Redirect back to where we came from
        bp_core_redirect(wp_get_referer());
    }
}
function bp_blogs_screen_index()
{
    if (is_multisite() && bp_is_blogs_component() && !bp_current_action()) {
        bp_update_is_directory(true, 'blogs');
        do_action('bp_blogs_screen_index');
        bp_core_load_template(apply_filters('bp_blogs_screen_index', 'blogs/index'));
    }
}
/**
 * Load the index page 
 */
function bp_portfolio_directory_setup()
{
    if (bp_is_portfolio_component() && !bp_current_action() && !bp_current_item()) {
        bp_update_is_directory(true, 'portfolio');
        do_action('bp_portfolio_directory_setup');
        bp_core_load_template(apply_filters('portfolio_directory_template', BP_PORTFOLIO_TEMPLATE . '/index'));
    }
}
function bp_forums_directory_forums_setup()
{
    global $bp;
    if (bp_is_forums_component() && (!bp_current_action() || 'tag' == bp_current_action() && bp_action_variables()) && !bp_current_item()) {
        if (!bp_forums_has_directory()) {
            return false;
        }
        if (!bp_forums_is_installed_correctly()) {
            bp_core_add_message(__('The forums component has not been set up yet.', 'buddypress'), 'error');
            bp_core_redirect(bp_get_root_domain());
        }
        bp_update_is_directory(true, 'forums');
        do_action('bbpress_init');
        // Check to see if the user has posted a new topic from the forums page.
        if (isset($_POST['submit_topic']) && bp_is_active('forums')) {
            check_admin_referer('bp_forums_new_topic');
            $bp->groups->current_group = groups_get_group(array('group_id' => $_POST['topic_group_id']));
            if (!empty($bp->groups->current_group->id)) {
                // Auto join this user if they are not yet a member of this group
                if (!is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member($bp->loggedin_user->id, $bp->groups->current_group->id)) {
                    groups_join_group($bp->groups->current_group->id);
                }
                $error_message = '';
                $forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
                if (!empty($forum_id)) {
                    if (empty($_POST['topic_title'])) {
                        $error_message = __('Please provide a title for your forum topic.', 'buddypress');
                    } else {
                        if (empty($_POST['topic_text'])) {
                            $error_message = __('Forum posts cannot be empty. Please enter some text.', 'buddypress');
                        }
                    }
                    if ($error_message) {
                        bp_core_add_message($error_message, 'error');
                        $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                    } else {
                        if (!($topic = groups_new_group_forum_topic($_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id))) {
                            bp_core_add_message(__('There was an error when creating the topic', 'buddypress'), 'error');
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                        } else {
                            bp_core_add_message(__('The topic was created successfully', 'buddypress'));
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic->topic_slug . '/';
                        }
                    }
                    bp_core_redirect($redirect);
                } else {
                    bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                    bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
                }
            } else {
                bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
            }
        }
        do_action('bp_forums_directory_forums_setup');
        bp_core_load_template(apply_filters('bp_forums_template_directory_forums_setup', 'forums/index'));
    }
}
function wplms_assignments_enqueue_scripts()
{
    if (is_singular('wplms-assignment') || isset($_GET['action']) && $_GET['action'] == 'admin' && isset($_GET['submissions']) || bp_current_action() == 'submissions') {
        wp_enqueue_style('wplms-assignments-css', plugins_url('css/wplms-assignments.css', __FILE__));
        wp_enqueue_script('wplms-assignments-js', plugins_url('js/wplms-assignments.js', __FILE__));
        $translation_array = array('assignment_reset' => __('This step is irreversible. All Assignment submissions would be reset for this user. Are you sure you want to Reset the Assignment for this User? ', 'wplms-assignments'), 'assignment_reset_button' => __('Confirm, Assignment reset for this User', 'wplms-assignments'), 'marks_saved' => __('Marks Saved', 'wplms-assignments'), 'assignment_marks_saved' => __('Assignment Marks Saved', 'wplms-assignments'), 'cancel' => __('Cancel', 'wplms-assignments'), 'incorrect_file_format' => __('Incorrect file format ', 'wplms-assignments'), 'duplicate_file' => __('File already selected ', 'wplms-assignments'));
        wp_localize_script('wplms-assignments-js', 'wplms_assignment_messages', $translation_array);
    }
}
Beispiel #13
0
/**
 * Get the current editable post id
 * 
 * Used with buddyPress simple front end post editing plugin
 * 
 * @return int id of the post to edit
 */
function buddyblog_get_editable_post_id($id)
{
    $action = bp_current_action();
    if (bp_is_buddyblog_component() && $action == 'edit') {
        $id = bp_action_variable(0);
    }
    return intval($id);
    //intval or absint?
}
/**
 * Adds a navigation item to the main navigation array used in BuddyPress themes.
 *
 * @package BuddyPress Core
 * @global object $bp Global BuddyPress settings object
 */
function bp_core_new_nav_item($args = '')
{
    global $bp;
    $defaults = array('name' => false, 'slug' => false, 'item_css_id' => false, 'show_for_displayed_user' => true, 'site_admin_only' => false, 'position' => 99, 'screen_function' => false, 'default_subnav_slug' => false);
    $r = nxt_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    // If we don't have the required info we need, don't create this subnav item
    if (empty($name) || empty($slug)) {
        return false;
    }
    // If this is for site admins only and the user is not one, don't create the subnav item
    if ($site_admin_only && !is_super_admin()) {
        return false;
    }
    if (empty($item_css_id)) {
        $item_css_id = $slug;
    }
    $bp->bp_nav[$slug] = array('name' => $name, 'slug' => $slug, 'link' => $bp->loggedin_user->domain . $slug . '/', 'css_id' => $item_css_id, 'show_for_displayed_user' => $show_for_displayed_user, 'position' => $position, 'screen_function' => &$screen_function);
    /***
     * If this nav item is hidden for the displayed user, and
     * the logged in user is not the displayed user
     * looking at their own profile, don't create the nav item.
     */
    if (!$show_for_displayed_user && !bp_user_has_access()) {
        return false;
    }
    /***
     * If the nav item is visible, we are not viewing a user, and this is a root
     * component, don't attach the default subnav function so we can display a
     * directory or something else.
     */
    if (-1 != $position && bp_is_root_component($slug) && !bp_displayed_user_id()) {
        return;
    }
    // Look for current component
    if (bp_is_current_component($slug) && !bp_current_action()) {
        if (!is_object($screen_function[0])) {
            add_action('bp_screens', $screen_function);
        } else {
            add_action('bp_screens', array(&$screen_function[0], $screen_function[1]), 3);
        }
        if (!empty($default_subnav_slug)) {
            $bp->current_action = apply_filters('bp_default_component_subnav', $default_subnav_slug, $r);
        }
        // Look for current item
    } elseif (bp_is_current_item($slug) && !bp_current_action()) {
        if (!is_object($screen_function[0])) {
            add_action('bp_screens', $screen_function);
        } else {
            add_action('bp_screens', array(&$screen_function[0], $screen_function[1]), 3);
        }
        if (!empty($default_subnav_slug)) {
            $bp->current_action = apply_filters('bp_default_component_subnav', $default_subnav_slug, $r);
        }
    }
    do_action('bp_core_new_nav_item', $r, $args, $defaults);
}
 /**
  * @ticket BP6475
  */
 public function test_member_directory_when_nested_under_wp_page()
 {
     $p = $this->factory->post->create(array('post_type' => 'page', 'post_name' => 'foo'));
     $members_page = get_page_by_path('members');
     wp_update_post(array('ID' => $members_page->ID, 'post_parent' => $p));
     $members_page_permalink = bp_get_root_domain() . '/foo/members/';
     $this->go_to($members_page_permalink);
     $this->assertTrue(bp_is_members_component());
     $this->assertEquals('', bp_current_action());
 }
Beispiel #16
0
 /**
  * @group invite_anyone_group_invite_access_test
  */
 public function test_group_access_test_no_group_during_group_creation()
 {
     $cc = bp_current_component();
     $ca = bp_current_action();
     buddypress()->current_component = buddypress()->groups->id;
     buddypress()->current_action = 'create';
     $u = $this->factory->user->create();
     $this->assertSame('anyone', invite_anyone_group_invite_access_test(0, $u));
     buddypress()->current_component = $cc;
     buddypress()->current_action = $ca;
 }
/**
 * If your component uses a top-level directory, this function will catch the requests and load
 * the index page.
 *
 * @package BuddyPress_Template_Pack
 * @since 1.6
 */
function bp_course_directory_setup()
{
    if (bp_is_course_component() && !bp_current_action() && !bp_current_item()) {
        // This wrapper function sets the $bp->is_directory flag to true, which help other
        // content to display content properly on your directory.
        bp_update_is_directory(true, BP_COURSE_SLUG);
        // Add an action so that plugins can add content or modify behavior
        do_action('bp_course_directory_setup');
        bp_core_load_template(apply_filters('course_directory_template', 'course/index'));
    }
}
/**
 * Determine whether you are viewing a BuddyPress Docs page
 *
 * @package BuddyPress Docs
 * @since 1.0-beta
 *
 * @return bool
 */
function bp_docs_is_bp_docs_page()
{
    global $bp;
    $is_bp_docs_page = false;
    // This is intentionally ambiguous and generous, to account for BP Docs is different
    // components. Probably should be cleaned up at some point
    if ($bp->bp_docs->slug == bp_current_component() || $bp->bp_docs->slug == bp_current_action()) {
        $is_bp_docs_page = true;
    }
    return apply_filters('bp_docs_is_bp_docs_page', $is_bp_docs_page);
}
 /**
  * Stores some handy information in the $bp global
  *
  * @package BuddyPress Docs
  * @since 1.0-beta
  */
 function setup_globals()
 {
     global $bp;
     $bp->bp_docs->format_notification_function = 'bp_docs_format_notifications';
     $bp->bp_docs->slug = BP_DOCS_SLUG;
     // This info is loaded here because it needs to happen after BP core globals are
     // set up
     $this->slugstocheck = bp_action_variables() ? bp_action_variables() : array();
     $this->slugstocheck[] = bp_current_component();
     $this->slugstocheck[] = bp_current_action();
     // Todo: You only need this if you need top level access: example.com/docs
     /* Register this in the active components array */
     //$bp->active_components[ $bp->wiki->slug ] = $bp->wiki->id;
 }
Beispiel #20
0
function breadcrumb_bp_current_item($item)
{
    $params = array('bp_component' => bp_current_component(), 'bp_item' => bp_current_item(), 'bp_action' => bp_current_action(), 'bp_action_variables' => bp_action_variables());
    switch (bp_current_component()) {
        case false:
            return $item;
            break;
        case 'groups':
            return new Breadcrumb_BP_Component_Group($item, $params);
            break;
        default:
            return new Breadcrumb_BP_Component($item, $params);
    }
}
/**
 * Add the Activity top-level menu link when viewing single activity item.
 *
 * @since 2.6.0
 *
 * @return null Null if user does not have access to editing functionality.
 */
function bp_activity_admin_menu()
{
    global $wp_admin_bar;
    // Only show if viewing a single activity item.
    if (!bp_is_single_activity()) {
        return;
    }
    // Only show this menu to super admins
    if (!bp_current_user_can('bp_moderate')) {
        return;
    }
    $activity_edit_link = add_query_arg(array('page' => 'bp-activity', 'aid' => bp_current_action(), 'action' => 'edit'), bp_get_admin_url('admin.php'));
    // Add the top-level Edit Activity button.
    $wp_admin_bar->add_menu(array('id' => 'activity-admin', 'title' => __('Edit Activity', 'buddypress'), 'href' => esc_url($activity_edit_link)));
}
/**
 * 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'));
}
function messages_action_bulk_delete()
{
    if (!bp_is_messages_component() || !bp_is_action_variable('bulk-delete', 0)) {
        return false;
    }
    $thread_ids = $_POST['thread_ids'];
    if (!$thread_ids || !messages_check_thread_access($thread_ids)) {
        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;
        }
        if (!messages_delete_thread($thread_ids)) {
            bp_core_add_message(__('There was an error deleting messages.', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('Messages deleted.', 'buddypress'));
        }
        bp_core_redirect(trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action()));
    }
}
 /**
  * Set up the theme compatibility hooks, if we're looking at an activity page.
  *
  * @since 1.7.0
  */
 public function is_activity()
 {
     // Bail if not looking at a group.
     if (!bp_is_activity_component()) {
         return;
     }
     // Activity Directory.
     if (!bp_displayed_user_id() && !bp_current_action()) {
         bp_update_is_directory(true, 'activity');
         /** This action is documented in bp-activity/bp-activity-screens.php */
         do_action('bp_activity_screen_index');
         add_filter('bp_get_buddypress_template', array($this, 'directory_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
         // Single activity.
     } elseif (bp_is_single_activity()) {
         add_filter('bp_get_buddypress_template', array($this, 'single_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'single_dummy_content'));
     }
 }
 /**
  * Are we looking at something that needs group theme compatability?
  *
  * @since BuddyPress (1.7)
  */
 public function is_blogs()
 {
     // Bail if not looking at a group
     if (!bp_is_blogs_component()) {
         return;
     }
     // Bail if looking at a users sites
     if (bp_is_user()) {
         return;
     }
     // Blog Directory
     if (is_multisite() && !bp_current_action()) {
         bp_update_is_directory(true, 'blogs');
         do_action('bp_blogs_screen_index');
         add_filter('bp_get_buddypress_template', array($this, 'directory_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
         // Create blog
     } elseif (is_user_logged_in() && bp_blog_signup_enabled()) {
         add_filter('bp_get_buddypress_template', array($this, 'create_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'create_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'create_content'));
     }
 }
function groups_screen_group_invites()
{
    $group_id = (int) bp_action_variable(1);
    if (bp_is_action_variable('accept') && is_numeric($group_id)) {
        // Check the nonce
        if (!check_admin_referer('groups_accept_invite')) {
            return false;
        }
        if (!groups_accept_invite(bp_loggedin_user_id(), $group_id)) {
            bp_core_add_message(__('Group invite could not be accepted', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('Group invite accepted', 'buddypress'));
            // Record this in activity streams
            $group = new BP_Groups_Group($group_id);
            groups_record_activity(array('action' => apply_filters_ref_array('groups_activity_accepted_invite_action', array(sprintf(__('%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink(bp_loggedin_user_id()), '<a href="' . bp_get_group_permalink($group) . '">' . esc_attr($group->name) . '</a>'), bp_loggedin_user_id(), &$group)), 'type' => 'joined_group', 'item_id' => $group->id));
        }
        bp_core_redirect(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action());
    } else {
        if (bp_is_action_variable('reject') && is_numeric($group_id)) {
            // Check the nonce
            if (!check_admin_referer('groups_reject_invite')) {
                return false;
            }
            if (!groups_reject_invite(bp_loggedin_user_id(), $group_id)) {
                bp_core_add_message(__('Group invite could not be rejected', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Group invite rejected', 'buddypress'));
            }
            bp_core_redirect(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action());
        }
    }
    // Remove notifications
    bp_core_delete_notifications_by_type(bp_loggedin_user_id(), 'groups', 'group_invite');
    do_action('groups_screen_group_invites', $group_id);
    bp_core_load_template(apply_filters('groups_template_group_invites', 'members/single/home'));
}
Beispiel #27
0
        }
        ?>
>
				<td width="1%" class="thread-count">
					<span class="unread-count"><?php 
        bp_message_thread_unread_count();
        ?>
</span>
				</td>
				<td width="1%" class="thread-avatar"><?php 
        bp_message_thread_avatar();
        ?>
</td>
				<td width="30%" class="thread-from">
					<?php 
        if ('sentbox' != bp_current_action()) {
            ?>
						<?php 
            _e('From:', 'buddypress');
            ?>
 <?php 
            bp_message_thread_from();
            ?>
<br />
						<span class="activity"><?php 
            bp_message_thread_last_post_date();
            ?>
</span>
					<?php 
        } else {
            ?>
 function _register()
 {
     global $bp;
     // If admin/create names and slugs are not provided, they fall back on the main
     // name and slug for the extension
     if (!$this->admin_name) {
         $this->admin_name = $this->name;
     }
     if (!$this->admin_slug) {
         $this->admin_slug = $this->slug;
     }
     if (!$this->create_name) {
         $this->create_name = $this->name;
     }
     if (!$this->create_slug) {
         $this->create_slug = $this->slug;
     }
     if (!empty($this->enable_create_step)) {
         // Insert the group creation step for the new group extension
         $bp->groups->group_creation_steps[$this->create_slug] = array('name' => $this->create_name, 'slug' => $this->create_slug, 'position' => $this->create_step_position);
         // Attach the group creation step display content action
         add_action('groups_custom_create_steps', array(&$this, 'create_screen'));
         // Attach the group creation step save content action
         add_action('groups_create_group_step_save_' . $this->create_slug, array(&$this, 'create_screen_save'));
     }
     // When we are viewing a single group, add the group extension nav item
     if (bp_is_group()) {
         if ($this->visibility == 'public' || $this->visibility != 'public' && $bp->groups->current_group->user_has_access) {
             if ($this->enable_nav_item) {
                 bp_core_new_subnav_item(array('name' => !$this->nav_item_name ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => $bp->groups->current_group->slug, 'parent_url' => bp_get_group_permalink($bp->groups->current_group), 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array(&$this, '_display_hook'), 'user_has_access' => $this->enable_nav_item));
                 // When we are viewing the extension display page, set the title and options title
                 if (bp_is_current_action($this->slug)) {
                     add_action('bp_template_content_header', create_function('', 'echo "' . esc_attr($this->name) . '";'));
                     add_action('bp_template_title', create_function('', 'echo "' . esc_attr($this->name) . '";'));
                 }
             }
             // Hook the group home widget
             if (!bp_current_action() && bp_is_current_action('home')) {
                 add_action($this->display_hook, array(&$this, 'widget_display'));
             }
         }
     }
     // Construct the admin edit tab for the new group extension
     if (!empty($this->enable_edit_item) && bp_is_item_admin()) {
         add_action('groups_admin_tabs', create_function('$current, $group_slug', '$selected = ""; if ( "' . esc_attr($this->admin_slug) . '" == $current ) $selected = " class=\\"current\\""; echo "<li{$selected}><a href=\\"' . trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/{$group_slug}/admin/' . esc_attr($this->admin_slug)) . '\\">' . esc_attr($this->admin_name) . '</a></li>";'), 10, 2);
         // Catch the edit screen and forward it to the plugin template
         if (bp_is_groups_component() && bp_is_current_action('admin') && bp_is_action_variable($this->admin_slug, 0)) {
             // Check whether the user is saving changes
             $this->edit_screen_save();
             add_action('groups_custom_edit_steps', array(&$this, 'edit_screen'));
             if ('' != locate_template(array('groups/single/home.php'), false)) {
                 bp_core_load_template(apply_filters('groups_template_group_home', 'groups/single/home'));
             } else {
                 add_action('bp_template_content_header', create_function('', 'echo "<ul class=\\"content-header-nav\\">"; bp_group_admin_tabs(); echo "</ul>";'));
                 add_action('bp_template_content', array(&$this, 'edit_screen'));
                 bp_core_load_template(apply_filters('bp_core_template_plugin', '/groups/single/plugins'));
             }
         }
     }
 }
Beispiel #29
0
     */
    do_action('bp_member_group_order_options');
    ?>

				</select>
			</li>

		<?php 
}
?>

	</ul>
</div><!-- .item-list-tabs -->

<?php 
switch (bp_current_action()) {
    // Home/My Groups
    case 'my-groups':
        /**
         * Fires before the display of member groups content.
         *
         * @since 1.2.0
         */
        do_action('bp_before_member_groups_content');
        ?>

		<div class="groups mygroups">

			<?php 
        bp_get_template_part('groups/groups-loop');
        ?>
 /**
  * Add custom template hierarchy to theme compat for member pages.
  *
  * This is to mirror how WordPress has
  * {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
  *
  * @since BuddyPress (1.8.0)
  *
  * @param string $templates The templates from
  *        bp_get_theme_compat_templates().
  * @return array $templates Array of custom templates to look for.
  */
 public function single_template_hierarchy($templates)
 {
     // Setup some variables we're going to reference in our custom templates
     $user_nicename = buddypress()->displayed_user->userdata->user_nicename;
     /**
      * Filters the template hierarchy for theme compat and member pages.
      *
      * @since BuddyPress (1.8.0)
      *
      * @param array $value Array of template paths to add to hierarchy.
      */
     $new_templates = apply_filters('bp_template_hierarchy_members_single_item', array('members/single/index-id-' . sanitize_file_name(bp_displayed_user_id()) . '.php', 'members/single/index-nicename-' . sanitize_file_name($user_nicename) . '.php', 'members/single/index-action-' . sanitize_file_name(bp_current_action()) . '.php', 'members/single/index-component-' . sanitize_file_name(bp_current_component()) . '.php', 'members/single/index.php'));
     // Merge new templates with existing stack
     // @see bp_get_theme_compat_templates()
     $templates = array_merge((array) $new_templates, $templates);
     return $templates;
 }