original_string: protected static function validate_course($courseorid, $throwexception = true) {
          $course = $courseorid;
          if (!is_object($course)) {
              $course = get_course($course);
          }
  
          $coursecontext = context_course::instance($course->id);
          if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
              if ($throwexception) {
                  throw new require_login_exception('Course is hidden');
              } else {
                  return false;
              }
          }
  
          return true;
      }
code: protected static function validate_course($courseorid, $throwexception = true) {
          $course = $courseorid;
          if (!is_object($course)) {
              $course = get_course($course);
          }
  
          $coursecontext = context_course::instance($course->id);
          if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
              if ($throwexception) {
                  throw new require_login_exception('Course is hidden');
              } else {
                  return false;
              }
          }
  
          return true;
      }
code_tokens: protected static function validate_course ( $ courseorid , $ throwexception = true ) { $ course = $ courseorid ; if ( ! is_object ( $ course ) ) { $ course = get_course ( $ course ) ; } $ coursecontext = context_course :: instance ( $ course -> id ) ; if ( ! $ course -> visible and ! has_capability ( 'moodle/course:viewhiddencourses' , $ coursecontext ) ) { if ( $ throwexception ) { throw new require_login_exception ( 'Course is hidden' ) ; } else { return false ; } } return true ; }
docstring: Validate if current user have acces to the course if hidden.
  
  @param mixed $courseorid The course or it ID.
  @param bool $throwexception Throw an exception or not.
  @return bool
docstring_tokens: Validate if current user have acces to the course if hidden .