$course_id = (int) $_GET['course_id'];
    $course = new Course($course_id);
    $units = $course->get_units();
}
if (!empty($course_id) && !CoursePress_Capabilities::can_view_course_units($_GET['course_id'])) {
    die(__('You do not have required permissions to access this page.', 'cp'));
}
if (isset($_GET['unit_id'])) {
    $unit_id = (int) $_GET['unit_id'];
    $unit = new Unit($unit_id);
}
if (isset($_GET['action']) && $_GET['action'] == 'delete_unit' && isset($_GET['unit_id']) && is_numeric($_GET['unit_id'])) {
    $unit = new Unit($unit_id);
    $unit_object = $unit->get_unit();
    if (CoursePress_Capabilities::can_delete_course_unit($course_id, $unit_id)) {
        $unit->delete_unit($force_delete = true);
    }
    $units = $course->get_units();
}
if (isset($_GET['action']) && $_GET['action'] == 'change_status' && isset($_GET['unit_id']) && is_numeric($_GET['unit_id'])) {
    $unit = new Unit($_GET['unit_id']);
    $unit_object = $unit->get_unit();
    if (CoursePress_Capabilities::can_change_course_unit_status($course_id, $unit_id)) {
        $unit->change_status($_GET['new_status']);
    }
}
if (isset($_GET['action']) && $_GET['action'] == 'add_new_unit' || isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['unit_id'])) {
    $coursepress->unit_page_num = !empty($_REQUEST['unit_page_num']) ? (int) $_REQUEST['unit_page_num'] : 1;
    $coursepress->active_element = isset($_REQUEST['active_element']) ? $_REQUEST['active_element'] : ($coursepress->unit_page_num == 1 ? 0 : 1);
    $coursepress->preview_redirect_url = isset($_REQUEST['preview_redirect_url']) ? $_REQUEST['preview_redirect_url'] : '';
    $this->show_unit_details($coursepress->unit_page_num, $coursepress->active_element, $coursepress->preview_redirect_url);
 function delete_course($force_delete = true)
 {
     $force_delete = apply_filters('coursepress_course_force_delete', $force_delete);
     /**
      * Allow course deletion to be cancelled when filter returns true.
      *
      * @since 1.2.1
      */
     if (apply_filters('coursepress_course_cancel_delete', false, $this->id)) {
         /**
          * Perform actions if the deletion was cancelled.
          *
          * @since 1.2.1
          */
         do_action('coursepress_course_delete_cancelled', $this->id);
         return false;
     }
     // Get object before it gets destroyed
     $course = new Course($this->id);
     // Clear cached object because we're deleting the object
     self::kill(self::TYPE_COURSE, $this->id);
     self::kill_related(self::TYPE_COURSE, $this->id);
     if (get_post_type($this->id) == 'course') {
         wp_delete_post($this->id, $force_delete);
         //Whether to bypass trash and force deletion
     }
     /* Delete all usermeta associated to the course */
     cp_delete_user_meta_by_key('course_' . $this->id);
     cp_delete_user_meta_by_key('enrolled_course_date_' . $this->id);
     cp_delete_user_meta_by_key('enrolled_course_class_' . $this->id);
     cp_delete_user_meta_by_key('enrolled_course_group_' . $this->id);
     // Get list of units from cached object
     $course_units = Unit::get_units_from_course($this->id, 'any');
     //Delete course units
     foreach ($course_units as $course_unit) {
         $unit = new Unit($course_unit);
         $unit->delete_unit(true);
     }
     //Delete course discussions
     $discussion = new Discussion();
     $discussion->delete_discussion(true, $this->id);
     //Delete course notification
     $notification = new Notification();
     $notification->delete_notification(true, $this->id);
     /**
      * Perform actions after a course is deleted.
      *
      * @var $course  The course object if the ID or post_ title is needed.
      *
      * @since 1.2.1
      */
     do_action('coursepress_course_deleted', $course);
 }