original_string: public function check_access($id) {
          global $DB;
  
          // Check we can get the section and the course modinfo.
          $sectionrec = $DB->get_record('course_sections', ['id' => $id], '*', IGNORE_MISSING);
          if (!$sectionrec) {
              return \core_search\manager::ACCESS_DELETED;
          }
          try {
              $modinfo = get_fast_modinfo($sectionrec->course);
          } catch (\moodle_exception $e) {
              return \core_search\manager::ACCESS_DELETED;
          }
          $section = $modinfo->get_section_info($sectionrec->section, IGNORE_MISSING);
          if (!$section) {
              return \core_search\manager::ACCESS_DELETED;
          }
  
          // Check access to course and that the section is visible to current user.
          if (can_access_course($modinfo->get_course()) && $section->uservisible) {
              return \core_search\manager::ACCESS_GRANTED;
          }
  
          return \core_search\manager::ACCESS_DENIED;
      }
code: public function check_access($id) {
          global $DB;
  
          // Check we can get the section and the course modinfo.
          $sectionrec = $DB->get_record('course_sections', ['id' => $id], '*', IGNORE_MISSING);
          if (!$sectionrec) {
              return \core_search\manager::ACCESS_DELETED;
          }
          try {
              $modinfo = get_fast_modinfo($sectionrec->course);
          } catch (\moodle_exception $e) {
              return \core_search\manager::ACCESS_DELETED;
          }
          $section = $modinfo->get_section_info($sectionrec->section, IGNORE_MISSING);
          if (!$section) {
              return \core_search\manager::ACCESS_DELETED;
          }
  
          // Check access to course and that the section is visible to current user.
          if (can_access_course($modinfo->get_course()) && $section->uservisible) {
              return \core_search\manager::ACCESS_GRANTED;
          }
  
          return \core_search\manager::ACCESS_DENIED;
      }
code_tokens: public function check_access ( $ id ) { global $ DB ; // Check we can get the section and the course modinfo. $ sectionrec = $ DB -> get_record ( 'course_sections' , [ 'id' => $ id ] , '*' , IGNORE_MISSING ) ; if ( ! $ sectionrec ) { return \ core_search \ manager :: ACCESS_DELETED ; } try { $ modinfo = get_fast_modinfo ( $ sectionrec -> course ) ; } catch ( \ moodle_exception $ e ) { return \ core_search \ manager :: ACCESS_DELETED ; } $ section = $ modinfo -> get_section_info ( $ sectionrec -> section , IGNORE_MISSING ) ; if ( ! $ section ) { return \ core_search \ manager :: ACCESS_DELETED ; } // Check access to course and that the section is visible to current user. if ( can_access_course ( $ modinfo -> get_course ( ) ) && $ section -> uservisible ) { return \ core_search \ manager :: ACCESS_GRANTED ; } return \ core_search \ manager :: ACCESS_DENIED ; }
docstring: Whether the user can access the section or not.
  
  @param int $id The course section id.
  @return int One of the \core_search\manager:ACCESS_xx constants
docstring_tokens: Whether the user can access the section or not .