original_string: public static function can_view_course_info($course, $user = null) {
          if ($course->id == SITEID) {
              return true;
          }
          if (!$course->visible) {
              $coursecontext = context_course::instance($course->id);
              if (!has_capability('moodle/course:viewhiddencourses', $coursecontext, $user)) {
                  return false;
              }
          }
          $categorycontext = isset($course->category) ? context_coursecat::instance($course->category) :
              context_course::instance($course->id)->get_parent_context();
          return has_capability('moodle/category:viewcourselist', $categorycontext, $user);
      }
code: public static function can_view_course_info($course, $user = null) {
          if ($course->id == SITEID) {
              return true;
          }
          if (!$course->visible) {
              $coursecontext = context_course::instance($course->id);
              if (!has_capability('moodle/course:viewhiddencourses', $coursecontext, $user)) {
                  return false;
              }
          }
          $categorycontext = isset($course->category) ? context_coursecat::instance($course->category) :
              context_course::instance($course->id)->get_parent_context();
          return has_capability('moodle/category:viewcourselist', $categorycontext, $user);
      }
code_tokens: public static function can_view_course_info ( $ course , $ user = null ) { if ( $ course -> id == SITEID ) { return true ; } if ( ! $ course -> visible ) { $ coursecontext = context_course :: instance ( $ course -> id ) ; if ( ! has_capability ( 'moodle/course:viewhiddencourses' , $ coursecontext , $ user ) ) { return false ; } } $ categorycontext = isset ( $ course -> category ) ? context_coursecat :: instance ( $ course -> category ) : context_course :: instance ( $ course -> id ) -> get_parent_context ( ) ; return has_capability ( 'moodle/category:viewcourselist' , $ categorycontext , $ user ) ; }
docstring: Checks if current user can view course information or enrolment page.
  
  This method does not check if user is already enrolled in the course
  
  @param stdClass $course course object (must have 'id', 'visible' and 'category' fields)
  @param null|stdClass $user The user id or object. By default (null) checks access for the current user.
docstring_tokens: Checks if current user can view course information or enrolment page .