/**
  * 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);
 }
 /**
  * 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>';
     }
 }