/** * Appends course information to group header */ function course_group_header() { global $bp; if (!$this->has_course_caps($bp->loggedin_user->id) || !BPSP_Roles::can_teach($bp->loggedin_user->id)) { return; } $vars['name'] = '_no_course_group_header'; $vars['echo'] = false; $this->current_uri = bp_get_group_permalink($bp->groups->current_group) . $bp->courseware->slug; $vars['init_course_link'] = $this->current_uri . '/course/edit'; echo BPSP_Groups::load_template($vars); }
/** * On plugins load */ function bpsp_on_plugins_load() { BPSP_Groups::activate_component(); }
/** * can_teach( $user_id = null ) * * This will check if current user is allowed to manage courseware for current group * @param Int $user_id, the id of the user to check * @return Bool, true or false */ function can_teach($user_id = null) { global $bp; if (!$user_id) { $user_id = $bp->loggedin_user->id; } $is_admin = false; if (!BPSP_Groups::courseware_status()) { return false; } if (is_super_admin($user_id)) { return true; } if (self::is_teacher($user_id)) { $is_admin = true; } if (!get_option('bpsp_allow_only_admins') && !bp_group_is_admin()) { $is_admin = false; } return $is_admin; }
/** * can_teach( $user_id ) * * This will check if current user is allowed to manage courseware for current group * @param Int $user_id, the id of the user to check * @return Bool, true or false */ function can_teach($user_id) { $is_admin = false; if (!BPSP_Groups::courseware_status()) { return false; } if (is_super_admin($user_id)) { return true; } if (self::is_teacher($user_id)) { $is_admin = true; } if (!get_option('bpsp_allow_only_admins') && !bp_group_is_admin()) { $is_admin = false; } return $is_admin; }
/** * nav_options() * * Courseware action to manage group navigation options */ function nav_options() { self::$nav_options = apply_filters('courseware_group_nav_options', self::$nav_options); $this->load_template(array('name' => '_nav', 'nav_options' => self::$nav_options, 'current_option' => self::$current_nav_option)); }
/** * standalone_screen_handler( $content ) * * Standalone courses screens handler. Used when showing/editing courses apart from the BuddyPress interface. * Handles uris like course/ID?action=action&args=args */ function standalone_screen_handler($content) { global $post, $bp; if ('course' == get_post_type()) { remove_filter('the_content', array($this, 'standalone_screen_handler')); // avoid an infinite loop $this->current_course = $post->ID; $post->permalink = get_permalink($post->ID); if (!isset($bp->groups->current_group) || !is_object($bp->groups->current_group)) { $bp->groups->current_group = new stdClass(); } $bp->groups->current_group->id = wp_get_object_terms($post->ID, 'group_id'); // @todo need setup default group to map courses to? or automatically match group id w/ course id? $bp->groups->current_group->id = $bp->groups->current_group->id[0]->slug; $bp->groups->current_group->slug = 'mock'; if (isset($_GET['action']) && 'edit' == $_GET['action']) { // @todo create /edit/ endpoint? $template = 'edit_course'; $vars = $this->edit_course_screen(array('current_uri' => '?action=edit')); $post = $vars['course']; } else { $template = 'single_course'; $vars = $this->single_course_screen(array('current_uri' => '')); // @todo even need the current_uri? } $vars = array_merge($vars, array('name' => $template, 'echo' => false, 'course' => $post, 'nav_options' => array('Home' => 'this-is-a-mock-value'), 'group_id' => 0, 'current_uri' => 'this-is-a-mock-value', 'course_permalink' => $post->permalink, 'course_edit_uri' => '?action=edit')); $content = BPSP_Groups::load_template($vars); add_filter('the_content', array($this, 'standalone_screen_handler')); // re-register the callback } return $content; }
function shortcode_courseware_dashboard($attributes) { global $bp; $course = false; if (isset($_GET['course_id'])) { $course = BPSP_Courses::is_course((int) $_GET['course_id']); } // @todo not pulling in # of lectures, assignments, etc if ($course) { $bp->groups->current_group->creator_id = 1; // @todo set to current user? no, to author of course post? $vars = array_merge($this->group_dashboard(array()), array('nav_options' => array(__('Home', 'bpsp') => ''), 'group_course' => $course)); BPSP_Groups::load_template($vars); } else { echo '<p>Invalid course ID</p>'; } }