function check_access($course_id, $unit_id = false)
 {
     // if( defined( 'DOING_AJAX' ) && DOING_AJAX ) { cp_write_log( 'doing ajax' ); }
     // $page_num not set...
     // @TODO: implement $page_num and remove next line.
     if ($this->is_preview($unit_id)) {
         //have access
     } else {
         $student = new Student(get_current_user_id());
         $instructor = new Instructor(get_current_user_id());
         $has_access = false;
         if (current_user_can('manage_options') || $student->has_access_to_course($course_id) || $instructor->is_assigned_to_course($course_id, get_current_user_id())) {
             $has_access = true;
         }
         if (!$has_access) {
             wp_redirect(get_permalink($course_id));
             exit;
         }
     }
     return true;
 }